Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Draw2d
3.3

org.eclipse.draw2d.geometry
Class PrecisionRectangle

java.lang.Object
  extended by

org.eclipse.draw2d.geometry.Rectangle
      extended by
org.eclipse.draw2d.geometry.PrecisionRectangle
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, Translatable

public final class PrecisionRectangle
extends Rectangle

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:
Serialized Form

Field Summary
 double preciseHeight
          Double value for height
 double preciseWidth
          Double value for width
 double preciseX
          Double value for X
 double preciseY
          Double value for Y
 
Fields inherited from class org.eclipse.draw2d.geometry. Rectangle
height, SINGLETON, width, x, y
 
Constructor Summary
PrecisionRectangle ()
          Constructs a new PrecisionRectangle with all values 0.
PrecisionRectangle ( Rectangle rect)
          Constructs a new PrecisionRectangle from the given integer Rectangle.
 
Method Summary
 boolean contains ( Point p)
          Returns whether the given point is within the boundaries of this Rectangle.
  Rectangle crop ( Insets insets)
          Crops this rectangle by the amount specified in insets.
 boolean equals (java.lang.Object o)
          Returns whether the input object is equal to this Rectangle or not.
  Rectangle 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.
  Point getCenter ()
          Returns the precise geometric centre of the rectangle
  Rectangle getCopy ()
          Returns a new Rectangle which has the exact same parameters as this Rectangle.
  PrecisionRectangle getPreciseCopy ()
          Returns a precise copy of this.
 void performScale (double factor)
          Scales this object by the scale factor.
 void performTranslate (int dx, int dy)
          Translates this object horizontally by dx and vertically by dy.
 double preciseBottom ()
          Returns the bottom coordinte in double precision.
 double preciseHeight ()
          Returns double height
 double preciseRight ()
          Returns the right side in double precision.
 double preciseWidth ()
          Returns double width
 double preciseX ()
          Returns double x coordinate
 double preciseY ()
          Returns double y coordinate
  Rectangle resize ( Dimension sizeDelta)
          Resizes this Rectangle by the Dimension provided as input and returns this for convenience.
 void setHeight (double value)
          Sets the height.
  Rectangle setLocation ( Point loc)
          Sets the location of this Rectangle to the point given as input and returns this for convenience.
  Rectangle setSize ( Dimension d)
          Sets the width and height of this Rectangle to the width and height of the given Dimension and returns this for convenience.
 void setWidth (double value)
          Sets the width.
 void setX (double value)
          Sets the x value.
 void setY (double value)
          Sets the y value.
  Rectangle 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.
  Rectangle 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.
  Rectangle translate ( Point p)
          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.
  Rectangle transpose ()
          Switches the x and y values, as well as the width and height of this Rectangle.
 void union ( Point p)
          Updates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the given Point.
  PrecisionRectangle union ( PrecisionRectangle other)
          Deprecated. Use union(Rectangle) instead
  Rectangle union ( Rectangle other)
          Updates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the given Rectangle.
 void updateInts ()
          Updates the integer values based on the current precise values.
 
Methods inherited from class org.eclipse.draw2d.geometry. Rectangle
bottom, contains, contains, expand, expand, getBottom, getBottomLeft, getBottomRight, getCropped, getExpanded, getExpanded, getIntersection, getLeft, getLocation, getPosition, getResized, getResized, getRight, getSize, getTop, getTopLeft, getTopRight, getTranslated, getTranslated, getTransposed, getUnion, hashCode, intersect, intersects, isEmpty, resize, right, scale, scale, setBounds, setLocation, setSize, toString, touches, translate, union, union, union
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

preciseHeight

public double preciseHeight
Double value for height


preciseWidth

public double preciseWidth
Double value for width


preciseX

public double preciseX
Double value for X


preciseY

public double preciseY
Double value for Y

Constructor Detail

PrecisionRectangle

public PrecisionRectangle()
Constructs a new PrecisionRectangle with all values 0.


PrecisionRectangle

public PrecisionRectangle(
Rectangle rect)
Constructs a new PrecisionRectangle from the given integer Rectangle.

Parameters:
rect - the base rectangle
Method Detail

getCopy

public 
Rectangle getCopy()
Description copied from class: Rectangle
Returns a new Rectangle which has the exact same parameters as this Rectangle.

Overrides:
getCopy in class Rectangle
Returns:
Copy of this Rectangle
See Also:
Rectangle.getCopy()

getPreciseCopy

public 
PrecisionRectangle getPreciseCopy()
Returns a precise copy of this.

Returns:
a precise copy

crop

public 
Rectangle crop(
Insets insets)
Description copied from class: Rectangle
Crops this rectangle by the amount specified in insets.

Overrides:
crop in class Rectangle
Parameters:
insets - Insets to be removed from the Rectangle
Returns:
this for convenience
See Also:
Rectangle.crop(org.eclipse.draw2d.geometry.Insets)

equals

public boolean equals(java.lang.Object o)
Description copied from class: Rectangle
Returns 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.

Overrides:
equals in class Rectangle
Parameters:
o - Object being tested for equality
Returns:
Returns the result of the equality test
See Also:
Rectangle.equals(Object)

performScale

public void performScale(double factor)
Description copied from interface: Translatable
Scales this object by the scale factor.

Specified by:
performScale in interface Translatable
Overrides:
performScale in class Rectangle
See Also:
Rectangle.performScale(double)

performTranslate

public void performTranslate(int dx,
                             int dy)
Description copied from interface: Translatable
Translates this object horizontally by dx and vertically by dy.

