Package org.cip4.jdflib.datatypes
Class JDFRectangle
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<java.lang.Object>
-
- org.cip4.jdflib.datatypes.JDFNumList
-
- org.cip4.jdflib.datatypes.JDFRectangle
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<java.lang.Object>,java.util.Collection<java.lang.Object>,java.util.List<java.lang.Object>,java.util.RandomAccess,JDFBaseDataTypes
public class JDFRectangle extends JDFNumList
This class represents a rectangle JDFRectangle) consisting of a lower left x value (llx), a lower left y value (lly), an upper right x value (urx) and an upper right y value (ury) all values are Double types.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.cip4.jdflib.datatypes.JDFNumList
JDFNumList.NormComparator, JDFNumList.VolumeComparator
-
Nested classes/interfaces inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
JDFBaseDataTypes.EnumFitsValue
-
-
Field Summary
-
Fields inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
EPSILON, MAX_CMYK_COLOR, MAX_LAB_COLOR, MAX_MATRIX_DIMENSION, MAX_RECTANGLE_DIMENSION, MAX_RGB_COLOR, MAX_SHAPE_DIMENSION, MAX_XY_DIMENSION
-
-
Constructor Summary
Constructors Constructor Description JDFRectangle()constructs a rectangle with all 4 values set to 0.0 DoubleJDFRectangle(double llx, double lly, double urx, double ury)constructs a new JDFRectangle with the given double valuesJDFRectangle(java.lang.String s)constructs a rectangle with all values set via a StringJDFRectangle(java.util.Vector v)Deprecated.use typesafe constructorsJDFRectangle(JDFNumList nl)constructs a rectangle with all values set via a JDFNumberListJDFRectangle(JDFRectangle rec)constructs a rectangle with all values set via a JDFRectangleJDFRectangle(JDFXYPair size)constructs a rectangle with all values set via a JDFRectangleJDFRectangle(JDFXYPair ll, JDFXYPair ur)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JDFRectangleclone()static JDFRectanglecreateRectangle(java.lang.String s)factory for JDFRectangle that silently returns null in case of illegal stringsdoublegetArea()JDFRectanglegetBoundingRect(JDFRectangle r)get the common (intersected area) of this with rJDFXYPairgetCenter()doublegetHeight()getHeight - returns the height of the rectangle, the difference between upper right y value and lower left y value as an absolute valueJDFRectanglegetInterSection(JDFRectangle r)get the common (intersected area) of this with rJDFXYPairgetLL()doublegetLlx()getLlx - returns the lower left x coordinatedoublegetLly()getLly - returns the lower left y coordinateJDFXYPairgetSize()JDFXYPairgetUR()doublegetUrx()getUrx - returns the upper right x coordinatedoublegetUry()getUry - returns the upper right y coordinatedoublegetWidth()getWidth - returns the width of the rectangle, the difference between upper right x value and lower left x value as an absolute valuebooleanisGreater(JDFRectangle r)isGreater - equality operator >booleanisGreaterOrEqual(JDFRectangle r)isGreaterOrEqual - equality operator >=booleanisInside(JDFXYPair p)isInside - true it the point is inside thisbooleanisLess(JDFRectangle r)isLess - equality operator <booleanisLessOrEqual(JDFRectangle r)isLessOrEqual - equality operator <=booleanisValid()isValid - true if the size of the vector is 4 and all instances are Double typesJDFRectanglenormalize()ensures the right points e.g after a rotationJDFRectanglescale(JDFXYPair scaleFactor)JDFRectanglesetCenter(JDFXYPair c)voidsetLlx(double x)setLlx - sets the lower left x coordinatevoidsetLlxMm(double mmX)setLlXMm - sets the lower left x coordinate in millimetervoidsetLly(double y)setLly - sets the lower left y coordinatevoidsetLlyMm(double mmY)setLlyMm - sets the lower left y coordinate in millimetervoidsetUrx(double x)setUrx - sets the upper right x coordinatevoidsetUrxMm(double mmX)setUrxMm - sets the upper right x coordinate in millimetervoidsetUry(double y)setUry - sets the upper right y coordinatevoidsetUryMm(double mmY)setUryMm - sets the upper right y coordinate in millimetervoidshift(double tx, double ty)shifts this by the amount specifiedvoidshift(JDFXYPair shift)shifts this by the amount specified-
Methods inherited from class org.cip4.jdflib.datatypes.JDFNumList
abs, contains, containsAll, copyNumList, doubleAt, elementAt, equals, getDouble, getDoubleList, getDoubleVector, getIntArray, getString, getString, hashCode, intAt, isValidString, matches, max, min, norm, removeElementAt, replaceElementAt, scale, scale, scaleFromCM, scaleFromCM, scaleFromMM, scaleFromMM, scaleToCM, scaleToCM, scaleToMM, scaleToMM, set, setString, setX, shift, sort, subtract, toString, unify, volume
-
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elements, ensureCapacity, firstElement, forEach, get, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeIf, removeRange, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Constructor Detail
-
JDFRectangle
public JDFRectangle()
constructs a rectangle with all 4 values set to 0.0 Double
-
JDFRectangle
@Deprecated public JDFRectangle(java.util.Vector v) throws java.util.zip.DataFormatExceptionDeprecated.use typesafe constructorsconstructs a rectangle with all values set via a Vector of Double objects- Parameters:
v- the given Vector with MAX_RECTANGLE_DIMENSION objects of type Double- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
JDFRectangle
public JDFRectangle(java.lang.String s) throws java.util.zip.DataFormatExceptionconstructs a rectangle with all values set via a String- Parameters:
s- the given String, blank separated numbers- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
JDFRectangle
public JDFRectangle(JDFRectangle rec)
constructs a rectangle with all values set via a JDFRectangle- Parameters:
rec- the given rectangle
-
JDFRectangle
public JDFRectangle(JDFXYPair size)
constructs a rectangle with all values set via a JDFRectangle- Parameters:
rec- the given rectangle
-
JDFRectangle
public JDFRectangle(JDFNumList nl) throws java.util.zip.DataFormatException
constructs a rectangle with all values set via a JDFNumberList- Parameters:
nl- the given number list- Throws:
java.util.zip.DataFormatException- - if the JDFNumberList has not a valid format
-
JDFRectangle
public JDFRectangle(double llx, double lly, double urx, double ury)constructs a new JDFRectangle with the given double values- Parameters:
llx- lower left x coordinatelly- lower left y coordinateurx- lower left x coordinateury- lower left y coordinate
-
-
Method Detail
-
clone
public JDFRectangle clone()
- Overrides:
clonein classJDFNumList- See Also:
JDFNumList.clone()
-
createRectangle
public static JDFRectangle createRectangle(java.lang.String s)
factory for JDFRectangle that silently returns null in case of illegal strings- Parameters:
s- the string to parse- Returns:
- the JDFRectangle, null if s is not compatible
-
isValid
public boolean isValid() throws java.util.zip.DataFormatExceptionisValid - true if the size of the vector is 4 and all instances are Double types- Specified by:
isValidin classJDFNumList- Returns:
- boolean - true if all instances are Double or Integer types
- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
getLlx
public double getLlx()
getLlx - returns the lower left x coordinate- Returns:
- double - the lower left x coordinate
-
setLlx
public void setLlx(double x)
setLlx - sets the lower left x coordinate- Parameters:
x- the lower left x coordinate
-
setLlxMm
public void setLlxMm(double mmX)
setLlXMm - sets the lower left x coordinate in millimeter- Parameters:
mmX- the lower left x coordinate in millimeter
-
getLly
public double getLly()
getLly - returns the lower left y coordinate- Returns:
- double - the lower left y coordinate
-
setLly
public void setLly(double y)
setLly - sets the lower left y coordinate- Parameters:
y- the lower left y coordinate
-
setLlyMm
public void setLlyMm(double mmY)
setLlyMm - sets the lower left y coordinate in millimeter- Parameters:
mmY- the lower left y coordinate in millimeter
-
getUrx
public double getUrx()
getUrx - returns the upper right x coordinate- Returns:
- double - the upper right x coordinate
-
setUrx
public void setUrx(double x)
setUrx - sets the upper right x coordinate- Parameters:
x- the upper right x coordinate
-
setUrxMm
public void setUrxMm(double mmX)
setUrxMm - sets the upper right x coordinate in millimeter- Parameters:
mmX- the upper right x coordinate in millimeter
-
getUry
public double getUry()
getUry - returns the upper right y coordinate- Returns:
- double - the upper right y coordinate
-
setUry
public void setUry(double y)
setUry - sets the upper right y coordinate- Parameters:
y- the upper right y coordinate
-
setUryMm
public void setUryMm(double mmY)
setUryMm - sets the upper right y coordinate in millimeter- Parameters:
mmY- the upper right y coordinate in millimeter
-
getWidth
public double getWidth()
getWidth - returns the width of the rectangle, the difference between upper right x value and lower left x value as an absolute value- Returns:
- double - the width of the rectangle
-
getHeight
public double getHeight()
getHeight - returns the height of the rectangle, the difference between upper right y value and lower left y value as an absolute value- Returns:
- double - the height of the rectangle
-
isGreater
public boolean isGreater(JDFRectangle r)
isGreater - equality operator >- Parameters:
r- the JDFRectangle object to compare to- Returns:
- boolean - true if
this > r
-
getInterSection
public JDFRectangle getInterSection(JDFRectangle r)
get the common (intersected area) of this with r- Parameters:
r- the new rect, null if r=null- Returns:
-
getBoundingRect
public JDFRectangle getBoundingRect(JDFRectangle r)
get the common (intersected area) of this with r- Parameters:
r- the new rect, null if r=null- Returns:
-
shift
public void shift(double tx, double ty)shifts this by the amount specified- Parameters:
tx- shift in x directionty- shift in y direction
-
normalize
public JDFRectangle normalize()
ensures the right points e.g after a rotation
-
getCenter
public JDFXYPair getCenter()
- Returns:
-
setCenter
public JDFRectangle setCenter(JDFXYPair c)
- Parameters:
c-- Returns:
-
scale
public JDFRectangle scale(JDFXYPair scaleFactor)
- Parameters:
scaleFactor-- Returns:
-
shift
public void shift(JDFXYPair shift)
shifts this by the amount specified- Parameters:
shift- in x and y direction
-
isGreaterOrEqual
public boolean isGreaterOrEqual(JDFRectangle r)
isGreaterOrEqual - equality operator >=- Parameters:
r- the JDFRectangle object to compare to- Returns:
- boolean - true if
this >= r
-
isInside
public boolean isInside(JDFXYPair p)
isInside - true it the point is inside this- Parameters:
p- the pount to check- Returns:
- boolean - true if
this < r
-
isLess
public boolean isLess(JDFRectangle r)
isLess - equality operator <- Parameters:
r- the JDFRectangle object to compare to- Returns:
- boolean - true if
this < r
-
isLessOrEqual
public boolean isLessOrEqual(JDFRectangle r)
isLessOrEqual - equality operator <=- Parameters:
r- the JDFRectangle object to compare to- Returns:
- boolean - true if
this <= r
-
getLL
public JDFXYPair getLL()
- Returns:
- the lower left pout
-
getUR
public JDFXYPair getUR()
- Returns:
- the upper right point
-
getSize
public JDFXYPair getSize()
- Returns:
- the width and height
-
getArea
public double getArea()
- Returns:
- the area
-
-