Beispiel #1
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);
    }
  }
 private Dimension calcTypeListPreferredSize(final List<ModuleBuilder> allModuleTypes) {
   int width = 0;
   int height = 0;
   final FontMetrics fontMetrics = myTypesList.getFontMetrics(myTypesList.getFont());
   final int fontHeight = fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent();
   for (final ModuleBuilder type : allModuleTypes) {
     final Icon icon = type.getBigIcon();
     final int iconHeight = icon != null ? icon.getIconHeight() : 0;
     final int iconWidth = icon != null ? icon.getIconWidth() : 0;
     height += Math.max(iconHeight, fontHeight) + 6;
     width = Math.max(width, iconWidth + fontMetrics.stringWidth(type.getPresentableName()) + 10);
   }
   return new Dimension(width, height);
 }