FileDocCategorySizeDatePackage
Dimension.javaAPI DocAndroid 1.5 API5472Wed May 06 22:41:54 BST 2009java.awt

Dimension

public class Dimension extends Dimension2D implements Serializable
The Dimension represents the size (width and height) of a component. The width and height values can be negative, but in that case the behavior of some methods is unexpected.
since
Android 1.0

Fields Summary
private static final long
serialVersionUID
The Constant serialVersionUID.
public int
width
The width dimension.
public int
height
The height dimension.
Constructors Summary
public Dimension(Dimension d)
Instantiates a new Dimension with the same data as the specified Dimension.

param
d the Dimension to copy the data from when creating the new Dimension object.


                                                           
       
        this(d.width, d.height);
    
public Dimension()
Instantiates a new Dimension with zero width and height.

        this(0, 0);
    
public Dimension(int width, int height)
Instantiates a new Dimension with the specified width and height.

param
width the width of the new Dimension.
param
height the height of the new Dimension.

        setSize(width, height);
    
Methods Summary
public booleanequals(java.lang.Object obj)
Compares this Dimension object with the specified object.

param
obj the Object to be compared.
return
true, if the specified Object is a Dimension with the same width and height data as this Dimension.

        if (obj == this) {
            return true;
        }
        if (obj instanceof Dimension) {
            Dimension d = (Dimension)obj;
            return (d.width == width && d.height == height);
        }
        return false;
    
public doublegetHeight()
Gets the height of the Dimension.

return
the height of the Dimension.
see
java.awt.geom.Dimension2D#getHeight()

        return height;
    
public java.awt.DimensiongetSize()
Gets the size of the Dimension.

return
the size of the Dimension.

        return new Dimension(width, height);
    
public doublegetWidth()
Gets the width of the Dimension.

return
the width of the Dimension.
see
java.awt.geom.Dimension2D#getWidth()

        return width;
    
public inthashCode()
Returns the hash code of the Dimension.

return
the hash code of the Dimension.

        HashCode hash = new HashCode();
        hash.append(width);
        hash.append(height);
        return hash.hashCode();
    
public voidsetSize(int width, int height)
Sets the size of this Dimension object with the specified width and height.

param
width the width of the Dimension.
param
height the height of the Dimension.

        this.width = width;
        this.height = height;
    
public voidsetSize(java.awt.Dimension d)
Sets the size of this Dimension object by copying the data from the specified Dimension object.

param
d the Dimension that gives the new size values.

        setSize(d.width, d.height);
    
public voidsetSize(double width, double height)
Sets the size of this Dimension object with the specified double width and height.

param
width the width of the Dimension.
param
height the height of the Dimension.
see
java.awt.geom.Dimension2D#setSize(double, double)

        setSize((int)Math.ceil(width), (int)Math.ceil(height));
    
public java.lang.StringtoString()
Returns the String associated to this Dimension object.

return
the String associated to this Dimension object.

        // The output format based on 1.5 release behaviour. It could be
        // obtained in the following way
        // System.out.println(new Dimension().toString())
        return getClass().getName() + "[width=" + width + ",height=" + height + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$