Class LayoutShape


  • public class LayoutShape
    extends java.lang.Object
    A LayoutShape is a set of LayoutShapePoint used to draw a shape. Each point can ether be a point on the shape or a control point that defines a curve that's part of the shape. The shape can be open (end points not connected) or closed (end points connected)
    • Constructor Detail

      • LayoutShape

        public LayoutShape​(java.lang.String name,
                           LayoutEditor layoutEditor)
        constructor method (used by XML loading code)
        Parameters:
        name - the name of the shape
        layoutEditor - reference to the LayoutEditor this shape is in
      • LayoutShape

        public LayoutShape​(java.lang.String name,
                           LayoutShape.LayoutShapeType t,
                           LayoutEditor layoutEditor)
        constructor method (used by XML loading code)
        Parameters:
        name - the name of the shape
        t - the layout shape type.
        layoutEditor - reference to the LayoutEditor this shape is in
      • LayoutShape

        public LayoutShape​(java.lang.String name,
                           java.awt.geom.Point2D c,
                           LayoutEditor layoutEditor)
        constructor method (used by LayoutEditor)
        Parameters:
        name - the name of the shape
        c - the Point2D for the initial point
        layoutEditor - reference to the LayoutEditor this shape is in
      • LayoutShape

        public LayoutShape​(LayoutShape layoutShape)
        constructor method (used by duplicate)
        Parameters:
        layoutShape - to duplicate (deep copy)
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getName

        public java.lang.String getName()
        accessor methods
        Returns:
        the name of this shape
      • setName

        public void setName​(java.lang.String n)
      • setLineColor

        public void setLineColor​(java.awt.Color color)
      • setFillColor

        public void setFillColor​(java.awt.Color color)
      • setLevel

        public void setLevel​(int l)
      • addPoint

        public void addPoint​(java.awt.geom.Point2D p)
        add point
        Parameters:
        p - the point to add
      • addPoint

        public void addPoint​(java.awt.geom.Point2D p,
                             int nearIndex)
        add point
        Parameters:
        p - the point to add
        nearIndex - the index of the existing point to add it near note: "near" is defined as before or after depending on closest neighbor
      • setPoint

        public void setPoint​(int idx,
                             java.awt.geom.Point2D p)
        set point
        Parameters:
        idx - the index of the point to add
        p - the point to add
      • getPoint

        public java.awt.geom.Point2D getPoint​(int idx)
        Get point.
        Parameters:
        idx - the index of the point to add.
        Returns:
        the 2D point of the ID, MathUtil.zeroPoint2D if no result.
      • getNumberPoints

        public int getNumberPoints()
        get the number of points
        Returns:
        the number of points
      • getMaxNumberPoints

        public int getMaxNumberPoints()
        get the maximum number of points
        Returns:
        the maximum number of points
      • getBounds

        public java.awt.geom.Rectangle2D getBounds()
        getBounds() - return the bounds of this shape
        Returns:
        Rectangle2D as bound of this shape
      • findHitPointType

        protected HitPointType findHitPointType​(@Nonnull
                                                java.awt.geom.Point2D hitPoint,
                                                boolean useRectangles)
        find the hit (location) type for a point
        Parameters:
        hitPoint - the point
        useRectangles - whether to use (larger) rectangles or (smaller) circles for hit testing
        Returns:
        the hit point type for the point (or NONE)
      • getCoordsCenter

        public java.awt.geom.Point2D getCoordsCenter()
        get coordinates of center point of shape
        Returns:
        Point2D coordinates of center point of shape
      • setCoordsCenter

        public void setCoordsCenter​(@Nonnull
                                    java.awt.geom.Point2D p)
        set center coordinates
        Parameters:
        p - the coordinates to set
      • scaleCoords

        public void scaleCoords​(double xFactor,
                                double yFactor)
        scale this shapes coordinates by the x and y factors
        Parameters:
        xFactor - the amount to scale X coordinates
        yFactor - the amount to scale Y coordinates
      • translateCoords

        public void translateCoords​(double xFactor,
                                    double yFactor)
        translate this shapes coordinates by the x and y factors
        Parameters:
        xFactor - the amount to translate X coordinates
        yFactor - the amount to translate Y coordinates
      • rotateCoords

        public void rotateCoords​(double angleDEG)
        rotate this LayoutTrack's coordinates by angleDEG's
        Parameters:
        angleDEG - the amount to rotate in degrees
      • dispose

        void dispose()
        Clean up when this object is no longer needed. Should not be called while the object is still displayed; see remove()
      • remove

        void remove()
        Removes this object from display and persistence
      • draw

        protected void draw​(java.awt.Graphics2D g2)
      • drawEditControls

        protected void drawEditControls​(java.awt.Graphics2D g2)