Beispiel #1
0
 @Override
 public boolean contains(Point2D.Double p) {
   double tolerance = Math.max(2f, AttributeKeys.getStrokeTotalWidth(this) / 2d);
   if (isClosed() || get(FILL_COLOR) != null && get(UNCLOSED_PATH_FILLED)) {
     if (path.contains(p)) {
       return true;
     }
     double grow = AttributeKeys.getPerpendicularHitGrowth(this) * 2d;
     GrowStroke gs =
         new GrowStroke(grow, AttributeKeys.getStrokeTotalWidth(this) * get(STROKE_MITER_LIMIT));
     if (gs.createStrokedShape(path).contains(p)) {
       return true;
     } else {
       if (isClosed()) {
         return false;
       }
     }
   }
   if (!isClosed()) {
     if (getCappedPath().outlineContains(p, tolerance)) {
       return true;
     }
     if (get(START_DECORATION) != null) {
       BezierPath cp = getCappedPath();
       Point2D.Double p1 = path.get(0, 0);
       Point2D.Double p2 = cp.get(0, 0);
       // FIXME - Check here, if caps path contains the point
       if (Geom.lineContainsPoint(p1.x, p1.y, p2.x, p2.y, p.x, p.y, tolerance)) {
         return true;
       }
     }
     if (get(END_DECORATION) != null) {
       BezierPath cp = getCappedPath();
       Point2D.Double p1 = path.get(path.size() - 1, 0);
       Point2D.Double p2 = cp.get(path.size() - 1, 0);
       // FIXME - Check here, if caps path contains the point
       if (Geom.lineContainsPoint(p1.x, p1.y, p2.x, p2.y, p.x, p.y, tolerance)) {
         return true;
       }
     }
   }
   return false;
 }
Beispiel #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));
     }
   }
 }
 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 #4
0
 public Point2D.Double chop(Point2D.Double p) {
   if (isClosed()) {
     double grow = AttributeKeys.getPerpendicularHitGrowth(this);
     if (grow == 0d) {
       return path.chop(p);
     } else {
       GrowStroke gs =
           new GrowStroke(grow, AttributeKeys.getStrokeTotalWidth(this) * get(STROKE_MITER_LIMIT));
       return Geom.chop(gs.createStrokedShape(path), p);
     }
   } else {
     return path.chop(p);
   }
 }
Beispiel #5
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);
 }