/*
   * (non-Javadoc)
   *
   * @see org.eclipse.draw2d.Shape#paintFigure(org.eclipse.draw2d.Graphics)
   */
  @Override
  public void paintFigure(Graphics graphics) {
    graphics.setLineWidth(2);

    Rectangle r = getBounds();

    // Define the points of a diamond
    Point p1 = new Point(r.x, r.y + r.height / 2);
    Point p2 = new Point(r.x + r.width / 2, r.y);
    Point p3 = new Point(r.x + r.width, r.y + r.height / 2);
    Point p4 = new Point(r.x + r.width / 2, r.y + r.height - 1);

    PointList pointList = new PointList();

    pointList.addPoint(p1);
    pointList.addPoint(p2);
    pointList.addPoint(p3);
    pointList.addPoint(p4);

    // Fill the shape
    graphics.fillPolygon(pointList);

    // Draw the outline
    graphics.drawLine(p1, p2);
    graphics.drawLine(p2, p3);
    graphics.drawLine(p3, p4);
    graphics.drawLine(p4, p1);
  }
 private void drawYMinorTicks(Graphics gc, LabelSide tickLabelSide, int x, int y) {
   // there is a misillumiation
   int verticalMinorTickLength = MINOR_TICK_LENGTH - 1;
   if (tickLabelSide == LabelSide.Primary)
     gc.drawLine(x + MAJOR_TICK_LENGTH - verticalMinorTickLength, y, x + MAJOR_TICK_LENGTH, y);
   else gc.drawLine(x, y, x + verticalMinorTickLength, y);
 }
Пример #3
0
  @Override
  protected void paintFigure(Graphics graphics) {
    graphics.setAntialias(SWT.ON);

    Rectangle bounds = getBounds().getCopy();

    graphics.setForegroundColor(getFillColor());
    graphics.setBackgroundColor(ColorFactory.getLighterColor(getFillColor(), 0.9f));
    graphics.fillGradient(bounds, false);

    // Border
    if (getBorderColor() != null) {
      graphics.setForegroundColor(ColorFactory.getLighterColor(getBorderColor(), 0.82f));
      graphics.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1, bounds.y);
      graphics.drawLine(
          bounds.x + bounds.width - 1,
          bounds.y,
          bounds.x + bounds.width - 1,
          bounds.y + bounds.height - 1);

      graphics.setForegroundColor(getBorderColor());
      graphics.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
      graphics.drawLine(
          bounds.x,
          bounds.y + bounds.height - 1,
          bounds.x + bounds.width - 1,
          bounds.y + bounds.height - 1);
    }

    fIconicDelegate.drawIcon(graphics, bounds);
  }
Пример #4
0
  private void drawDarkerSide(
      Graphics graphics, Color[] br, int top, int left, int bottom, int right) {
    graphics.setLineWidth(1);
    graphics.setAlpha(200);
    Color color;
    for (int i = 0; i < br.length; i++) {
      color = br[i];
      graphics.setForegroundColor(color);

      graphics.drawArc(
          right - i - corner.width,
          bottom - i - corner.height,
          corner.width,
          corner.height,
          270,
          90);
      Point rightButtomRight = new Point(right - i, bottom - i - corner.height / 2);
      Point rightTopRight = new Point(right - i, top + i + corner.height / 2);
      graphics.drawLine(rightButtomRight, rightTopRight);
      graphics.drawArc(right - i - corner.width, top - i, corner.width, corner.height, 0, 45);

      Point rightButtomButtom = new Point(right - i - corner.width / 2, bottom - i);
      Point leftBottomLeft = new Point(left + i + corner.width / 2, bottom - i);
      graphics.drawLine(rightButtomButtom, leftBottomLeft);
      graphics.drawArc(
          left - i, bottom - i - corner.height, corner.width, corner.height, 180 + 45, 45);
    }
  }
Пример #5
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);
    }
  }
Пример #6
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);
  }
Пример #7
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);
 }
