List of usage examples for java.awt.geom Path2D.Double lineTo
public abstract void lineTo(double x, double y);
From source file:org.mabb.fontverter.opentype.TtfGlyph.java
/** * Debug only method at the moment, will not return an entireley accurate path in many cases. */// ww w.ja v a 2 s .co m List<Path2D.Double> getPaths() { LinkedList<Path2D.Double> paths = new LinkedList<Path2D.Double>(); int startPtOn = 0; Point2D.Double lastPoint = new Point2D.Double(); for (Integer endPtOn : countourEndPoints) { Path2D.Double pathOn = new Path2D.Double(); if (startPtOn == 0) pathOn.moveTo(0, 0); Point2D.Double firstPoint = new Point2D.Double(); for (int i = startPtOn; i < endPtOn + 1; i++) { Point2D.Double relativePoint = points.get(i); Point2D.Double point = new Point2D.Double(); point.x = relativePoint.x + lastPoint.x; point.y = relativePoint.y + lastPoint.y; if (startPtOn != 0 && i == startPtOn) pathOn.moveTo(point.x, point.y); else pathOn.lineTo(point.x, point.y); if (i == startPtOn) firstPoint = point; lastPoint = point; } startPtOn = endPtOn + 1; pathOn.lineTo(firstPoint.x, firstPoint.y); paths.add(pathOn); } return paths; }
From source file:savant.util.MiscUtils.java
/** * Utility method to create a polygonal path from a list of coordinates * @param coords a sequence of x,y coordinates (should be an even number and at least 4) */// w ww. jav a 2s.c o m public static Path2D.Double createPolygon(double... coords) { if (coords.length < 4 || (coords.length & 1) != 0) throw new IllegalArgumentException("Invalid coordinates for createPolygon"); Path2D.Double result = new Path2D.Double(Path2D.WIND_NON_ZERO, coords.length / 2); result.moveTo(coords[0], coords[1]); for (int i = 2; i < coords.length; i += 2) { result.lineTo(coords[i], coords[i + 1]); } result.closePath(); return result; }
From source file:savant.view.tracks.TrackRenderer.java
/** * Shared by BAMTrackRenderer and RichIntervalTrackRenderer to draw the white diamond * which indicates an insertion./*w w w. j av a 2 s.c om*/ */ public Shape drawInsertion(Graphics2D g2, double x, double y, double unitWidth, double unitHeight) { ColourScheme cs = (ColourScheme) instructions.get(DrawingInstruction.COLOUR_SCHEME); g2.setColor(cs.getColor(ColourKey.INSERTED_BASE)); double w = unitWidth * 0.5; Path2D.Double rhombus = new Path2D.Double(); rhombus.moveTo(x, y); rhombus.lineTo(x + w, y + unitHeight * 0.5); rhombus.lineTo(x, y + unitHeight); rhombus.lineTo(x - w, y + unitHeight * 0.5); rhombus.closePath(); g2.fill(rhombus); return rhombus; }