Package adams.core.base
Class LabeledRectangle
- java.lang.Object
-
- adams.core.base.BaseObject
-
- adams.core.base.AbstractBaseString
-
- adams.core.base.LabeledRectangle
-
- All Implemented Interfaces:
CloneHandler<BaseObject>
,Serializable
,Comparable
public class LabeledRectangle extends AbstractBaseString
Wrapper for a rectangle object (with a label) 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 LabeledRectangle()
Initializes the string with "0 0 1 1 object".LabeledRectangle(double x, double y, double w_or_x, double h_or_y, boolean isXY, String label)
Initializes the object with the string to parse.LabeledRectangle(double x, double y, double w, double h, String label)
Initializes the object with the string to parse.LabeledRectangle(int x, int y, int w_or_x, int h_or_y, boolean isXY, String label)
Initializes the object with the string to parse.LabeledRectangle(int x, int y, int w, int h, String label)
Initializes the object with the string to parse.LabeledRectangle(Rectangle location, String label)
Initializes the object with the location to use.LabeledRectangle(String s)
Initializes the object with the string to parse.LabeledRectangle(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.String
labelValue()
Returns the label, if possible.Rectangle
rectangleValue()
Returns the quadrilateral location.String
xyValue()
Returns the rectangle in 'x0 y0 x1 y1 label' 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
-
LabeledRectangle
public LabeledRectangle()
Initializes the string with "0 0 1 1 object".
-
LabeledRectangle
public LabeledRectangle(String s)
Initializes the object with the string to parse.- Parameters:
s
- the string to parse
-
LabeledRectangle
public LabeledRectangle(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 label' (true) or 'x y w h label' (false)
-
LabeledRectangle
public LabeledRectangle(Rectangle location, String label)
Initializes the object with the location to use.- Parameters:
location
- the location to uselabel
- the label
-
LabeledRectangle
public LabeledRectangle(int x, int y, int w, int h, String label)
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 heightlabel
- the label
-
LabeledRectangle
public LabeledRectangle(int x, int y, int w_or_x, int h_or_y, boolean isXY, String label)
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)
-
LabeledRectangle
public LabeledRectangle(double x, double y, double w, double h, String label)
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 heightlabel
- the label
-
LabeledRectangle
public LabeledRectangle(double x, double y, double w_or_x, double h_or_y, boolean isXY, String label)
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)label
- the label
-
-
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
-
labelValue
public String labelValue()
Returns the label, if possible.- Returns:
- the label or empty string if not present
-
xyValue
public String xyValue()
Returns the rectangle in 'x0 y0 x1 y1 label' 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 and a label present.- Parameters:
x0y0x1y1
- the string to parse- Returns:
- the converted string
- See Also:
isValidFormat(String)
-
-