Package org.eclipse.draw2d.geometry
Class PrecisionRectangle
java.lang.Object
org.eclipse.draw2d.geometry.Rectangle
org.eclipse.draw2d.geometry.PrecisionRectangle
- All Implemented Interfaces:
- Serializable,- Cloneable,- Translatable
A Rectangle implementation using floating point values which are truncated
 into the inherited integer fields. The use of floating point prevents
 rounding errors from accumulating.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptiondoubleDeprecated, for removal: This API element is subject to removal in a future version.doubleDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseWidth(double)andpreciseWidth()instead.doubleDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseX(double)andpreciseX()instead.doubleDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseX(double)andpreciseY()instead.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a new PrecisionRectangle with all values 0.PrecisionRectangle(double x, double y, double width, double height) Constructs a PrecisionRectangle with the provided values.PrecisionRectangle(Point p, Dimension d) Constructs a new PrecisionRectangle from a given Point and a DimensionPrecisionRectangle(Rectangle rect) Constructs a new PrecisionRectangle from the given integer Rectangle.
- 
Method SummaryModifier and TypeMethodDescriptionbooleancontains(double x, double y) Returns whether the given coordinates are within the boundaries of this Rectangle.booleancontains(int x, int y) Returns whether the given coordinates are within the boundaries of this Rectangle.booleanReturns whether the given point is within the boundaries of this Rectangle.booleanReturnstrueif the given rectangle is contained within the boundaries of this Rectangle.booleanReturns whether the input object is equal to this Rectangle or not.expand(double h, double v) Expands the horizontal and vertical sides of this Rectangle with the values provided as input, and returns this for convenience.expand(int h, int v) Expands the horizontal and vertical sides of this Rectangle with the values provided as input, and returns this for convenience.Expands the horizontal and vertical sides of this Rectangle by the width and height of the given Insets, and returns this for convenience.Returns a new Point representing the middle point of the bottom side of this Rectangle.Returns a new Point representing the bottom left point of this Rectangle.Returns a new Point representing the bottom right point of this Rectangle.Returns a new point representing the center of this Rectangle.getCopy()Returns a new Rectangle which has the exact same parameters as this Rectangle.Returns a precise copy of this.getTop()Returns a new Point which represents the middle point of the top side of this Rectangle.Returns a new Point which represents the top left hand corner of this Rectangle.Returns a new Point which represents the top right hand corner of this Rectangle.Sets the size of this Rectangle to the intersection region with the Rectangle supplied as input, and returns this for convenience.voidperformScale(double factor) Scales this object by the scale factor.voidperformTranslate(int dx, int dy) Translates this object horizontally bydxand vertically bydy.doubleReturns the bottom coordinte in double precision.doubleReturnsdoubleheightdoubleReturns the right side in double precision.doubleReturnsdoublewidthdoublepreciseX()Returnsdoublex coordinatedoublepreciseY()Returnsdoubley coordinateresize(double w, double h) Resizes this Rectangle by the values supplied as input and returns this for convenience.resize(int w, int h) Resizes this Rectangle by the values supplied as input and returns this for convenience.Resizes this Rectangle by the Dimension provided as input and returns this for convenience.setBounds(int x, int y, int width, int height) Sets the x, y, width, and height values of this Rectangle to the provided values.Sets the location and size of this rectangle to the provided ones.Sets the parameters of this Rectangle from the Rectangle passed in and returns this for convenience.voidsetHeight(double value) Deprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseHeight(double)instead.setHeight(int height) Sets the height of this Rectangle to the specified one.setLocation(int x, int y) Sets the location of this Rectangle to the coordinates given as input and returns this for convenience.setLocation(Point loc) Sets the location of this Rectangle to the point given as input and returns this for convenience.setPreciseBounds(double x, double y, double width, double height) Sets the preciseX, preciseY, preciseWidth, and preciseHeight values of this PrecisionRectangle to the provided values and updates the integer values of x, y, width, and height accordingly.setPreciseHeight(double value) Sets the height of this PrecisionRectangle to the specified value.setPreciseLocation(double x, double y) Sets the preciseX and preciseY values of this PrecisionRectangle to the provided values and updates the integer values of x and y accordingly.Sets the precise location of this PrecisionRectanglesetPreciseSize(double w, double h) Sets the preciseWidth and preciseHeight values of this PrecisionRectangle to the provided values and updates the integer values of width and height accordingly.Set the size of this PrecisionRectangle to the given dimension's width and height.setPreciseWidth(double value) Sets the width of this PrecisionRectangle to the specified one.setPreciseX(double value) Sets the x value.setPreciseY(double value) Sets the y value.setSize(int w, int h) Sets the width of this Rectangle to w and the height of this Rectangle to h and returns this for convenience.Sets the width and height of this Rectangle to the width and height of the given Dimension and returns this for convenience.voidsetWidth(double value) Deprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseWidth(double)instead.setWidth(int width) Sets the width of this Rectangle to the specified one.voidsetX(double value) Deprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseX(double)instead.setX(int value) Sets the x value of the Rectangle and returns this for convenience.voidsetY(double value) Deprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseX(double)instead.setY(int value) Sets the y value of the Rectangle and returns this for convenience.shrink(double h, double v) Shrinks the sides of this Rectangle by the horizontal and vertical values provided as input, and returns this Rectangle for convenience.shrink(int h, int v) Shrinks the sides of this Rectangle by the horizontal and vertical values provided as input, and returns this Rectangle for convenience.Shrinks this rectangle by the amount specified ininsets.booleanReturnstrueif the input Rectangle touches this Rectangle.translate(double dx, double dy) Moves this Rectangle horizontally by dx and vertically by dy, then returns this Rectangle for convenience.translate(int dx, int dy) Moves this Rectangle horizontally by dx and vertically by dy, then returns this Rectangle for convenience.Moves this Rectangle horizontally by the x value of the given Point and vertically by the y value of the given Point, then returns this Rectangle for convenience.Switches the x and y values, as well as the width and height of this Rectangle.union(double x, double y) Updates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the coordinate (x,y).union(double x, double y, double w, double h) Updates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the rectangle (x, y, w, h).union(int x, int y) Updates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the coordinate (x,y).union(int x, int y, int w, int h) Updates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the rectangle (x, y, w, h).voidUpdates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the given Point.union(PrecisionRectangle rect) Deprecated, for removal: This API element is subject to removal in a future version.Useunion(Rectangle)insteadUpdates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the given Rectangle.voidDeprecated, for removal: This API element is subject to removal in a future version.This method should not be accessed by clients any more (it will be made private in future releases).Methods inherited from class org.eclipse.draw2d.geometry.Rectanglebottom, crop, equals, getCropped, getExpanded, getExpanded, getExpanded, getHorizontalInterval, getIntersection, getLeft, getLocation, getPosition, getResized, getResized, getResized, getRight, getShrinked, getShrinked, getShrinked, getSize, getTranslated, getTranslated, getTranslated, getTransposed, getUnion, getUnion, getVerticalInterval, hashCode, height, intersects, isEmpty, left, right, scale, scale, setBottom, setRight, shrinkLeft, shrinkTop, top, toString, union, width, x, yMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.draw2d.geometry.TranslatableperformTranslate, performTranslate, performTranslate
- 
Field Details- 
preciseHeightDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseHeight(double)andpreciseHeight()instead. This field will become private in the future.Double value for height- @noreference
- This field is not intended to be referenced by clients.
 
