@Override public Arc create(JSONObject node, ValidationContext ctx) { return new Arc(node); } }
/** * Draws this arc. * * @param context the {@link Context2D} used to draw this arc. */ @Override public boolean prepare(Context2D context, Attributes attr, double alpha) { context.beginPath(); context.arc(0, 0, getRadius(), getStartAngle(), getEndAngle(), isCounterClockwise()); return true; }
/** * Constructor. Creates an instance of an arc, drawn clockwise. * * @param radius radius of the circle * @param startAngle starting angle (in radians) of this arc * @param endAngle end angle (in radians) of this arc */ public Arc(double radius, double startAngle, double endAngle) { super(ShapeType.ARC); setRadius(radius).setStartAngle(startAngle).setEndAngle(endAngle).setCounterClockwise(false); }
/** * Returns whether the drawing direction of this arc is counter clockwise. * * @return boolean */ public boolean isCounterClockwise() { return getAttributes().isCounterClockwise(); }
/** * Gets this arc's radius. * * @return double */ public double getRadius() { return getAttributes().getRadius(); }
/** * Constructor. Creates an instance of an arc. * * @param radius radius of the circle * @param startAngle starting angle (in radians) of this arc * @param endAngle end angle (in radians) of this arc * @param counterClockwise * direction in which the arc is drawn. True draws the arc counter clockwise; * false draws the arc clockwise. * */ public Arc(double radius, double startAngle, double endAngle, boolean counterClockwise) { super(ShapeType.ARC); setRadius(radius).setStartAngle(startAngle).setEndAngle(endAngle).setCounterClockwise(counterClockwise); }
/** * Sets the starting angle of this arc. * * @param angle (in radians) * @return this Arc */ public Arc setStartAngle(double angle) { getAttributes().setStartAngle(angle); return this; }
/** * Sets the end angle of this arc. * * @param angle (in radians) * @return this Arc */ public Arc setEndAngle(double angle) { getAttributes().setEndAngle(angle); return this; }
/** * Sets this arc's radius. * * @param radius * @return this Arc */ public Arc setRadius(double radius) { getAttributes().setRadius(radius); return this; }
/** * Gets the starting angle of this arc. * * @return double (in radians) */ public double getStartAngle() { return getAttributes().getStartAngle(); }
/** * Gets the end angle of this arc. * * @return double (in radians) */ public double getEndAngle() { return getAttributes().getEndAngle(); }
/** * Sets the drawing direction for this arc. * * @param counterClockwise If true, it's drawn counter clockwise. * @return this Arc */ public Arc setCounterClockwise(boolean counterClockwise) { getAttributes().setCounterClockwise(counterClockwise); return this; }