@Override public Bow create(JSONObject node, ValidationContext ctx) { return new Bow(node); } }
/** * Constructor. Creates an instance of a slice, drawn clockwise. * * @param radius * @param startAngle in radians * @param endAngle in radians */ public Bow(double innerRadius, double outerRadius, double startAngle, double endAngle) { super(ShapeType.BOW); setInnerRadius(innerRadius).setOuterRadius(outerRadius).setStartAngle(startAngle).setEndAngle(endAngle).setCounterClockwise(false); }
/** * Draws this slice. * * @param context */ @Override public boolean prepare(Context2D context, Attributes attr, double alpha) { final double end = getEndAngle(); final double start = getStartAngle(); final boolean ccw = isCounterClockwise(); if (start == end) { return false; } context.beginPath(); context.arc(0, 0, getOuterRadius(), start, end, ccw); context.arc(0, 0, getInnerRadius(), end, start, (false == ccw)); context.closePath(); return true; }
/** * Gets the {@link Star} inner radius. * * @return double */ public double getInnerRadius() { return getAttributes().getInnerRadius(); }
/** * Sets the outer radius. * * @param radius * @return this Star */ public Bow setOuterRadius(double radius) { getAttributes().setOuterRadius(radius); return this; }
/** * Constructor. Creates an instance of a slice. * * @param radius * @param startAngle in radians * @param endAngle in radians * @param counterClockwise */ public Bow(double innerRadius, double outerRadius, double startAngle, double endAngle, boolean counterClockwise) { super(ShapeType.BOW); setInnerRadius(innerRadius).setOuterRadius(outerRadius).setStartAngle(startAngle).setEndAngle(endAngle).setCounterClockwise(counterClockwise); }
/** * Gets the end angle of this slice. * * @param angle in radians * @return this Slice. */ public Bow setEndAngle(double angle) { getAttributes().setEndAngle(angle); return this; }
/** * Returns whether the slice is drawn counter clockwise. * The default value is true. * * @return boolean */ public boolean isCounterClockwise() { return getAttributes().isCounterClockwise(); }
/** * Sets the {@link Star} inner radius. * * @param radius * @return this Star */ public Bow setInnerRadius(double radius) { getAttributes().setInnerRadius(radius); return this; }
/** * Gets the starting angle of this slice. * * @return double in radians */ public double getStartAngle() { return getAttributes().getStartAngle(); }
/** * Sets the starting angle of this slice. * * @param angle in radians * @return this Slice. */ public Bow setStartAngle(double angle) { getAttributes().setStartAngle(angle); return this; }
/** * Sets whether the drawing direction of this slice is counter clockwise. * The default value is true. * * @param counterclockwise * @return this Slice */ public Bow setCounterClockwise(boolean counterclockwise) { getAttributes().setCounterClockwise(counterclockwise); return this; }
/** * Returns the {@link Star} outer radius. * * @return double */ public double getOuterRadius() { return getAttributes().getOuterRadius(); }
/** * Gets the end angle of this slice. * * @return double in radians */ public double getEndAngle() { return getAttributes().getEndAngle(); }