Пример #8
0
  protected void paintFigure(Graphics g) {
    super.paintFigure(g);
    Rectangle r = getTextBounds();

    r.resize(-1, -1);
    r.expand(1, 1);
    r.width -= 1;
    r.x -= 2;
    g.drawLine(r.x, r.y, r.right(), r.y); // Top line
    g.drawLine(r.x, r.bottom(), r.right(), r.bottom()); // Bottom line
    g.drawLine(r.x, r.bottom(), r.x, r.y); // left line

    g.drawLine(r.right() + 7, r.y + r.height / 2, r.right(), r.y);
    g.drawLine(r.right() + 7, r.y + r.height / 2, r.right(), r.bottom());
  }
        @Override
        public void paint(IFigure figure, Graphics graphics, Insets insets) {
          /* Calling getPaintRectangle() initializes the AbstractBorder#tempRect bounds and crops the same */
          Rectangle editedRect = getPaintRectangle(figure, insets);

          /* After calling the above method, we can directly make use of the tempRect*/
          graphics.drawLine(editedRect.getTopLeft(), editedRect.getTopRight());
        }
Пример #10
0
 /**
  * @see org.eclipse.draw2d.Border#paint(org.eclipse.draw2d.IFigure, org.eclipse.draw2d.Graphics,
  *     org.eclipse.draw2d.geometry.Insets)
  */
 public void paint(IFigure figure, Graphics graphics, Insets insets) {
   graphics.setForegroundColor(ColorConstants.buttonDarker);
   if (horizontal) {
     graphics.drawLine(
         figure.getBounds().getTopLeft(),
         figure
             .getBounds()
             .getBottomLeft()
             .translate(new org.eclipse.draw2d.geometry.Point(0, -4)));
   } else {
     graphics.drawLine(
         figure.getBounds().getTopLeft(),
         figure
             .getBounds()
             .getTopRight()
             .translate(new org.eclipse.draw2d.geometry.Point(-4, 0)));
   }
 }
Пример #11
0
  /**
   * Draws a line at the given angle, relative to the given center.
   *
   * @param gfx the graphics context
   * @param minrad the radius at which the line should begin
   * @param maxrad the radius at which the ine should end
   * @param angl the angle at which the line is to be drawn
   * @param x x coordinate of the circle's center
   * @param y y coordinate of the circle's center
   */
  public static void drawLineAtAngle(
      Graphics gfx, double minrad, double maxrad, double angl, int x, int y) {
    int x1, y1, x2, y2;

    x1 = x + (int) (minrad * Trigonometry.cos(angl));
    y1 = y - (int) (minrad * Trigonometry.sin(angl));
    x2 = x + (int) (maxrad * Trigonometry.cos(angl));
    y2 = y - (int) (maxrad * Trigonometry.sin(angl));
    gfx.drawLine(x1, y1, x2, y2);
  }
Пример #12
0
  protected void paintFigure(Graphics g) {
    super.paintFigure(g);

    Rectangle bounds = getBounds();
    Rectangle nameBounds = getContentPane(1).getBounds();
    Rectangle r = Rectangle.SINGLETON;

    r.setLocation(nameBounds.x - 3, nameBounds.y);
    r.setSize(bounds.width - 4, nameBounds.height);
    g.setBackgroundColor(FigurePrefs.lightBlueColor);
    g.fillRectangle(r);

    int baseline = getLayoutManager().getBaseline(0) + 1;
    Rectangle ruleBounds = getContentPane(0).getClientArea();

    g.setForegroundColor(FigurePrefs.relationsColor);
    g.drawLine(bounds.x, baseline, ruleBounds.x, baseline);
    g.drawLine(ruleBounds.right() - 1, baseline, bounds.right(), baseline);
  }
  /** @see org.eclipse.draw2d.Shape#outlineShape(org.eclipse.draw2d.Graphics) */
  protected void outlineShape(Graphics graphics) {
    super.outlineShape(graphics);

    // Calculate the intersection coordinates.
    int x = (int) (bounds.width / (2 * Math.sqrt(2)));
    int y = (int) (bounds.height / (2 * Math.sqrt(2)));

    // Draw the cross
    graphics.drawLine(bounds.getCenter().translate(x, -y), bounds.getCenter().translate(-x, y));
    graphics.drawLine(bounds.getCenter().translate(-x, -y), bounds.getCenter().translate(x, y));
  }
