Class SVGArrow
- java.lang.Object
-
- hudson.plugins.project_inheritance.util.svg.primitives.SVGArrow
-
- All Implemented Interfaces:
SVGPrimitive
public class SVGArrow extends Object implements SVGPrimitive
-
-
Field Summary
Fields Modifier and Type Field Description protected SVGLine
body
protected ArrowProperty
head
-
Constructor Summary
Constructors Constructor Description SVGArrow(SVGLine body, ArrowProperty head)
Creates an SVG arrow with an optional single head at the end point of the given line.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SVGArrow
createConnection(SVGPrimitive start, SVGPrimitive end, ColorProperty stroke, ArrowProperty head)
List<Point2D.Double>
getAttachmentPoints()
Returns the list of points to which other elements (especially arrows) can be attached.Rectangle2D.Double
getBounds()
Returns the outer, rectangular bounds of this primitive.void
moveTo(Point2D.Double pos)
Move the object to the given (x,y) position.Element
render(Document doc)
This function should return an element containing the primitive in question at its current location that can be inserted into the givenDocument
.void
rescale(double factor, boolean applyToStyles)
Rescales the primitive by the given positive factor.String
toString()
void
translate(Point2D.Double offset)
Translate the current position by the given (x,y) tuple.
-
-
-
Field Detail
-
body
protected final SVGLine body
-
head
protected ArrowProperty head
-
-
Constructor Detail
-
SVGArrow
public SVGArrow(SVGLine body, ArrowProperty head)
Creates an SVG arrow with an optional single head at the end point of the given line.- Parameters:
body
- the line the arrow is based on; may not be null.head
- the properties of the arrow head; may be null in which case only a regular line will be drawn.
-
-
Method Detail
-
render
public Element render(Document doc)
Description copied from interface:SVGPrimitive
This function should return an element containing the primitive in question at its current location that can be inserted into the givenDocument
.- Specified by:
render
in interfaceSVGPrimitive
- Parameters:
doc
- the document to render into- Returns:
- an XML
Element
that contains the necessary attributes to draw the primitive into an SVG document. Must return a new copy of the element on every invocation to allow for one primitive to generate multiple copies.
-
translate
public void translate(Point2D.Double offset)
Description copied from interface:SVGPrimitive
Translate the current position by the given (x,y) tuple.It is strictly necessary that the translation is applied identically to all sub-elements as long as it makes sense to translate them. Links or rotations for example do not need to be moved; as they only alter their child primitives and do not have a "location" to speak of.
- Specified by:
translate
in interfaceSVGPrimitive
- Parameters:
offset
- the amount to move the primitive in (x,y) direction.
-
moveTo
public void moveTo(Point2D.Double pos)
Description copied from interface:SVGPrimitive
Move the object to the given (x,y) position.It is strictly necessary that the move is applied identically to all sub-elements as long as it makes sense to move them. Links or rotations for example do not need to be moved; as they only alter their child primitives and do not have a "location" to speak of.
- Specified by:
moveTo
in interfaceSVGPrimitive
- Parameters:
pos
- the new position in the (x,y) plane.
-
rescale
public void rescale(double factor, boolean applyToStyles)
Description copied from interface:SVGPrimitive
Rescales the primitive by the given positive factor. Rescaling must keep the aspect ratio and must not alter the (x,y) position of the top left corner.That means; resizing does not move the primitive; but only expands or shrinks it in the positive x/y direction.
- Specified by:
rescale
in interfaceSVGPrimitive
- Parameters:
factor
- the multiplier to rescale the primitive by. Must be positive.applyToStyles
- if set to true; rescaling also affects styling, for example line widths.
-
getBounds
public Rectangle2D.Double getBounds()
Description copied from interface:SVGPrimitive
Returns the outer, rectangular bounds of this primitive.It is assumed that this value is being cached and not recomputed until the element is translated. After recomputation, the returned element can, but does not have to be a new object.
If you want to get the center of this element, call this function followed by
RectangularShape.getCenterX()
andRectangularShape.getCenterY()
.- Specified by:
getBounds
in interfaceSVGPrimitive
- Returns:
- the outer bounds of this object; or null if not a graphical primitive.
-
getAttachmentPoints
public List<Point2D.Double> getAttachmentPoints()
Description copied from interface:SVGPrimitive
Returns the list of points to which other elements (especially arrows) can be attached. The points should ideally be on the exterior surface of the element; but that is not a strict demand.This function may return null or an empty list if the element is not graphical.
- Specified by:
getAttachmentPoints
in interfaceSVGPrimitive
- Returns:
- a list of points.
-
createConnection
public static SVGArrow createConnection(SVGPrimitive start, SVGPrimitive end, ColorProperty stroke, ArrowProperty head)
-
-