6 added + 8 modified, total 14 files
lcsim/src/org/lcsim/conditions
diff -u -r1.7 -r1.8
--- ConditionsReader.java 15 Jul 2005 20:32:26 -0000 1.7
+++ ConditionsReader.java 5 Apr 2006 09:09:10 -0000 1.8
@@ -1,14 +1,21 @@
package org.lcsim.conditions;
import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
import java.util.Properties;
+import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
@@ -19,12 +26,57 @@
*
* @author tonyj
*/
-abstract class ConditionsReader
+public abstract class ConditionsReader
{
private static Properties aliases;
private static final File home = new File(FileCache.getCacheRoot(),".lcsim");
private static FileCache cache;
+ /**
+ * Get a list of available detectors
+ */
+ public static List<String> getDetectorNames()
+ {
+ Set<String> set = new HashSet<String>();
+ if (aliases == null) aliases = loadAliases();
+ for (Object key : aliases.keySet()) set.add(key.toString());
+
+ try
+ {
+ if (cache == null) cache = new FileCache(new File(home,"cache"));
+ File file = cache.getCachedFile(new URL("http://www.lcsim.org/detectors/taglist.txt"));
+ if (file != null)
+ {
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ for (;;)
+ {
+ String line = reader.readLine();
+ if (line == null) break;
+ set.add(line);
+ }
+ reader.close();
+ }
+ }
+ catch (Exception ex)
+ {
+ System.err.println("Error reading file taglist.txt: "+ex);
+ }
+
+ List result = new ArrayList(set);
+ Collections.sort(result);
+ return result;
+ }
+ public static void addAlias(String alias, String target)
+ {
+ if (aliases == null) aliases = loadAliases();
+ aliases.setProperty(alias,target);
+ }
+
+ public static ConditionsReader createDummy()
+ {
+ return new DummyConditionsReader();
+ }
+
/** Try to find the conditions associated with this detector.
* For more details see @link http://confluence.slac.stanford.edu/display/ilc/Conditions+database
*/
@@ -258,5 +310,16 @@
{
}
}
+ private static class DummyConditionsReader extends ConditionsReader
+ {
+ InputStream open(String name, String type) throws IOException
+ {
+ throw new IOException("Conditions "+name+"."+type+" not found");
+ }
+
+ void close() throws IOException
+ {
+ }
+ }
}
lcsim/src/org/lcsim/conditions
diff -u -r1.5 -r1.6
--- ConditionsManager.java 15 Mar 2005 05:14:08 -0000 1.5
+++ ConditionsManager.java 5 Apr 2006 09:09:10 -0000 1.6
@@ -18,6 +18,10 @@
if (theConditionsManager == null) theConditionsManager = new ConditionsManagerImplementation();
return theConditionsManager;
}
+ public static void setDefaultConditionsManager(ConditionsManager manager)
+ {
+ theConditionsManager = manager;
+ }
/**
* Normally called automatically by the framework to set the
* detector name and run number,
lcsim/src/org/lcsim/conditions
diff -u -r1.5 -r1.6
--- ConditionsManagerImplementation.java 30 Jun 2005 23:21:09 -0000 1.5
+++ ConditionsManagerImplementation.java 5 Apr 2006 09:09:10 -0000 1.6
@@ -16,7 +16,7 @@
* @author Tony Johnson
*/
-class ConditionsManagerImplementation extends ConditionsManager
+public class ConditionsManagerImplementation extends ConditionsManager
{
private Map<Class,ConditionsConverter> converters = new HashMap<Class,ConditionsConverter>();
private Map<String,CachedConditions> cache = new HashMap<String,CachedConditions>();
@@ -25,12 +25,12 @@
private int run;
private List listenerList = new ArrayList();
private Logger logger = Logger.getLogger(ConditionsManagerImplementation.class.getName());
-
+
/**
* The default implementation of ConditionsManager.
* This implementation does not currently handle run-dependent constants.
*/
- ConditionsManagerImplementation()
+ protected ConditionsManagerImplementation()
{
// logger.setLevel(Level.ALL);
// ConsoleHandler handler = new ConsoleHandler();
@@ -42,19 +42,23 @@
this.run = run;
if (!name.equals(detectorName))
{
+ setConditionsReader(ConditionsReader.create(name,run),name);
logger.fine("Detector changed: "+name+" "+run);
- ConditionsReader oldReader = reader;
- reader = ConditionsReader.create(name,run);
- detectorName = name;
- fireConditionsChanged();
- try
- {
- if (oldReader != null) oldReader.close();
- }
- catch (IOException x)
- {
-
- }
+ }
+ }
+ public void setConditionsReader(ConditionsReader newReader, String name)
+ {
+ ConditionsReader oldReader = reader;
+ reader = newReader;
+ detectorName = name;
+ fireConditionsChanged();
+ try
+ {
+ if (oldReader != null) oldReader.close();
+ }
+ catch (IOException x)
+ {
+
}
}
public void removeConditionsConverter(ConditionsConverter conv)
lcsim/src/org/lcsim/plugin/conditions
diff -N ConditionsAliasWizardPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ConditionsAliasWizardPage.java 5 Apr 2006 09:09:10 -0000 1.1
@@ -0,0 +1,70 @@
+package org.lcsim.plugin.conditions;
+
+import javax.swing.DefaultComboBoxModel;
+import org.freehep.application.Application;
+import org.freehep.swing.wizard.Finishable;
+import org.freehep.swing.wizard.WizardPage;
+import org.lcsim.conditions.*;
+
+/**
+ *
+ * @author tonyj
+ * @version $Id: ConditionsAliasWizardPage.java,v 1.1 2006/04/05 09:09:10 tonyj Exp $
+ */
+public class ConditionsAliasWizardPage extends WizardPage implements Finishable
+{
+ private ConditionsWizardPage wp;
+ /** Creates new form ConditionsAliasWizardPage */
+ public ConditionsAliasWizardPage(ConditionsWizardPage wp)
+ {
+ this.wp = wp;
+ initComponents();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
+ private void initComponents()
+ {
+ java.awt.GridBagConstraints gridBagConstraints;
+
+ jLabel1 = new javax.swing.JLabel();
+ jComboBox1 = new javax.swing.JComboBox();
+
+ setLayout(new java.awt.GridBagLayout());
+
+ jLabel1.setText("Set as alias for");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ add(jLabel1, gridBagConstraints);
+
+ jComboBox1.setModel(new DefaultComboBoxModel(ConditionsReader.getDetectorNames().toArray()));
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ add(jComboBox1, gridBagConstraints);
+
+ }// </editor-fold>//GEN-END:initComponents
+
+ public void onFinish()
+ {
+ try
+ {
+ wp.addAlias(jComboBox1.getSelectedItem().toString());
+ dispose();
+ }
+ catch (ConditionsManager.ConditionsNotFoundException x)
+ {
+ Application.error(this,"Error creating alias",x);
+ }
+ }
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JComboBox jComboBox1;
+ private javax.swing.JLabel jLabel1;
+ // End of variables declaration//GEN-END:variables
+
+}
lcsim/src/org/lcsim/plugin/conditions
diff -N InteractiveConditionsManagerImplementation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ InteractiveConditionsManagerImplementation.java 5 Apr 2006 09:09:11 -0000 1.1
@@ -0,0 +1,74 @@
+package org.lcsim.plugin.conditions;
+
+import java.awt.Frame;
+import javax.swing.SwingUtilities;
+import org.freehep.application.Application;
+import org.freehep.application.studio.Studio;
+import org.freehep.swing.wizard.WizardDialog;
+import org.freehep.swing.wizard.WizardPage;
+import org.lcsim.conditions.*;
+
+/**
+ * Extends the default ConditionsManager to add interactive prompting for detector conditions
+ * @author tonyj
+ * @version $Id: InteractiveConditionsManagerImplementation.java,v 1.1 2006/04/05 09:09:11 tonyj Exp $
+ */
+public class InteractiveConditionsManagerImplementation extends ConditionsManagerImplementation
+{
+ private Studio app;
+ private int run;
+ private boolean newDetectorSet = false;
+
+ /** Creates a new instance of InteractiveConditionsManagerImplementation */
+ public InteractiveConditionsManagerImplementation(Studio app)
+ {
+ super();
+ this.app = app;
+ }
+
+ public void setDetector(String name, int run) throws ConditionsManager.ConditionsNotFoundException
+ {
+ try
+ {
+ super.setDetector(name, run);
+ }
+ catch (ConditionsManager.ConditionsNotFoundException x)
+ {
+ this.run = run;
+ displayWizardPage(name);
+ if (!newDetectorSet) throw x;
+ }
+ }
+ private void displayWizardPage(String name)
+ {
+ Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class,app);
+ WizardDialog wizard = new AppWizardDialog(frame,"Open Data Source...", new ConditionsWizardPage(this,name));
+ wizard.pack();
+ wizard.setLocationRelativeTo(app);
+ wizard.setVisible(true);
+ }
+ void setDetectorFound(boolean found)
+ {
+ this.newDetectorSet = found;
+ }
+ void addAlias(String alias, String target) throws ConditionsNotFoundException
+ {
+ ConditionsReader.addAlias(alias,target);
+ super.setDetector(alias,run);
+ setDetectorFound(true);
+ }
+
+ private class AppWizardDialog extends WizardDialog
+ {
+ AppWizardDialog(Frame frame, String title, WizardPage firstPage)
+ {
+ super(frame,title,firstPage);
+ }
+
+ protected void handleError(String message, Throwable t)
+ {
+ Application.error(this,message,t);
+ }
+
+ }
+}
lcsim/src/org/lcsim/plugin/conditions
diff -N ConditionsWizardPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ConditionsWizardPage.java 5 Apr 2006 09:09:11 -0000 1.1
@@ -0,0 +1,189 @@
+package org.lcsim.plugin.conditions;
+
+import org.freehep.swing.wizard.Finishable;
+import org.freehep.swing.wizard.HasNextPages;
+import org.freehep.swing.wizard.WizardPage;
+import org.lcsim.conditions.*;
+import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException;
+
+/**
+ *
+ * @author tonyj
+ */
+public class ConditionsWizardPage extends WizardPage implements HasNextPages, Finishable
+{
+ private WizardPage nextPage;
+ private InteractiveConditionsManagerImplementation cm;
+ private final WizardPage[] pages;
+ private String detectorName;
+ /** Creates new form ConditionsWizardPanel */
+ public ConditionsWizardPage(InteractiveConditionsManagerImplementation cm, String detectorName)
+ {
+ this.cm = cm;
+ this.detectorName = detectorName;
+ pages = new WizardPage[]{ new ConditionsAliasWizardPage(this) };
+ initComponents();
+ detectorLabel.setText(detectorName);
+ setNextEnabled(false);
+ setFinishEnabled(false);
+ }
+
+ public WizardPage getNext()
+ {
+ return nextPage;
+ }
+ public WizardPage[] getNextWizardPages()
+ {
+ return pages;
+ }
+
+ public void onFinish()
+ {
+ if (noDetectorButton.isSelected())
+ {
+ cm.setConditionsReader(ConditionsReader.createDummy(),detectorName);
+ cm.setDetectorFound(true);
+ }
+ dispose();
+ }
+ void addAlias(String name) throws ConditionsNotFoundException
+ {
+ cm.addAlias(detectorName,name);
+ cm.setDetectorFound(true);
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
+ private void initComponents()
+ {
+ java.awt.GridBagConstraints gridBagConstraints;
+ javax.swing.JLabel jLabel1;
+ javax.swing.JLabel jLabel3;
+
+ buttonGroup1 = new javax.swing.ButtonGroup();
+ jLabel1 = new javax.swing.JLabel();
+ detectorLabel = new javax.swing.JLabel();
+ jLabel3 = new javax.swing.JLabel();
+ aliasButton = new javax.swing.JRadioButton();
+ locateButton = new javax.swing.JRadioButton();
+ heprepButton = new javax.swing.JRadioButton();
+ noDetectorButton = new javax.swing.JRadioButton();
+
+ setLayout(new java.awt.GridBagLayout());
+
+ jLabel1.setText("Sorry, no information could be found on the following detector:");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ add(jLabel1, gridBagConstraints);
+
+ detectorLabel.setText("jLabel2");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ add(detectorLabel, gridBagConstraints);
+
+ jLabel3.setText("Please choose one of the following");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ add(jLabel3, gridBagConstraints);
+
+ buttonGroup1.add(aliasButton);
+ aliasButton.setText("Alias this detector to an existing detector");
+ aliasButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ aliasButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ aliasButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ radioButtonSelected(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
+ add(aliasButton, gridBagConstraints);
+
+ buttonGroup1.add(locateButton);
+ locateButton.setText("Give location of a conditions database for this detector");
+ locateButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ locateButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ locateButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ radioButtonSelected(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
+ add(locateButton, gridBagConstraints);
+
+ buttonGroup1.add(heprepButton);
+ heprepButton.setText("Give location of a HepRep file for this detector");
+ heprepButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ heprepButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ heprepButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ radioButtonSelected(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
+ add(heprepButton, gridBagConstraints);
+
+ buttonGroup1.add(noDetectorButton);
+ noDetectorButton.setText("Proceed with no detector information");
+ noDetectorButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ noDetectorButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
+ noDetectorButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ radioButtonSelected(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
+ add(noDetectorButton, gridBagConstraints);
+
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void radioButtonSelected(java.awt.event.ActionEvent evt)//GEN-FIRST:event_radioButtonSelected
+ {//GEN-HEADEREND:event_radioButtonSelected
+ Object source = evt.getSource();
+ WizardPage next = null;
+ if (source == aliasButton) next = pages[0];
+ nextPage = next;
+ setNextEnabled(next != null);
+ setFinishEnabled(next == null);
+ }//GEN-LAST:event_radioButtonSelected
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JRadioButton aliasButton;
+ private javax.swing.ButtonGroup buttonGroup1;
+ private javax.swing.JLabel detectorLabel;
+ private javax.swing.JRadioButton heprepButton;
+ private javax.swing.JRadioButton locateButton;
+ private javax.swing.JRadioButton noDetectorButton;
+ // End of variables declaration//GEN-END:variables
+
+}
lcsim/src/org/lcsim/plugin/conditions
diff -N ConditionsAliasWizardPage.form
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ConditionsAliasWizardPage.form 5 Apr 2006 09:09:11 -0000 1.1
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <AuxValues>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Set as alias for"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JComboBox" name="jComboBox1">
+ <Properties>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="new DefaultComboBoxModel(ConditionsReader.getDetectorNames().toArray())" type="code"/>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ </SubComponents>
+</Form>
lcsim/src/org/lcsim/plugin/conditions
diff -N ConditionsWizardPage.form
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ConditionsWizardPage.form 5 Apr 2006 09:09:11 -0000 1.1
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <NonVisualComponents>
+ <Component class="javax.swing.ButtonGroup" name="buttonGroup1">
+ </Component>
+ </NonVisualComponents>
+ <AuxValues>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-125,0,0,1,-110"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Sorry, no information could be found on the following detector:"/>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
+ </AuxValues>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JLabel" name="detectorLabel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="jLabel2"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JLabel" name="jLabel3">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Please choose one of the following"/>
+ </Properties>
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
+ </AuxValues>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JRadioButton" name="aliasButton">
+ <Properties>
+ <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="buttonGroup1"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Alias this detector to an existing detector"/>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+ <EmptyBorder bottom="0" left="0" right="0" top="0"/>
+ </Border>
+ </Property>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[0, 0, 0, 0]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioButtonSelected"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JRadioButton" name="locateButton">
+ <Properties>
+ <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="buttonGroup1"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Give location of a conditions database for this detector"/>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+ <EmptyBorder bottom="0" left="0" right="0" top="0"/>
+ </Border>
+ </Property>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[0, 0, 0, 0]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioButtonSelected"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JRadioButton" name="heprepButton">
+ <Properties>
+ <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="buttonGroup1"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Give location of a HepRep file for this detector"/>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+ <EmptyBorder bottom="0" left="0" right="0" top="0"/>
+ </Border>
+ </Property>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[0, 0, 0, 0]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioButtonSelected"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JRadioButton" name="noDetectorButton">
+ <Properties>
+ <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+ <ComponentRef name="buttonGroup1"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Proceed with no detector information"/>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+ <EmptyBorder bottom="0" left="0" right="0" top="0"/>
+ </Border>
+ </Property>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[0, 0, 0, 0]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioButtonSelected"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="10" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ </SubComponents>
+</Form>
lcsim/src/org/lcsim/plugin/browser
diff -N CellIDTableModel.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CellIDTableModel.java 5 Apr 2006 09:09:12 -0000 1.1
@@ -0,0 +1,83 @@
+package org.lcsim.plugin.browser;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.table.AbstractTableModel;
+import org.lcsim.event.EventHeader;
+import org.lcsim.geometry.IDDecoder;
+
+/**
+ *
+ * @author tonyj
+ */
+public abstract class CellIDTableModel extends AbstractTableModel implements EventBrowserTableModel
+{
+ private List hits;
+ private final String[] defaultColumns;
+ private List<String> columns;
+ private IDDecoder decoder;
+
+ /** Creates a new instance of CellIDTableModel */
+ protected CellIDTableModel(String[] defaultColumns)
+ {
+ this.defaultColumns = defaultColumns;
+ }
+
+
+ public void setData(EventHeader.LCMetaData meta, List hits)
+ {
+ this.hits = hits;
+ List oldColumns = columns;
+ columns = new ArrayList<String>();
+
+ try
+ {
+ this.decoder = meta.getIDDecoder();
+ for (int i = 0; i < decoder.getFieldCount(); i++)columns.add("id: " + decoder.getFieldName(i));
+ for (int i = 1; i < defaultColumns.length; i++)columns.add(defaultColumns[i]);
+ } catch (Exception x)
+ {
+ System.err.println("Error accessing decoder "+x);
+ decoder = null;
+ for (int i = 0; i < defaultColumns.length; i++)columns.add(defaultColumns[i]);
+ }
+
+ if (columns.equals(oldColumns)) fireTableDataChanged();
+ else super.fireTableStructureChanged();
+ }
+
+
+ public int getColumnCount()
+ {
+ return columns.size();
+ }
+
+
+ public String getColumnName(int index)
+ {
+ return columns.get(index);
+ }
+
+
+ public int getRowCount()
+ {
+ return hits == null ? 0 : hits.size();
+ }
+
+
+ protected int getFieldCount()
+ {
+ return decoder == null ? 1 : decoder.getFieldCount();
+ }
+
+ protected IDDecoder getIDDecoder()
+ {
+ return decoder;
+ }
+
+ protected Object getHit(int row)
+ {
+ return hits.get(row);
+ }
+}
+
lcsim/src/org/lcsim/plugin/browser
diff -u -r1.9 -r1.10
--- SimTrackerHitTableModel.java 23 Mar 2006 01:03:08 -0000 1.9
+++ SimTrackerHitTableModel.java 5 Apr 2006 09:09:12 -0000 1.10
@@ -1,76 +1,44 @@
package org.lcsim.plugin.browser;
-import javax.swing.table.AbstractTableModel;
-import java.util.List;
-import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.event.SimTrackerHit;
-import java.util.ArrayList;
-import org.lcsim.geometry.util.BaseIDDecoder;
+import org.lcsim.geometry.IDDecoder;
/**
* @author tonyj
*/
-class SimTrackerHitTableModel extends AbstractTableModel implements EventBrowserTableModel
+class SimTrackerHitTableModel extends CellIDTableModel
{
- private List hits;
private static final String[] defaultColumns =
- { "x (mm)", "y (mm)", "z (mm)", "dEdx (GeV)", "time (ns)", "px (GeV)", "py (GeV)", "pz (GeV)", "pathLength (mm)" };
- private List<String> columns;
- // private IDDecoder decoder;
- private BaseIDDecoder decoder;
+ { "id", "x (mm)", "y (mm)", "z (mm)", "dEdx (GeV)", "time (ns)", "px (GeV)", "py (GeV)", "pz (GeV)", "pathLength (mm)" };
- public boolean canDisplay(Class c)
+ SimTrackerHitTableModel()
{
- return SimTrackerHit.class.isAssignableFrom(c);
+ super(defaultColumns);
}
-
- public void setData(LCMetaData meta, List hits)
- {
- this.hits = hits;
- this.decoder = (BaseIDDecoder) meta.getIDDecoder();
-
- List oldColumns = columns;
- columns = new ArrayList<String>();
- for (int i = 0; i < decoder.getFieldCount(); i++)
- columns.add("id: " + decoder.getFieldName(i));
- for (int i = 0; i < defaultColumns.length; i++)
- columns.add(defaultColumns[i]);
- if (columns.equals(oldColumns))
- fireTableDataChanged();
- else
- super.fireTableStructureChanged();
- }
-
- public int getRowCount()
- {
- return hits == null ? 0 : hits.size();
- }
-
- public int getColumnCount()
- {
- return columns.size();
- }
-
- public String getColumnName(int index)
+
+ public boolean canDisplay(Class c)
{
- return columns.get(index);
+ return SimTrackerHit.class.isAssignableFrom(c);
}
public Class getColumnClass(int row)
{
- return row < decoder.getFieldCount() ? Integer.class : Double.class;
+ return row < getFieldCount() ? Integer.class : Double.class;
}
public Object getValueAt(int row, int column)
{
- SimTrackerHit hit = (SimTrackerHit) hits.get(row);
- decoder.setID(hit.getCellID());
- if (column < decoder.getFieldCount())
+ SimTrackerHit hit = (SimTrackerHit) getHit(row);
+ int fieldCount = getFieldCount();
+
+ if (column < fieldCount)
{
- return decoder.getValue(column);
+ IDDecoder decoder = getIDDecoder();
+ if (decoder != null) decoder.setID(hit.getCellID());
+ return decoder == null ? hit.getCellID() : decoder.getValue(column);
}
else
- switch (column - decoder.getFieldCount())
+ switch (column - fieldCount)
{
case 0:
return hit.getPoint()[0];
lcsim/src/org/lcsim/plugin/browser
diff -u -r1.6 -r1.7
--- CalorimeterHitTableModel.java 8 Feb 2006 22:18:58 -0000 1.6
+++ CalorimeterHitTableModel.java 5 Apr 2006 09:09:12 -0000 1.7
@@ -8,73 +8,45 @@
import org.freehep.util.ScientificFormat;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader.LCMetaData;
-import org.lcsim.geometry.util.BaseIDDecoder;
+import org.lcsim.geometry.IDDecoder;
/**
* @author tonyj
*/
-class CalorimeterHitTableModel extends AbstractTableModel implements EventBrowserTableModel
+class CalorimeterHitTableModel extends CellIDTableModel
{
- private List hits;
- private LCMetaData meta;
- // private CalorimeterIDDecoder decoder;
- private BaseIDDecoder decoder;
private static final String[] defaultColumns =
- { "raw energy (GeV)", "corrected energy (GeV)", "x (mm)", "y (mm)", "z (mm)", "time (ns)" };
- private List<String> columns;
- private static final ScientificFormat format = new ScientificFormat();
+ { "id", "raw energy (GeV)", "corrected energy (GeV)", "x (mm)", "y (mm)", "z (mm)", "time (ns)" };
- public boolean canDisplay(Class c)
- {
- return CalorimeterHit.class.isAssignableFrom(c);
- }
-
- public void setData(LCMetaData meta, List hits)
- {
- this.hits = hits;
- this.meta = meta;
- // this.decoder = (CalorimeterIDDecoder) meta.getIDDecoder();
- this.decoder = (BaseIDDecoder) meta.getIDDecoder();
- List oldColumns = columns;
- columns = new ArrayList<String>();
- for (int i = 0; i < decoder.getFieldCount(); i++)
- columns.add("id: " + decoder.getFieldName(i));
- for (int i = 0; i < defaultColumns.length; i++)
- columns.add(defaultColumns[i]);
- if (columns.equals(oldColumns))
- fireTableDataChanged();
- else
- super.fireTableStructureChanged();
- }
-
- public int getRowCount()
- {
- return hits == null ? 0 : hits.size();
- }
-
- public int getColumnCount()
+ CalorimeterHitTableModel()
{
- return columns.size();
+ super(defaultColumns);
}
-
- public String getColumnName(int index)
+
+ public boolean canDisplay(Class c)
{
- return columns.get(index);
+ return CalorimeterHit.class.isAssignableFrom(c);
}
public Class getColumnClass(int row)
{
- return row < decoder.getFieldCount() ? Integer.class : Double.class;
+ return row < getFieldCount() ? (getIDDecoder() == null) ? Long.class : Integer.class : Double.class;
}
public Object getValueAt(int row, int column)
{
- CalorimeterHit hit = (CalorimeterHit) hits.get(row);
- decoder.setID(hit.getCellID());
- if (column < decoder.getFieldCount())
- return decoder.getValue(column);
+ CalorimeterHit hit = (CalorimeterHit) getHit(row);
+ int fieldCount = getFieldCount();
+
+ if (column < fieldCount)
+ {
+ IDDecoder decoder = getIDDecoder();
+ if (decoder != null) decoder.setID(hit.getCellID());
+ return decoder == null ? hit.getCellID() : decoder.getValue(column);
+ }
else
- switch (column - decoder.getFieldCount())
+ {
+ switch (column - fieldCount)
{
case 0:
return hit.getRawEnergy();
@@ -89,15 +61,16 @@
}
return cE;
case 2:
- return decoder.getX();
+ return hit.getPosition()[0];
case 3:
- return decoder.getY();
+ return hit.getPosition()[1];
case 4:
- return decoder.getZ();
+ return hit.getPosition()[2];
case 5:
return hit.getTime();
default:
return " ";
}
+ }
}
}
lcsim/src/org/lcsim/util/lcio
diff -u -r1.5 -r1.6
--- SIOCalorimeterHit.java 25 Aug 2005 23:53:35 -0000 1.5
+++ SIOCalorimeterHit.java 5 Apr 2006 09:09:12 -0000 1.6
@@ -2,19 +2,17 @@
import hep.lcd.io.sio.SIOInputStream;
import hep.lcd.io.sio.SIOOutputStream;
-import hep.lcd.io.sio.SIORef;
import java.io.IOException;
import org.lcsim.event.CalorimeterHit;
import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.util.event.BaseCalorimeterHit;
-import org.lcsim.event.RawCalorimeterHit;
/**
* SIO-based I/O implementation of the CalorimeterHit interface
*
* @author Guilherme Lima
- * @version $Id: SIOCalorimeterHit.java,v 1.5 2005/08/25 23:53:35 lima Exp $
+ * @version $Id: SIOCalorimeterHit.java,v 1.6 2006/04/05 09:09:12 tonyj Exp $
*/
class SIOCalorimeterHit extends BaseCalorimeterHit
{
@@ -28,18 +26,31 @@
}
this.id = ((long) cellid1)<<32 | cellid0;
this.rawEnergy = in.readFloat();
-
- if( LCIOUtil.bitTest(flags,LCIOConstants.RCHBIT_TIME) || version==8) {
- time = in.readFloat();
+
+ if (version>1002 && (flags&(1<<LCIOConstants.RCHBIT_TIME)) != 0)
+ {
+ time = in.readFloat();
+ }
+ if ((flags & (1 << LCIOConstants.RCHBIT_LONG)) != 0)
+ {
+ position = new double[3];
+ position[0] = in.readFloat();
+ position[1] = in.readFloat();
+ position[2] = in.readFloat();
+ }
+
+ if( version > 1002)
+ {
+ int type = in.readInt() ;
+ Object tempHit = in.readPntr();
+
+ // the logic has been reverted in v1.3 !
+ if ( (flags & (1 << LCIOConstants.RCHBIT_NO_PTR)) == 0 ) in.readPTag(this) ;
+ }
+ else
+ {
+ if ( (flags & (1 << LCIOConstants.RCHBIT_NO_PTR)) != 0 ) in.readPTag(this) ;
}
-
- int type = in.readInt();
-
- if (!LCIOUtil.bitTest(flags,LCIOConstants.RCHBIT_NO_PTR)) {
- SIORef rawhit = in.readPntr();
- }
-
- in.readPTag(this);
}
static void write(CalorimeterHit hit, SIOOutputStream out, int flags) throws IOException
lcsim/src/org/lcsim/plugin
diff -u -r1.6 -r1.7
--- LCSimPlugin.java 21 Mar 2006 19:47:27 -0000 1.6
+++ LCSimPlugin.java 5 Apr 2006 09:09:12 -0000 1.7
@@ -19,6 +19,8 @@
import org.freehep.util.commanddispatcher.CommandProcessor;
import org.freehep.util.template.Template;
import org.freehep.xml.menus.XMLMenuBuilder;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.plugin.conditions.InteractiveConditionsManagerImplementation;
import org.lcsim.plugin.browser.LCSimEventBrowser;
import org.lcsim.util.Driver;
import org.lcsim.util.DriverAdapter;
@@ -29,7 +31,7 @@
/**
*
* @author tonyj
- * @version $Id: LCSimPlugin.java,v 1.6 2006/03/21 19:47:27 tonyj Exp $
+ * @version $Id: LCSimPlugin.java,v 1.7 2006/04/05 09:09:12 tonyj Exp $
*/
public class LCSimPlugin extends Plugin implements StudioListener, PageListener
@@ -61,6 +63,8 @@
map.set("url","classpath:/org/lcsim/plugin/web/examples.html");
map.set("description","Examples of using the org.lcsim package");
app.getLookup().add(map,"examples");
+
+ ConditionsManager.setDefaultConditionsManager(new InteractiveConditionsManagerImplementation(app));
}
protected void postInit()
lcsim/src/org/lcsim/util/heprep
diff -u -r1.10 -r1.11
--- LCSimHepRepConverter.java 10 Feb 2006 17:31:01 -0000 1.10
+++ LCSimHepRepConverter.java 5 Apr 2006 09:09:12 -0000 1.11
@@ -6,6 +6,7 @@
import hep.graphics.heprep.HepRepInstanceTree;
import hep.graphics.heprep.HepRepTreeID;
import hep.graphics.heprep.HepRepTypeTree;
+import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.lcsim.event.EventHeader;
@@ -62,12 +63,19 @@
public HepRep convert(Object object)
{
EventHeader event = (EventHeader) object;
-
+ HepRep root = factory.createHepRep();
+
// Lets start with the detector
- Detector detector = event.getDetector();
- HepRep root = factory.createHepRep();
- detector.appendHepRep(factory,root);
+ try
+ {
+ Detector detector = event.getDetector();
+ detector.appendHepRep(factory,root);
+ }
+ catch (Exception x)
+ {
+
+ }
// Now on to deal with the event data
CVSspam 0.2.8