5 added + 9 modified, total 14 files
lcsim/src/org/lcsim/plugin/conditions
diff -N HepRepSelectWizardPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HepRepSelectWizardPage.java 9 Apr 2007 05:11:10 -0000 1.1
@@ -0,0 +1,132 @@
+package org.lcsim.plugin.conditions;
+
+import hep.graphics.heprep.HepRep;
+import hep.graphics.heprep.HepRepFactory;
+import hep.graphics.heprep.HepRepReader;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import org.freehep.application.Application;
+import org.freehep.jas.util.OpenLocalFilePanel;
+import org.freehep.swing.ExtensionFileFilter;
+import org.freehep.swing.wizard.Finishable;
+import org.freehep.swing.wizard.WizardPage;
+import org.lcsim.conditions.ConditionsReader;
+
+/**
+ *
+ * @author tonyj
+ * @version $Id: HepRepSelectWizardPage.java,v 1.1 2007/04/09 05:11:10 tonyj Exp $
+ */
+class HepRepSelectWizardPage extends WizardPage implements Finishable, ChangeListener
+{
+ private ConditionsWizardPage wp;
+ private OpenLocalFilePanel olfp;
+ /** Creates new form ConditionsAliasWizardPage */
+ HepRepSelectWizardPage(ConditionsWizardPage wp)
+ {
+ this.wp = wp;
+ this.olfp = new OpenLocalFilePanel("heprep",new HepRepFileFilter(),false,true);
+ initComponents();
+ olfp.addChangeListener(this);
+ stateChanged(null);
+ }
+
+ /** 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;
+
+ jPanel1 = olfp;
+ jLabel2 = new javax.swing.JLabel();
+ jTextField2 = new javax.swing.JTextField();
+
+ setLayout(new java.awt.GridBagLayout());
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ add(jPanel1, gridBagConstraints);
+
+ jLabel2.setText("Field:");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
+ gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
+ add(jLabel2, gridBagConstraints);
+
+ jTextField2.setColumns(10);
+ jTextField2.setText("5");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ add(jTextField2, gridBagConstraints);
+
+ }// </editor-fold>//GEN-END:initComponents
+
+ public void onFinish()
+ {
+ try
+ {
+ InputStream in = new FileInputStream(olfp.getFile());
+ try
+ {
+ double field = Double.parseDouble(jTextField2.getText());
+
+ if (olfp.getGZIPed()) in = new GZIPInputStream(in);
+ else in = new BufferedInputStream(in);
+ HepRepReader reader = HepRepFactory.create().createHepRepReader(in);
+ HepRep hepRep = reader.next();
+
+ String detectorName = wp.getDetectorName();
+ InteractiveConditionsManagerImplementation cm = wp.getConditionsManager();
+ ConditionsReader dummyReader = ConditionsReader.createDummy();
+ cm.setConditionsReader(dummyReader, detectorName);
+ HepRepOnlyDetector detector = new HepRepOnlyDetector(detectorName, hepRep, field);
+ cm.registerConditionsConverter(new HepRepConditionsConverter(detector));
+ cm.setDetectorFound(true);
+
+ olfp.saveState();
+ dispose();
+ }
+ finally
+ {
+ in.close();
+ }
+
+
+ }
+ catch (Exception x)
+ {
+ Application.error(this,"Error handling heprep",x);
+ }
+ }
+
+ public void stateChanged(ChangeEvent e)
+ {
+ this.setFinishEnabled(olfp.isFileSelected());
+ }
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JTextField jTextField2;
+ // End of variables declaration//GEN-END:variables
+
+ private class HepRepFileFilter extends ExtensionFileFilter
+ {
+ HepRepFileFilter()
+ {
+ super(new String[]{".heprep", ".heprep.gz"}, "HepRep file");
+ }
+ }
+}
lcsim/src/org/lcsim/plugin/conditions
diff -N HepRepOnlyDetector.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HepRepOnlyDetector.java 9 Apr 2007 05:11:10 -0000 1.1
@@ -0,0 +1,83 @@
+package org.lcsim.plugin.conditions;
+
+import hep.graphics.heprep.HepRep;
+import hep.graphics.heprep.HepRepFactory;
+import hep.graphics.heprep.HepRepInstanceTree;
+import hep.graphics.heprep.HepRepTypeTree;
+import hep.physics.vec.BasicHep3Vector;
+import hep.physics.vec.Hep3Vector;
+import java.util.List;
+import org.lcsim.geometry.Detector;
+import org.lcsim.geometry.FieldMap;
+
+/**
+ * A "dummy" detector which is only able to provide HepRep's for WIRED for
+ * when no other geometry is available.
+ * @author tonyj
+ */
+class HepRepOnlyDetector extends Detector
+{
+ private String name;
+ private HepRep detector;
+ private FieldMap field;
+ /** Creates a new instance of HeprepOnlyDetector */
+ HepRepOnlyDetector(String name, HepRep heprep, double field)
+ {
+ super(null);
+ this.name = name;
+ this.detector = heprep;
+ this.field = new SolenoidalField(field);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void appendHepRep(HepRepFactory factory, HepRep heprep)
+ {
+ List<HepRepTypeTree> types = detector.getTypeTreeList();
+ for (HepRepTypeTree gTypeTree : types) heprep.addTypeTree(gTypeTree);
+
+ List<HepRepInstanceTree> instances = detector.getInstanceTreeList();
+ for (HepRepInstanceTree gInstanceTree : instances) heprep.addInstanceTree(gInstanceTree);
+
+ List<String> layers = detector.getLayerOrder();
+ for (String layer : layers ) heprep.addLayer(layer);
+ }
+
+ public FieldMap getFieldMap()
+ {
+ return field;
+ }
+
+ private class SolenoidalField implements FieldMap
+ {
+ private double[] field;
+ SolenoidalField(double zField)
+ {
+ field = new double[]{0,0,zField};
+ }
+ public void getField(double[] position, double[] b)
+ {
+ for (int i=0;i<3;i++) b[i] = field[1];
+ }
+
+ public double[] getField(double[] position)
+ {
+ return field;
+ }
+
+ public Hep3Vector getField(Hep3Vector position, BasicHep3Vector field)
+ {
+ if (field == null) field = new BasicHep3Vector();
+ getField(position.v(),field.v());
+ return field;
+ }
+
+ public Hep3Vector getField(Hep3Vector position)
+ {
+ return getField(position,null);
+ }
+ }
+}
lcsim/src/org/lcsim/plugin/conditions
diff -N HepRepSelectWizardPage.form
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HepRepSelectWizardPage.form 9 Apr 2007 05:11:10 -0000 1.1
@@ -0,0 +1,50 @@
+<?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_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <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>
+ <Container class="javax.swing.JPanel" name="jPanel1">
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="olfp;"/>
+ </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="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ </Container>
+ <Component class="javax.swing.JLabel" name="jLabel2">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Field:"/>
+ </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="-1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="5" anchor="13" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JTextField" name="jTextField2">
+ <Properties>
+ <Property name="columns" type="int" value="10"/>
+ <Property name="text" type="java.lang.String" value="5"/>
+ </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>
+ </SubComponents>
+</Form>
lcsim/src/org/lcsim/plugin/conditions
diff -N HepRepConditionsConverter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HepRepConditionsConverter.java 9 Apr 2007 05:11:11 -0000 1.1
@@ -0,0 +1,27 @@
+package org.lcsim.plugin.conditions;
+
+import org.lcsim.conditions.ConditionsConverter;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.geometry.Detector;
+
+/**
+ * Used to return the dummy HepRepOnlyDetector
+ * @author tonyj
+ */
+class HepRepConditionsConverter implements ConditionsConverter<Detector>
+{
+ private Detector detector;
+ HepRepConditionsConverter(Detector detector)
+ {
+ this.detector = detector;
+ }
+ public Detector getData(ConditionsManager manager, String name)
+ {
+ return detector;
+ }
+
+ public Class<Detector> getType()
+ {
+ return Detector.class;
+ }
+}
lcsim/src/org/lcsim/plugin/conditions
diff -u -r1.2 -r1.3
--- ConditionsWizardPage.form 5 Apr 2006 10:40:21 -0000 1.2
+++ ConditionsWizardPage.form 9 Apr 2007 05:11:10 -0000 1.3
@@ -14,6 +14,7 @@
</Properties>
<AuxValues>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" 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"/>
@@ -65,7 +66,9 @@
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
+ <Property name="mnemonic" type="int" value="65"/>
<Property name="text" type="java.lang.String" value="Alias this detector to an existing detector"/>
+ <Property name="actionCommand" type="java.lang.String" value="alias"/>
<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"/>
@@ -89,7 +92,9 @@
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
+ <Property name="mnemonic" type="int" value="71"/>
<Property name="text" type="java.lang.String" value="Give location of a conditions database for this detector (not yet implemented)"/>
+ <Property name="actionCommand" type="java.lang.String" value="give"/>
<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"/>
@@ -114,13 +119,17 @@
<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 (not yet implemented)"/>
+ <Property name="mnemonic" type="int" value="72"/>
+ <Property name="text" type="java.lang.String" value="Give location of a HepRep file for this detector"/>
+ <Property name="actionCommand" type="java.lang.String" value="heprep"/>
<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="enabled" type="boolean" value="false"/>
+ <Property name="enabled" type="boolean" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="hepRepPluginInstalled" type="code"/>
+ </Property>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[0, 0, 0, 0]"/>
</Property>
@@ -139,7 +148,9 @@
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
+ <Property name="mnemonic" type="int" value="80"/>
<Property name="text" type="java.lang.String" value="Proceed with no detector information (limited functionality)"/>
+ <Property name="actionCommand" type="java.lang.String" value="proceed"/>
<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"/>
lcsim/src/org/lcsim/plugin/conditions
diff -u -r1.2 -r1.3
--- ConditionsWizardPage.java 5 Apr 2006 10:40:21 -0000 1.2
+++ ConditionsWizardPage.java 9 Apr 2007 05:11:11 -0000 1.3
@@ -1,31 +1,53 @@
package org.lcsim.plugin.conditions;
+import java.util.Enumeration;
+import javax.swing.AbstractButton;
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;
+import org.lcsim.conditions.ConditionsReader;
/**
*
- * @author tonyj
+ * @author tonyj
*/
-public class ConditionsWizardPage extends WizardPage implements HasNextPages, Finishable
+class ConditionsWizardPage extends WizardPage implements HasNextPages, Finishable
{
private WizardPage nextPage;
private InteractiveConditionsManagerImplementation cm;
private final WizardPage[] pages;
private String detectorName;
+ private boolean hepRepPluginInstalled;
/** Creates new form ConditionsWizardPanel */
- public ConditionsWizardPage(InteractiveConditionsManagerImplementation cm, String detectorName)
+ ConditionsWizardPage(InteractiveConditionsManagerImplementation cm, String detectorName)
{
this.cm = cm;
this.detectorName = detectorName;
- pages = new WizardPage[]{ new ConditionsAliasWizardPage(this) };
+ try
+ {
+ Class.forName("hep.graphics.heprep.HepRep");
+ hepRepPluginInstalled = true;
+ }
+ catch (Exception x)
+ {
+ hepRepPluginInstalled = false;
+ }
+ pages = hepRepPluginInstalled ? new WizardPage[]{ new ConditionsAliasWizardPage(this) , new HepRepSelectWizardPage(this) } : new WizardPage[]{ new ConditionsAliasWizardPage(this) };
initComponents();
detectorLabel.setText(detectorName);
setNextEnabled(false);
setFinishEnabled(false);
+ String lastSelected = cm.getStudio().getUserProperties().getProperty(getClass().getName()+".lastSelected");
+ if (lastSelected != null)
+ {
+ Enumeration e = buttonGroup1.getElements();
+ while (e.hasMoreElements())
+ {
+ AbstractButton button = (AbstractButton) e.nextElement();
+ if (lastSelected.equals(button.getActionCommand())) button.setSelected(true);
+ }
+ }
}
public WizardPage getNext()
@@ -44,6 +66,7 @@
cm.setConditionsReader(ConditionsReader.createDummy(),detectorName);
cm.setDetectorFound(true);
}
+ cm.getStudio().getUserProperties().setProperty(getClass().getName()+".lastSelected",buttonGroup1.getSelection().getActionCommand());
dispose();
}
void addAlias(String name) throws ConditionsNotFoundException
@@ -97,7 +120,9 @@
add(jLabel3, gridBagConstraints);
buttonGroup1.add(aliasButton);
+ aliasButton.setMnemonic('A');
aliasButton.setText("Alias this detector to an existing detector");
+ aliasButton.setActionCommand("alias");
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()
@@ -115,7 +140,9 @@
add(aliasButton, gridBagConstraints);
buttonGroup1.add(locateButton);
+ locateButton.setMnemonic('G');
locateButton.setText("Give location of a conditions database for this detector (not yet implemented)");
+ locateButton.setActionCommand("give");
locateButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
locateButton.setEnabled(false);
locateButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
@@ -134,9 +161,11 @@
add(locateButton, gridBagConstraints);
buttonGroup1.add(heprepButton);
- heprepButton.setText("Give location of a HepRep file for this detector (not yet implemented)");
+ heprepButton.setMnemonic('H');
+ heprepButton.setText("Give location of a HepRep file for this detector");
+ heprepButton.setActionCommand("heprep");
heprepButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
- heprepButton.setEnabled(false);
+ heprepButton.setEnabled(hepRepPluginInstalled);
heprepButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
heprepButton.addActionListener(new java.awt.event.ActionListener()
{
@@ -153,7 +182,9 @@
add(heprepButton, gridBagConstraints);
buttonGroup1.add(noDetectorButton);
+ noDetectorButton.setMnemonic('P');
noDetectorButton.setText("Proceed with no detector information (limited functionality)");
+ noDetectorButton.setActionCommand("proceed");
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()
@@ -177,10 +208,22 @@
Object source = evt.getSource();
WizardPage next = null;
if (source == aliasButton) next = pages[0];
+ else if (source == heprepButton) next = pages[1];
nextPage = next;
setNextEnabled(next != null);
setFinishEnabled(next == null);
}//GEN-LAST:event_radioButtonSelected
+
+ String getDetectorName()
+ {
+ return detectorName;
+ }
+
+ InteractiveConditionsManagerImplementation getConditionsManager()
+ {
+ return cm;
+ }
+
// Variables declaration - do not modify//GEN-BEGIN:variables
lcsim/src/org/lcsim/plugin/conditions
diff -u -r1.1 -r1.2
--- InteractiveConditionsManagerImplementation.java 5 Apr 2006 09:09:11 -0000 1.1
+++ InteractiveConditionsManagerImplementation.java 9 Apr 2007 05:11:11 -0000 1.2
@@ -11,7 +11,7 @@
/**
* 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 $
+ * @version $Id: InteractiveConditionsManagerImplementation.java,v 1.2 2007/04/09 05:11:11 tonyj Exp $
*/
public class InteractiveConditionsManagerImplementation extends ConditionsManagerImplementation
{
@@ -58,6 +58,11 @@
setDetectorFound(true);
}
+ Studio getStudio()
+ {
+ return app;
+ }
+
private class AppWizardDialog extends WizardDialog
{
AppWizardDialog(Frame frame, String title, WizardPage firstPage)
lcsim/src/org/lcsim/plugin/conditions
diff -u -r1.1 -r1.2
--- ConditionsAliasWizardPage.java 5 Apr 2006 09:09:10 -0000 1.1
+++ ConditionsAliasWizardPage.java 9 Apr 2007 05:11:11 -0000 1.2
@@ -9,13 +9,13 @@
/**
*
* @author tonyj
- * @version $Id: ConditionsAliasWizardPage.java,v 1.1 2006/04/05 09:09:10 tonyj Exp $
+ * @version $Id: ConditionsAliasWizardPage.java,v 1.2 2007/04/09 05:11:11 tonyj Exp $
*/
-public class ConditionsAliasWizardPage extends WizardPage implements Finishable
+class ConditionsAliasWizardPage extends WizardPage implements Finishable
{
private ConditionsWizardPage wp;
/** Creates new form ConditionsAliasWizardPage */
- public ConditionsAliasWizardPage(ConditionsWizardPage wp)
+ ConditionsAliasWizardPage(ConditionsWizardPage wp)
{
this.wp = wp;
initComponents();
lcsim/src/org/lcsim/plugin/browser
diff -u -r1.1 -r1.2
--- LCSimEventTree.java 21 Jun 2005 18:19:53 -0000 1.1
+++ LCSimEventTree.java 9 Apr 2007 05:11:11 -0000 1.2
@@ -20,7 +20,7 @@
/**
*
* @author tonyj
- * @version $Id: LCSimEventTree.java,v 1.1 2005/06/21 18:19:53 tonyj Exp $
+ * @version $Id: LCSimEventTree.java,v 1.2 2007/04/09 05:11:11 tonyj Exp $
*/
class LCSimEventTree extends JComponent
{
@@ -38,7 +38,7 @@
m_root.clear();
m_event = event;
- if (m_event != null)
+ if (m_event != null && m_event.hasCollection(MCParticle.class, EventHeader.MC_PARTICLES))
{
// Any particle which has no parents should appear at the
// root level
lcsim/test/org/lcsim/plugin/conditions
diff -N HepRepOnlyDetectorTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ HepRepOnlyDetectorTest.java 9 Apr 2007 05:11:11 -0000 1.1
@@ -0,0 +1,36 @@
+package org.lcsim.plugin.conditions;
+
+import junit.framework.*;
+import hep.graphics.heprep.HepRep;
+import hep.graphics.heprep.HepRepFactory;
+import org.lcsim.conditions.ConditionsManager;
+import org.lcsim.geometry.Detector;
+
+/**
+ *
+ * @author tonyj
+ */
+public class HepRepOnlyDetectorTest extends TestCase
+{
+
+ public HepRepOnlyDetectorTest(String testName)
+ {
+ super(testName);
+ }
+
+
+ public void testHepRepOnlyDetector() throws ClassNotFoundException, IllegalAccessException, InstantiationException
+ {
+ HepRep heprep = HepRepFactory.create().createHepRep();
+ HepRepOnlyDetector det = new HepRepOnlyDetector("test",heprep,4);
+ assertEquals("test",det.getName());
+ assertEquals(4.0,det.getFieldMap().getField(new double[]{0,0,0})[2],1e-16);
+
+ HepRepConditionsConverter cc = new HepRepConditionsConverter(det);
+ ConditionsManager cm = ConditionsManager.defaultInstance();
+ cm.registerConditionsConverter(cc);
+ Detector det2 = cm.getCachedConditions(Detector.class,"detector").getCachedData();
+ assertEquals(det,det2);
+ }
+
+}
\ No newline at end of file
lcsim
diff -u -r1.8 -r1.9
--- .cvsignore 28 Jun 2006 04:48:34 -0000 1.8
+++ .cvsignore 9 Apr 2007 05:11:11 -0000 1.9
@@ -1,19 +1,20 @@
+mcfastgenerator.slcio
FixedConeRecon.slcio
NearestNeighborRecon.slcio
-target
-build.properties
-test.heprep
fastmc.aida
-line.aida
-x.aida
-test.slcio
-crash.steer
-mcfastgenerator.slcio
-fastmcgenerator.aida
-test2.slcio
-helix.aida
mcfast.slcio
-digisim.slcio
-bin
.settings
+helix.aida
+digisim.slcio
+crash.steer
+fastmcgenerator.aida
.classpath
+build.properties
+test.slcio
+target
+x.aida
+line.aida
+test.heprep
+filter.stdhep
+bin
+test2.slcio
lcsim/src/org/lcsim/util/event
diff -u -r1.20 -r1.21
--- BaseLCSimEvent.java 22 May 2006 20:53:01 -0000 1.20
+++ BaseLCSimEvent.java 9 Apr 2007 05:11:11 -0000 1.21
@@ -191,6 +191,29 @@
{
return detectorName;
}
+
+ public boolean hasCollection(Class type, String name)
+ {
+ if (!hasItem(name)) return false;
+ Object collection = get(name);
+ if (!(collection instanceof List)) return false;
+ return type.isAssignableFrom(metaDataMap.get(collection).getType());
+ }
+ public boolean hasCollection(Class type)
+ {
+ for (LCMetaData meta : metaDataMap.values())
+ {
+ if (type.isAssignableFrom(meta.getType()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ public boolean hasItem(String name)
+ {
+ return super.keys().contains(name);
+ }
private class MetaData implements LCMetaData
{
lcsim/src/org/lcsim/util
diff -u -r1.12 -r1.13
--- Driver.java 3 Apr 2007 18:02:34 -0000 1.12
+++ Driver.java 9 Apr 2007 05:11:11 -0000 1.13
@@ -23,7 +23,7 @@
* and handles coordination of random numbers between Monte Carlo processors.
*
* @author Tony Johnson
- * @version $Id: Driver.java,v 1.12 2007/04/03 18:02:34 tonyj Exp $
+ * @version $Id: Driver.java,v 1.13 2007/04/09 05:11:11 tonyj Exp $
*/
public class Driver
@@ -42,8 +42,9 @@
private int histogramLevel = HLEVEL_DEFAULT;
private Random random;
private final String driverName;
-
-
+
+ /** Creates a driver
+ */
public Driver()
{
this(null);
lcsim/src/org/lcsim/event
diff -u -r1.14 -r1.15
--- EventHeader.java 28 Jun 2006 04:48:31 -0000 1.14
+++ EventHeader.java 9 Apr 2007 05:11:11 -0000 1.15
@@ -10,7 +10,7 @@
* The event header from which information about the rest of the event
* can be obtained.
* @author Tony Johnson
- * @version $Id: EventHeader.java,v 1.14 2006/06/28 04:48:31 jstrube Exp $
+ * @version $Id: EventHeader.java,v 1.15 2007/04/09 05:11:11 tonyj Exp $
*/
public interface EventHeader extends MCEvent
{
@@ -48,7 +48,7 @@
*/
String getDetectorName();
/**
- * The creation time of this event (in nS since 1-Jan-1970).
+ * The creation time of this event (in nS since 1-Jan-1970 GMT).
*/
long getTimeStamp();
/**
@@ -84,6 +84,24 @@
* Removes an item from the event
*/
void remove(String name);
+
+ /**
+ * Test if the event contains a collection of a given type and name. Can be used to avoid having
+ * to catch an exception if the event does not contain an expected collection when calling get.
+ */
+ boolean hasCollection(Class type, String collection);
+
+ /**
+ * Test if the event contains at least one collection of the given type.
+ */
+ boolean hasCollection(Class type);
+
+ /**
+ * Test if the event contains a given item.
+ * @param name The name of the item to look for
+ * @return <code>true</code> if the event contains an item with the given name.
+ */
+ boolean hasItem(String name);
/**
* List of elements stored in the event may have meta-data associated with
CVSspam 0.2.8