Class SVGRectangle
- java.lang.Object
-
- hudson.plugins.project_inheritance.util.svg.primitives.SVGRectangle
-
- All Implemented Interfaces:
SVGPrimitive
public class SVGRectangle extends Object implements SVGPrimitive
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SVGRectangle.AttachPoints
-
Field Summary
Fields Modifier and Type Field Description protected SVGRectangle.AttachPoints
attach
protected Rectangle2D.Double
box
protected ColorProperty
fill
protected ColorProperty
stroke
-
Constructor Summary
Constructors Constructor Description SVGRectangle(Rectangle2D.Double box, ColorProperty stroke, ColorProperty fill)
SVGRectangle(Rectangle2D.Double box, ColorProperty stroke, ColorProperty fill, SVGRectangle.AttachPoints pts)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
box
protected final Rectangle2D.Double box
-
stroke
protected final ColorProperty stroke
-
fill
protected final ColorProperty fill
-
attach
protected final SVGRectangle.AttachPoints attach
-
-
Constructor Detail
-
SVGRectangle
public SVGRectangle(Rectangle2D.Double box, ColorProperty stroke, ColorProperty fill)
-
SVGRectangle
public SVGRectangle(Rectangle2D.Double box, ColorProperty stroke, ColorProperty fill, SVGRectangle.AttachPoints pts)
-
-
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.
-
-