Java Code Examples for java.awt.geom.Arc2D#Float

The following examples show how to use java.awt.geom.Arc2D#Float . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Draw.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Draw pie
 *
 * @param aPoint Start point
 * @param width Width
 * @param height Height
 * @param startAngle Start angle
 * @param sweepAngle Sweep angle
 * @param aPGB Polygon break
 * @param wedgeWidth Wedge width
 * @param g Graphics2D
 */
public static void drawPie(PointF aPoint, float width, float height, float startAngle,
        float sweepAngle, PolygonBreak aPGB, float wedgeWidth, Graphics2D g) {
    Color aColor = aPGB.getColor();
    Arc2D.Float arc2D = new Arc2D.Float(aPoint.X, aPoint.Y, width, height, startAngle, sweepAngle, Arc2D.PIE);
    Area area1 = new Area(arc2D);
    Ellipse2D e2 = new Ellipse2D.Float(aPoint.X + wedgeWidth, aPoint.Y + wedgeWidth, width - wedgeWidth * 2,
            height - wedgeWidth * 2);
    Area area2 = new Area(e2);
    area1.subtract(area2);
    if (aPGB.isDrawFill()) {
        g.setColor(aColor);
        g.fill(area1);
    }
    if (aPGB.isDrawOutline()) {
        g.setColor(aPGB.getOutlineColor());
        g.setStroke(new BasicStroke(aPGB.getOutlineSize()));
        g.draw(area1);
    }
}
 
Example 2
Source File: ProgressPieComponent.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	//Construct the arc
	Arc2D.Float arc = new Arc2D.Float(Arc2D.PIE);
	arc.setAngleStart(90);
	arc.setAngleExtent(progress * 360);
	arc.setFrame(position.getX() - diameter / 2, position.getY() - diameter / 2, diameter, diameter);

	//Draw the inside of the arc
	graphics.setColor(fill);
	graphics.fill(arc);

	//Draw the outlines of the arc
	graphics.setStroke(stroke);
	graphics.setColor(borderColor);
	graphics.drawOval(position.getX() - diameter / 2, position.getY() - diameter / 2, diameter, diameter);

	return new Dimension(diameter, diameter);
}
 
Example 3
Source File: VectorGraphics2D.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void drawArc(int x, int y, int width, int height, int startAngle,
		int arcAngle) {
	Arc2D a = new Arc2D.Float(x, y, width, height, startAngle, arcAngle,
			Arc2D.OPEN);
	draw(a);
}
 
Example 4
Source File: VectorGraphics2D.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void fillArc(int x, int y, int width, int height, int startAngle,
		int arcAngle) {
	Arc2D a = new Arc2D.Float(x, y, width, height, startAngle, arcAngle,
			Arc2D.OPEN);
	fill(a);
}
 
Example 5
Source File: Symbol.java    From energy2d with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void paintIcon(Component c, Graphics g, int x, int y) {
	super.paintIcon(c, g, x, y);
	Graphics2D g2 = (Graphics2D) g;
	float thickness = ((BasicStroke) stroke).getLineWidth();
	Rectangle2D.Float s = new Rectangle2D.Float(xSymbol + wSymbol * 0.2f, ySymbol + hSymbol * 0.2f, wSymbol * 0.6f, hSymbol * 0.6f);
	Arc2D.Float a = new Arc2D.Float(s, 80 - thickness * 10, thickness * 20 - 340, Arc2D.OPEN);
	g2.draw(a);
	g2.drawLine((int) (xSymbol + wSymbol * 0.5f), (int) (ySymbol + hSymbol * 0.1f), (int) (xSymbol + wSymbol * 0.5f), (int) (ySymbol + hSymbol * 0.4f));
}
 
