/** 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();
  }
Example #2
0
  @SuppressWarnings("unchecked")
  @Override
  protected void paintFigure(final Graphics graphics) {
    if (gc == null || gc.isDisposed()) {
      return;
    }

    Rectangle clip = graphics.getClip(new Rectangle());
    graphics.setClip(getBounds());
    ArrayList<IFigure> children = new ArrayList<IFigure>(getChildren());
    Collections.sort(
        children,
        new Comparator<IFigure>() {
          public int compare(final IFigure o1, final IFigure o2) {
            Integer z1 = ObjectFigure.Z0;
            Integer z2 = ObjectFigure.Z0;
            if (o1 instanceof ObjectFigure) {
              z1 = ((ObjectFigure) o1).getZ();
            }
            if (o2 instanceof ObjectFigure) {
              z2 = ((ObjectFigure) o2).getZ();
            }
            return z1.compareTo(z2);
          }
        });

    for (final Object object : children) {
      ((IFigure) object).paint(graphics);
    }
    graphics.setClip(clip);
  }
 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);
 }
  /*
   * (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);
  }
Example #5
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);
  }
 /**
  * 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);
 }
 public void paintBackground(Graphics g) {
   g.pushState();
   try {
     renderers.get(curRenderer).paintBackground(g);
   } finally {
     g.popState();
   }
 }
 public void paint(Graphics g) {
   if (lblCnnName.getBorder() != null) {
     g.setLineWidth(2);
   } else {
     g.setLineWidth(1);
   }
   super.paint(g);
 }
Example #9
0
 @Override
 protected void outlineShape(Graphics g) {
   int x = getParent().getBounds().x + 15;
   int x2 = x + getParent().getBounds().width - 30;
   g.setForegroundColor(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
   g.drawPolyline(new int[] {x - 2, position - 2, x, position, x - 2, position + 2});
   g.drawPolyline(new int[] {x, position, x2, position});
   g.drawPolyline(new int[] {x2 + 3, position - 3, x2, position, x2 + 2, position + 2});
 }
Example #10
0
 protected void paintFigure(Graphics graphics) {
   graphics.setAntialias(SWT.ON);
   if (control != null && !control.isDisposed() && control.isEnabled()) {
     graphics.setAlpha(0xff);
   } else {
     graphics.setAlpha(0x80);
   }
   super.paintFigure(graphics);
 }
Example #11
0
  /** @see org.eclipse.draw2d.Figure#paintFigure(Graphics) */
  protected void paintFigure(final Graphics graphics) {
    super.paintFigure(graphics);

    Image image = getImage();
    if (image != null) {
      graphics.setAntialias(SWT.ON);
      if (getAlpha() != IUseTransparency.DONT_USE_ALPHA) graphics.setAlpha(getAlpha());
      paintImage(graphics, image);
    }
  }
 @Override
 protected void paintChildren(Graphics graphics) {
   if (getEditing()) {
     // configure the graphics to use an alpha value
     graphics.setAdvanced(true);
     graphics.setAlpha(125);
     graphics.pushState();
   }
   super.paintChildren(graphics);
 }
Example #13
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.draw2d.IFigure#paint(org.eclipse.draw2d.Graphics)
  */
 public void paint(Graphics graphics) {
   if (!isVisible()) return;
   if (uncheckedImage != null) {
     if (hilite) {
       if (state == false) graphics.drawImage(uncheckedHiliteImage, getLocation());
       else graphics.drawImage(checkedHiliteImage, getLocation());
     } else {
       if (state == false) graphics.drawImage(uncheckedImage, getLocation());
       else graphics.drawImage(checkedImage, getLocation());
     }
   } else {
     Iterator<Rectangle> iter = null;
     if (state == false) iter = uncheckedRects.iterator();
     else iter = checkedRects.iterator();
     while (iter.hasNext()) {
       Point p = getLocation();
       Rectangle r = iter.next().getCopy();
       r = r.translate(p.x, p.y);
       graphics.setForegroundColor(getForegroundColor());
       if (hilite) graphics.setBackgroundColor(ColorConstants.lightBlue);
       else graphics.setBackgroundColor(ColorConstants.white);
       graphics.fillRectangle(r);
       graphics.drawRectangle(r);
     }
   }
 }
