edu.rit.draw.item
Class Size
- java.lang.Object
-
- edu.rit.draw.item.Size
-
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable
public class Size extends java.lang.Object implements java.io.ExternalizableClass Size provides a size (width,height) for a DrawingItem.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description Size()Construct a new size with width = height = 0.Size(double width, double height)Construct a new size with the given width and height.Size(Size theSize)Construct a new size with the same width and height as the given size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Sizeadd(double incr)Returns a new size equal to this size increased by the given amount in both width and height.Sizeadd(double wincr, double hincr)Returns a new size equal to this size increased by the given amounts in width and height.Sizeceil()Returns a new size with its width and height set to the ceiling of this size's width and height, respectively.Sizediv(double scale)Returns a new size equal to this size divided by the given scale factor.Sizediv(double wscale, double hscale)Returns a new size equal to this size divided by the given scale factors.booleanequals(java.lang.Object obj)Determine if this size is equal to the given object.inthashCode()Returns a hash code for this size.doubleheight()Returns this size's height.Sizemul(double scale)Returns a new size equal to this size multiplied by the given scale factor.Sizemul(double wscale, double hscale)Returns a new size equal to this size multiplied by the given scale factors.voidreadExternal(java.io.ObjectInput in)Read this size from the given object input stream.Sizesub(double decr)Returns a new size equal to this size decreased by the given amount in both width and height.Sizesub(double wdecr, double hdecr)Returns a new size equal to this size decreased by the given amounts in width and height.java.lang.StringtoString()Returns a string version of this size.doublewidth()Returns this size's width.voidwriteExternal(java.io.ObjectOutput out)Write this size to the given object output stream.
-
-
-
Constructor Detail
-
Size
public Size()
Construct a new size with width = height = 0.
-
Size
public Size(double width, double height)Construct a new size with the given width and height.- Parameters:
width- Width.height- Height.
-
Size
public Size(Size theSize)
Construct a new size with the same width and height as the given size.- Parameters:
theSize- Size to copy.
-
-
Method Detail
-
width
public double width()
Returns this size's width.
-
height
public double height()
Returns this size's height.
-
ceil
public Size ceil()
Returns a new size with its width and height set to the ceiling of this size's width and height, respectively.
-
add
public Size add(double incr)
Returns a new size equal to this size increased by the given amount in both width and height.- Parameters:
incr- Increment.
-
add
public Size add(double wincr, double hincr)
Returns a new size equal to this size increased by the given amounts in width and height.- Parameters:
wincr- Width increment.hincr- Height increment.
-
sub
public Size sub(double decr)
Returns a new size equal to this size decreased by the given amount in both width and height.- Parameters:
decr- Decrement.
-
sub
public Size sub(double wdecr, double hdecr)
Returns a new size equal to this size decreased by the given amounts in width and height.- Parameters:
wdecr- Width decrement.hdecr- Height decrement.
-
mul
public Size mul(double scale)
Returns a new size equal to this size multiplied by the given scale factor.- Parameters:
scale- Scale factor.
-
mul
public Size mul(double wscale, double hscale)
Returns a new size equal to this size multiplied by the given scale factors.- Parameters:
wscale- Width scale factor.hscale- Height scale factor.
-
div
public Size div(double scale)
Returns a new size equal to this size divided by the given scale factor.- Parameters:
scale- Scale factor.
-
div
public Size div(double wscale, double hscale)
Returns a new size equal to this size divided by the given scale factors.- Parameters:
wscale- Width scale factor.hscale- Height scale factor.
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOExceptionWrite this size to the given object output stream.- Specified by:
writeExternalin interfacejava.io.Externalizable- Parameters:
out- Object output stream.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOExceptionRead this size from the given object input stream.- Specified by:
readExternalin interfacejava.io.Externalizable- Parameters:
in- Object input stream.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
equals
public boolean equals(java.lang.Object obj)
Determine if this size is equal to the given object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- Object to test.- Returns:
- True if this size is equal to obj, false otherwise.
-
hashCode
public int hashCode()
Returns a hash code for this size.- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Returns a string version of this size.- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG