예제 #1
0
 /** Calculate the minimum and preferred size for every row and column. */
 private void calculateSizes() {
   Dimension dim[] = new Dimension[child.size()];
   for (int i = 0; i < dim.length; i++) dim[i] = child.get(i).widget.getMinimumSize();
   minRowSize = calculateRequiredSizes(dim, true);
   minColSize = calculateRequiredSizes(dim, false);
   for (int i = 0; i < dim.length; i++) {
     ChildInfo info = child.get(i);
     LayoutInfo layout = (info.layout == null ? defaultLayout : info.layout);
     dim[i] = layout.getPreferredSize(info.widget);
   }
   prefRowSize = calculateRequiredSizes(dim, true);
   prefColSize = calculateRequiredSizes(dim, false);
 }
예제 #2
0
 /**
  * Layout the child Widgets. This may be invoked whenever something has changed (the size of this
  * WidgetContainer, the preferred size of one of its children, etc.) that causes the layout to no
  * longer be correct. If a child is itself a WidgetContainer, its layoutChildren() method will be
  * called in turn.
  */
 public void layoutChildren() {
   if (minColSize == null) calculateSizes();
   Dimension size = getComponent().getSize();
   int rowPos[] = calculatePositions(minRowSize, prefRowSize, rowWeight, size.height);
   int colPos[] = calculatePositions(minColSize, prefColSize, colWeight, size.width);
   Rectangle cell = new Rectangle();
   for (int i = 0; i < child.size(); i++) {
     ChildInfo info = child.get(i);
     LayoutInfo layout = (info.layout == null ? defaultLayout : info.layout);
     cell.x = (info.x == 0 ? 0 : colPos[info.x - 1]);
     cell.y = (info.y == 0 ? 0 : rowPos[info.y - 1]);
     cell.width = colPos[info.x + info.width - 1] - cell.x;
     cell.height = rowPos[info.y + info.height - 1] - cell.y;
     info.widget.getComponent().setBounds(layout.getWidgetLayout(info.widget, cell));
     if (info.widget instanceof WidgetContainer) ((WidgetContainer) info.widget).layoutChildren();
   }
 }
예제 #3
0
 public LayoutInfo copyOfThisLayoutInfo() {
   LayoutInfo copyI = new LayoutInfo();
   for (NodeLayout nl : nodes) {
     copyI.addNodeLayout(nl.processID, nl.nodeID, nl.cofactor, nl.x, nl.y);
   }
   for (EdgeLayout el : edges) {
     ArrayList<LayoutPoint> copyBends = new ArrayList<LayoutPoint>();
     for (LayoutPoint lp : el.bends) {
       copyBends.add(new LayoutPoint(lp.x, lp.y));
     }
     copyI.addEdgeLayout(
         el.sourcepid,
         el.sourceNode,
         el.scofactor,
         el.targetpid,
         el.targetNode,
         el.tcofactor,
         copyBends);
   }
   return copyI;
 }
예제 #4
0
 public int compare(LayoutInfo i1, LayoutInfo i2) {
   LayoutBox box1 = i1.getExactLayoutBox();
   LayoutBox box2 = i2.getExactLayoutBox();
   return (box1.size() < box2.size() ? -1 : (box1.size() == box2.size() ? 0 : 1));
 }
예제 #5
0
 public static void main(String[] args) {
   LayoutInfo info = new LayoutInfo();
   System.out.println(info.toXMLString());
 }
예제 #6
0
 /**
  * to check if the two layouts' exact box overlapping
  *
  * @see binevi.View.LayoutInfo#overlapLayoutBox(LayoutBox)
  */
 public boolean overlapLayoutBox(LayoutInfo i) {
   LayoutBox b2 = i.getExactLayoutBox();
   return overlapLayoutBox(b2);
 }