- 
preciseWidthDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseWidth(double)andpreciseWidth()instead. This field will become private in the future.Double value for width- @noreference
- This field is not intended to be referenced by clients.
 
- 
preciseXDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseX(double)andpreciseX()instead. This field will become private in the future.Double value for X- @noreference
- This field is not intended to be referenced by clients.
 
- 
preciseYDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseX(double)andpreciseY()instead. This field will become private in the future.Double value for Y- @noreference
- This field is not intended to be referenced by clients.
 
 
- 
- 
Constructor Details- 
PrecisionRectanglepublic PrecisionRectangle()Constructs a new PrecisionRectangle with all values 0.
- 
PrecisionRectanglepublic PrecisionRectangle(double x, double y, double width, double height) Constructs a PrecisionRectangle with the provided values.- Parameters:
- x- X location
- y- Y location
- width- Width of the rectangle
- height- Height of the rectangle
- Since:
- 3.7
 
- 
PrecisionRectangleConstructs a new PrecisionRectangle from a given Point and a Dimension- Parameters:
- p- The Point to specify x and y location of the PrecisionRectangle
- d- The Dimension to use for width and height of the PrecisionRectangle
- Since:
- 3.7
 
- 
PrecisionRectangleConstructs a new PrecisionRectangle from the given integer Rectangle.- Parameters:
- rect- the base rectangle
 
 
- 
- 
Method Details- 
containspublic boolean contains(double x, double y) Description copied from class:RectangleReturns whether the given coordinates are within the boundaries of this Rectangle. The boundaries are inclusive of the top and left edges, but exclusive of the bottom and right edges.
- 
containspublic boolean contains(int x, int y) Description copied from class:RectangleReturns whether the given coordinates are within the boundaries of this Rectangle. The boundaries are inclusive of the top and left edges, but exclusive of the bottom and right edges.
- 
containsDescription copied from class:RectangleReturns whether the given point is within the boundaries of this Rectangle. The boundaries are inclusive of the top and left edges, but exclusive of the bottom and right edges.
- 
containsDescription copied from class:RectangleReturnstrueif the given rectangle is contained within the boundaries of this Rectangle.
- 
equalsDescription copied from class:RectangleReturns whether the input object is equal to this Rectangle or not. Rectangles are equivalent if their x, y, height, and width values are the same.
- 
expandExpands the horizontal and vertical sides of this Rectangle with the values provided as input, and returns this for convenience. The location of its center is kept constant.
- 
expandDescription copied from class:RectangleExpands the horizontal and vertical sides of this Rectangle by the width and height of the given Insets, and returns this for convenience.
- 
expandDescription copied from class:RectangleExpands the horizontal and vertical sides of this Rectangle with the values provided as input, and returns this for convenience. The location of its center is kept constant.
- 
getBottomDescription copied from class:RectangleReturns a new Point representing the middle point of the bottom side of this Rectangle.
- 
getBottomLeftDescription copied from class:RectangleReturns a new Point representing the bottom left point of this Rectangle.- Overrides:
- getBottomLeftin class- Rectangle
- Returns:
- Point at the bottom left of the rectangle
- See Also:
 
