/** Draw the icon */
  protected void drawIcon(Graphics graphics) {
    graphics.pushState();

    graphics.setLineWidthFloat(1);
    graphics.setForegroundColor(isEnabled() ? ColorConstants.black : ColorConstants.gray);

    Point pt = getIconOrigin();

    Path path = new Path(null);

    path.addArc(pt.x, pt.y, 5, 5, 0, 360);
    path.addArc(pt.x + 2, pt.y - 8, 5, 5, 0, 360);
    path.addArc(pt.x + 10, pt.y - 8, 5, 5, 0, 360);
    path.addArc(pt.x + 8, pt.y, 5, 5, 0, 360);

    path.moveTo(pt.x + 3, pt.y);
    path.lineTo(pt.x + 4, pt.y - 3);

    path.moveTo(pt.x + 11, pt.y);
    path.lineTo(pt.x + 12, pt.y - 3);

    path.moveTo(pt.x + 5, pt.y + 2.5f);
    path.lineTo(pt.x + 8, pt.y + 2.5f);

    path.moveTo(pt.x + 7, pt.y - 5.5f);
    path.lineTo(pt.x + 10, pt.y - 5.5f);

    graphics.drawPath(path);
    path.dispose();

    graphics.popState();
  }
예제 #2
0
 /** @see org.eclipse.draw2d.Figure#paint(org.eclipse.draw2d.Graphics) */
 public void paint(Graphics graphics) {
   super.paint(graphics);
   computeHandlerIconPositions(ModelHelper.isHorizontalLayout(getModel()));
   if (hasFH) {
     graphics.pushState();
     graphics.setClip(faultImageFigure.getBounds().getCopy());
     faultImageFigure.paint(graphics);
     graphics.popState();
   }
   if (hasEH) {
     graphics.pushState();
     graphics.setClip(eventImageFigure.getBounds().getCopy());
     eventImageFigure.paint(graphics);
     graphics.popState();
   }
 }
예제 #3
0
 /**
  * Fills the circle.
  *
  * @param graphics the graphics
  * @see org.eclipse.draw2d.Shape#fillShape(org.eclipse.draw2d.Graphics)
  */
 protected void fillShape(Graphics graphics) {
   graphics.pushState();
   graphics.setBackgroundColor(ColorConstants.white);
   graphics.fillOval(getBounds());
   graphics.popState();
   Dimension dim = new Dimension(20, 20);
   this.setMaximumSize(dim);
 }
예제 #4
0
 public void paintBackground(Graphics g) {
   g.pushState();
   try {
     renderers.get(curRenderer).paintBackground(g);
   } finally {
     g.popState();
   }
 }
예제 #5
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);
    }
