public Rectangle2D.Double getDrawingArea() {
   double strokeTotalWidth = AttributeKeys.getStrokeTotalWidth(this);
   double width = strokeTotalWidth / 2d;
   if (STROKE_JOIN.get(this) == BasicStroke.JOIN_MITER) {
     width *= STROKE_MITER_LIMIT.get(this);
   } else if (STROKE_CAP.get(this) != BasicStroke.CAP_BUTT) {
     width += strokeTotalWidth * 2;
   }
   width++;
   Rectangle2D.Double r = getBounds();
   Geom.grow(r, width, width);
   return r;
 }
Beispiel #2
0
 @Override
 public Rectangle2D.Double getDrawingArea() {
   if (cachedDrawingArea == null) {
     Rectangle2D rx = getBounds();
     Rectangle2D.Double r =
         (rx instanceof Rectangle2D.Double)
             ? (Rectangle2D.Double) rx
             : new Rectangle2D.Double(rx.getX(), rx.getY(), rx.getWidth(), rx.getHeight());
     double g = SVGAttributeKeys.getPerpendicularHitGrowth(this);
     Geom.grow(r, g, g);
     if (TRANSFORM.get(this) == null) {
       cachedDrawingArea = r;
     } else {
       cachedDrawingArea = new Rectangle2D.Double();
       cachedDrawingArea.setRect(TRANSFORM.get(this).createTransformedShape(r).getBounds2D());
     }
   }
   return (Rectangle2D.Double) cachedDrawingArea.clone();
 }
 @Override
 public Rectangle2D.Double getDrawingArea() {
   if (cachedDrawingArea == null) {
     if (get(TRANSFORM) == null) {
       cachedDrawingArea = path.getBounds2D();
     } else {
       BezierPath p2 = (BezierPath) path.clone();
       p2.transform(get(TRANSFORM));
       cachedDrawingArea = p2.getBounds2D();
     }
     double strokeTotalWidth = AttributeKeys.getStrokeTotalWidth(this);
     double width = strokeTotalWidth / 2d;
     if (get(STROKE_JOIN) == BasicStroke.JOIN_MITER) {
       width *= get(STROKE_MITER_LIMIT);
     } else if (get(STROKE_CAP) != BasicStroke.CAP_BUTT) {
       width += strokeTotalWidth * 2;
     }
     Geom.grow(cachedDrawingArea, width, width);
   }
   return (Rectangle2D.Double) cachedDrawingArea.clone();
 }
Beispiel #4
0
 /** Gets the drawing area without taking the decorator into account. */
 @Override
 protected Rectangle2D.Double getFigureDrawingArea() {
   if (getText() == null) {
     return getBounds();
   } else {
     TextLayout layout = getTextLayout();
     Rectangle2D.Double r =
         new Rectangle2D.Double(origin.x, origin.y, layout.getAdvance(), layout.getAscent());
     Rectangle2D lBounds = layout.getBounds();
     if (!lBounds.isEmpty() && !Double.isNaN(lBounds.getX())) {
       r.add(
           new Rectangle2D.Double(
               lBounds.getX() + origin.x,
               (lBounds.getY() + origin.y + layout.getAscent()),
               lBounds.getWidth(),
               lBounds.getHeight()));
     }
     // grow by two pixels to take antialiasing into account
     Geom.grow(r, 2d, 2d);
     return r;
   }
 }