Example #1
0
  /** Draws the panel. */
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Log.setTrace(true);
    //      Log.trace(this, getBounds().toString());
    //      Log.trace(this, getInsets().toString());

    // respect borders
    Insets insets = getInsets();
    Rectangle r = getBounds();
    r.x += insets.left;
    r.y += insets.top;
    r.width -= insets.left + insets.right;
    r.height -= insets.top + insets.bottom;

    // System.out.println("paintComponent" + count++);

    g.setColor(Color.black);
    DirectedGraph<LayoutNode, DirectedEdge<LayoutNode>> graph = fLayout.graph();

    // draw edges
    Iterator<DirectedEdge<LayoutNode>> edgeIter = graph.edgeIterator();
    while (edgeIter.hasNext()) {
      DirectedEdge<LayoutNode> edge = edgeIter.next();
      // Log.trace(this, edge.toString());
      LayoutNode source = (LayoutNode) edge.source();
      LayoutNode target = (LayoutNode) edge.target();
      int x1 = source.getX() * 80 + 30;
      int y1 = 50 + source.fLayer * 50;
      //          if (source.isDummy() )
      //          x1 += 5;
      int x2 = target.getX() * 80 + 30;
      int y2 = 50 + target.fLayer * 50;
      //          if (target.isDummy() )
      //          x2 += 5;
      g.drawLine(x1, y1, x2, y2);
    }

    // draw nodes
    Iterator<LayoutNode> nodeIter = graph.iterator();
    while (nodeIter.hasNext()) {
      LayoutNode node = nodeIter.next();
      if (node.isDummy()) continue;
      int x = node.getX() * 80 + 30;
      int y = 50 + node.fLayer * 50;
      g.setColor(Color.white);
      g.fillRect(x - 10, y - 10, 20, 20);
      g.setColor(Color.black);
      g.drawRect(x - 10, y - 10, 20, 20);
      g.drawString(node.toString(), x - 7, y + 8);
    }
  }
  @Override
  public void containerLayoutChanged(PropertyChangeEvent ev) throws PropertyVetoException {
    if (ev != null && ev.getPropertyName() != null) {
      layoutDelegate.acceptContainerLayoutChange(ev);

      FormModel formModel = radContainer.getFormModel();
      formModel.fireContainerLayoutChanged(
          radContainer, ev.getPropertyName(), ev.getOldValue(), ev.getNewValue());
    } else {
      propertySets = null;
    }

    LayoutNode node = radContainer.getLayoutNodeReference();
    if (node != null) {
      // propagate the change to node
      if (ev != null && ev.getPropertyName() != null) {
        node.fireLayoutPropertiesChange();
      } else {
        node.fireLayoutPropertySetsChange();
      }
    }
  }