Refine search
@Implementation protected void rLineTo(float dx, float dy) { if (!hasPoints()) { mPath.moveTo(mLastX = 0, mLastY = 0); } if (Math.abs(dx) < EPSILON && Math.abs(dy) < EPSILON) { // The delta is so small that this shouldn't generate a line return; } dx += mLastX; dy += mLastY; mPath.lineTo(mLastX = dx, mLastY = dy); }
x += .5; int lineLength = 18; path.moveTo(x + lineLength, y); path.lineTo(x, y); path.lineTo(x, y + height); path.lineTo(x + lineLength, y + height); path.lineTo(x + lineLength, y + height - 1); path.lineTo(x + 1, y + height - 1); path.lineTo(x + 1, y + 1); path.lineTo(x + lineLength, y + 1); path.closePath();
/** * Add short barbs to the shape * * @param path * @param positionOnPath * @return */ private int drawShortBarb(Path2D path, int positionOnPath) { if (pennants == 0 && longBarbs == 0) { positionOnPath = -windBarbDefinition.vectorLength + DEFAULT_ELEMENTS_SPACING; } path.moveTo(0, positionOnPath); path.lineTo( windBarbDefinition.shortBarbLength, positionOnPath - windBarbDefinition.basePennantLength / 4.0); return positionOnPath; }
/** * Add long barbs to the shape * * @param path * @param positionOnPath * @return */ private int drawLongBarbs(Path2D path, int positionOnPath) { if (longBarbs <= 0) { return positionOnPath; } for (int elements = 0; elements < longBarbs; elements++) { if (elements >= 1) { // spacing if neede positionOnPath += windBarbDefinition.elementsSpacing; } // draw long barb path.moveTo(0, positionOnPath); path.lineTo( windBarbDefinition.longBarbLength, positionOnPath - windBarbDefinition.basePennantLength / 2.0); } return positionOnPath; }
/** * add Pennants to the shape * * @param path * @param positionOnPath * @return */ private int drawPennants(Path2D path, int positionOnPath) { if (pennants <= 0) { return positionOnPath; } for (int elements = 0; elements < pennants; elements++) { // move forward one pennant at a time // draw pennant path.moveTo(0, positionOnPath); positionOnPath += windBarbDefinition.basePennantLength / 2.0; path.lineTo(windBarbDefinition.longBarbLength, positionOnPath); // first edge positionOnPath += windBarbDefinition.basePennantLength / 2.0; path.lineTo(0, positionOnPath); // second edge path.closePath(); // only one square } return positionOnPath; } }
/** * Build a {@Shape} WindBarb * * @return */ Shape buildAbsentModule() { // Base barb Path2D path = new Path2D.Double(); int positionOnPath = 0; // draw wind barb line path.moveTo(0, positionOnPath); positionOnPath -= windBarbDefinition.vectorLength; path.lineTo(0, positionOnPath); path.moveTo( windBarbDefinition.shortBarbLength / 2.0f, positionOnPath - windBarbDefinition.shortBarbLength / 2.0f); path.lineTo( -windBarbDefinition.shortBarbLength / 2.0f, positionOnPath + windBarbDefinition.shortBarbLength / 2.0f); path.moveTo( -windBarbDefinition.shortBarbLength / 2.0f, positionOnPath - windBarbDefinition.shortBarbLength / 2.0f); path.lineTo( windBarbDefinition.shortBarbLength / 2.0f, positionOnPath + windBarbDefinition.shortBarbLength / 2.0f); // FLIP for geotools final Shape createTransformedShape = path.createTransformedShape(AffineTransform.getScaleInstance(1, -1)); return createTransformedShape; }
private GeneralPath createSquareBracket(Point2d p1, Point2d p2, Vector2d perp) { Path2D path = new Path2D.Double(); path.moveTo(p1.x + perp.x, p1.y + perp.y); path.lineTo(p1.x, p1.y); path.lineTo(p2.x, p2.y); path.lineTo(p2.x + perp.x, p2.y + perp.y); return GeneralPath.outlineOf(path, stroke, foreground); }
@Override public Area getArea (double above, double below) { Path2D path = new Path2D.Double(); path.moveTo(left.getX(), left.getY() + above); path.lineTo(right.getX(), right.getY() + above); path.lineTo(right.getX(), right.getY() + below + 1); path.lineTo(left.getX(), left.getY() + below + 1); path.closePath(); return new Area(path); }
Path2D path = new Path2D.Double(); AffineTransform at = new AffineTransform(); path.moveTo(p1p2a.x, p1p2a.y); path.lineTo(p1p2b.x, p1p2b.y); path.append(c1.getPathIterator(at), true); path.lineTo(p2p3b.x, p2p3b.y); path.append(c2.getPathIterator(at), true); path.lineTo(p3p1b.x, p3p1b.y); path.append(c3.getPathIterator(at), true); path.closePath(); g.fill(path);
public static void fillPolygon( Polygon2D_F64 polygon, double scale, Graphics2D g2 ) { g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Path2D path = new Path2D.Double(); Point2D_F64 p = polygon.get(0); path.moveTo(p.x*scale,p.y*scale); for( int i = 1; i <= polygon.size(); i++ ) { p = polygon.get(i%polygon.size()); path.lineTo(p.x*scale,p.y*scale); } g2.fill(path); }