Пример #14
0
 @Override
 protected void paintClientArea(Graphics graphics) {
   super.paintClientArea(graphics);
   graphics.setForegroundColor(GRAY_COLOR);
   graphics.setLineWidth(1);
   graphics.drawLine(
       bounds.x + bounds.width / 2,
       bounds.y,
       bounds.x + bounds.width / 2,
       bounds.y + bounds.height);
 }
  public void drawIcon(Graphics graphics, Point origin) {
    graphics.pushState();

    graphics.setLineWidth(1);

    // fills
    graphics.setForegroundColor(blue3);
    graphics.setBackgroundColor(blue4);
    graphics.fillGradient(origin.x, origin.y, 5, 5, true);
    graphics.fillGradient(origin.x, origin.y + 9, 5, 5, true);

    graphics.setForegroundColor(blue1);

    // squares
    graphics.drawRectangle(origin.x, origin.y, 5, 5);
    graphics.drawRectangle(origin.x, origin.y + 9, 5, 5);

    graphics.drawRectangle(origin.x + 8, origin.y + 6, 2, 2); // little square

    // lines
    graphics.translate(7, 2);
    graphics.setForegroundColor(blue2);
    graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y);
    graphics.translate(0, 1);
    graphics.setForegroundColor(blue1);
    graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y);

    graphics.translate(0, 8);
    graphics.setForegroundColor(blue2);
    graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y);
    graphics.translate(0, 1);
    graphics.setForegroundColor(blue1);
    graphics.drawLine(origin.x, origin.y, origin.x + 6, origin.y);

    // small line
    graphics.translate(4, -5);
    graphics.setForegroundColor(blue1);
    graphics.drawLine(origin.x, origin.y, origin.x + 2, origin.y);

    graphics.popState();
  }
Пример #16
0
  @SuppressWarnings("unchecked")
  @Override
  public void paintFigure(Graphics g) {
    super.paintFigure(g);
    Rectangle r = getBounds();
    Rectangle rc = getContentPane(1).getBounds();
    List<IFigure> children = ((IFigure) getContentPane(1).getChildren().get(0)).getChildren();

    if (children.size() > 0) {
      int xm = rc.x + rc.width / 2;
      int y0 = rc.y - 6;
      int y1 = y0;

      if (getContentPane(1).isVisible()) {
        g.drawLine(xm, r.y, xm, y0);

        y1 = rc.y + rc.height - 1 + 5;

        if (children.size() >= 2) {
          Rectangle r0 = children.get(0).getBounds();
          Rectangle r1 = children.get(children.size() - 1).getBounds();
          int x0 = r0.x + r0.width / 2;
          int x1 = r1.x + r1.width / 2;

          g.drawLine(x0, y0, x1, y0);
          g.drawLine(x0, y1, x1, y1);
        }

        for (int i = 0; i < children.size(); i++) {
          Rectangle ri = children.get(i).getBounds();
          int xi = ri.x + ri.width / 2;
          int yi = ri.y + ri.height;

          g.drawLine(xi, y0, xi, ri.y);
          g.drawLine(xi, yi, xi, y1);
        }

        g.drawLine(xm, y1, xm, r.y + r.height - 1);
      }
    }
  }
  /**
   * @see
   *     nexcore.tool.uml.ui.core.diagram.figure.AbstractNotationNodeFigure#paintFigure(org.eclipse.draw2d.Graphics)
   */
  @Override
  protected void paintFigure(Graphics graphics) {
    super.paintFigure(graphics);

    graphics.setAntialias(SWT.ON);
    Rectangle bounds = getBounds();
    if (isDangling()) {
      graphics.setForegroundColor(ColorConstants.red);
      graphics.drawOval(bounds.x, bounds.y, 12, 12);
      graphics.drawLine(bounds.x + 2, bounds.y + 2, bounds.x + 10, bounds.y + 10);
      graphics.drawLine(bounds.x + 10, bounds.y + 2, bounds.x + 2, bounds.y + 10);
    }
  }
  /**
   * If the rendering is occuring on a separate thread, this method is a hook to draw a temporary
   * image onto the drawing surface.
   *
   * @param g the <code>Graphics</code> object to paint the temporary image to
   */
  protected void paintFigureWhileRendering(Graphics g) {
    Rectangle area = getClientArea().getCopy();

    g.pushState();
    g.setBackgroundColor(ColorConstants.white);
    g.fillRectangle(area.x, area.y, area.width - 1, area.height - 1);
    g.setForegroundColor(ColorConstants.red);
    g.drawRectangle(area.x, area.y, area.width - 1, area.height - 1);
    g.setLineStyle(SWT.LINE_DOT);
    g.drawLine(area.x, area.y, area.x + area.width, area.y + area.height);
    g.drawLine(area.x + area.width, area.y, area.x, area.y + area.height);
    g.popState();
  }