Example #14
0
    protected void paintFigure(Graphics graphics) {
      int alpha = 0x60;
      graphics.setAntialias(SWT.ON);
      if (control != null && !control.isDisposed() && control.isEnabled()) {
        graphics.setAlpha(0xff);
      } else {
        graphics.setAlpha(0x90);
      }
      Rectangle r = getBounds();
      Path shape = new Path(Display.getCurrent());
      float corner = Math.max(2, (vertical ? r.width : r.height) / 2);
      SWTUtils.addRoundedRectangle(shape, r.x, r.y, r.width - 1, r.height - 1, corner);

      Pattern pattern =
          new Pattern(
              Display.getCurrent(), //
              r.x,
              r.y, //
              vertical ? r.right() - 1 : r.x, //
              vertical ? r.y : r.bottom() - 1, //
              ColorConstants.gray,
              alpha, //
              ColorConstants.lightGray,
              alpha);
      graphics.setBackgroundPattern(pattern);
      graphics.fillPath(shape);
      graphics.setBackgroundPattern(null);
      pattern.dispose();

      graphics.setAlpha(alpha);
      graphics.setForegroundColor(ColorConstants.gray);
      graphics.drawPath(shape);
      shape.dispose();
    }
 public void paintBackground(Graphics g) {
   Iterator<GraphicalWidgetRenderer> i = renderers.iterator();
   while (i.hasNext()) {
     g.pushState();
     try {
       i.next().paintBackground(g);
     } finally {
       g.popState();
     }
   }
 }
 /* (non-Javadoc)
  * @see org.eclipse.draw2d.Figure#paint(org.eclipse.draw2d.Graphics)
  */
 @Override
 public void paint(Graphics graphics) {
   int oldAntialias = graphics.getAntialias();
   if (Animation.isAnimating() && Animation.getProgress() < .9) {
     graphics.setAntialias(SWT.OFF);
   } else {
     graphics.setAntialias(antialiasing);
   }
   super.paint(graphics);
   graphics.setAntialias(oldAntialias);
 }
Example #17
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);
 }
