Esempio n. 1
0
  @Override
  protected void outlineShape(Graphics graphics) {

    Rectangle a = start(graphics);
    try {

      graphics.setAlpha(100);

      // graphics.setLineStyle(SWT.LINE_DASH);

      graphics.setLineStyle(SWT.LINE_DOT);
      a.width--;
      a.height--;
      graphics.drawRoundRectangle(a, 20, 20);
      if (innerLine != 0) {
        graphics.drawLine(0, innerLine, a.width, innerLine);
        graphics.drawText("inner name boundary", 10, innerLine - 14);
      }
      if (outerLine != 0) {
        graphics.drawLine(0, outerLine, a.width, outerLine);
        graphics.drawText("outer name boundary", 10, outerLine + 2);
      }

    } finally {
      stop(graphics);
    }
  }
Esempio n. 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);
    }
Esempio n. 3
0
 public void paintFigure(Graphics g) {
   Rectangle r = bounds;
   PointList pl = new PointList(4);
   pl.addPoint(r.x + r.width / 2, r.y);
   pl.addPoint(r.x, r.y + r.height / 2);
   pl.addPoint(r.x + r.width / 2, r.y + r.height - 1);
   pl.addPoint(r.x + r.width, r.y + r.height / 2);
   g.drawPolygon(pl);
   g.drawText(message, r.x + r.width / 4 + 5, r.y + 3 * r.height / 8);
   g.drawText("N", r.x + 7 * r.width / 8, r.y + 3 * r.height / 8);
   g.drawText("Y", r.x + r.width / 2 - 2, r.y + 3 * r.height / 4);
 }
Esempio n. 4
0
  /** @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */
  protected void paintFigure(Graphics g) {
    IMapMode mm = MapModeUtil.getMapMode(this);
    Rectangle displayRectangle =
        new Rectangle(mm.DPtoLP(15), mm.DPtoLP(11), mm.DPtoLP(31), mm.DPtoLP(25));
    Rectangle displayShadow =
        new Rectangle(mm.DPtoLP(14), mm.DPtoLP(10), mm.DPtoLP(32), mm.DPtoLP(26));
    Rectangle displayHighlight =
        new Rectangle(mm.DPtoLP(15), mm.DPtoLP(11), mm.DPtoLP(32), mm.DPtoLP(26));
    Point valuePoint = new Point(mm.DPtoLP(16), mm.DPtoLP(10));

    int Y1 = mm.DPtoLP(0);
    int Y2 = mm.DPtoLP(44);

    Rectangle r = getBounds().getCopy();

    g.translate(r.getLocation());
    g.fillRectangle(mm.DPtoLP(0), mm.DPtoLP(0), r.width, r.height /*- MapMode.DPtoLP(4)*/);
    int right = r.width - 1;
    g.drawLine(mm.DPtoLP(0), Y1, right, Y1);
    g.drawLine(mm.DPtoLP(0), Y1, mm.DPtoLP(0), Y2);

    g.drawLine(mm.DPtoLP(0), Y2, right, Y2);
    g.drawLine(right, Y1, right, Y2);

    // Draw the display
    RGB whiteColor = ColorConstants.white.getRGB();
    RGB backgroundColor = getBackgroundColor().getRGB();
    RGB newHightlightRGB =
        new RGB(
            (whiteColor.red + backgroundColor.red) / 2,
            (whiteColor.green + backgroundColor.green) / 2,
            (whiteColor.blue + backgroundColor.blue) / 2);
    g.setBackgroundColor(DiagramColorRegistry.getInstance().getColor(newHightlightRGB));
    g.fillRectangle(displayHighlight);
    RGB blackColor = ColorConstants.black.getRGB();
    RGB newShadowRGB =
        new RGB(
            (blackColor.red + backgroundColor.red) / 2,
            (blackColor.green + backgroundColor.green) / 2,
            (blackColor.blue + backgroundColor.blue) / 2);
    g.setBackgroundColor(DiagramColorRegistry.getInstance().getColor(newShadowRGB));
    g.fillRectangle(displayShadow);

    g.setBackgroundColor(ColorConstants.black);
    g.fillRectangle(displayRectangle);

    // Draw the value
    g.setForegroundColor(getFontColor());
    g.drawText(value, valuePoint);
  }
Esempio n. 5
0
 // 自己画出来一个 圆角矩形
 public void paintFigure(Graphics g) {
   Rectangle r = bounds; // 矩形边界
   //    x - the x coordinate
   //    y - the y coordinate
   //    w - the width
   //    h - the height
   //    offset - 开始的角度,180决定了是个半圆,90决定了角度,90就是弧度向左突起,270就是弧度向右突起,180就是向下突起,360就是向上突起
   //    length - 圆的多少,90是1/4圆,180是半圆,360是全圆
   g.drawArc(r.x + r.width / 8, r.y, r.width / 4, r.height - 1, 90, 180); // 左邊的圓
   g.drawLine(r.x + r.width / 4, r.y, r.x + 3 * r.width / 4, r.y); // 上边的线
   g.drawLine(
       r.x + r.width / 4, r.y + r.height - 1, r.x + 3 * r.width / 4, r.y + r.height - 1); // 下边的线
   g.drawArc(r.x + 5 * r.width / 8, r.y, r.width / 4, r.height - 1, 270, 180); // 右邊的圓
   g.drawText(message, r.x + 3 * r.width / 8, r.y + r.height / 8);
 }
Esempio n. 6
0
 @Override
 protected void paintFigure(Graphics graphics) {
   if (roiInfoProvider != null && roiDataBounds != null) {
     String text =
         roiInfoProvider.getROIInfo(
             roiDataBounds.x, roiDataBounds.y, roiDataBounds.width, roiDataBounds.height);
     Dimension size = TextUtilities.INSTANCE.getTextExtents(text, getFont());
     graphics.pushState();
     graphics.translate(getLocation());
     graphics.fillRectangle(roiGeoBounds.x, roiGeoBounds.y - size.height, size.width, size.height);
     graphics.drawText(text, roiGeoBounds.x, roiGeoBounds.y - size.height);
     graphics.popState();
   }
   super.paintFigure(graphics);
 }
Esempio n. 7
0
 @Override
 public void paintFigure(Graphics g) {
   Rectangle r = bounds;
   g.drawText(message, r.x + r.width / 4, r.y + r.height / 4);
   g.drawRectangle(r.x, r.y, r.width - 1, r.height - 1);
 }