- 
getBottomRightDescription copied from class:RectangleReturns a new Point representing the bottom right point of this Rectangle.- Overrides:
- getBottomRightin class- Rectangle
- Returns:
- Point at the bottom right of the rectangle
- See Also:
 
- 
getCenterDescription copied from class:RectangleReturns a new point representing the center of this Rectangle.
- 
getCopyDescription copied from class:RectangleReturns a new Rectangle which has the exact same parameters as this Rectangle.
- 
getPreciseCopyReturns a precise copy of this.- Returns:
- a precise copy
 
- 
getTopDescription copied from class:RectangleReturns a new Point which represents the middle point of the top side of this Rectangle.
- 
getTopLeftDescription copied from class:RectangleReturns a new Point which represents the top left hand corner of this Rectangle.- Overrides:
- getTopLeftin class- Rectangle
- Returns:
- Point at the top left of the rectangle
- See Also:
 
- 
getTopRightDescription copied from class:RectangleReturns a new Point which represents the top right hand corner of this Rectangle.- Overrides:
- getTopRightin class- Rectangle
- Returns:
- Point at the top right of the rectangle
- See Also:
 
- 
intersectDescription copied from class:RectangleSets the size of this Rectangle to the intersection region with the Rectangle supplied as input, and returns this for convenience. The location and dimensions are set to zero if there is no intersection with the input Rectangle.
- 
performScalepublic void performScale(double factor) Description copied from interface:TranslatableScales this object by the scale factor.- Specified by:
- performScalein interface- Translatable
- Overrides:
- performScalein class- Rectangle
- Parameters:
- factor- The scale factor
- See Also:
 
- 
performTranslatepublic void performTranslate(int dx, int dy) Description copied from interface:TranslatableTranslates this object horizontally bydxand vertically bydy.- Specified by:
- performTranslatein interface- Translatable
- Overrides:
- performTranslatein class- Rectangle
- Parameters:
- dx- The amount to translate horizontally
- dy- The amount to translate vertically
- See Also:
 