Example #18
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);
 }
 @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);
   }
 }
  protected void paintGrid(
      Graphics g,
      IFigure f,
      org.eclipse.draw2d.geometry.Point origin,
      int distanceX,
      int distanceY) {
    FreeformFigure ff = (FreeformFigure) this.getParent();
    Rectangle clientArea = getClientArea();
    Rectangle bounds = ff.getFreeformExtent().getCopy();
    bounds.union(clientArea.x, clientArea.y, clientArea.width, clientArea.height);
    ff.setFreeformBounds(bounds);

    Rectangle original = g.getClip(Rectangle.SINGLETON);

    Rectangle clip =
        new Rectangle(
            original.x - original.x % distanceX,
            original.y - original.y % distanceY,
            original.width + Math.abs(original.x % distanceX),
            original.height + Math.abs(original.y % distanceY));
    if (distanceX > 0 && distanceY > 0) {
      if (origin.x >= clip.x) {
        while (origin.x - distanceX >= clip.x) {
          origin.x -= distanceX;
        }
      } else {
        while (origin.x < clip.x) {
          origin.x += distanceX;
        }
      }

      if (origin.y >= clip.y) {
        while (origin.y - distanceY >= clip.y) {
          origin.y -= distanceY;
        }
      } else {
        while (origin.y < clip.y) {
          origin.y += distanceY;
        }
      }

      for (int i = origin.x; i < clip.x + clip.width; i += distanceX) {
        for (int j = origin.y; j < clip.y + clip.height; j += distanceY) {
          // g.drawPoint(i, j);
          int re = Math.abs(i - j);
          if (re / distanceY % 2 == 0) {
            g.drawImage(ImageProvider.getImage(EImage.CHESS_GRAY), i, j);
          }
        }
      }
    }
  }
  /** @see Shape#outlineShape(Graphics) */
  protected void outlineShape(Graphics graphics) {
    float lineInset = Math.max(1.0f, getLineWidth()) / 2.0f;
    int inset1 = (int) Math.floor(lineInset);
    int inset2 = (int) Math.ceil(lineInset);

    Rectangle r = Draw2dSingletonUtil.getRectangle().setBounds(getClientArea());
    r.x += inset1;
    r.y += inset1;
    r.width -= inset1 + inset2;
    r.height -= inset1 + inset2;
    if (isEnabled()) graphics.setForegroundColor(lineColor);
    graphics.drawRectangle(r);
  }
  @Override
  public void paint(Graphics graphics) {
    graphics.setBackgroundColor(NodeUtil.BG_COLOR);

    if (node.getGraph().getRule() != null) {
      Rule rule = node.getGraph().getRule();
      if (!NodeUtil.nodeIsMapped(node, rule.getMappings())) {
        if (node.getGraph().isLhs()) graphics.setBackgroundColor(NodeUtil.BG_COLOR_DELETED);
        if (node.getGraph().isRhs()) graphics.setBackgroundColor(NodeUtil.BG_COLOR_CREATED);
      }
    }
    super.paint(graphics);
  }
  /**
   * @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);
    }
  }
Example #24
0
 @Override
 protected void fillShape(Graphics graphics) {
   Rectangle a = start(graphics);
   try {
     if (shape instanceof Ellipse) {
       graphics.fillOval(1, 1, a.width - 1, a.height - 1);
     } else if (shape instanceof PointList) {
       graphics.fillPolygon((PointList) shape);
     }
   } finally {
     stop(graphics);
   }
 }
  @Override
  protected void paintFigure(final org.eclipse.draw2d.Graphics graphics) {
    if (!getBackgroundColor().isDisposed()) {
      graphics.setBackgroundColor(getBackgroundColor());
    }
    final int boxWidth = getBounds().height / HALF;
    final int laneYStart = getBounds().y;
    final int y = laneYStart + boxWidth / HALF;
    graphics.fillRectangle(3, y, boxWidth, boxWidth);
    graphics.drawRectangle(3, y, boxWidth, boxWidth);

    final int textXOffset = getBounds().height;
    graphics.drawString(user.getName(), textXOffset, laneYStart);
  }
Example #26
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);
    }
  }
 @Override
 public void paintFigure(Graphics g) {
   Rectangle r = getBounds();
   r.shrink(1, 1);
   try {
     g.setBackgroundColor(getFillColor());
     g.fillOval(r);
     g.setForegroundColor(getLineColor());
     g.drawOval(r);
   } finally {
     // We don't really own rect 'r', so fix it.
     r.expand(1, 1);
   }
 }
 /**
  * The main drawing routine.
  *
  * @param gfx The {@link Graphics} to use
  */
 @Override
 public synchronized void paintFigure(final Graphics gfx) {
   if (isLoadingImage()) return;
   Rectangle bounds = getBounds().getCopy();
   ImageUtils.crop(bounds, this.getInsets());
   IPath imagePath = booleanValue ? onImagePath : offImagePath;
   if (loadingError) {
     if (!imagePath.isEmpty()) {
       gfx.setBackgroundColor(getBackgroundColor());
       gfx.setForegroundColor(getForegroundColor());
       gfx.fillRectangle(bounds);
       gfx.translate(bounds.getLocation());
       TextPainter.drawText(
           gfx,
           "ERROR in loading image\n" + imagePath,
           bounds.width / 2,
           bounds.height / 2,
           TextPainter.CENTER);
     }
     return;
   }
   Color currentcolor = null;
   if (useForegroundColor) currentcolor = getForegroundColor();
   else currentcolor = booleanValue ? onColor : offColor;
   getCurrentImage().setCurrentColor(currentcolor);
   getCurrentImage().setBounds(bounds);
   getCurrentImage().setBorder(getBorder());
   getCurrentImage().setAbsoluteScale(gfx.getAbsoluteScale());
   getCurrentImage().paintFigure(gfx);
   if (!isEnabled()) {
     gfx.setAlpha(DISABLED_ALPHA);
     gfx.setBackgroundColor(DISABLE_COLOR);
     gfx.fillRectangle(bounds);
   }
 }
 /** {@inheritDoc} */
 @Override
 protected synchronized void fillShape(final Graphics graphics) {
   Rectangle figureBounds = getClientArea();
   if (!transparent) {
     if (isEnabled()) graphics.setBackgroundColor(getBackgroundColor());
     if (gradient && useAdvancedGraphics) {
       graphics.setForegroundColor(backGradientStartColor);
       graphics.fillGradient(figureBounds, horizontalFill);
     } else graphics.fillRectangle(figureBounds);
   }
   if (getFill() > 0) {
     if (isEnabled()) graphics.setBackgroundColor(getForegroundColor());
     Rectangle fillRectangle;
     if (horizontalFill) {
       int newW = (int) Math.round(figureBounds.width * (getFill() / 100));
       fillRectangle = new Rectangle(figureBounds.x, figureBounds.y, newW, figureBounds.height);
     } else {
       int newH = (int) Math.round(figureBounds.height * (getFill() / 100));
       fillRectangle =
           new Rectangle(
               figureBounds.x,
               figureBounds.y + figureBounds.height - newH,
               figureBounds.width,
               newH);
     }
     if (gradient && useAdvancedGraphics) {
       graphics.setForegroundColor(foreGradientStartColor);
       graphics.fillGradient(fillRectangle, horizontalFill);
     } else graphics.fillRectangle(fillRectangle);
   }
 }
Example #30
0
  @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);
  }