Specified by:
performTranslate in interface Translatable
Overrides:
performTranslate in class Rectangle
See Also:
Rectangle.performTranslate(int, int)

preciseBottom

public double preciseBottom()
Returns the bottom coordinte in double precision.

Returns:
the precise bottom

preciseRight

public double preciseRight()
Returns the right side in double precision.

Returns:
the precise right

resize

public 
Rectangle resize(
Dimension sizeDelta)
Description copied from class: Rectangle
Resizes 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.

Overrides:
resize in class Rectangle
Parameters:
sizeDelta - Resize data as a Dimension
Returns:
this for convenience
See Also:
Rectangle.resize(org.eclipse.draw2d.geometry.Dimension)

setHeight

public void setHeight(double value)
Sets the height.

Parameters:
value - the new height

setWidth

public void setWidth(double value)
Sets the width.

Parameters:
value - the new width

setX

public void setX(double value)
Sets the x value.

Parameters:
value - the new x value

setY

public void setY(double value)
Sets the y value.

Parameters:
value - the new y value

translate

public 
Rectangle translate(
Point p)
Description copied from class: Rectangle
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.

Overrides:
translate in class Rectangle
Parameters:
p - Point which provides translation information
Returns:
this for convenience
See Also:
Rectangle.translate(org.eclipse.draw2d.geometry.Point)

union

public 
PrecisionRectangle union(
PrecisionRectangle other)
Deprecated. Use union(Rectangle) instead

Unions the given PrecisionRectangle with this rectangle and returns this for convenience.

Parameters:
other - the rectangle being unioned
Returns:
this for convenience
Since:
3.0

union

public 
Rectangle union(
Rectangle other)
Description copied from class: Rectangle
Updates this Rectangle's dimensions to the minimum size which can hold both this Rectangle and the given Rectangle.

Overrides:
union in class Rectangle
Parameters:
other - Rectangle to be unioned with this Rectangle
Returns:
this for convenience
See Also:
Rectangle.union(org.eclipse.draw2d.geometry.Rectangle)

updateInts

public void updateInts()
Updates the integer values based on the current precise values. The integer values ar the floor of the double values. This is called automatically when calling api which is overridden in this class.

Since:
3.0

union

public void union(
Point p)
Description copied from class: Rectangle
Updates this Rectangle's bounds to the minimum size which can hold both this Rectangle and the given Point.

Overrides:
union in class Rectangle
Parameters:
p - Point to be unioned with this Rectangle
See Also:
Rectangle.union(org.eclipse.draw2d.geometry.Point)

transpose

public 
Rectangle transpose()
Description copied from class: Rectangle
Switches the x and y values, as well as the width and height of this Rectangle. Useful for orientation changes.

Overrides:
transpose in class Rectangle
Returns:
this for convenience
See Also:
Rectangle.transpose()

setLocation

public 
Rectangle setLocation(
Point loc)
Description copied from class: Rectangle
Sets the location of this Rectangle to the point given as input and returns this for convenience.

Overrides:
setLocation in class Rectangle
Parameters:
loc - New position of this Rectangle
Returns:
this for convenience
See Also:
Rectangle.setLocation(org.eclipse.draw2d.geometry.Point)

getCenter

public 
Point getCenter()
Returns the precise geometric centre of the rectangle

Overrides:
getCenter in class Rectangle
Returns:
PrecisionPoint geometric center of the rectangle
Since:
3.4

shrink

public 
Rectangle 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. The center of this Rectangle is kept constant.

Parameters:
h - Horizontal reduction amount
v - Vertical reduction amount
Returns:
this for convenience
Since:
3.4

expand

public 
Rectangle 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. The location of its center is kept constant.

Parameters:
h - Horizontal increment
v - Vertical increment
Returns:
this for convenience
Since:
3.4

shrink

public 
Rectangle shrink(int h,
                        int v)
Description copied from class: Rectangle
Shrinks 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.

Overrides:
shrink in class Rectangle
Parameters:
h - Horizontal reduction amount
v - Vertical reduction amount
Returns:
this for convenience
See Also:
Rectangle.shrink(int, int)

contains

public boolean contains(
Point p)
Description copied from class: Rectangle
Returns 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.

Overrides:
contains in class Rectangle
Parameters:
p - Point being tested for containment
Returns:
true if the Point is within this Rectangle
See Also:
Rectangle.contains(org.eclipse.draw2d.geometry.Point)

preciseX

public double preciseX()
Description copied from class: Rectangle
Returns double x coordinate

Overrides:
preciseX in class Rectangle
Returns:
double x coordinate
See Also:
Rectangle.preciseX()

preciseY

public double preciseY()
Description copied from class: Rectangle
Returns double y coordinate

Overrides:
preciseY in class Rectangle
Returns:
double y coordinate
See Also:
Rectangle.preciseY()

preciseWidth

public double preciseWidth()
Description copied from class: Rectangle
Returns double width

Overrides:
preciseWidth in class Rectangle
Returns:
double width
See Also:
Rectangle.preciseWidth()

preciseHeight

public double preciseHeight()
Description copied from class: Rectangle
Returns double height

Overrides:
preciseHeight in class Rectangle
Returns:
double height
See Also:
Rectangle.preciseHeight()

setSize

public 
Rectangle setSize(
Dimension d)
Description copied from class: Rectangle
Sets the width and height of this Rectangle to the width and height of the given Dimension and returns this for convenience.

Overrides:
setSize in class Rectangle
Parameters:
d - The new Dimension
Returns:
this for convenience
See Also:
Rectangle.setSize(org.eclipse.draw2d.geometry.Dimension)

Eclipse Draw2d
3.3

Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire