Beispiel #1
0
 @Override
 protected void outlineShape(Graphics g) {
   int x = getParent().getBounds().x + 15;
   int x2 = x + getParent().getBounds().width - 30;
   g.setForegroundColor(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
   g.drawPolyline(new int[] {x - 2, position - 2, x, position, x - 2, position + 2});
   g.drawPolyline(new int[] {x, position, x2, position});
   g.drawPolyline(new int[] {x2 + 3, position - 3, x2, position, x2 + 2, position + 2});
 }
Beispiel #2
0
    @Override
    protected void paintClientArea(Graphics graphics) {
      if (support3d == null) support3d = GraphicsUtil.testPatternSupported(graphics);
      Rectangle clientArea = getClientArea();
      Rectangle square =
          new Rectangle(
              clientArea.x,
              clientArea.y + clientArea.height / 2 - BOX_SIZE / 2,
              BOX_SIZE,
              BOX_SIZE);
      graphics.pushState();
      if (support3d)
        graphics.setBackgroundPattern(
            GraphicsUtil.createScaledPattern(
                graphics,
                Display.getCurrent(),
                square.x,
                square.y + 1,
                square.x,
                square.y + square.height,
                ColorConstants.white,
                graphics.getBackgroundColor()));
      graphics.fillRoundRectangle(square, 4, 4);
      graphics.setForegroundColor(CustomMediaFactory.getInstance().getColor(130, 130, 130));
      graphics.drawRoundRectangle(square, 4, 4);

      if (boolValue) {
        graphics.translate(square.x, square.y);
        graphics.setLineWidth(3);
        graphics.setForegroundColor(selectedColor);

        graphics.drawPolyline(
            new int[] {
              3,
              (int) (BOX_SIZE * 0.45),
              (int) (BOX_SIZE * 0.45),
              BOX_SIZE * 3 / 4 - 1,
              BOX_SIZE - 2,
              3
            });
      }
      graphics.popState();
      Dimension textSize = FigureUtilities.getTextExtents(text, graphics.getFont());

      if (!isEnabled()) {
        graphics.translate(1, 1);
        graphics.setForegroundColor(ColorConstants.buttonLightest);
        graphics.drawText(text, square.getRight().getTranslated(GAP, -textSize.height / 2));
        graphics.translate(-1, -1);
        graphics.setForegroundColor(ColorConstants.buttonDarker);
      }
      graphics.drawText(text, square.getRight().getTranslated(GAP, -textSize.height / 2));

      super.paintClientArea(graphics);
    }
  /** @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */
  protected void paintFigure(Graphics g) {
    Rectangle r = getBounds().getCopy();

    IMapMode mm = MapModeUtil.getMapMode(this);
    r.translate(mm.DPtoLP(2), mm.DPtoLP(2));
    r.setSize(mm.DPtoLP(11), mm.DPtoLP(9));

    // Draw the bottom arc of the gate
    r.y += mm.DPtoLP(4);
    r.width = r.width - mm.DPtoLP(1);
    g.fillOval(r);
    r.height--;
    g.drawOval(r);

    // draw gate
    g.translate(getLocation());
    PointList outline = points.getCopy();
    mm.DPtoLP(outline);
    g.fillPolygon(outline);
    g.drawPolyline(outline);
    g.translate(getLocation().getNegated());
  }