Class SVGArrow

    • 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 given Document.
        Specified by:
        render in interface SVGPrimitive
        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 interface SVGPrimitive
        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 interface SVGPrimitive
        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 interface SVGPrimitive
        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() and RectangularShape.getCenterY().

        Specified by:
        getBounds in interface SVGPrimitive
        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 interface SVGPrimitive
        Returns:
        a list of points.