edu.neu.ccs.util
Class DimensionUtilities

java.lang.Object
  extended byedu.neu.ccs.util.DimensionUtilities

public class DimensionUtilities
extends Object

Provides utilities for manipulating Dimension objects.

Since:
1.0
Version:
2.2

Constructor Summary
DimensionUtilities()
           
 
Method Summary
static Dimension createDimension(Dimension d)
          Returns a new Dimension object with the width and height of the given Dimension; if the given width or height is less than zero, it is set to zero.
static Dimension createDimension(int width, int height)
          Returns a new Dimension object with the given width and height; if the given width or height is less than zero, it is set to zero.
static Dimension createMaximumDimension()
          Returns a new Dimension object with the maximum possible width and height.
static Dimension createMinimumDimension()
          Returns a new Dimension object with zero width and height.
static Dimension expand(Dimension d, Insets insets)
          Returns a new Dimension object whose width and height are equal to the corresponding values in the given Dimension object, expanded to include the given Insets.
static Dimension max(Dimension d1, Dimension d2)
          Returns a new Dimension object whose width and height are set to the maximum corresponding values in the given Dimension objects.
static Dimension min(Dimension d1, Dimension d2)
          Returns a new Dimension object whose width and height are set to the minimum corresponding values in the given Dimension objects.
static Dimension shrink(Dimension d, Insets insets)
          Returns a new Dimension object whose width and height are equal to the corresponding values in the given Dimension object, shrinked to exclude the given Insets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DimensionUtilities

public DimensionUtilities()
Method Detail

createDimension

public static Dimension createDimension(int width,
                                        int height)
Returns a new Dimension object with the given width and height; if the given width or height is less than zero, it is set to zero.

Parameters:
width - the width for the new Dimension
height - the height for the new Dimension
See Also:
createDimension(Dimension)

createDimension

public static Dimension createDimension(Dimension d)
Returns a new Dimension object with the width and height of the given Dimension; if the given width or height is less than zero, it is set to zero.

Parameters:
d - the Dimension to be copied
Throws:
NullPointerException - if the given Dimension is null
See Also:
createDimension(int, int)

createMinimumDimension

public static Dimension createMinimumDimension()
Returns a new Dimension object with zero width and height.

See Also:
createMinimumDimension()

createMaximumDimension

public static Dimension createMaximumDimension()
Returns a new Dimension object with the maximum possible width and height.

See Also:
createMaximumDimension()

min

public static Dimension min(Dimension d1,
                            Dimension d2)
Returns a new Dimension object whose width and height are set to the minimum corresponding values in the given Dimension objects.

Parameters:
d1 - one of two Dimension objects
d2 - the other of the two Dimension objects
Throws:
NullPointerException - if either of the given Dimension objects is null
See Also:
max(Dimension, Dimension)

max

public static Dimension max(Dimension d1,
                            Dimension d2)
Returns a new Dimension object whose width and height are set to the maximum corresponding values in the given Dimension objects.

Parameters:
d1 - one of two Dimension objects
d2 - the other of the two Dimension objects
Throws:
NullPointerException - if either of the given Dimension objects is null
See Also:
min(Dimension, Dimension)

expand

public static Dimension expand(Dimension d,
                               Insets insets)
Returns a new Dimension object whose width and height are equal to the corresponding values in the given Dimension object, expanded to include the given Insets. If the given Insets are negative with respect to either the x or y direction, the given Dimension is neither expanded nor shrinked in that direction.

Parameters:
d - the Dimension to be copied and expanded
insets - the Insets to be considered
Throws:
NullPointerException - if either the given Dimension object or the given Insets object is null
See Also:
shrink(Dimension, Insets)

shrink

public static Dimension shrink(Dimension d,
                               Insets insets)
Returns a new Dimension object whose width and height are equal to the corresponding values in the given Dimension object, shrinked to exclude the given Insets. If the given Insets are negative with respect to either the x or y direction, the given Dimension is neither expanded nor shrinked in that direction.

Parameters:
d - the Dimension to be copied and shrinked
insets - the Insets to be considered
Throws:
NullPointerException - if either the given Dimension object or the given Insets object is null
See Also:
expand(Dimension, Insets)