Example 6
Source File: Symbol.java    From energy2d with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void paintIcon(Component c, Graphics g, int x, int y) {
	super.paintIcon(c, g, x, y);
	Graphics2D g2 = (Graphics2D) g;
	Rectangle2D.Float s = new Rectangle2D.Float(xSymbol + wSymbol * 0.4f, ySymbol + hSymbol * 0.3f, wSymbol * 0.4f, hSymbol * 0.4f);
	Arc2D.Float a = new Arc2D.Float(s, -90, 180, Arc2D.OPEN);
	g2.draw(a);
	int x0 = Math.round(xSymbol + wSymbol * 0.3f);
	int y0 = Math.round(ySymbol + hSymbol * 0.28f);
	g2.drawLine(Math.round(xSymbol + wSymbol * 0.55f), y0, x0, y0);
	g2.drawLine(x0, y0, x0 + 2, y0 - 2);
	g2.drawLine(x0, y0, x0 + 2, y0 + 2);
	y0 += Math.round(hSymbol * 0.4f);
	g2.drawLine(Math.round(xSymbol + wSymbol * 0.55f), y0, x0, y0);
}
 
Example 7
Source File: EditSelectionOperation.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
@Override
    protected void tick(int centreX, int centreY, boolean inverse, boolean first, float dynamicLevel) {
        // Create a geometric shape corresponding to the brush size, shape and
        // rotation
        Shape shape;
        final Brush brush = getBrush();
        final int brushRadius = brush.getRadius();
        switch (brush.getBrushShape()) {
            case BITMAP:
            case SQUARE:
                shape = new Rectangle(centreX - brushRadius, centreY - brushRadius, brushRadius * 2 + 1, brushRadius * 2 + 1);
                if (brush instanceof RotatedBrush) {
                    int rotation = ((RotatedBrush) brush).getDegrees();
                    if (rotation != 0) {
                        shape = new Path2D.Float(shape, AffineTransform.getRotateInstance(rotation / DEGREES_TO_RADIANS, centreX, centreY));
                    }
                }
                break;
            case CIRCLE:
                shape = new Arc2D.Float(centreX - brushRadius, centreY - brushRadius, brushRadius * 2 + 1, brushRadius * 2 + 1, 0.0f, 360.0f, Arc2D.CHORD);
                break;
            default:
                throw new InternalError();
        }

        final Dimension dimension = getDimension();
        dimension.setEventsInhibited(true);
        try {
            SelectionHelper selectionHelper = new SelectionHelper(dimension);
            if (inverse) {
                selectionHelper.removeFromSelection(shape);
            } else {
                selectionHelper.addToSelection(shape);
                // TODO: make this work correctly with undo/redo, and make "inside selection" ineffective when there is no selection, to avoid confusion
//                selectionState.setValue(true);
            }
        } finally {
            dimension.setEventsInhibited(false);
        }
    }
 
Example 8
Source File: AbstractGraphics2D.java    From pumpernickel with MIT License 4 votes vote down vote up
/**
 * Calls <code>draw(Arc2D)</code>
 */
@Override
public void drawArc(int x, int y, int w, int h, int startAngle, int endAngle) {
	Arc2D a = new Arc2D.Float(x, y, w, h, startAngle, endAngle, Arc2D.OPEN);
	draw(a);
}
 
Example 9
Source File: AbstractGraphics2D.java    From pumpernickel with MIT License 4 votes vote down vote up
/**
 * Calls <code>fill(Arc2D)</code>
 */
@Override
public void fillArc(int x, int y, int w, int h, int startAngle, int endAngle) {
	Arc2D a = new Arc2D.Float(x, y, w, h, startAngle, endAngle, Arc2D.OPEN);
	fill(a);
}
 
Example 10
Source File: EpsGraphics2D.java    From osp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws an arc.
 */
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
  Shape shape = new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN);
  draw(shape);
}
 
Example 11
Source File: EpsGraphics2D.java    From osp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Fills an arc.
 */
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
  Shape shape = new Arc2D.Float(x, y, width, height, startAngle, arcAngle, Arc2D.PIE);
  draw(shape, "fill"); //$NON-NLS-1$
}