Author: [log in to unmask]
Date: Thu Apr 16 15:54:37 2015
New Revision: 2725
Log:
Run panel redraw on the Swing EDT.
Modified:
java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/PEventViewer.java
Modified: java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/PEventViewer.java
=============================================================================
--- java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/PEventViewer.java (original)
+++ java/trunk/ecal-event-display/src/main/java/org/hps/monitoring/ecal/eventdisplay/ui/PEventViewer.java Thu Apr 16 15:54:37 2015
@@ -2,6 +2,8 @@
import java.awt.Point;
import java.util.ArrayList;
+
+import javax.swing.SwingUtilities;
import org.hps.monitoring.ecal.eventdisplay.event.Association;
import org.hps.monitoring.ecal.eventdisplay.event.Cluster;
@@ -11,7 +13,7 @@
/**
* Class <code>PEventViewer</code> represents a <code>PassiveViewer
* </code> implementation which displays hits and clusters.
- *
+ *
* @author Kyle McCarty
*/
public class PEventViewer extends PassiveViewer {
@@ -20,73 +22,92 @@
protected ArrayList<Cluster> clusterList = new ArrayList<Cluster>();
// Stores hit objects.
protected ArrayList<EcalHit> hitList = new ArrayList<EcalHit>();
-
+
@Override
- public void addHit(CalorimeterHit lcioHit) { hitList.add(toPanelHit(lcioHit)); }
-
+ public void addCluster(final Cluster cluster) {
+ this.clusterList.add(cluster);
+ }
+
@Override
- public void addHit(EcalHit hit) { hitList.add(hit); }
-
+ public void addCluster(final org.lcsim.event.Cluster lcioCluster) {
+ this.clusterList.add(toPanelCluster(lcioCluster));
+ }
+
@Override
- public void addCluster(Cluster cluster) { clusterList.add(cluster); }
-
+ public void addHit(final CalorimeterHit lcioHit) {
+ this.hitList.add(toPanelHit(lcioHit));
+ }
+
@Override
- public void addCluster(org.lcsim.event.Cluster lcioCluster) { clusterList.add(toPanelCluster(lcioCluster)); }
-
+ public void addHit(final EcalHit hit) {
+ this.hitList.add(hit);
+ }
+
+ /**
+ * Removes all of the cluster data from the viewer.
+ */
+ public void clearClusters() {
+ this.hitList.clear();
+ }
+
/**
* Removes all of the hit data from the viewer.
*/
- public void clearHits() { hitList.clear(); }
-
- /**
- * Removes all of the cluster data from the viewer.
- */
- public void clearClusters() { hitList.clear(); }
-
+ public void clearHits() {
+ this.hitList.clear();
+ }
+
@Override
public void resetDisplay() {
// Reset the hit and cluster lists.
- hitList.clear();
- clusterList.clear();
+ this.hitList.clear();
+ this.clusterList.clear();
}
-
+
@Override
public void updateDisplay() {
// Suppress the calorimeter panel's redrawing.
- ecalPanel.setSuppressRedraw(true);
-
+ this.ecalPanel.setSuppressRedraw(true);
+
// Clear the panel data.
- ecalPanel.clearCrystals();
-
+ this.ecalPanel.clearCrystals();
+
// Display the hits.
- for (EcalHit h : hitList) {
- int ix = toPanelX(h.getX());
- int iy = toPanelY(h.getY());
- ecalPanel.addCrystalEnergy(ix, iy, h.getEnergy());
+ for (final EcalHit h : this.hitList) {
+ final int ix = toPanelX(h.getX());
+ final int iy = toPanelY(h.getY());
+ this.ecalPanel.addCrystalEnergy(ix, iy, h.getEnergy());
}
-
+
// Display the clusters.
- for(Cluster cluster : clusterList) {
- Point rawCluster = cluster.getClusterCenter();
- Point clusterCenter = toPanelPoint(rawCluster);
- ecalPanel.setCrystalCluster(clusterCenter.x, clusterCenter.y, true);
-
+ for (final Cluster cluster : this.clusterList) {
+ final Point rawCluster = cluster.getClusterCenter();
+ final Point clusterCenter = toPanelPoint(rawCluster);
+ this.ecalPanel.setCrystalCluster(clusterCenter.x, clusterCenter.y, true);
+
// Add component hits to the calorimeter panel.
- for(Point ch : cluster.getComponentHits()) {
- ecalPanel.addAssociation(new Association(clusterCenter, toPanelPoint(ch), HIGHLIGHT_CLUSTER_COMPONENT));
+ for (final Point ch : cluster.getComponentHits()) {
+ this.ecalPanel.addAssociation(new Association(clusterCenter, toPanelPoint(ch),
+ HIGHLIGHT_CLUSTER_COMPONENT));
}
-
+
// Add shared hits to the calorimeter panel.
- for(Point sh : cluster.getSharedHits()) {
- ecalPanel.addAssociation(new Association(clusterCenter, toPanelPoint(sh), HIGHLIGHT_CLUSTER_SHARED));
+ for (final Point sh : cluster.getSharedHits()) {
+ this.ecalPanel
+ .addAssociation(new Association(clusterCenter, toPanelPoint(sh), HIGHLIGHT_CLUSTER_SHARED));
}
}
-
+
// Stop suppressing the redraw and order the panel to update.
- ecalPanel.setSuppressRedraw(false);
- ecalPanel.repaint();
-
+ this.ecalPanel.setSuppressRedraw(false);
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ PEventViewer.this.ecalPanel.repaint();
+ }
+ });
+
// Update the status panel to account for the new event.
- updateStatusPanel();
+ this.updateStatusPanel();
}
}
|