/** Draws this handle. */
  public void draw(Graphics2D g) {
    Graphics2D gg = (Graphics2D) g.create();
    gg.transform(view.getDrawingToViewTransform());
    for (Connector c : connectors) {
      c.draw(gg);
    }

    gg.dispose();
    drawCircle(g, (getTarget() == null) ? Color.red : Color.green, Color.black);
  }
Exemple #2
0
 @Override
 protected void drawFill(Graphics2D g) {
   if (isClosed() || get(UNCLOSED_PATH_FILLED)) {
     double grow = AttributeKeys.getPerpendicularFillGrowth(this);
     if (grow == 0d) {
       g.fill(path);
     } else {
       GrowStroke gs =
           new GrowStroke(grow, AttributeKeys.getStrokeTotalWidth(this) * get(STROKE_MITER_LIMIT));
       g.fill(gs.createStrokedShape(path));
     }
   }
 }
Exemple #3
0
 @Override
 protected void drawStroke(Graphics2D g) {
   if (isClosed()) {
     double grow = AttributeKeys.getPerpendicularDrawGrowth(this);
     if (grow == 0d) {
       g.draw(path);
     } else {
       GrowStroke gs =
           new GrowStroke(grow, AttributeKeys.getStrokeTotalWidth(this) * get(STROKE_MITER_LIMIT));
       g.draw(gs.createStrokedShape(path));
     }
   } else {
     g.draw(getCappedPath());
   }
   drawCaps(g);
 }
 public void draw(Graphics2D g) {
   Rectangle2D clipBounds = g.getClipBounds();
   if (clipBounds != null) {
     Collection<Figure> c = quadTree.findIntersects(clipBounds);
     Collection<Figure> toDraw = sort(c);
     draw(g, toDraw);
   } else {
     draw(g, children);
   }
 }
  /** This method is invoked before the rendered image of the figure is composited. */
  public void drawFigure(Graphics2D g) {
    AffineTransform savedTransform = null;
    if (get(TRANSFORM) != null) {
      savedTransform = g.getTransform();
      g.transform(get(TRANSFORM));
    }

    if (get(FILL_STYLE) != ODGConstants.FillStyle.NONE) {
      Paint paint = ODGAttributeKeys.getFillPaint(this);
      if (paint != null) {
        g.setPaint(paint);
        drawFill(g);
      }
    }

    if (get(STROKE_STYLE) != ODGConstants.StrokeStyle.NONE) {
      Paint paint = ODGAttributeKeys.getStrokePaint(this);
      if (paint != null) {
        g.setPaint(paint);
        g.setStroke(ODGAttributeKeys.getStroke(this));
        drawStroke(g);
      }
    }
    if (get(TRANSFORM) != null) {
      g.setTransform(savedTransform);
    }
  }
  @Override
  public void draw(Graphics2D g) {
    double opacity = get(OPACITY);
    opacity = Math.min(Math.max(0d, opacity), 1d);
    if (opacity != 0d) {
      if (opacity != 1d) {
        Rectangle2D.Double drawingArea = getDrawingArea();

        Rectangle2D clipBounds = g.getClipBounds();
        if (clipBounds != null) {
          Rectangle2D.intersect(drawingArea, clipBounds, drawingArea);
        }

        if (!drawingArea.isEmpty()) {

          BufferedImage buf =
              new BufferedImage(
                  (int) ((2 + drawingArea.width) * g.getTransform().getScaleX()),
                  (int) ((2 + drawingArea.height) * g.getTransform().getScaleY()),
                  BufferedImage.TYPE_INT_ARGB);
          Graphics2D gr = buf.createGraphics();
          gr.scale(g.getTransform().getScaleX(), g.getTransform().getScaleY());
          gr.translate((int) -drawingArea.x, (int) -drawingArea.y);
          gr.setRenderingHints(g.getRenderingHints());
          drawFigure(gr);
          gr.dispose();
          Composite savedComposite = g.getComposite();
          g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) opacity));
          g.drawImage(
              buf,
              (int) drawingArea.x,
              (int) drawingArea.y,
              2 + (int) drawingArea.width,
              2 + (int) drawingArea.height,
              null);
          g.setComposite(savedComposite);
        }
      } else {
        drawFigure(g);
      }
    }
  }
 protected void drawStroke(Graphics2D g) {
   g.draw(getTextShape());
 }
 protected void drawFill(Graphics2D g) {
   g.fill(getTextShape());
 }