Пример #19
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.draw2d.Shape#paintFigure(org.eclipse.draw2d.Graphics)
   */
  public void paintFigure(Graphics graphics) {
    graphics.setAntialias(SWT.LOW);
    super.paintFigure(graphics);
    graphics.pushState();
    graphics.setBackgroundColor(ColorConstants.black);

    /* Creates the cross in the circle */
    Rectangle rect1 = getBounds().getCopy();
    int scaleFactor_horizontale = rect1.height / 2;
    int scaleFactor_verticale = rect1.width / 2;
    Rectangle rect = getBounds().getCopy();
    graphics.drawLine(
        rect1.x,
        rect1.y + scaleFactor_horizontale,
        rect1.x + (int) Math.floor(rect1.width * (scaleFactor_horizontale)),
        rect1.y - (1 - scaleFactor_horizontale));
    graphics.drawLine(
        rect1.x + scaleFactor_verticale,
        rect1.y,
        rect1.x - (1 - scaleFactor_verticale),
        rect1.y + (int) Math.floor(rect1.height * (scaleFactor_verticale)));

    graphics.popState();
  }
Пример #20
0
  private void drawLighterSide(
      Graphics graphics, Color[] tl, int top, int left, int bottom, int right) {
    graphics.setAlpha(255);
    right--;
    bottom--;
    Color color;
    graphics.setLineWidth(1);

    for (int i = 0; i < tl.length; i++) {
      color = tl[i];
      graphics.setForegroundColor(color);

      graphics.drawArc(left - i, top - i, corner.width, corner.height, 90, 90);
      Point leftTopLeft = new Point(left - i, top - i + corner.height / 2);
      Point leftBottomLeft = new Point(left - i, bottom + i - corner.height / 2);
      graphics.drawLine(leftTopLeft, leftBottomLeft);
      graphics.drawArc(left - i, bottom - i - corner.height, corner.width, corner.height, 180, 45);

      Point rightTopTop = new Point(right - i - corner.width / 2, top - i);
      Point leftTopTop = new Point(left + i + corner.width / 2, top - i);
      graphics.drawLine(rightTopTop, leftTopTop);
      graphics.drawArc(right - i - corner.width, top - i, corner.width, corner.height, 0 + 45, 45);
    }
  }
  /** @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */
  protected void paintFigure(Graphics g) {
    g.setXORMode(true);
    g.setForegroundColor(ColorConstants.white);

    g.setBackgroundColor(LogicColorConstants.ghostFillColor);

    Rectangle r = getBounds().getCopy();

    g.fillOval(r);
    r.height--;
    r.width--;
    g.drawOval(r);
    g.translate(r.getLocation());

    // Draw the "V"
    g.drawLine(3, 4, 5, 9);
    g.drawLine(5, 9, 7, 4);
    g.drawLine(5, 8, 5, 9);

    // Draw the "+"
    g.drawLine(9, 7, 9, 11);
    g.drawLine(7, 9, 11, 9);
    g.drawPoint(9, 9);
  }
