org.eesgmbh.gimv.shared.util
Class Bounds

java.lang.Object
  extended by org.eesgmbh.gimv.shared.util.Bounds
All Implemented Interfaces:
IsSerializable

public class Bounds
extends Object
implements IsSerializable

An immutable support class for working with left, right, top and bottom bounds.


Constructor Summary
Bounds()
           
Bounds(Double left, Double right, Double top, Double bottom)
          Constructor that takes Double values.
Bounds(Integer left, Integer right, Integer top, Integer bottom)
          Constructor that takes Integer values.
Bounds(Long left, Long right, Long top, Long bottom)
          Constructor that takes Long values.
 
Method Summary
 boolean contains(double x, double y)
           
 boolean containsHorizontally(double... values)
           
 boolean containsVertically(double... values)
           
 boolean equals(Object obj)
           
 Point findAbsolutePoint(Point relPoint)
          Determines the point in absolute coordinates based upon the passed in point which represents fraction values.
static Bounds from(Bounds bounds)
          Returns a new instance of Bounds with the same attributes as the passed bounds object.
 Double getAbsHeight()
           
 Double getAbsWidth()
           
 Double getBottom()
           
 Double getHeight()
           
 Double getHorizontalCenter()
           
 Double getLeft()
           
 Double getRight()
           
 Double getTop()
           
 Double getVerticalCenter()
           
 Double getWidth()
           
 int hashCode()
           
 boolean isBottomDefined()
           
 boolean isHorizontalBoundsDefined()
           
 boolean isLeftDefined()
           
 boolean isRightDefined()
           
 boolean isTopDefined()
           
 boolean isVerticalBoundsDefined()
           
 Bounds normalizeBounds()
          Replaces left and right and top and bottom, so that left <= right and top <= bottom.
 Bounds setBottom(Double bottom)
          Returns a new Bounds object, whose bounds are the same except bottom, which is set to new value.
 Bounds setBottom(Integer bottom)
           
 Bounds setBottom(Long bottom)
           
 Bounds setLeft(Double left)
          Returns a new Bounds object, whose bounds are the same except left, which is set to new value.
 Bounds setLeft(Integer left)
           
 Bounds setLeft(Long left)
           
 Bounds setRight(Double right)
          Returns a new Bounds object, whose bounds are the same except right, which is set to new value.
 Bounds setRight(Integer right)
           
 Bounds setRight(Long right)
           
 Bounds setTop(Double top)
          Returns a new Bounds object, whose bounds are the same except top, which is set to new value.
 Bounds setTop(Integer top)
           
 Bounds setTop(Long top)
           
 Bounds shiftAbsolute(double horizontal, double vertical)
           
 Bounds shiftBottom(double amount)
           
 Bounds shiftBottomProportionally(double proportion)
           
 Bounds shiftLeft(double amount)
           
 Bounds shiftLeftProportionally(double proportion)
           
 Bounds shiftProportional(double horizontal, double vertical)
           
 Bounds shiftRight(double amount)
           
 Bounds shiftRightProportionally(double proportion)
           
 Bounds shiftTop(double amount)
           
 Bounds shiftTopProportionally(double proportion)
           
 String toString()
           
 Bounds transform(Bounds reference, Bounds target)
          Converts the bounds proportionally from one range into another.
 Bounds transformProportional(Bounds transBounds)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bounds

public Bounds()

Bounds

public Bounds(Double left,
              Double right,
              Double top,
              Double bottom)
Constructor that takes Double values.

Parameters:
left - The left bound
right - The right bound
top - The top bound
bottom - The bottom bound

Bounds

public Bounds(Integer left,
              Integer right,
              Integer top,
              Integer bottom)
Constructor that takes Integer values.

Parameters:
left - The left bound
right - The right bound
top - The top bound
bottom - The bottom bound

Bounds

public Bounds(Long left,
              Long right,
              Long top,
              Long bottom)
Constructor that takes Long values.

Parameters:
left - The left bound
right - The right bound
top - The top bound
bottom - The bottom bound
Method Detail

contains

