View Javadoc

1   /*
2    * Copyright 2006 - 2012 Christina Bohk and Roland Ewald
3    *  
4    * Licensed under the Apache License, Version 2.0 (the "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at 
7    *  
8    *  http://www.apache.org/licenses/LICENSE-2.0
9    *  
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License. 
15   */
16  package p3j.gui.panels.projections;
17  
18  import java.util.List;
19  
20  import javax.swing.JPanel;
21  import javax.swing.tree.TreePath;
22  
23  import p3j.gui.panels.PropertiesShowPanelFactory;
24  import p3j.pppm.parameters.ParameterInstance;
25  
26  /**
27   * Represents a set of instances that belongs to the same generation.
28   * 
29   * Created: August 24, 2008
30   * 
31   * @author Christina Bohk
32   * @author Roland Ewald
33   * 
34   */
35  public class GenerationNode extends ProjectionTreeNode<List<ParameterInstance>> {
36  
37    /**
38     * Serialization ID.
39     */
40    private static final long serialVersionUID = 6051811013784521035L;
41  
42    /**
43     * Default constructor.
44     * 
45     * @param instances
46     *          non-empty list of instances belonging to the same generation
47     */
48    public GenerationNode(List<ParameterInstance> instances) {
49      super(instances, "Descendant Generation "
50          + (instances.get(0).getGeneration()));
51    }
52  
53    @Override
54    public JPanel selected(TreePath selectionPath, final IProjectionTree projTree) {
55      PropertiesShowPanelFactory pspf = new PropertiesShowPanelFactory();
56      pspf.sep("General Information");
57      pspf.app("Descendant Generation:", getEntity().get(0).getGeneration());
58      pspf.app("Parameters:", getEntity().size());
59      pspf.app("Populations:", this.getChildCount());
60      return pspf.constructPanel();
61    }
62  
63  }