List of usage examples for java.awt.geom GeneralPath GeneralPath
public GeneralPath()
From source file:MainClass.java
protected Shape create() { GeneralPath path = new GeneralPath(); path.moveTo(50, 30); path.lineTo(30, 200); return path; }
From source file:GeneralPathDemo.java
public GeneralPathDemo() { oddShape = new GeneralPath(); firstTime = true; area = new Rectangle(); }
From source file:TransformersRotationTranslation.java
protected Shape createAxes() { GeneralPath path = new GeneralPath(); // Axes./*from w w w.j ava 2s . co m*/ path.moveTo(-length, 0); path.lineTo(length, 0); path.moveTo(0, -length); path.lineTo(0, length); // Arrows. path.moveTo(length - arrowLength, -arrowLength); path.lineTo(length, 0); path.lineTo(length - arrowLength, arrowLength); path.moveTo(-arrowLength, length - arrowLength); path.lineTo(0, length); path.lineTo(arrowLength, length - arrowLength); // Half-centimeter tick marks float cm = 72 / 2.54f; float lengthCentimeter = length / cm; for (float i = 0.5f; i < lengthCentimeter; i += 1.0f) { float tick = i * cm; path.moveTo(tick, -tickSize / 2); path.lineTo(tick, tickSize / 2); path.moveTo(-tick, -tickSize / 2); path.lineTo(-tick, tickSize / 2); path.moveTo(-tickSize / 2, tick); path.lineTo(tickSize / 2, tick); path.moveTo(-tickSize / 2, -tick); path.lineTo(tickSize / 2, -tick); } // Full-centimeter tick marks for (float i = 1.0f; i < lengthCentimeter; i += 1.0f) { float tick = i * cm; path.moveTo(tick, -tickSize); path.lineTo(tick, tickSize); path.moveTo(-tick, -tickSize); path.lineTo(-tick, tickSize); path.moveTo(-tickSize, tick); path.lineTo(tickSize, tick); path.moveTo(-tickSize, -tick); path.lineTo(tickSize, -tick); } return path; }
From source file:grafix.graficos.comparativo.ConstrutorGraficoComparativos.java
private static JFreeChart criarChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Comparativo da Evoluo de Papis", "Perodo", "Evoluo (%)", dataset, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); GeneralPath zigzag = new GeneralPath(); zigzag.moveTo(-6.0f, 0.0f);/*w w w. j a va 2s . c om*/ zigzag.lineTo(-3.0f, 6.0f); zigzag.lineTo(3.0f, -6.0f); zigzag.lineTo(6.0f, 0.0f); renderer.setLegendLine(zigzag); return chart; }
From source file:BezLab.java
public void paint(Graphics g) { for (int i = 0; i < 4; i++) { if (i == 0 || i == 3) g.setColor(Color.blue); else/*w w w . j a v a 2s. c om*/ g.setColor(Color.cyan); g.fillOval(xs[i] - 6, ys[i] - 6, 12, 12); } Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.black); GeneralPath path = new GeneralPath(); path.moveTo(xs[0], ys[0]); path.curveTo(xs[1], ys[1], xs[2], ys[2], xs[3], ys[3]); g2d.draw(path); }
From source file:AttributesApp.java
public AttributesApp() { setBackground(Color.lightGray); setSize(500, 200);/* ww w . j a va 2 s. c o m*/ attribString = new AttributedString(text); GeneralPath star = new GeneralPath(); star.moveTo(0, 0); star.lineTo(10, 30); star.lineTo(-10, 10); star.lineTo(10, 10); star.lineTo(-10, 30); star.closePath(); GraphicAttribute starShapeAttr = new ShapeGraphicAttribute(star, GraphicAttribute.TOP_ALIGNMENT, false); attribString.addAttribute(TextAttribute.CHAR_REPLACEMENT, starShapeAttr, 0, 1); attribString.addAttribute(TextAttribute.FOREGROUND, new Color(255, 255, 0), 0, 1); int index = text.indexOf("Java Source"); attribString.addAttribute(TextAttribute.FOREGROUND, Color.blue, index, index + 7); Font font = new Font("sanserif", Font.ITALIC, 40); attribString.addAttribute(TextAttribute.FONT, font, index, index + 7); loadImage(); BufferedImage bimage = new BufferedImage(image.getWidth(this), image.getHeight(this), BufferedImage.TYPE_INT_ARGB); Graphics2D big = bimage.createGraphics(); big.drawImage(image, null, this); GraphicAttribute javaImageAttr = new ImageGraphicAttribute(bimage, GraphicAttribute.TOP_ALIGNMENT, 0, 0); index = text.indexOf("Java"); attribString.addAttribute(TextAttribute.CHAR_REPLACEMENT, javaImageAttr, index - 1, index); font = new Font("serif", Font.BOLD, 60); attribString.addAttribute(TextAttribute.FONT, font, index, index + 4); attribString.addAttribute(TextAttribute.FOREGROUND, new Color(243, 63, 163), index, index + 4); // Start and end indexes. index = text.indexOf("source"); attribString.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, index, index + 2); index = text.indexOf("and support"); font = new Font("sanserif", Font.ITALIC, 40); attribString.addAttribute(TextAttribute.FONT, font, index, index + 10); attribString.addAttribute(TextAttribute.FOREGROUND, Color.white, index, index + 2); // Start and end indexes. attribString.addAttribute(TextAttribute.FOREGROUND, Color.blue, index + 3, index + 10); // Start and end indexes. }
From source file:DrawShapes_2008.java
/** * Generates a star Shape from the given location, radii, and points * parameters. The Shape is created by constructing a GeneralPath * that moves between the inner and outer rings. *///from ww w . ja v a 2 s . co m private static Shape generateStar(double x, double y, double innerRadius, double outerRadius, int pointsCount) { GeneralPath path = new GeneralPath(); double outerAngleIncrement = 2 * Math.PI / pointsCount; double outerAngle = 0.0; double innerAngle = outerAngleIncrement / 2.0; x += outerRadius; y += outerRadius; float x1 = (float) (Math.cos(outerAngle) * outerRadius + x); float y1 = (float) (Math.sin(outerAngle) * outerRadius + y); float x2 = (float) (Math.cos(innerAngle) * innerRadius + x); float y2 = (float) (Math.sin(innerAngle) * innerRadius + y); path.moveTo(x1, y1); path.lineTo(x2, y2); outerAngle += outerAngleIncrement; innerAngle += outerAngleIncrement; for (int i = 1; i < pointsCount; i++) { x1 = (float) (Math.cos(outerAngle) * outerRadius + x); y1 = (float) (Math.sin(outerAngle) * outerRadius + y); path.lineTo(x1, y1); x2 = (float) (Math.cos(innerAngle) * innerRadius + x); y2 = (float) (Math.sin(innerAngle) * innerRadius + y); path.lineTo(x2, y2); outerAngle += outerAngleIncrement; innerAngle += outerAngleIncrement; } path.closePath(); return path; }
From source file:Main.java
/** * Creates a diamond shape.//ww w . ja v a 2 s . c om * * @param s the size factor (equal to half the height of the diamond). * * @return A diamond shape. */ public static Shape createDiamond(final float s) { final GeneralPath p0 = new GeneralPath(); p0.moveTo(0.0f, -s); p0.lineTo(s, 0.0f); p0.lineTo(0.0f, s); p0.lineTo(-s, 0.0f); p0.closePath(); return p0; }
From source file:Main.java
/** * Creates a triangle shape that points upwards. * * @param s the size factor (equal to half the height of the triangle). * * @return A triangle shape./*from ww w. ja va2 s . com*/ */ public static Shape createUpTriangle(final float s) { final GeneralPath p0 = new GeneralPath(); p0.moveTo(0.0f, -s); p0.lineTo(s, s); p0.lineTo(-s, s); p0.closePath(); return p0; }
From source file:Main.java
/** * Creates a triangle shape that points downwards. * * @param s the size factor (equal to half the height of the triangle). * * @return A triangle shape./*from w ww . j av a 2 s .co m*/ */ public static Shape createDownTriangle(final float s) { final GeneralPath p0 = new GeneralPath(); p0.moveTo(0.0f, s); p0.lineTo(s, -s); p0.lineTo(-s, -s); p0.closePath(); return p0; }