View Javadoc

1   package org.catacomb.druid.blocks;
2   
3   import org.catacomb.druid.build.Context;
4   import org.catacomb.druid.build.GUIPath;
5   import org.catacomb.druid.gui.base.DruBorderPanel;
6   import org.catacomb.druid.gui.base.DruPanel;
7   import org.catacomb.interlish.structure.AddableTo;
8   import org.catacomb.report.E;
9   
10  
11  import java.util.ArrayList;
12  
13  
14  public class BorderPanel extends Panel implements AddableTo {
15  
16  
17      public int xspace;
18      public int yspace;
19  
20  
21      ArrayList<PanelInserter> inserters;
22  
23  
24      public BorderPanel() {
25          xspace = 0;
26          yspace = 0;
27      }
28  
29  
30      public void add(Object obj) {
31          if (inserters == null) {
32              inserters = new ArrayList<PanelInserter>();
33          }
34          if (obj instanceof PanelInserter) {
35              inserters.add((PanelInserter)obj);
36  
37          } else {
38              E.error("cant add " + obj);
39          }
40      }
41  
42  
43  
44  
45  
46      public DruPanel instantiatePanel() {
47          return new DruBorderPanel(xspace, yspace);
48      }
49  
50  
51  
52      public void populatePanel(DruPanel drup, Context ctx, GUIPath gpath) {
53          if (inserters != null) {
54              for (PanelInserter pi : inserters) {
55                  DruPanel dp = pi.realizePanel(ctx, gpath);
56                  if (pi == null) {
57                      E.error("null panel from inserter " + pi);
58                  } else if (dp == null) {
59                      // OK - nothing was specified to go in the panel;
60  
61                  } else {
62                      pi.insert(dp, (DruBorderPanel)drup);
63                  }
64              }
65          }
66  
67      }
68  
69  }