예제 #6
0
 public void paintBackground(Graphics g) {
   Iterator<GraphicalWidgetRenderer> i = renderers.iterator();
   while (i.hasNext()) {
     g.pushState();
     try {
       i.next().paintBackground(g);
     } finally {
       g.popState();
     }
   }
 }
 @Override
 protected void fillShape(Graphics graphics) {
   if (shouldUseGradient()) {
     graphics.pushState();
     graphics.setBackgroundColor(DiagramColorConstants.white);
     graphics.setForegroundColor(getBackgroundColor());
     graphics.fillGradient(getBounds(), true);
     graphics.popState();
   } else {
     super.fillShape(graphics);
   }
 }
  /**
   * 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();
  }
예제 #9
0
  @Override
  public void paintFigure(Graphics graphics) {
    graphics.pushState();

    graphics.setAntialias(SWT.ON);

    if (!isEnabled()) {
      setDisabledState(graphics);
    }

    graphics.setBackgroundColor(getFillColor());
    graphics.fillOval(bounds.getCopy());

    graphics.popState();
  }
예제 #10
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);
 }
예제 #11
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 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();
  }
예제 #14
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();
  }
예제 #15
0
  @Override
  protected void paintClientArea(Graphics graphics) {
    graphics.setAntialias(SWT.ON);
    Rectangle area = getClientArea();
    area.width = Math.min(area.width, area.height);
    area.height = area.width;
    Pattern pattern = null;
    graphics.pushState();
    graphics.setBackgroundColor(GRAY_COLOR);
    boolean support3D = GraphicsUtil.testPatternSupported(graphics);
    if (effect3D && support3D) {
      // add this to eliminate the repaint bug on Mac
      graphics.fillOval(new Rectangle());
      pattern =
          new Pattern(
              Display.getCurrent(),
              area.x,
              area.y,
              area.x + area.width,
              area.y + area.height,
              BORDER_COLOR,
              WHITE_COLOR);
      graphics.setBackgroundPattern(pattern);
    }
    graphics.fillOval(area);
    graphics.popState();

    if (effect3D && support3D) {
      pattern.dispose();
      area.shrink(BORDER_WIDTH, BORDER_WIDTH);
    } else area.shrink(1, 1);

    graphics.fillOval(area);

    super.paintClientArea(graphics);

    // glossy effect
    if (effect3D && support3D) {
      graphics.pushState();
      graphics.setAntialias(SWT.ON);
      final double R = area.width / 2.0d;
      final double UD_FILL_PART = 9.5d / 10d;
      final double UP_DOWN_RATIO = 1d / 2d;
      final double LR_FILL_PART = 8.5d / 10d;
      final double UP_ANGLE = 0d * Math.PI / 180d;
      final double DOWN_ANGLE = 35d * Math.PI / 180d;
      // add this to eliminate the repaint bug on Mac

      graphics.fillOval(new Rectangle());

      Pattern glossyPattern =
          new Pattern(
              Display.getCurrent(),
              area.x + area.width / 2,
              (float) (area.y + area.height / 2 - R * UD_FILL_PART),
              area.x + area.width / 2,
              (float) (area.y + area.height / 2 + R * UP_DOWN_RATIO),
              WHITE_COLOR,
              90,
              WHITE_COLOR,
              0);
      graphics.setBackgroundPattern(glossyPattern);
      Rectangle rectangle =
          new Rectangle(
              (int) (area.x + area.width / 2 - R * LR_FILL_PART * Math.cos(UP_ANGLE)),
              (int) (area.y + area.height / 2 - R * UD_FILL_PART),
              (int) (2 * R * LR_FILL_PART * Math.cos(UP_ANGLE)),
              (int) (R * UD_FILL_PART + R * UP_DOWN_RATIO));
      graphics.fillOval(rectangle);
      glossyPattern.dispose();

      glossyPattern =
          new Pattern(
              Display.getCurrent(),
              area.x + area.width / 2,
              (float) (area.y + area.height / 2 + R * UP_DOWN_RATIO - 1),
              area.x + area.width / 2,
              (float) (area.y + area.height / 2 + R * UD_FILL_PART + 1),
              WHITE_COLOR,
              0,
              WHITE_COLOR,
              40);
      graphics.setBackgroundPattern(glossyPattern);
      rectangle =
          new Rectangle(
              (int) (area.x + area.width / 2 - R * LR_FILL_PART * Math.sin(DOWN_ANGLE)),
              (int) Math.ceil(area.y + area.height / 2 + R * UP_DOWN_RATIO),
              (int) (2 * R * LR_FILL_PART * Math.sin(DOWN_ANGLE)),
              (int) Math.ceil(R * UD_FILL_PART - R * UP_DOWN_RATIO));
      graphics.fillOval(rectangle);
      glossyPattern.dispose();
      graphics.popState();
    }
  }
예제 #16
0
  @Override
  protected void paintClientArea(Graphics graphics) {
    updateThresholdPosition();
    graphics.setAntialias(SWT.ON);
    graphics.setLineWidth(rampWidth);
    graphics.pushState();
    int overlap = 0;
    Pattern pattern = null;
    boolean support3D = GraphicsUtil.testPatternSupported(graphics);
    // draw lolo part
    if (lolo.visible) {
      graphics.setBackgroundColor(lolo.color);
      graphics.fillArc(bounds, lolo.absolutePosition, min.relativePosition - lolo.relativePosition);
    }
    // draw lo part
    if (lo.visible) {
      if (support3D && gradient && lolo.visible) {
        try {
          pattern =
              new Pattern(
                  Display.getCurrent(),
                  lolo.leftPoint.x,
                  lolo.leftPoint.y,
                  lo.rightPoint.x,
                  lo.rightPoint.y,
                  lolo.color,
                  lo.color);
          graphics.setBackgroundPattern(pattern);
          overlap = OVERLAP_DEGREE / 2;
        } catch (Exception e) {
          support3D = false;
          pattern.dispose();
          graphics.setBackgroundColor(lo.color);
          overlap = 0;
        }
      } else {
        graphics.setBackgroundColor(lo.color);
        overlap = 0;
      }

      if (lolo.visible)
        graphics.fillArc(
            bounds, lo.absolutePosition, lolo.relativePosition - lo.relativePosition + overlap);
      else
        graphics.fillArc(bounds, lo.absolutePosition, min.relativePosition - lo.relativePosition);
      if (gradient && lolo.visible && support3D) pattern.dispose();
    }

    // draw left normal part
    // get the left marker
    boolean leftMarkerVisible = false;
    ThresholdMarker leftMarker = null;
    if (lo.visible) {
      leftMarkerVisible = true;
      leftMarker = lo;
    } else if (lolo.visible) {
      leftMarkerVisible = true;
      leftMarker = lolo;
    } else leftMarkerVisible = false;

    if (gradient && leftMarkerVisible && support3D) {
      pattern =
          new Pattern(
              Display.getCurrent(),
              leftMarker.leftPoint.x,
              leftMarker.leftPoint.y,
              normal.rightPoint.x,
              normal.rightPoint.y,
              leftMarker.color,
              normal.color);
      graphics.setBackgroundPattern(pattern);
      overlap = OVERLAP_DEGREE / 2;
    } else {
      graphics.setBackgroundColor(normal.color);
      overlap = 0;
    }

    if (leftMarkerVisible)
      graphics.fillArc(
          bounds,
          normal.absolutePosition,
          leftMarker.relativePosition - normal.relativePosition + overlap);
    else
      graphics.fillArc(
          bounds, normal.absolutePosition, min.relativePosition - normal.relativePosition);

    if (gradient && leftMarkerVisible && support3D) pattern.dispose();

    // draw right normal part
    // get the right marker
    boolean rightMarkerVisible = false;
    ThresholdMarker rightMarker = null;
    if (hi.visible) {
      rightMarkerVisible = true;
      rightMarker = hi;
    } else if (hihi.visible) {
      rightMarkerVisible = true;
      rightMarker = hihi;
    } else rightMarkerVisible = false;

    if (gradient && rightMarkerVisible && support3D) {
      pattern =
          new Pattern(
              Display.getCurrent(),
              rightMarker.rightPoint.x,
              rightMarker.rightPoint.y,
              normal.leftPoint.x,
              normal.leftPoint.y,
              rightMarker.color,
              normal.color);
      graphics.setBackgroundPattern(pattern);
      overlap = OVERLAP_DEGREE / 2;
    } else {
      graphics.setBackgroundColor(normal.color);
      overlap = 0;
    }

    if (rightMarkerVisible)
      graphics.fillArc(
          bounds,
          rightMarker.absolutePosition,
          normal.relativePosition - rightMarker.relativePosition + overlap + 1);
    else
      graphics.fillArc(
          bounds, max.absolutePosition, normal.relativePosition - max.relativePosition + 1);

    if (gradient && rightMarkerVisible && support3D) pattern.dispose();

    // draw hi part
    if (hi.visible) {
      if (hihi.visible) {
        rightMarkerVisible = true;
        rightMarker = hihi;
      } else rightMarkerVisible = false;

      if (gradient && rightMarkerVisible && support3D) {
        pattern =
            new Pattern(
                Display.getCurrent(),
                rightMarker.rightPoint.x,
                rightMarker.rightPoint.y,
                hi.leftPoint.x,
                hi.leftPoint.y,
                rightMarker.color,
                hi.color);
        graphics.setBackgroundPattern(pattern);
        overlap = OVERLAP_DEGREE / 2;
      } else {
        graphics.setBackgroundColor(hi.color);
        overlap = 0;
      }

      if (rightMarkerVisible)
        graphics.fillArc(
            bounds,
            rightMarker.absolutePosition,
            hi.relativePosition - rightMarker.relativePosition + overlap);
      else
        graphics.fillArc(bounds, max.absolutePosition, hi.relativePosition - max.relativePosition);

      if (gradient && rightMarkerVisible && support3D) pattern.dispose();
    }

    // draw hihi part
    if (hihi.visible) {
      if (gradient && support3D) overlap = OVERLAP_DEGREE / 2;
      else overlap = 0;
      graphics.setBackgroundColor(hihi.color);
      graphics.fillArc(
          bounds, max.absolutePosition, hihi.relativePosition - max.relativePosition + overlap);
    }

    graphics.popState();
    graphics.fillOval(
        bounds.x + rampWidth,
        bounds.y + rampWidth,
        bounds.width - 2 * rampWidth,
        bounds.height - 2 * rampWidth);

    super.paintClientArea(graphics);
  }