Esempio n. 1
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. 2
0
  @Override
  protected void outlineShape(Graphics graphics) {
    Rectangle a = start(graphics);
    try {
      graphics.setLineWidth(2);
      graphics.setLineStyle(SWT.LINE_SOLID);

      if (shape instanceof Ellipse) {
        graphics.drawOval(1, 1, a.width - 2, a.height - 2);
      } else if (shape instanceof PointList) {
        graphics.drawPolygon((PointList) shape);
      }
    } finally {
      stop(graphics);
    }
  }
 /** @see Shape#outlineShape(Graphics) */
 @Override
 protected void outlineShape(Graphics g) {
   g.drawPolygon(triangle);
 }
  @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;
    }
  }