View Javadoc

1   package org.lcsim.plugin.browser;
2   import org.lcsim.event.ReconstructedParticle;
3   
4   
5   /**
6    *
7    * @author tonyj
8    */
9   class ReconstructedParticleTableModel extends GenericTableModel
10  {
11     private static final String[] columns = {"Type","Momentum","Energy","Mass","Charge","ReferencePoint", "ParticleIDs"};
12     private static Class klass = ReconstructedParticle.class;
13  
14     ReconstructedParticleTableModel()
15     {
16        super(klass,columns);
17     }
18  
19  
20  
21     /* We will have a string for the 6th column*/
22     @Override
23     public Class getColumnClass(int index) {
24         if (index == 6)
25             return String.class;
26         else return super.getColumnClass(index);
27     }
28                     
29  
30     /* For the 6th column, build up a string from the list of particle types*/
31     @Override
32     public Object getValueAt(int r, int c) {
33         if (c!=6)
34             return super.getValueAt(r, c);
35  
36         ReconstructedParticle p = (ReconstructedParticle) getData(r);
37  
38         String str = "[";
39         int size = p.getParticleIDs().size();
40  
41         for (int i = 0; i < size; i++) {
42  
43             str+= " " + p.getParticleIDs().get(i).getPDG() + " ";
44             if  (i < size-1)
45                 str+=",";
46         }
47  
48         str+="]";
49  
50         return str; 
51     }
52   
53  }