public boolean contains(double x,
                        double y)

containsHorizontally

public boolean containsHorizontally(double... values)
Parameters:
values -
Returns:
true if the values are within left and right or left and right is undefined, false otherwise

containsVertically

public boolean containsVertically(double... values)
Parameters:
values -
Returns:
true if the values are within top and bottom or top and bottom is undefined, false otherwise

isLeftDefined

public boolean isLeftDefined()

isRightDefined

public boolean isRightDefined()

isTopDefined

public boolean isTopDefined()

isBottomDefined

public boolean isBottomDefined()

isHorizontalBoundsDefined

public boolean isHorizontalBoundsDefined()

isVerticalBoundsDefined

public boolean isVerticalBoundsDefined()

getHorizontalCenter

public Double getHorizontalCenter()

getVerticalCenter

public Double getVerticalCenter()

shiftProportional

public Bounds shiftProportional(double horizontal,
                                double vertical)

shiftLeft

public Bounds shiftLeft(double amount)

shiftRight

public Bounds shiftRight(double amount)

shiftTop

public Bounds shiftTop(double amount)

shiftBottom

public Bounds shiftBottom(double amount)

shiftLeftProportionally

public Bounds shiftLeftProportionally(double proportion)

shiftRightProportionally

public Bounds shiftRightProportionally(double proportion)

shiftTopProportionally

public Bounds shiftTopProportionally(double proportion)

shiftBottomProportionally

public Bounds shiftBottomProportionally(double proportion)

shiftAbsolute

public Bounds shiftAbsolute(double horizontal,
                            double vertical)

transformProportional

public Bounds transformProportional(Bounds transBounds)

normalizeBounds

public Bounds normalizeBounds()
Replaces left and right and top and bottom, so that left <= right and top <= bottom.

Returns:
A new normalized Bounds object.

transform

public Bounds transform(Bounds reference,
                        Bounds target)
Converts the bounds proportionally from one range into another.

Example:

Parameters:
reference - The minima and maxima of the range this bound is currently related to.
target - The minima and maxima of the range this bound is going to be converted to.
Returns:
Converted bounds to targetRange.

findAbsolutePoint

public Point findAbsolutePoint(Point relPoint)
Determines the point in absolute coordinates based upon the passed in point which represents fraction values.

Parameters:
relPoint -
Returns:
Absolute Point or null if either horizontal or vertical bounds is undefind

getLeft

public Double getLeft()

getRight

public Double getRight()

getTop

public Double getTop()

getBottom

public Double getBottom()

getWidth

public Double getWidth()

getAbsWidth

public Double getAbsWidth()

getHeight

public Double getHeight()

getAbsHeight

public Double getAbsHeight()

setLeft

public Bounds setLeft(Double left)
Returns a new Bounds object, whose bounds are the same except left, which is set to new value.

Parameters:
left -
Returns:
a new bounds object

setLeft

public Bounds setLeft(Long left)

setLeft

public Bounds setLeft(Integer left)

setRight

public Bounds setRight(Double right)
Returns a new Bounds object, whose bounds are the same except right, which is set to new value.

Parameters:
right -
Returns:
a new bounds object

setRight

public Bounds setRight(Long right)

setRight

public Bounds setRight(Integer right)

setTop

public Bounds setTop(Double top)
Returns a new Bounds object, whose bounds are the same except top, which is set to new value.

Parameters:
top -
Returns:
a new bounds object

setTop

public Bounds setTop(Long top)

setTop

public Bounds setTop(Integer top)

setBottom

public Bounds setBottom(Double bottom)
Returns a new Bounds object, whose bounds are the same except bottom, which is set to new value.

Parameters:
bottom -
Returns:
a new bounds object

setBottom

public Bounds setBottom(Long bottom)

setBottom

public Bounds setBottom(Integer bottom)

from

public static Bounds from(Bounds bounds)
Returns a new instance of Bounds with the same attributes as the passed bounds object.

Parameters:
bounds - Bounds to be copied
Returns:
new instance of Bounds with copied values from bounds

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010 - EES GmbH