view
Class MyDimension

java.lang.Object
  extended by java.awt.geom.Dimension2D
      extended by java.awt.Dimension
          extended by view.MyDimension
All Implemented Interfaces:
Serializable, Cloneable

public class MyDimension
extends Dimension

Adds a String constructor to Dimension. A dimension object can now also be defined with a string of the format:

              200x300
   

See Also:
Serialized Form

Field Summary
static char X
          The separator char between width and height, an 'x'.
 
Fields inherited from class java.awt.Dimension
height, width
 
Constructor Summary
MyDimension()
          Constructs an empty dimension.
MyDimension(Dimension dim)
           
MyDimension(int w, int h)
           
MyDimension(String xed)
          Parses the string with parseDimension(java.lang.String) and calls the super-constructor with the resulting dimension.
 
Method Summary
private static String getAfter(String arg, char sep)
          Returns the portion of the string after the separator char, excluding it.
private static String getBefore(String arg, char sep)
          Returns the portion of the string before the separator char, excluding it.
static Dimension parseDimension(String xed)
          Parses a string by separating it at the central 'x'.
 String toString()
           
static String toString(Dimension size)
          Converts a dimension object to a string that can be parsed into a Dimension object with a call to parseDimension(java.lang.String).
 
Methods inherited from class java.awt.Dimension
equals, getHeight, getSize, getWidth, hashCode, setSize, setSize, setSize
 
Methods inherited from class java.awt.geom.Dimension2D
clone, setSize
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

X

public static final char X
The separator char between width and height, an 'x'.

See Also:
Constant Field Values
Constructor Detail

MyDimension

public MyDimension()
Constructs an empty dimension.


MyDimension

public MyDimension(Dimension dim)

MyDimension

public MyDimension(int w,
                   int h)

MyDimension

public MyDimension(String xed)
Parses the string with parseDimension(java.lang.String) and calls the super-constructor with the resulting dimension.

Method Detail

parseDimension

public static final Dimension parseDimension(String xed)
Parses a string by separating it at the central 'x'. Parses without trimming the strings to the left and to the right of the 'x' to integers. Returns a new Dimension Object with these sizes, left part as width.


toString

public static String toString(Dimension size)
Converts a dimension object to a string that can be parsed into a Dimension object with a call to parseDimension(java.lang.String).


toString

public String toString()
Overrides:
toString in class Dimension

getBefore

private static String getBefore(String arg,
                                char sep)
Returns the portion of the string before the separator char, excluding it.


getAfter

private static String getAfter(String arg,
                               char sep)
Returns the portion of the string after the separator char, excluding it.