Class MRectangle

All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
MBracket, MEllipse, MRoundedRectangle, MTextBox

@PublicApi public class MRectangle extends MPolyline
Rectangle object.
Since:
Marvin 3.3, 10/17/2003
See Also:
  • Field Details

    • T_NOROT

      public static final int T_NOROT
      Disable rotation.
      Since:
      Marvin 4.1, 01/23/2006
      See Also:
    • P_NW

      public static final int P_NW
      Top-left corner index.
      Since:
      Marvin 4.1, 01/23/2006
      See Also:
    • P_NE

      public static final int P_NE
      Top-right corner index.
      Since:
      Marvin 4.1, 01/23/2006
      See Also:
    • P_SE

      public static final int P_SE
      Botton-right corner index.
      Since:
      Marvin 4.1, 01/23/2006
      See Also:
    • P_SW

      public static final int P_SW
      Bottom-left corner index.
      Since:
      Marvin 4.1, 01/23/2006
      See Also:
    • P_CENTER

      public static final int P_CENTER
      Central point ID.
      Since:
      Marvin 4.1, 01/23/2006
      See Also:
    • P_N

      public static final int P_N
      Middle point on top edge.
      Since:
      Marvin 4.1, 01/25/2006
      See Also:
    • P_E

      public static final int P_E
      Middle point on right edge.
      Since:
      Marvin 4.1, 01/25/2006
      See Also:
    • P_S

      public static final int P_S
      Middle point on bottom edge.
      Since:
      Marvin 4.1, 01/25/2006
      See Also:
    • P_W

      public static final int P_W
      Middle point on left edge.
      Since:
      Marvin 4.1, 01/25/2006
      See Also:
  • Constructor Details

    • MRectangle

      public MRectangle()
      Constructs a rectangle.
    • MRectangle

      public MRectangle(MPoint p1, MPoint p2)
      Constructs a rectangle with the specified corner points.
      Parameters:
      p1 - the top left corner
      p2 - the bottom right corner
      Since:
      Marvin 4.1, 03/07/2006
    • MRectangle

      public MRectangle(MPoint p1, MPoint p2, Color c, Color bg)
      Constructs a rectangle with the specified corner points.
      Parameters:
      p1 - the top left corner
      p2 - the bottom right corner
      c - the color
      bg - the background color
    • MRectangle

      protected MRectangle(MRectangle r)
      Copy constructor.
      Parameters:
      r - the original rectangle
  • Method Details

    • calcCenter

      public void calcCenter(DPoint3 p, CTransform3D t)
      Calculates the geometrical center.
      Overrides:
      calcCenter in class MPolyline
      Parameters:
      p - store the coordinates here
      t - the transformation matrix or null
      Since:
      Marvin 4.1, 04/28/2006
    • transform

      public void transform(CTransform3D t, int opts, CTransform3D trot)
      Transforms the rectangle.
      Overrides:
      transform in class MPolyline
      Parameters:
      t - the transformation matrix
      opts - transform options or 0
      trot - the viewing transformation or null
      Since:
      Marvin 4.1, 04/28/2006
      See Also:
    • transformTo2D

      public void transformTo2D()
      Rotate to the XY plane.
      Since:
      Marvin 4.1, 01/27/2006
    • convertTransform

      public CTransform3D convertTransform(CTransform3D t, boolean paint)
    • addAttributeKeys

      public void addAttributeKeys(List<String> l)
      Adds the attribute names to the specified list. CDATA attributes are not added.
      Overrides:
      addAttributeKeys in class MPolyline
      Parameters:
      l - the list
    • getAttribute

      public String getAttribute(String s)
      Gets the value of an attribute.
      Supported attributes:
      • transformOption: NOROT (only scaling transformations are allowed)
      • centralPoint: NE (north-east corner), NW, (north-west corner), SW (south-west corner), SE (south-east corner) or CENTER (geometrical center)
      Overrides:
      getAttribute in class MPolyline
      Parameters:
      s - the attribute name
      Returns:
      the value or null
    • setAttribute

      public void setAttribute(String s, String v)
      Sets the value of an attribute.
      Supported attributes:
      • transformOption: NOROT (only scaling transformations are allowed)
      • centralPoint: NE (north-east corner), NW, (north-west corner), SW (south-west corner), SE (south-east corner) or CENTER (geometrical center)
      Overrides:
      setAttribute in class MPolyline
      Parameters:
      s - the attribute name
      v - the attribute value
    • distanceFrom

      public double distanceFrom(double x, double y, CTransform3D t)
      Gets the 2D distance from the specified point.
      Overrides:
      distanceFrom in class MPolyline
      Parameters:
      x - the x coordinate
      y - the y coordinate
      t - transformation or null
      Since:
      4.1, 01/25/2006
    • setCorners

      public void setCorners(MPoint p1, MPoint p2)
      Sets the corners.
      Parameters:
      p1 - the top left corner
      p2 - the bottom right corner
    • getTOption

      public int getTOption()
      Gets the transformation options.
      Returns:
      the options
      Since:
      Marvin 4.1, 01/23/2006
    • setTOption

      public void setTOption(int opts)
      Sets the transformation options.
      Parameters:
      opts - the options
      Since:
      Marvin 4.1, 01/23/2006
      See Also:
    • getTCenter

      public int getTCenter()
      Gets the transformed point.
      Returns:
      the transformed point index (if it is a corner point) or ID
      Since:
      Marvin 4.1, 01/23/2006
    • setTCenter

      public void setTCenter(int t)
      Sets the transformed point.
      Parameters:
      t - the transformed point (if it is a corner point) or ID
      Since:
      Marvin 4.1, 01/23/2006
      See Also:
    • clone

      public MRectangle clone()
      Description copied from class: MObject
      Creates a clone.
      Overrides:
      clone in class MPolyline
      Returns:
      the clone
    • removeChild

      public void removeChild(MObject o)
      Description copied from class: MObject
      Removes a child object.
      Overrides:
      removeChild in class MPolyline
      Parameters:
      o - the child
    • getPointRefCount

      public int getPointRefCount()
      Gets the number of internal selectable point references.
      Overrides:
      getPointRefCount in class MPolyline
      Returns:
      8
    • getPointRef

      public MPoint getPointRef(int i, CTransform3D trot)
      Gets an internal selectable point of the rectangle.
      Overrides:
      getPointRef in class MPolyline
      Parameters:
      i - the point index
      trot - the viewing transformation or null
      Returns:
      the point's reference
    • fixRectanglePointClones

      public static void fixRectanglePointClones(MObject[] objarr0, MObject[] objarr)
      Fixes the parents of the cloned MRectanglePoints.
      Parameters:
      objarr0 - the original object array
      objarr - the cloned object array
      Since:
      Marvin 4.1, 03/06/2006
    • fixClonedPoints

      public void fixClonedPoints(MObject[] objarr0, MObject[] objarr, int i)
      Description copied from class: MObject
      Sets the parent object for this object. Should only be called by the copy constructor.
      Overrides:
      fixClonedPoints in class MPolyline
      Parameters:
      objarr0 - the new object list
      objarr - the old object list
      i - the corresponding index from the old object list
    • getClip

      public final Shape getClip(CTransform3D t)
      Gets the clipping rectangle.
      Parameters:
      t - the transformation matrix
      Returns:
      the clipping rectangle