Package adams.core.base
Class BaseRectangle
- java.lang.Object
-
- adams.core.base.BaseObject
-
- adams.core.base.AbstractBaseString
-
- adams.core.base.BaseRectangle
-
- All Implemented Interfaces:
CloneHandler<BaseObject>
,Serializable
,Comparable
public class BaseRectangle extends AbstractBaseString
Wrapper for a rectangle object to be editable in the GOE.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.core.base.BaseObject
m_Internal, m_Properties, SUFFIX_DISPLAY, SUFFIX_VALUE
-
-
Constructor Summary
Constructors Constructor Description BaseRectangle()
Initializes the string with "0 0 1 1".BaseRectangle(double x, double y, double w, double h)
Initializes the object with the string to parse.BaseRectangle(double x, double y, double w_or_x, double h_or_y, boolean isXY)
Initializes the object with the string to parse.BaseRectangle(int x, int y, int w, int h)
Initializes the object with the string to parse.BaseRectangle(int x, int y, int w_or_x, int h_or_y, boolean isXY)
Initializes the object with the string to parse.BaseRectangle(Rectangle location)
Initializes the object with the location to use.BaseRectangle(String s)
Initializes the object with the string to parse.BaseRectangle(String s, boolean isXYXY)
Initializes the object with the string to parse.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Point2D
centerValue()
Returns the center of the quadrilateral.double[]
doubleValue()
Returns the location as array (x, y, w, h).static String
fromXYXY(String x0y0x1y1)
Parses the string in XY format and returns it in xywh format.String
getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).int[]
intValue()
Returns the location as array (x, y, w, h).boolean
isValid(String value)
Checks whether the string value is a valid presentation for this class.static boolean
isValidFormat(String value)
Checks whether the string value is a valid presentation for this class.Rectangle
rectangleValue()
Returns the quadrilateral location.String
xyValue()
Returns the rectangle in 'x0 y0 x1 y1' format.-
Methods inherited from class adams.core.base.AbstractBaseString
convert, getValue, initialize, isEmpty, length, setValue, stringValue
-
Methods inherited from class adams.core.base.BaseObject
compareTo, equals, getClone, getInternal, getTemplates, getUnicode, hasFavoritesSupport, hashCode, isValidUnicode, newInstance, setUnicode, toObjectArray, toObjectArray, toString, toStringArray, toStringList
-
-
-
-
Constructor Detail
-
BaseRectangle
public BaseRectangle()
Initializes the string with "0 0 1 1".
-
BaseRectangle
public BaseRectangle(String s)
Initializes the object with the string to parse.- Parameters:
s
- the string to parse
-
BaseRectangle
public BaseRectangle(String s, boolean isXYXY)
Initializes the object with the string to parse.- Parameters:
s
- the string to parseisXYXY
- whether in format 'x0 y0 x1 y1' (true) or 'x y w h' (false)
-
BaseRectangle
public BaseRectangle(Rectangle location)
Initializes the object with the location to use.- Parameters:
location
- the location to use
-
BaseRectangle
public BaseRectangle(int x, int y, int w, int h)
Initializes the object with the string to parse.- Parameters:
x
- the x of the top-left cornery
- the y of the top-left cornerw
- the widthh
- the height
-
BaseRectangle
public BaseRectangle(int x, int y, int w_or_x, int h_or_y, boolean isXY)
Initializes the object with the string to parse.- Parameters:
x
- the x of the top-left cornery
- the y of the top-left cornerw_or_x
- the width or x of bottom-right cornerh_or_y
- the height or y of bottom-right cornerisXY
- whether in format 'x0 y0 x1 y1' (true) or 'x y w h' (false)
-
BaseRectangle
public BaseRectangle(double x, double y, double w, double h)
Initializes the object with the string to parse.- Parameters:
x
- the x of the top-left cornery
- the y of the top-left cornerw
- the widthh
- the height
-
BaseRectangle
public BaseRectangle(double x, double y, double w_or_x, double h_or_y, boolean isXY)
Initializes the object with the string to parse.- Parameters:
x
- the x of the top-left cornery
- the y of the top-left cornerw_or_x
- the width or x of bottom-right cornerh_or_y
- the height or y of bottom-right cornerisXY
- whether in format 'x0 y0 x1 y1' (true) or 'x y w h' (false)
-
-
Method Detail
-
isValid
public boolean isValid(String value)
Checks whether the string value is a valid presentation for this class.- Overrides:
isValid
in classAbstractBaseString
- Parameters:
value
- the string value to check- Returns:
- true if non-null
-
doubleValue
public double[] doubleValue()
Returns the location as array (x, y, w, h).- Returns:
- the location array
-
intValue
public int[] intValue()
Returns the location as array (x, y, w, h).- Returns:
- the location array
-
rectangleValue
public Rectangle rectangleValue()
Returns the quadrilateral location.- Returns:
- the quadrilateral
-
xyValue
public String xyValue()
Returns the rectangle in 'x0 y0 x1 y1' format.- Returns:
- the string value
-
centerValue
public Point2D centerValue()
Returns the center of the quadrilateral.- Returns:
- the center
-
getTipText
public String getTipText()
Returns a tool tip for the GUI editor (ignored if null is returned).- Specified by:
getTipText
in classAbstractBaseString
- Returns:
- the tool tip
-
isValidFormat
public static boolean isValidFormat(String value)
Checks whether the string value is a valid presentation for this class.- Parameters:
value
- the string value to check- Returns:
- true if non-null
-
fromXYXY
public static String fromXYXY(String x0y0x1y1)
Parses the string in XY format and returns it in xywh format. Assumes there are 4 numbers present.- Parameters:
x0y0x1y1
- the string to parse- Returns:
- the converted string
- See Also:
isValidFormat(String)
-
-