- 
preciseBottompublic double preciseBottom()Returns the bottom coordinte in double precision.- Returns:
- the precise bottom
 
- 
preciseHeightpublic double preciseHeight()Description copied from class:RectangleReturnsdoubleheight- Overrides:
- preciseHeightin class- Rectangle
- Returns:
- doubleheight
- See Also:
 
- 
preciseRightpublic double preciseRight()Returns the right side in double precision.- Returns:
- the precise right
 
- 
preciseWidthpublic double preciseWidth()Description copied from class:RectangleReturnsdoublewidth- Overrides:
- preciseWidthin class- Rectangle
- Returns:
- doublewidth
- See Also:
 
- 
preciseXpublic double preciseX()Description copied from class:RectangleReturnsdoublex coordinate
- 
preciseYpublic double preciseY()Description copied from class:RectangleReturnsdoubley coordinate
- 
resizeDescription copied from class:RectangleResizes this Rectangle by the Dimension provided as input and returns this for convenience. This Rectange's width will become this.width + sizeDelta.width. Likewise for height.
- 
resizeDescription copied from class:RectangleResizes this Rectangle by the values supplied as input and returns this for convenience. This Rectangle's width will become this.width + dw. This Rectangle's height will become this.height + dh.
- 
resizeDescription copied from class:RectangleResizes this Rectangle by the values supplied as input and returns this for convenience. This Rectangle's width will become this.width + dw. This Rectangle's height will become this.height + dh.
- 
setBoundsDescription copied from class:RectangleSets the x, y, width, and height values of this Rectangle to the provided values.
- 
setBoundsDescription copied from class:RectangleSets the location and size of this rectangle to the provided ones.
- 
setBoundsDescription copied from class:RectangleSets the parameters of this Rectangle from the Rectangle passed in and returns this for convenience.
- 
setHeightDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseHeight(double)instead.Sets the height.- Parameters:
- value- the new height
- @noreference
- This method is not intended to be referenced by clients.
 
- 
setHeightDescription copied from class:RectangleSets the height of this Rectangle to the specified one.
- 
setLocationDescription copied from class:RectangleSets the location of this Rectangle to the coordinates given as input and returns this for convenience.- Overrides:
- setLocationin class- Rectangle
- Parameters:
- x- The new X coordinate
- y- The new Y coordinate
- Returns:
- thisfor convenience
- See Also:
 
- 
setLocationDescription copied from class:RectangleSets the location of this Rectangle to the point given as input and returns this for convenience.- Overrides:
- setLocationin class- Rectangle
- Parameters:
- loc- New position of this Rectangle
- Returns:
- thisfor convenience
- See Also:
 
- 
setPreciseBoundsSets the preciseX, preciseY, preciseWidth, and preciseHeight values of this PrecisionRectangle to the provided values and updates the integer values of x, y, width, and height accordingly.- Parameters:
- x- The new x
- y- The new y
- width- The new width
- height- The new height
- Returns:
- this for convenience
- Since:
- 3.7
 
- 
setPreciseHeightSets the height of this PrecisionRectangle to the specified value.- Parameters:
- value- The new height.
- Returns:
- this for convenience
- Since:
- 3.7
 
- 
setPreciseLocationSets the preciseX and preciseY values of this PrecisionRectangle to the provided values and updates the integer values of x and y accordingly.- Parameters:
- x- The new x value
- y- The new y value
- Returns:
- this for convenience
- Since:
- 3.7
 
- 
setPreciseLocationSets the precise location of this PrecisionRectangle- Parameters:
- loc- The new location
- Returns:
- this for convenience.
- Since:
- 3.7
 
- 
setPreciseSizeSets the preciseWidth and preciseHeight values of this PrecisionRectangle to the provided values and updates the integer values of width and height accordingly.- Parameters:
- w- The new width
- h- The new height
- Returns:
- this for convenience.
- Since:
- 3.7
 
- 
setPreciseSizeSet the size of this PrecisionRectangle to the given dimension's width and height. Returns this for convenience.- Parameters:
- size- The new size
- Returns:
- this for convenience.
- Since:
- 3.7
 
