LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  March 2015

HPS-SVN March 2015

Subject:

r2450 - in /java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting: MonitoringPlotFactory.java PlotterRegistry.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Sat, 14 Mar 2015 19:26:06 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (137 lines)

Author: [log in to unmask]
Date: Sat Mar 14 12:26:02 2015
New Revision: 2450

Log:
Add global plotter registry for use in monitoring app.

Added:
    java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/PlotterRegistry.java
Modified:
    java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java

Modified: java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java
 =============================================================================
--- java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java	(original)
+++ java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java	Sat Mar 14 12:26:02 2015
@@ -22,7 +22,9 @@
  * by the MonitoringApplication before any calls to AIDA are made from Drivers.
  */
 public class MonitoringPlotFactory extends PlotterFactory {
-
+    
+    static PlotterRegistry plotters = new PlotterRegistry();
+    
     // The name of the factory which will be used in naming tabs in the monitoring app.
     String name = null;
 
@@ -33,6 +35,8 @@
     private static JTabbedPane rootPane = null;
 
     private static PlotterRegionListener regionListener;
+    
+    int tabIndex;
 
     public static void setPlotterRegionListener(PlotterRegionListener regionListener) {
         MonitoringPlotFactory.regionListener = regionListener;
@@ -66,7 +70,8 @@
         // FIXME: Hack to disregard call from an AIDA related class.
         if (!(new RuntimeException()).getStackTrace()[2].getClassName().equals("hep.aida.ref.plotter.style.registry.StyleStoreXMLReader")) {
             rootPane.addTab(name, tabs);
-            rootPane.setTabComponentAt(rootPane.getTabCount() - 1, new JLabel(name));
+            tabIndex = rootPane.getTabCount() - 1;
+            rootPane.setTabComponentAt(tabIndex, new JLabel(name));
         }
     }
 
@@ -98,10 +103,16 @@
     }
 
     private void setupPlotterTab(String plotterName, IPlotter plotter) {
+        
+        // Setup the plotter's GUI pane and tab.
         JPanel plotterPanel = new JPanel(new BorderLayout());
         plotterPanel.add(PlotterUtilities.componentForPlotter(plotter), BorderLayout.CENTER);
         tabs.addTab(plotterName, plotterPanel);
-        tabs.setTabComponentAt(tabs.getTabCount() - 1, new JLabel(plotterName));
+        int plotterIndex = tabs.getTabCount() - 1;
+        tabs.setTabComponentAt(plotterIndex, new JLabel(plotterName));
+        
+        // Register plotter globally with its tab indices.
+        plotters.register(plotter, tabIndex, plotterIndex);
     }
 
     private void addChart(JFreeChart chart) {
@@ -143,5 +154,13 @@
         stripChart.getLegend().setVisible(false); /* Legend turned off for now. */
         addChart(stripChart);
         return stripChart;
+    }       
+    
+    /**
+     * 
+     * @return
+     */
+    public static PlotterRegistry getPlotterRegistry() {
+        return plotters;
     }
-}
+}

Added: java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/PlotterRegistry.java
 =============================================================================
--- java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/PlotterRegistry.java	(added)
+++ java/trunk/monitoring-util/src/main/java/org/hps/monitoring/plotting/PlotterRegistry.java	Sat Mar 14 12:26:02 2015
@@ -0,0 +1,51 @@
+/**
+ * 
+ */
+package org.hps.monitoring.plotting;
+
+import hep.aida.IPlotter;
+import hep.aida.IPlotterRegion;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * @author Jeremy McCormick <[log in to unmask]>
+ *
+ */
+public class PlotterRegistry {
+
+    Set<IPlotter> plotters = new HashSet<IPlotter>();    
+    HashMap<IPlotter, int[]> tabMap = new HashMap<IPlotter, int[]>();
+    
+    public void clear() {
+        plotters.clear();
+    }
+    
+    public IPlotter find(IPlotterRegion region) {
+        for (IPlotter plotter : plotters) {
+            for (int i = 0; i < plotter.numberOfRegions(); i++) {
+                if (plotter.region(i) == region) {
+                    return plotter;
+                }
+            }
+        }
+        return null;
+    }
+    
+    public void register(IPlotter plotter, int index1, int index2) {
+        tabMap.put(plotter, new int[] { index1, index2 });
+    }
+    
+    public IPlotter find(int index1, int index2) {
+        for (Entry<IPlotter, int[]> entry : tabMap.entrySet()) {
+            int[] indices = entry.getValue();
+            if (indices[0] == index1 && indices[1] == index2) {
+                return entry.getKey();
+            }
+        }
+        return null;
+    }
+}

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use