コード例 #1
0
  public SwatNewNetToolbar(SwatTabView tabView, SwatTreeView treeView) {
    this.treeView = treeView;

    setFloatable(false);
    setRollover(true);

    // HACK!: To show PNEditor-Icons (they seem to be bigger)
    // setPreferredSize(new Dimension(200, ICON_SIZE + 30));

    setLayout(new WrapLayout(3));
    createButtons();
    addStandardButtons();

    try {
      SwatState.getInstance().addListener(this);
    } catch (ParameterException e) {
      // Cannot happen, since this is never null.
    }

    // try to get ICONSize
    try {
      EditorProperties.getInstance().getIconSize().getSize();
    } catch (Exception e) {
      // Cannot read property. Ignore and stay with default value (32)
    }
  }
コード例 #2
0
  private static Image setUpGui() throws PropertyException, IOException {
    Color defaultFillColor = Utils.parseColor(nodeColor);
    IconSize iconsize = null;
    iconsize = EditorProperties.getInstance().getIconSize();
    int size = iconsize.getSize();

    Image image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB_PRE);
    Graphics g = image.getGraphics();
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    mxRectangle bounds = new mxRectangle(0, 0, size, size);
    float x1 = (float) bounds.getX();
    float y1 = (float) bounds.getY();
    float x2 = (float) bounds.getX();
    float y2 = (float) bounds.getY();

    GradientPaint fillPaint =
        new GradientPaint(x1, y1, defaultFillColor, x2, y2, defaultFillColor, false);
    g2.setPaint(fillPaint);
    int transitionSize = (size - 1) / 2;
    g2.fillRect(
        transitionSize - (transitionSize / 2),
        transitionSize - (transitionSize / 2),
        transitionSize + (transitionSize / 2),
        transitionSize + (transitionSize / 2));
    g2.setColor(new Color(0, 0, 0));
    g2.setStroke(new BasicStroke(1));
    g2.drawRect(
        transitionSize - (transitionSize / 2),
        transitionSize - (transitionSize / 2),
        transitionSize + (transitionSize / 2),
        transitionSize + (transitionSize / 2));

    int placeSize = (size - 1) / 2;
    Color bgcolor = UIManager.getColor("Panel.background");
    g2.setColor(bgcolor);
    g2.fillOval(0, 0, placeSize + placeSize / 2 + 2, placeSize + placeSize / 2 + 2);
    g2.setColor(defaultFillColor);
    g2.fillOval(0, 0, placeSize + placeSize / 2, placeSize + placeSize / 2);
    g2.setColor(new Color(0, 0, 0));
    g2.setStroke(new BasicStroke(1));
    g2.drawOval(0, 0, placeSize + placeSize / 2, placeSize + placeSize / 2);

    g2.dispose();
    return image;
  }