@Override public Arrow create(JSONObject node, ValidationContext ctx) { return new Arrow(node); } }
/** * Sets the arrow type which specifies if the arrow has one or two arrow heads, * where they are located and whether the end without the arrow head is tapered or not. * * @param end * @return this Arrow */ public Arrow setArrowType(ArrowType arrowType) { getAttributes().setArrowType(arrowType); invalidatePolygon(); return this; }
/** * Sets the end point of the arrow. * * @param end * @return this Arrow */ public Arrow setEnd(Point2D end) { getPoints().setPoint(1, end); invalidatePolygon(); return this; }
try ArrowType type = getArrowType(); double a = Geometry.toRadians(getArrowAngle()); double sina = Math.sin(a); double cosa = Math.cos(a); double b_degrees = 180 - getBaseAngle() - getArrowAngle(); double b = Geometry.toRadians(b_degrees); double sinb = Math.sin(b); double cosb = Math.cos(b); double w = getBaseWidth(); double aw = getHeadWidth(); Point2D s = getStart(); // arr.getPoint(0); Point2D e = getEnd(); // arr.getPoint(1); Point2D dv = e.minus(s);
/** * Gets the width of the arrow head. * * @return double */ public double getHeadWidth() { return getAttributes().getHeadWidth(); }
/** * Gets the start point of this arrow. * * @return Point2D */ public Point2D getStart() { return getPoints().getPoint(0); }
/** * Draws this arrow. * * @param context the {@link Context2D} used to draw this arrow. */ @Override public boolean prepare(Context2D context, Attributes attr, double alpha) { Point2DArray list = getPolygon(); // is null for invalid arrow definition if ((null != list) && (list.getLength() > 2)) { Point2D point = list.getPoint(0); context.beginPath(); context.moveTo(point.getX(), point.getY()); final int leng = list.getLength(); for (int i = 1; i < leng; i++) { point = list.getPoint(i); context.lineTo(point.getX(), point.getY()); } context.closePath(); return true; } return false; }
/** * Gets the end-points of this arrow. * Point[0] is the start point and point[1] is the end point. * * @return Point2DArray */ public Point2DArray getPoints() { return getAttributes().getPoints(); }
/** * Gets the end point of this arrow. * * @return Point2D */ public Point2D getEnd() { return getPoints().getPoint(1); }
/** * Sets the end-points of this arrow. The points should be a 2-element {@link Point2DArray} * * @param points Point2DArray * @return this Arrow */ public Arrow setPoints(Point2DArray points) { getAttributes().setPoints(points); invalidatePolygon(); return this; }
/** * Sets the start point of the arrow. * * @param start * @return this Arrow */ public Arrow setStart(Point2D start) { getPoints().setPoint(0, start); invalidatePolygon(); return this; }
/** * Gets the width of the base of the arrow. * * @return double */ public double getBaseWidth() { return getAttributes().getBaseWidth(); }
/** * Sets the width of the base of the arrow. * * @param baseWidth * @return this Arrow */ public Arrow setBaseWidth(double baseWidth) { getAttributes().setBaseWidth(baseWidth); invalidatePolygon(); return this; }
/** * Gets the arrow type which specifies if the arrow has one or two arrow heads, * where they are located and whether the end without the arrow head is tapered or not. * * @return ArrowType */ public ArrowType getArrowType() { return getAttributes().getArrowType(); }
/** * Sets the width of the arrow head. * * @param headWidth * @return this Arrow */ public Arrow setHeadWidth(double headWidth) { getAttributes().setHeadWidth(headWidth); invalidatePolygon(); return this; }
/** * Gets the angle between the outer diagonal and the inner diagonal * of the arrow head. * * @return angle in degrees, e.g. 45.0 */ public double getBaseAngle() { return getAttributes().getBaseAngle(); }
/** * Sets the angle between the midline of the arrow (between start and end points) * and the outer diagonal. * * @param arrowAngle in degrees, e.g. 45.0 * @return this Arrow */ public Arrow setArrowAngle(double arrowAngle) { getAttributes().setArrowAngle(arrowAngle); invalidatePolygon(); return this; }
/** * Gets the angle between the midline of the arrow (between start and end points) * and the outer diagonal. * * @return angle in degrees, e.g. 45.0 */ public double getArrowAngle() { return getAttributes().getArrowAngle(); }
/** * Sets the angle between the outer diagonal and the inner diagonal * of the arrow head. * * @param baseAngle in degrees, e.g. 45.0 * @return this Arrow */ public Arrow setBaseAngle(double baseAngle) { getAttributes().setBaseAngle(baseAngle); invalidatePolygon(); return this; }