- 
setPreciseWidthSets the width of this PrecisionRectangle to the specified one.- Parameters:
- value- The new width
- Returns:
- this for convenience
- Since:
- 3.7
 
- 
setPreciseXSets the x value.- Parameters:
- value- The new x value
- Returns:
- this for convenience
- Since:
- 3.7
 
- 
setPreciseYSets the y value.- Parameters:
- value- the new y value
- Returns:
- this for convenience
- Since:
- 3.7
 
- 
setSizeDescription copied from class:RectangleSets the width and height of this Rectangle to the width and height of the given Dimension and returns this for convenience.
- 
setSizeDescription copied from class:RectangleSets the width of this Rectangle to w and the height of this Rectangle to h and returns this for convenience.
- 
setWidthDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseWidth(double)instead.Sets the width.- Parameters:
- value- the new width
- @noreference
- This method is not intended to be referenced by clients.
 
- 
setWidthDescription copied from class:RectangleSets the width of this Rectangle to the specified one.
- 
setXDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseX(double)instead.Sets the x value.- Parameters:
- value- the new x value
- @noreference
- This method is not intended to be referenced by clients.
 
- 
setXDescription copied from class:RectangleSets the x value of the Rectangle and returns this for convenience.
- 
setYDeprecated, for removal: This API element is subject to removal in a future version.UsesetPreciseX(double)instead.Sets the y value.- Parameters:
- value- the new y value
- @noreference
- This method is not intended to be referenced by clients.
 
- 
setYDescription copied from class:RectangleSets the y value of the Rectangle and returns this for convenience.
- 
shrinkShrinks the sides of this Rectangle by the horizontal and vertical values provided as input, and returns this Rectangle for convenience. The center of this Rectangle is kept constant.
- 
shrinkDescription copied from class:RectangleShrinks this rectangle by the amount specified ininsets.
- 
shrinkDescription copied from class:RectangleShrinks the sides of this Rectangle by the horizontal and vertical values provided as input, and returns this Rectangle for convenience. If the given reduction amount of larger than the currentRectangle.width()orRectangle.height()of the rectangle,0is used instead. The center of this Rectangle is kept constant.
- 
touchesDescription copied from class:RectangleReturnstrueif the input Rectangle touches this Rectangle.
- 
translateDescription copied from class:RectangleMoves this Rectangle horizontally by dx and vertically by dy, then returns this Rectangle for convenience.
- 
translateDescription copied from class:RectangleMoves this Rectangle horizontally by dx and vertically by dy, then returns this Rectangle for convenience.
- 
translateDescription copied from class:RectangleMoves this Rectangle horizontally by the x value of the given Point and vertically by the y value of the given Point, then returns this Rectangle for convenience.
- 
transposeDescription copied from class:RectangleSwitches the x and y values, as well as the width and height of this Rectangle. Useful for orientation changes.
- 
unionDescription copied from class:RectangleUpdates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the coordinate (x,y).
- 
unionDescription copied from class:RectangleUpdates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the rectangle (x, y, w, h).
- 
unionDescription copied from class:RectangleUpdates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the coordinate (x,y).
- 
unionDescription copied from class:RectangleUpdates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the rectangle (x, y, w, h).
- 
unionDescription copied from class:RectangleUpdates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the given Point.
- 
unionDeprecated, for removal: This API element is subject to removal in a future version.Useunion(Rectangle)insteadUnions the given PrecisionRectangle with this rectangle and returnsthisfor convenience.- Parameters:
- rect- the rectangle being unioned
- Returns:
- thisfor convenience
- Since:
- 3.0
- @noreference
- This method is not intended to be referenced by clients.
 
- 
unionDescription copied from class:RectangleUpdates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the given Rectangle.
- 
updateIntsDeprecated, for removal: This API element is subject to removal in a future version.This method should not be accessed by clients any more (it will be made private in future releases). The update of integer and precision fields is performed automatically ifpreciseX,preciseY,preciseWidth, andpreciseHeightfield values are not manipulated directly, but only via respective methods offered by this class.Updates the integer values based on the current precise values.- Since:
- 3.0
- @noreference
- This method is not intended to be referenced by clients.
 
 
- 
setPreciseHeight(double)andpreciseHeight()instead.