コード例 #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);
    }
  }
コード例 #2
0
  /**
   * 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();
  }
コード例 #3
0
ファイル: ShadowBoarder.java プロジェクト: kompiro/jamcircle
  @Override
  protected void paint(Graphics graphics, IFigure fig, Insets insets, Color[] tl, Color[] br) {
    graphics.setLineStyle(Graphics.LINE_SOLID);
    graphics.setXORMode(false);

    Rectangle rect = getPaintRectangle(fig, insets);

    int top = rect.y;
    int left = rect.x;
    int bottom = rect.bottom() - 1;
    int right = rect.right() - 1;
    drawDarkerSide(graphics, br, top, left, bottom, right);
    drawLighterSide(graphics, tl, top, left, bottom, right);
  }
コード例 #4
0
ファイル: NodeFigure.java プロジェクト: juyingnan/BigM
  @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);
    }
  }
コード例 #5
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());
      }
    }
  }
コード例 #6
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);
      }
    }
  }
コード例 #7
0
 /**
  * Set the drawing state when disabled
  *
  * @param graphics
  */
 protected void setDisabledState(Graphics graphics) {
   graphics.setAlpha(100);
   graphics.setLineStyle(SWT.LINE_DOT);
 }