1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// $Id: DimensionUtilities.java,v 1.1 2004/11/03 18:30:04 bobtarling Exp $
/*
* DimensionUtilities.java
*
* Created on 15 July 2002, 22:08
*/
package org.tigris.swidgets;
import java.awt.*;
/**
* A collection of utility methods for Dimensions.
*
* @author Eugenio Alvarez
* @stereotype utility
*/
public class DimensionUtilities {
/**
* Create a new <code>Dimension</code> from an existing
* <code>Dimension</code> with its width and height increased by
* the width and height of another <code>Dimension</code>.
*
* @param original The <code>Dimension</code> to be added to.
* @param add The <code>Dimension</code> whose length and
* breadth are to be taken as the added values.
* @return The resulting <code>Dimension</code>.
*/
public static Dimension add(Dimension original, Dimension add) {
return new Dimension((int) (original.getWidth() + add.getWidth()),
(int) (original.getHeight() + add.getHeight()));
}
/**
* Create a new <code>Dimension</code> from an existing
* <code>Dimension</code> with its width and height increased by
* the width and height of an <code>Insets</code> object.
*
* @param original The <code>Dimension</code> to be added to.
* @param add The <code>Insets</code> object whose width and
* height are to be taken as the added values.
* @return The resulting <code>Dimension</code>.
*/
public static Dimension add(Dimension original, Insets add) {
return new Dimension((int) original.getWidth() + add.right + add.left,
(int) original.getHeight() + add.top + add.bottom);
}
}
|