Пример #1
0
  /** draw the arrows between items */
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (_glist != null && _glist.size() > 1) {
      Graphics2D g2 = (Graphics2D) g;
      Arrow leftArrow = new Arrow();
      leftArrow.setColor(Color.BLACK);

      Arrow rightArrow = new Arrow();
      rightArrow.setColor(Color.RED);

      Iterator<GNode> iter = _glist.iterator();

      while (iter.hasNext()) {
        GNode nCur = iter.next();
        if (nCur.left != null) {
          leftArrow.setLine(nCur.getStart(), nCur.left.getEnd());
          leftArrow.draw(g2);
        }
        if (nCur.right != null) {
          rightArrow.setLine(nCur.getStart(), nCur.right.getEnd());
          rightArrow.draw(g2);
        }
      }
    }
  }
Пример #2
0
  /**
   * Paint the arrow in the panel, using the current style.
   *
   * @param g the graphic context.
   */
  public void paintComponent(Graphics g) {
    g.setColor(isSelected ? list.getSelectionBackground() : list.getBackground());

    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(isSelected ? list.getSelectionForeground() : list.getForeground());

    g.drawLine(getWidth() / 3, getHeight() / 2, 2 * getWidth() / 3, getHeight() / 2);
    Arrow arrowDummy = new Arrow();

    arrowDummy.drawArrowPixels(
        new Graphics2DSwing(g),
        getWidth() / 3,
        getHeight() / 2,
        2 * getWidth() / 3,
        getHeight() / 2,
        10,
        4,
        arrow.style);
  }