Пример #22
0
 @Override
 public void paintFigure(final Graphics g) {
   // super.paintFigure(g);
   g.pushState();
   // DEBUG
   // g.setLineDash(new int[] { 1, 5 });
   // g.drawRectangle(this.bounds.x, this.bounds.y, this.bounds.width - 1, this.bounds.height - 1);
   // g.setLineDash(new int[] {});
   // END DEBUG
   // final int y = this.bounds.y;
   final int x = this.bounds.x;
   final int w = this.bounds.width;
   final int y = this.posY;
   g.setLineWidth(1);
   g.drawLine(x, y, x + w, y);
   g.popState();
 }
 /**
  * The stop is a cross
  *
  * @see org.eclipse.draw2d.Figure#paintFigure(org.eclipse.draw2d.Graphics)
  */
 @Override
 protected void paintFigure(Graphics graphics) {
   super.paintFigure(graphics);
   graphics.pushState();
   int width = bounds.width;
   int height = bounds.height;
   if (width > height) {
     width = height;
   } else if (width < height) {
     height = width;
   }
   int x = bounds.x + bounds.width / 2 - width / 2;
   int y = bounds.y + bounds.height / 2 - height / 2;
   graphics.setLineWidth(lineWidth);
   graphics.drawLine(x, y, x + width, y + height);
   graphics.drawLine(x + width, y, x, y + height);
   graphics.popState();
 }
 public void paint(IFigure figure, Graphics graphics, Insets insets) {
   graphics.drawLine(getPaintRectangle(figure, insets).getTopLeft(), tempRect.getTopRight());
 }
Пример #25
0
  public void paint(IFigure figure, Graphics graphics, Insets insets) {
    tempRect.setBounds(getPaintRectangle(figure, insets));
    BorderComponent borderDef = this.rectPresentation.getTopBorder();
    if (this.hasUniformBorders && borderDef.getWeight().getContent() > 0) {
      int w = borderDef.getWeight().getContent();
      int inset = Math.max(1, w >> 1);
      tempRect.x += inset;
      tempRect.y += inset;
      tempRect.width -= inset + inset;
      tempRect.height -= inset + inset;

      int cornerRadius = this.rectPresentation.getCornerRadius();
      float cornerWidth = cornerRadius;
      float cornerHeight = cornerRadius;
      // adjust corner for the inner path (formula found by experimenting)
      cornerHeight = Math.max(1, cornerHeight - (w + cornerHeight / 64));
      cornerWidth = Math.max(1, cornerWidth - (w + cornerWidth / 64));

      graphics.setLineWidth(borderDef.getWeight().getContent());
      graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent()));
      graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent()));
      graphics.drawRoundRectangle(
          tempRect, Math.max(0, (int) cornerWidth), Math.max(0, (int) cornerHeight));

    } else {
      if (borderDef.getWeight().getContent() > 0) {
        int w = borderDef.getWeight().getContent();
        graphics.setLineWidth(w);
        graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent()));
        graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent()));
        int inset = Math.max(1, w >> 1);
        int x = tempRect.x;
        int y = tempRect.y + inset;
        int x2 = tempRect.x + tempRect.width;
        graphics.drawLine(x, y, x2, y);
      }

      borderDef = this.rectPresentation.getBottomBorder();
      if (borderDef.getWeight().getContent() > 0) {
        int w = borderDef.getWeight().getContent();
        graphics.setLineWidth(w);
        graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent()));
        graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent()));
        int inset = Math.max(1, w >> 1);
        int x = tempRect.x;
        int y = tempRect.y + tempRect.height - inset;
        int x2 = tempRect.x + tempRect.width;
        graphics.drawLine(x, y, x2, y);
      }

      borderDef = this.rectPresentation.getLeftBorder();
      if (borderDef.getWeight().getContent() > 0) {
        int w = borderDef.getWeight().getContent();
        graphics.setLineWidth(w);
        graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent()));
        graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent()));
        int inset = Math.max(1, w >> 1);
        int x = tempRect.x + inset;
        int y = tempRect.y;
        int y2 = tempRect.y + tempRect.height;
        graphics.drawLine(x, y, x, y2);
      }

      borderDef = this.rectPresentation.getRightBorder();
      if (borderDef.getWeight().getContent() > 0) {
        int w = borderDef.getWeight().getContent();
        graphics.setLineWidth(w);
        graphics.setForegroundColor(resourceCache.getColor(borderDef.getColor().getContent()));
        graphics.setLineStyle(FigureUtil.convertLineStyle(borderDef.getStyle().getContent()));
        int inset = Math.max(1, w >> 1);
        int x = tempRect.x + tempRect.width - inset;
        int y = tempRect.y;
        int y2 = tempRect.y + tempRect.height;
        graphics.drawLine(x, y, x, y2);
      }
    }
  }
Пример #26
0
  @Override
  public void paint(Graphics graphics) {

    Rectangle r = getBounds();
    if (getShape() == 0) {

      // Define the points of a parallelogram
      Point p1 = new Point(r.x + r.width / 12, r.y);
      Point p2 = new Point(r.x + r.width, r.y);
      Point p3 = new Point(r.x, r.y + r.height);
      Point p4 = new Point(r.x + 11 * r.width / 12, r.y + r.height);

      PointList pointList = new PointList();
      pointList.addPoint(p1);
      pointList.addPoint(p2);
      pointList.addPoint(p3);
      pointList.addPoint(p4);

      // Fill the shape
      graphics.fillPolygon(pointList);
      // Draw the outline
      graphics.drawLine(p1, p2);
      graphics.drawLine(p1, p3);
      graphics.drawLine(p3, p4);
      graphics.drawLine(p2, p4);

    } else {
      // Define the points of a parallelogram
      Point p1 = new Point(r.x + r.width / 12, r.y);
      Point p2 = new Point(r.x + r.width, r.y);
      Point p3 = new Point(r.x, r.y + 3 * r.height / 4);
      Point p4 = new Point(r.x + 11 * r.width / 12, r.y + 3 * r.height / 4);

      PointList pointList = new PointList();
      pointList.addPoint(p1);
      pointList.addPoint(p2);
      pointList.addPoint(p3);
      pointList.addPoint(p4);
      // undeveloped element status
      if (getShape() == 1) {
        Point p5 = new Point(r.x + r.width / 2, r.y + 3 * r.height / 4);
        Point p6 = new Point(r.x + 5 * r.width / 8, r.y + 7 * r.height / 8);
        Point p7 = new Point(r.x + r.width / 2, r.y + r.height);
        Point p8 = new Point(r.x + 3 * r.width / 8, r.y + 7 * r.height / 8);

        pointList.addPoint(p5);
        pointList.addPoint(p6);
        pointList.addPoint(p7);
        pointList.addPoint(p8);
        // Fill the shape
        graphics.fillPolygon(pointList);

        // Draw the outline
        graphics.drawLine(p1, p2);
        graphics.drawLine(p1, p3);
        graphics.drawLine(p3, p4);
        graphics.drawLine(p2, p4);

        // Draw the outline
        graphics.drawLine(p5, p6);
        graphics.drawLine(p6, p7);
        graphics.drawLine(p7, p8);
        graphics.drawLine(p5, p8);

      }
      // uninstantiated element status
      else if (getShape() == 2) {

        Point p5 = new Point(r.x + r.width / 2, r.y + 3 * r.height / 4);
        Point p6 = new Point(r.x + 5 * r.width / 8, r.y + 7 * r.height / 8);
        Point p7 = new Point(r.x + r.width / 2, r.y + r.height);
        Point p8 = new Point(r.x + 3 * r.width / 8, r.y + 7 * r.height / 8);

        pointList.addPoint(p5);
        pointList.addPoint(p6);
        pointList.addPoint(p7);
        pointList.addPoint(p8);
        // Fill the shape
        graphics.fillPolygon(pointList);

        // Draw the outline
        graphics.drawLine(p1, p2);
        graphics.drawLine(p1, p3);
        graphics.drawLine(p3, p4);
        graphics.drawLine(p2, p4);

        // Draw the outline
        graphics.drawLine(p5, p6);
        graphics.drawLine(p6, p8);
        graphics.drawLine(p5, p8);

      }
      // undeveloped and uninstantiated element status
      else if (getShape() == 3) {

        Point p5 = new Point(r.x + r.width / 2, r.y + 3 * r.height / 4);
        Point p6 = new Point(r.x + 5 * r.width / 8, r.y + 7 * r.height / 8);
        Point p7 = new Point(r.x + r.width / 2, r.y + r.height);
        Point p8 = new Point(r.x + 3 * r.width / 8, r.y + 7 * r.height / 8);

        pointList.addPoint(p5);
        pointList.addPoint(p6);
        pointList.addPoint(p7);
        pointList.addPoint(p8);
        // Fill the shape
        graphics.fillPolygon(pointList);

        // Draw the outline
        graphics.drawLine(p1, p2);
        graphics.drawLine(p1, p3);
        graphics.drawLine(p3, p4);
        graphics.drawLine(p2, p4);

        // Draw the outline
        graphics.drawLine(p5, p6);
        graphics.drawLine(p6, p7);
        graphics.drawLine(p7, p8);
        graphics.drawLine(p5, p8);
        graphics.drawLine(p6, p8);
      }
    }

    // Move the first label to the center of the parallelogram
    WrappingLabel label = (WrappingLabel) getChildren().get(0);
    LayoutUtil.moveToCenterAndUp(label, this, graphics);
    label.paint(graphics);
    // Move the second label to the center of the parallelogram
    label = (WrappingLabel) getChildren().get(1);
    LayoutUtil.moveToCenterAndDown(label, this, graphics);
    label.paint(graphics);
  }
Пример #27
0
  @Override
  protected void drawSymbol(Graphics g) {
    PointList points = null;

    super.drawSymbol(g);

    int centerPointX = (int) Math.ceil((H_EXTENT / 2.0f)); // Center point of odd #.

    switch (this.featureCategory) {
      case BUS_ACCESS:
      case DATA_ACCESS:
        // Configure GC.
        g.setForegroundColor(this.getForegroundColor());
        g.setBackgroundColor(ColorConstants.white);
        g.setLineWidth(2);

        // Create point list that defines the symbol.
        points = new PointList();

        /* Populate point list. */
        points.addPoint(centerPointX, 0);
        points.addPoint(0, V_EXTENT - 8);
        points.addPoint(0, V_EXTENT);
        points.addPoint(centerPointX, V_EXTENT - 2);
        points.addPoint(H_EXTENT, V_EXTENT);
        points.addPoint(H_EXTENT, V_EXTENT - 8);

        // Fill symbol.
        g.fillPolygon(points);
        // Draw symbol.
        g.drawPolygon(points);

        break;
      case SUBPROGRAM_ACCESS:
      case SUBPROGRAM_GROUP_ACCESS:
        // Configure GC
        if (this.featureCategory == FeatureAdapterCategory.SUBPROGRAM_ACCESS) {
          g.setBackgroundColor(ColorConstants.white);
          g.setForegroundColor(ColorConstants.black);
        } else {
          g.setBackgroundColor(ColorConstants.black);
          g.setForegroundColor(ColorConstants.white);
        }

        g.setLineCap(SWT.CAP_ROUND);
        g.setLineWidth(2);

        int ovalWidth = H_EXTENT;
        int ovalHeight = V_EXTENT;
        // Draw oval.
        Rectangle ovalRect =
            new Rectangle(
                (int) (0.5f * (H_EXTENT - ovalWidth)),
                (int) (0.5f * (V_EXTENT - ovalHeight)),
                ovalWidth,
                ovalHeight);
        g.fillOval(ovalRect);

        if (this.featureCategory == FeatureAdapterCategory.SUBPROGRAM_ACCESS) g.drawOval(ovalRect);

        int triangleWidth = 7;
        int triangleHeight = 5;
        int triangleStartX = (int) Math.ceil((0.5f * (H_EXTENT - triangleWidth)));
        int triangleStartY = (int) Math.ceil((0.5f * (V_EXTENT - triangleHeight)));

        // Draw triangle.
        g.drawLine(triangleStartX, triangleStartY, centerPointX, triangleStartY + triangleHeight);
        g.drawLine(
            triangleStartX + triangleWidth,
            triangleStartY,
            centerPointX,
            triangleStartY + triangleHeight);

        break;
    }
  }
