@Override public Chord create(JSONObject node, ValidationContext ctx) { return new Chord(node); } }
/** * Constructor. Creates an instance of a chord. * * @param radius * @param startAngle in radians * @param endAngle in radians * @param counterClockwise */ public Chord(double radius, double startAngle, double endAngle, boolean counterClockwise) { super(ShapeType.CHORD); setRadius(radius).setStartAngle(startAngle).setEndAngle(endAngle).setCounterClockwise(counterClockwise); }
/** * Draws this chord. * * @param context */ @Override public boolean prepare(Context2D context, Attributes attr, double alpha) { double beg = getStartAngle(); double end = getEndAngle(); context.beginPath(); context.arc(0, 0, getRadius(), beg, end, isCounterClockwise()); context.closePath(); return true; }
/** * Sets whether the drawing direction of this chord is counter clockwise. * The default value is true. * * @param counterclockwise * @return this chord */ public Chord setCounterClockwise(boolean counterclockwise) { getAttributes().setCounterClockwise(counterclockwise); return this; }
/** * Gets the starting angle of this chord. * * @return double in radians */ public double getStartAngle() { return getAttributes().getStartAngle(); }
/** * Constructor. Creates an instance of a chord, drawn clockwise. * * @param radius * @param startAngle in radians * @param endAngle in radians */ public Chord(double radius, double startAngle, double endAngle) { super(ShapeType.CHORD); setRadius(radius).setStartAngle(startAngle).setEndAngle(endAngle).setCounterClockwise(false); }
/** * Gets this chord's radius * * @return double */ public double getRadius() { return getAttributes().getRadius(); }
/** * Gets the end angle of this chord. * * @return double in radians */ public double getEndAngle() { return getAttributes().getEndAngle(); }
/** * Sets this chord's radius. * * @param radius * @return this chord. */ public Chord setRadius(double radius) { getAttributes().setRadius(radius); return this; }
/** * Sets the starting angle of this chord. * * @param angle in radians * @return this chord. */ public Chord setStartAngle(double angle) { getAttributes().setStartAngle(angle); return this; }
/** * Gets the end angle of this chord. * * @param angle in radians * @return this chord. */ public Chord setEndAngle(double angle) { getAttributes().setEndAngle(angle); return this; }
/** * Returns whether the chord is drawn counter clockwise. * The default value is true. * * @return boolean */ public boolean isCounterClockwise() { return getAttributes().isCounterClockwise(); }