Esempio n. 1
0
  /**
   * This is called to paint when we are managed by other objects (e.g., StationLocationRenderer)
   *
   * @param g graphics to draw on
   * @param loc location to draw at. Used to normalize the bounds.
   * @see #getBounds(Point2D)
   */
  public void draw(Graphics2D g, Point2D loc) {

    getBounds(loc);
    //      g.setColor (Color.green);
    //      g.drawRect (bounds.x, bounds.y, bounds.width, bounds.height);
    draw(g, bounds.x, bounds.y, bounds.width, bounds.height);
  }
Esempio n. 2
0
  /**
   * This is called to paint within the EditCanvas
   *
   * @param g Graphics
   * @param c DisplayCanvas to paint on.
   */
  public void paint(Graphics g, DisplayCanvas c) {
    Rectangle nb = transformOutput(c, getBounds());
    if (!getActive()) {
      Rectangle r = getBounds();
      g.setColor(Color.lightGray);
      g.fillRect(r.x, r.y, r.width, r.height);
    }

    draw((Graphics2D) g, nb.x, nb.y, nb.width, nb.height);

    if ((c instanceof StationModelCanvas) && ((StationModelCanvas) c).getShowParams()) {
      int xoff = 0;
      FontMetrics fm = g.getFontMetrics();
      g.setColor(Color.black);
      for (int i = 0; i < paramIds.length; i++) {
        String s = paramIds[i];
        if (i > 0) {
          s = ", " + s;
        }
        g.drawString(s, nb.x + xoff, nb.y + nb.height + fm.getMaxDescent() + fm.getMaxAscent() + 4);
        xoff += fm.stringWidth(s);
      }
    }
    if ((c instanceof StationModelCanvas) && ((StationModelCanvas) c).shouldShowAlignmentPoints()) {
      paintRectPoint(g, c);
    }
  }