/** Request the painting of the border */
  @Override
  public void paint(Graphics graphics) {
    try {
      Graphics2D g = ComponentFigure.getG2D(graphics);
      if (g != null) {

        Rectangle b = getBounds();

        JRPrintElement pe = new JRBasePrintText(null);
        pe.setX(b.x + 10);
        pe.setY(b.y + 10);
        pe.setWidth(b.width - 20);
        pe.setHeight(b.height - 20);
        if (section.getElement() instanceof ILineBox && section.getElement() != null)
          bd.drawBox(g, ((ILineBox) section.getElement()).getBoxContainer().getLineBox(), pe);
        else if (section.getElement() instanceof MStyle) {
          MStyle styleModel = (MStyle) section.getElement();
          bd.drawBox(g, ((JRStyle) styleModel.getValue()).getLineBox(), pe);
        }
      } else {
        graphics.drawRectangle(0, 0, 100, 100);
      }
    } catch (Exception e) {
      // when a font is missing exception is thrown by DrawVisitor
      // FIXME: maybe draw something, else?
      e.printStackTrace();
    }
  }
Beispiel #2
0
    @Override
    public void paintFigure(Graphics graphics) {

      int offsetX;
      int offsetY;

      if (ci.getShape() == ComponentShape.CIRCLE) {
        offsetX = OFFSET_SMALL_CIRCLE_COMPONENT_ICON;
        offsetY = OFFSET_SMALL_CIRCLE_COMPONENT_ICON;
        graphics.fillOval(this.getBounds());
        graphics.setAntialias(SWT.ON);
        Rectangle b = this.getBounds().getCopy();
        b.width--;
        b.height--;
        graphics.drawOval(b);

        graphics.setAntialias(SWT.OFF);
      } else {
        offsetX = OFFSET_SMALL_SQUARE_COMPONENT_ICON_X;
        offsetY = OFFSET_SMALL_SQUARE_COMPONENT_ICON_Y;
        graphics.fillRectangle(this.getBounds());
        Rectangle b = this.getBounds().getCopy();
        b.width--;
        b.height--;
        graphics.drawRectangle(b);
      }
      graphics.drawImage(
          icon, new Point(this.getLocation().x + offsetX, this.getLocation().y - 1 + offsetY));
    }
 /*
  * (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);
     }
   }
 }
Beispiel #4
0
  protected void paintFigure(Graphics graphics) {
    label.setBounds(
        new Rectangle(bounds.x, bounds.y + bounds.height - labelHeight, bounds.width, labelHeight));

    Rectangle rect = getBounds().getCopy();
    rect.height--;
    rect.width--;
    graphics.drawRectangle(rect);
  }
  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();
  }
  /** @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);
  }
  /**
   * 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();
  }
  @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);
  }
Beispiel #9
0
 @Override
 public void paintFigure(Graphics g) {
   Rectangle r = bounds;
   g.drawText(message, r.x + r.width / 4, r.y + r.height / 4);
   g.drawRectangle(r.x, r.y, r.width - 1, r.height - 1);
 }