/* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javafx.scene.shape; import com.sun.javafx.geom.Arc2D; import com.sun.javafx.scene.DirtyBits; import com.sun.javafx.sg.prism.NGArc; import com.sun.javafx.sg.prism.NGNode; import javafx.beans.property.DoubleProperty; import javafx.beans.property.DoublePropertyBase; import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectPropertyBase; import javafx.scene.paint.Paint; /** * The {@code Arc} class represents a 2D arc object, defined by a center point, * start angle (in degrees), angular extent (length of the arc in degrees), * and an arc type ({@link ArcType#OPEN}, {@link ArcType#CHORD}, * or {@link ArcType#ROUND}). * *
Example usage: the following code creates an Arc which is centered around * 50,50, has a radius of 25 and extends from the angle 45 to the angle 315 * (270 degrees long), and is round. *
import javafx.scene.shape.*; Arc arc = new Arc(); arc.setCenterX(50.0f); arc.setCenterY(50.0f); arc.setRadiusX(25.0f); arc.setRadiusY(25.0f); arc.setStartAngle(45.0f); arc.setLength(270.0f); arc.setType(ArcType.ROUND);* @since JavaFX 2.0 */ public class Arc extends Shape { private final Arc2D shape = new Arc2D(); /** * Creates an empty instance of Arc. */ public Arc() { } /** * Creates a new instance of Arc. * @param centerX the X coordinate of the center point of the arc * @param centerY the Y coordinate of the center point of the arc * @param radiusX the overall width (horizontal radius) of the full ellipse * of which this arc is a partial section * @param radiusY the overall height (vertical radius) of the full ellipse * of which this arc is a partial section * @param startAngle the starting angle of the arc in degrees * @param length the angular extent of the arc in degrees */ public Arc(double centerX, double centerY, double radiusX, double radiusY, double startAngle, double length) { setCenterX(centerX); setCenterY(centerY); setRadiusX(radiusX); setRadiusY(radiusY); setStartAngle(startAngle); setLength(length); } /** * Defines the X coordinate of the center point of the arc. * * @defaultValue 0.0 */ private DoubleProperty centerX; public final void setCenterX(double value) { if (centerX != null || value != 0.0) { centerXProperty().set(value); } } public final double getCenterX() { return centerX == null ? 0.0 : centerX.get(); } public final DoubleProperty centerXProperty() { if (centerX == null) { centerX = new DoublePropertyBase() { @Override public void invalidated() { impl_markDirty(DirtyBits.NODE_GEOMETRY); impl_geomChanged(); } @Override public Object getBean() { return Arc.this; } @Override public String getName() { return "centerX"; } }; } return centerX; } /** * Defines the Y coordinate of the center point of the arc. * * @defaultValue 0.0 */ private DoubleProperty centerY; public final void setCenterY(double value) { if (centerY != null || value != 0.0) { centerYProperty().set(value); } } public final double getCenterY() { return centerY == null ? 0.0 : centerY.get(); } public final DoubleProperty centerYProperty() { if (centerY == null) { centerY = new DoublePropertyBase() { @Override public void invalidated() { impl_markDirty(DirtyBits.NODE_GEOMETRY); impl_geomChanged(); } @Override public Object getBean() { return Arc.this; } @Override public String getName() { return "centerY"; } }; } return centerY; } /** * Defines the overall width (horizontal radius) of the full ellipse * of which this arc is a partial section. * * @defaultValue 0.0 */ private final DoubleProperty radiusX = new DoublePropertyBase() { @Override public void invalidated() { impl_markDirty(DirtyBits.NODE_GEOMETRY); impl_geomChanged(); } @Override public Object getBean() { return Arc.this; } @Override public String getName() { return "radiusX"; } }; public final void setRadiusX(double value) { radiusX.set(value); } public final double getRadiusX() { return radiusX.get(); } public final DoubleProperty radiusXProperty() { return radiusX; } /** * Defines the overall height (vertical radius) of the full ellipse * of which this arc is a partial section. * * @defaultValue 0.0 */ private final DoubleProperty radiusY = new DoublePropertyBase() { @Override public void invalidated() { impl_markDirty(DirtyBits.NODE_GEOMETRY); impl_geomChanged(); } @Override public Object getBean() { return Arc.this; } @Override public String getName() { return "radiusY"; } }; public final void setRadiusY(double value) { radiusY.set(value); } public final double getRadiusY() { return radiusY.get(); } public final DoubleProperty radiusYProperty() { return radiusY; } /** * Defines the starting angle of the arc in degrees. * * @defaultValue 0.0 */ private DoubleProperty startAngle; public final void setStartAngle(double value) { if (startAngle != null || value != 0.0) { startAngleProperty().set(value); } } public final double getStartAngle() { return startAngle == null ? 0.0 : startAngle.get(); } public final DoubleProperty startAngleProperty() { if (startAngle == null) { startAngle = new DoublePropertyBase() { @Override public void invalidated() { impl_markDirty(DirtyBits.NODE_GEOMETRY); impl_geomChanged(); } @Override public Object getBean() { return Arc.this; } @Override public String getName() { return "startAngle"; } }; } return startAngle; } /** * Defines the angular extent of the arc in degrees. * * @defaultValue 0.0 */ private final DoubleProperty length = new DoublePropertyBase() { @Override public void invalidated() { impl_markDirty(DirtyBits.NODE_GEOMETRY); impl_geomChanged(); } @Override public Object getBean() { return Arc.this; } @Override public String getName() { return "length"; } }; public final void setLength(double value) { length.set(value); } public final double getLength() { return length.get(); } public final DoubleProperty lengthProperty() { return length; } /** * Defines the closure type for the arc: * {@link ArcType#OPEN}, {@link ArcType#CHORD},or {@link ArcType#ROUND}. * * @defaultValue OPEN */ private ObjectProperty