Class LabeledRectangle

    • 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 parse
        isXYXY - 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 use
        label - 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 corner
        y - the y of the top-left corner
        w - the width
        h - the height
        label - 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 corner
        y - the y of the top-left corner
        w_or_x - the width or x of bottom-right corner
        h_or_y - the height or y of bottom-right corner
        isXY - 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 corner
        y - the y of the top-left corner
        w - the width
        h - the height
        label - 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 corner
        y - the y of the top-left corner
        w_or_x - the width or x of bottom-right corner
        h_or_y - the height or y of bottom-right corner
        isXY - 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 class AbstractBaseString
        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 class AbstractBaseString
        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)