Пример #28
0
 private void drawXMinorTicks(Graphics gc, LabelSide tickLabelSide, int x, int y) {
   if (tickLabelSide == LabelSide.Primary) gc.drawLine(x, y, x, y + MINOR_TICK_LENGTH);
   else gc.drawLine(x, y + MAJOR_TICK_LENGTH - MINOR_TICK_LENGTH, x, y + MAJOR_TICK_LENGTH);
 }
Пример #29
0
  /**
   * Draw the Y tick marks.
   *
   * @param tickLabelPositions the tick label positions
   * @param tickLabelSide the side of tick label relative to tick marks
   * @param width the width to draw tick marks
   * @param height the height to draw tick marks
   * @param gc the graphics context
   */
  private void drawYTickMarks(
      Graphics gc,
      ArrayList<Integer> tickLabelPositions,
      LabelSide tickLabelSide,
      int width,
      int height) {
    updateMinorTickParas();
    // draw tick marks
    gc.setLineStyle(SWTConstants.LINE_SOLID);
    int x = 0;
    int y = 0;
    if (scale.isLogScaleEnabled()) {
      ArrayList<Boolean> tickLabelVisibilities = scale.getScaleTickLabels().getTickVisibilities();
      for (int i = 0; i < tickLabelPositions.size(); i++) {

        int tickLength = 0;
        if (tickLabelVisibilities.get(i)) tickLength = MAJOR_TICK_LENGTH;
        else tickLength = MINOR_TICK_LENGTH;

        if (tickLabelSide == LabelSide.Primary) {
          x = width - 1 - LINE_WIDTH - tickLength;
        } else {
          x = LINE_WIDTH;
        }
        y = height - tickLabelPositions.get(i);
        if (tickLabelVisibilities.get(i) || scale.isMinorTicksVisible())
          gc.drawLine(x, y, x + tickLength, y);
      }
    } else {
      for (int i = 0; i < tickLabelPositions.size(); i++) {
        if (tickLabelSide == LabelSide.Primary) {
          x = width - 1 - LINE_WIDTH - MAJOR_TICK_LENGTH;
        } else {
          x = LINE_WIDTH;
        }
        y = height - tickLabelPositions.get(i);
        gc.drawLine(x, y, x + MAJOR_TICK_LENGTH, y);
        // draw minor ticks for linear scale
        if (scale.isMinorTicksVisible()) {
          if (i > 0) {
            // draw the first grid step which is start from min
            // value
            if (i == 1
                && (tickLabelPositions.get(1) - tickLabelPositions.get(0))
                    < scale.getScaleTickLabels().getGridStepInPixel()) {
              y = tickLabelPositions.get(1);
              while ((y - tickLabelPositions.get(0)) > minorGridStepInPixel + 3) {
                y = y - minorGridStepInPixel;
                drawYMinorTicks(gc, tickLabelSide, x, height - y);
              }
            } // draw the last grid step which is end to max value
            else if (i == tickLabelPositions.size() - 1
                && (tickLabelPositions.get(i) - tickLabelPositions.get(i - 1))
                    < scale.getScaleTickLabels().getGridStepInPixel()) {
              y = tickLabelPositions.get(i - 1);
              while ((tickLabelPositions.get(i) - y) > minorGridStepInPixel + 3) {
                y = y + minorGridStepInPixel;
                drawYMinorTicks(gc, tickLabelSide, x, height - y);
              }
            } else { // draw regular steps
              for (int j = 0; j < minorTicksNumber; j++) {
                y =
                    height
                        - tickLabelPositions.get(i - 1)
                        - (tickLabelPositions.get(i) - tickLabelPositions.get(i - 1))
                            * j
                            / minorTicksNumber;
                drawYMinorTicks(gc, tickLabelSide, x, y);
              }
            }
          }
        }
      }
    }

    // draw scale line
    if (scale.isScaleLineVisible()) {
      if (tickLabelSide == LabelSide.Primary) {
        gc.drawLine(width - 1, scale.getMargin(), width - 1, height - scale.getMargin());
      } else {
        gc.drawLine(0, scale.getMargin(), 0, height - scale.getMargin());
      }
    }
  }