Class JDFXYPair

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, RandomAccess, JDFBaseDataTypes

public class JDFXYPair extends JDFNumList
This class represents a x y pair (JDFXYPair). It is a whitespace separated list of 2 numbers.
See Also:
  • Constructor Details

    • JDFXYPair

      public JDFXYPair()
      constructs a xy pair with all values set to 0.0 Double
    • JDFXYPair

      @Deprecated public JDFXYPair(Vector v) throws DataFormatException
      Deprecated.
      use typesafe constructors
      constructs a xy pair with all values set via a Vector of Double objects
      Parameters:
      v - Vector of Double
      Throws:
      DataFormatException - - if the Vector has not a valid format
    • JDFXYPair

      public JDFXYPair(String s) throws DataFormatException
      constructs a xy pair with all values set via a String if a single numerical value is specified, s is padded with " 0"
      Parameters:
      s - the given String
      Throws:
      DataFormatException - - if the String has not a valid format
    • JDFXYPair

      public JDFXYPair(JDFNumList nl) throws DataFormatException
      constructs a xy pair with all values set via a JDFNumberList
      Parameters:
      nl - the given number list
      Throws:
      DataFormatException - - if the JDFNumberList has not a valid format
    • JDFXYPair

      public JDFXYPair(JDFShape shape)
      constructs a xy pair with all values set via a JDFNumberList
      Parameters:
      shape - the given number list
    • JDFXYPair

      public JDFXYPair(JDFXYPair nl)
      constructs a xy pair with all values set via a JDFNumberList
      Parameters:
      nl - the given number list
    • JDFXYPair

      public JDFXYPair(double x, double y)
      constructs a new JDFXYPair with the given double values
      Parameters:
      x - the x coordinate
      y - the y coordinate
    • JDFXYPair

      public JDFXYPair(int x, int y)
      constructs a new JDFXYPair with the given double values
      Parameters:
      x - the x coordinate
      y - the y coordinate
  • Method Details

    • createXYPair

      public static JDFXYPair createXYPair(String s)
      factory for JDFXYPair that silently returns null in case of illegal strings
      Parameters:
      s - the string to parse
      Returns:
      the JDFXYPair, null if s is not compatible
    • isValid

      public boolean isValid() throws DataFormatException
      isValid - valid if the size of the vector is 2 and all instances are Double types
      Specified by:
      isValid in class JDFNumList
      Returns:
      boolean - true if all instances are Double or Integer types
      Throws:
      DataFormatException - - if the Vector has not a valid format
    • getX

      public double getX()
      getX - returns the x coordinate
      Returns:
      double - the x coordinate
    • getPoint2D

      public Point2D getPoint2D()
      Returns:
    • setX

      public void setX(double x)
      setX - sets the x coordinate
      Parameters:
      x - the x coordinate
    • getY

      public double getY()
      getY - returns the y coordinate
      Returns:
      double - the y coordinate
    • swapXY

      public void swapXY()
      swap x and y coordinates -
    • setY

      public void setY(double y)
      setY - sets the y coordinate
      Parameters:
      y - the y coordinate
    • isGreaterOrEqual

      public boolean isGreaterOrEqual(JDFXYPair x)
      isGreaterOrEqual - equality operator >=
      Parameters:
      x - the JDFXYPair object to compare to
      Returns:
      boolean - true if this >= x
    • isLessOrEqual

      public boolean isLessOrEqual(JDFXYPair x)
      isLessOrEqual - equality operator <=
      Parameters:
      x - the JDFXYPair object to compare to
      Returns:
      boolean - true if this <= x
    • isGreater

      public boolean isGreater(JDFXYPair x)
      isGreater - equality operator >
      Parameters:
      x - the JDFXYPair object to compare to
      Returns:
      boolean - true if this > x
    • isPortrait

      public boolean isPortrait()
      return true if y is > x
      Returns:
    • isLess

      public boolean isLess(JDFXYPair x)
      isLess - equality operator <
      Parameters:
      x - the JDFXYPair object to compare to
      Returns:
      boolean - true if this < x
    • setString

      public JDFXYPair setString(String string) throws DataFormatException
      setString with some heuristics to allow for a single numerical or values like "i/j"
      Overrides:
      setString in class JDFNumList
      Throws:
      DataFormatException
      See Also:
    • shift

      public JDFXYPair shift(double x, double y)
      Parameters:
      x -
      y -
      Returns:
    • shift

      public JDFXYPair shift(JDFXYPair xy)
      Parameters:
      xy -
      Returns:
    • clone

      public JDFXYPair clone()
      Overrides:
      clone in class JDFNumList
      See Also: