org.argouml.swingext
Class Horizontal

java.lang.Object
  |
  +--org.argouml.swingext.Orientation
        |
        +--org.argouml.swingext.Horizontal

public class Horizontal
extends Orientation

A horizontal implementation of Orientation. The Singleton pattern is used to ensure that only one instance of this class can exist.

Horizontal treats length as width, breadth as height and position as x.

    HORIZONTAL

                                                    A
                                                    |
                                                 position = y
                                                    |
                                                    V
                +-------------+   A                 +-------------+   A
                |             |   |                 |             |   |
 <--position--> |             | breadth = height    |             | length =
    = x         |             |   |                 |             |   |height
                +-------------+   V                 +-------------+   V
                 <-- length-->                       <--breadth-->
                    = width                             = width


Field Summary
private static Horizontal horizontal
           
 
Constructor Summary
protected Horizontal()
           
 
Method Summary
 java.awt.Dimension addLength(java.awt.Dimension original, java.awt.Component add)
          Create a new Dimension from an existing Dimension with its length increased by the length of a Component.
 java.awt.Dimension addLength(java.awt.Dimension original, java.awt.Dimension add)
          Create a new Dimension from an existing Dimension with its length increased by the length of another Dimension.
 java.awt.Dimension addLength(java.awt.Dimension original, int add)
          Create a new Dimension from an existing Dimension with its length increased by a given value.
 java.awt.Point addToPosition(java.awt.Point original, java.awt.Component add)
          Create a new Point from an existing Point with its length increased by the length of a Component.
 java.awt.Point addToPosition(java.awt.Point original, java.awt.Dimension add)
          Create a new Point from an existing Point with its length increased by the length of a Dimension.
 java.awt.Point addToPosition(java.awt.Point original, int add)
          Create a new Point from an existing Point with its position increased by a given value.
 int getBreadth(java.awt.Component comp)
          Get the breadth of a Component.
 int getBreadth(java.awt.Dimension dim)
          Get the breadth of a Dimension.
 java.awt.Cursor getCursor()
          Get a cursor object pointing in the same direction as the orientation.
 ArrowButton getEndArrowButton()
          Get an arrow button pointing to the end of the orientation.
 int getFirstUsableOffset(java.awt.Container cont)
          Determines the first usable offset in a Container.
static Orientation getInstance()
          Get an instance of a Horizontal object.
 int getLastUsablePosition(java.awt.Container cont)
          Determines the last usable position in a Container.
 int getLength(java.awt.Component comp)
          Get the length of a Component.
 int getLength(java.awt.Dimension dim)
          Get the length of a Dimension.
 int getLengthMinusInsets(java.awt.Container cont)
          Get the usable length of a Container minus its insets.
 int getOffset(java.awt.Point point)
          Get the offset of a Component.
 Orientation getPerpendicular()
          Get an instance of an Orientation perpendicular to this instance.
 int getPosition(java.awt.Component comp)
          Get the position of a Component.
 int getPosition(java.awt.event.MouseEvent me)
          Get the position of a MouseEvent.
 int getPosition(java.awt.Point point)
          Get the position of a Point.
 ArrowButton getStartArrowButton()
          Get an arrow button pointing to the start of the orientation.
 java.awt.Point newPoint(int position, int offset)
          Generate a new Point object from position and offset values.
 java.awt.Dimension setBreadth(java.awt.Dimension original, java.awt.Dimension breadth)
          Create a new Dimension from an existing Dimension with its breadth changed to the breadth of another given Dimension.
 java.awt.Dimension setBreadth(java.awt.Dimension original, int breadth)
          Create a new Dimension from an existing Dimension with its breadth changed to a given value.
 java.awt.Dimension setLength(java.awt.Dimension original, java.awt.Dimension length)
          Create a new Dimension from an existing Dimension with its length changed to the length of another given Dimension.
 java.awt.Dimension setLength(java.awt.Dimension original, int length)
          Create a new Dimension from an existing Dimension with its length changed to a given value.
 java.awt.Point setPosition(java.awt.Point original, int position)
          Create a new Point from an existing Point with its position changed to a given value.
 java.awt.Point subtractFromPosition(java.awt.Point original, java.awt.Component subtract)
          Create a new Point from an existing Point with its length decreased by the length of a Component.
 java.awt.Point subtractFromPosition(java.awt.Point original, java.awt.Dimension subtract)
          Create a new Point from an existing Point with its length decreased by the length of a Dimension.
 java.awt.Point subtractFromPosition(java.awt.Point original, int subtract)
          Create a new Point from an existing Point with its position decreased by a given value.
 java.awt.Dimension subtractLength(java.awt.Dimension original, java.awt.Component subtract)
          Create a new Dimension from an existing Dimension with its length decreased by the length of a Component.
 java.awt.Dimension subtractLength(java.awt.Dimension original, java.awt.Dimension subtract)
          Create a new Dimension from an existing Dimension with its length decreased by the length of another Dimension.
 java.awt.Dimension subtractLength(java.awt.Dimension original, int subtract)
          Create a new Dimension from an existing Dimension with its length decreased by a given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

horizontal

private static final Horizontal horizontal
Constructor Detail

Horizontal

protected Horizontal()
Method Detail

getInstance

public static Orientation getInstance()
Get an instance of a Horizontal object.

Returns:
An instance of Orientation.

getPerpendicular

public Orientation getPerpendicular()
Get an instance of an Orientation perpendicular to this instance.

If called on a horizontal instance then a vertical instance is returned.

If called on a vertical instance then a horizontal instance is returned.

Specified by:
getPerpendicular in class Orientation
Returns:
A vertical or horizontal orientation.

getLength

public int getLength(java.awt.Dimension dim)
Get the length of a Dimension.

Specified by:
getLength in class Orientation
Parameters:
dim - The Dimension of which to determine the length
Returns:
The length of the Dimension.

getLength

public int getLength(java.awt.Component comp)
Get the length of a Component.

Specified by:
getLength in class Orientation
Parameters:
comp - The Component of which to determine the length
Returns:
The length of the Component.

getLengthMinusInsets

public int getLengthMinusInsets(java.awt.Container cont)
Get the usable length of a Container minus its insets.

Specified by:
getLengthMinusInsets in class Orientation
Parameters:
cont - The Container of which to determine the length
Returns:
The length of the Component.

getBreadth

public int getBreadth(java.awt.Dimension dim)
Get the breadth of a Dimension.

Specified by:
getBreadth in class Orientation
Parameters:
dim - The Dimension of which to determine the breadth
Returns:
The breadth of the Dimension.

getBreadth

public int getBreadth(java.awt.Component comp)
Get the breadth of a Component.

Specified by:
getBreadth in class Orientation
Parameters:
comp - The Component of which to determine the breadth
Returns:
The breadth of the Component.

getPosition

public int getPosition(java.awt.Point point)
Get the position of a Point.

Specified by:
getPosition in class Orientation
Parameters:
point - The Point of which to determine the position
Returns:
The position of the Point.

getPosition

public int getPosition(java.awt.Component comp)
Get the position of a Component.

Specified by:
getPosition in class Orientation
Parameters:
comp - The Component of which to determine the position
Returns:
The position of the Component.

getOffset

public int getOffset(java.awt.Point point)
Get the offset of a Component.

Specified by:
getOffset in class Orientation
Parameters:
point - The Component of which to determine the offset.
Returns:
The position of the Component.

getLastUsablePosition

public int getLastUsablePosition(java.awt.Container cont)
Determines the last usable position in a Container. This takes into account the Insets of the Container.

Specified by:
getLastUsablePosition in class Orientation
Parameters:
cont - the Container from which to determine the last usable position.
Returns:
The offset of the Container.

getFirstUsableOffset

public int getFirstUsableOffset(java.awt.Container cont)
Determines the first usable offset in a Container. This takes into account the Insets of the Container.

Specified by:
getFirstUsableOffset in class Orientation
Parameters:
cont - the Container from which to determine the first usable position.
Returns:
The offset of the Container.

newPoint

public java.awt.Point newPoint(int position,
                               int offset)
Generate a new Point object from position and offset values.

Specified by:
newPoint in class Orientation
Parameters:
position - the required position of the new Point.
offset - the required offset of the new Point.
Returns:
The newly created Point object.

getPosition

public int getPosition(java.awt.event.MouseEvent me)
Get the position of a MouseEvent.

Specified by:
getPosition in class Orientation
Parameters:
me - The MouseEvent of which to determine the position
Returns:
The position of the MouseEvent.

addLength

public java.awt.Dimension addLength(java.awt.Dimension original,
                                    int add)
Create a new Dimension from an existing Dimension with its length increased by a given value.

Specified by:
addLength in class Orientation
Parameters:
original - The Dimension to be added to.
add - The amount to add to the Dimension.
Returns:
The resulting Dimension.

addLength

public java.awt.Dimension addLength(java.awt.Dimension original,
                                    java.awt.Dimension add)
Create a new Dimension from an existing Dimension with its length increased by the length of another Dimension.

Overrides:
addLength in class Orientation
Parameters:
original - The Dimension to be added to.
add - The Dimension whose length is to be taken as the added value.
Returns:
The resulting Dimension.

addLength

public java.awt.Dimension addLength(java.awt.Dimension original,
                                    java.awt.Component add)
Create a new Dimension from an existing Dimension with its length increased by the length of a Component.

Overrides:
addLength in class Orientation
Parameters:
original - The Dimension to be added to.
add - The Component whose length is to be taken as the added value.
Returns:
The resulting Dimension.

subtractLength

public java.awt.Dimension subtractLength(java.awt.Dimension original,
                                         int subtract)
Create a new Dimension from an existing Dimension with its length decreased by a given value.

Overrides:
subtractLength in class Orientation
Parameters:
original - The Dimension to be subtracted from.
subtract - The amount to subtract from the Dimension.
Returns:
The resulting Dimension.

subtractLength

public java.awt.Dimension subtractLength(java.awt.Dimension original,
                                         java.awt.Dimension subtract)
Create a new Dimension from an existing Dimension with its length decreased by the length of another Dimension.

Overrides:
subtractLength in class Orientation
Parameters:
original - The Dimension to be subtracted from.
subtract - The Dimension whose length is to be taken as the subtracted value.
Returns:
The resulting Dimension.

subtractLength

public java.awt.Dimension subtractLength(java.awt.Dimension original,
                                         java.awt.Component subtract)
Create a new Dimension from an existing Dimension with its length decreased by the length of a Component.

Overrides:
subtractLength in class Orientation
Parameters:
original - The Dimension to be subtracted from.
subtract - The Component whose length is to be taken as the subtracted value.
Returns:
The resulting Dimension.

addToPosition

public java.awt.Point addToPosition(java.awt.Point original,
                                    int add)
Create a new Point from an existing Point with its position increased by a given value.

Specified by:
addToPosition in class Orientation
Parameters:
original - The Point to be added to.
add - The amount to add to the Point.
Returns:
The resulting Point.

addToPosition

public java.awt.Point addToPosition(java.awt.Point original,
                                    java.awt.Dimension add)
Create a new Point from an existing Point with its length increased by the length of a Dimension.

Overrides:
addToPosition in class Orientation
Parameters:
original - The Point to be added to.
add - The Dimension whose length is to be taken as the added value.
Returns:
The resulting Point.

addToPosition

public java.awt.Point addToPosition(java.awt.Point original,
                                    java.awt.Component add)
Create a new Point from an existing Point with its length increased by the length of a Component.

Overrides:
addToPosition in class Orientation
Parameters:
original - The Point to be added to.
add - The Dimension whose length is to be taken as the added value.
Returns:
The resulting Point.

subtractFromPosition

public java.awt.Point subtractFromPosition(java.awt.Point original,
                                           int subtract)
Create a new Point from an existing Point with its position decreased by a given value.

Overrides:
subtractFromPosition in class Orientation
Parameters:
original - The Point to be added to.
subtract - The amount to subtract to the Point.
Returns:
The resulting Point.

subtractFromPosition

public java.awt.Point subtractFromPosition(java.awt.Point original,
                                           java.awt.Dimension subtract)
Create a new Point from an existing Point with its length decreased by the length of a Dimension.

Overrides:
subtractFromPosition in class Orientation
Parameters:
original - The Point to be added to.
subtract - The Dimension whose length is to be taken as the subtracted value.
Returns:
The resulting Point.

subtractFromPosition

public java.awt.Point subtractFromPosition(java.awt.Point original,
                                           java.awt.Component subtract)
Create a new Point from an existing Point with its length decreased by the length of a Component.

Overrides:
subtractFromPosition in class Orientation
Parameters:
original - The Point to be added to.
subtract - The Component whose length is to be taken as the subtracted value.
Returns:
The resulting Point.

setLength

public java.awt.Dimension setLength(java.awt.Dimension original,
                                    int length)
Create a new Dimension from an existing Dimension with its length changed to a given value.

Specified by:
setLength in class Orientation
Parameters:
original - The Dimension to be added to.
length - The length to assign to the new Dimension.
Returns:
The resulting Dimension.

setLength

public java.awt.Dimension setLength(java.awt.Dimension original,
                                    java.awt.Dimension length)
Create a new Dimension from an existing Dimension with its length changed to the length of another given Dimension.

Specified by:
setLength in class Orientation
Parameters:
original - The Dimension to be added to.
length - The Dimension whose length is to be assigned to the new Dimension.
Returns:
The resulting Dimension.

setBreadth

public java.awt.Dimension setBreadth(java.awt.Dimension original,
                                     int breadth)
Create a new Dimension from an existing Dimension with its breadth changed to a given value.

Specified by:
setBreadth in class Orientation
Parameters:
original - The Dimension to be added to.
breadth - The breadth to assign to the new Dimension.
Returns:
The resulting Dimension.

setBreadth

public java.awt.Dimension setBreadth(java.awt.Dimension original,
                                     java.awt.Dimension breadth)
Create a new Dimension from an existing Dimension with its breadth changed to the breadth of another given Dimension.

Specified by:
setBreadth in class Orientation
Parameters:
original - The Dimension to be added to.
breadth - The Dimension whose breadth is to be assigned to the new Dimension.
Returns:
The resulting Dimension.

setPosition

public java.awt.Point setPosition(java.awt.Point original,
                                  int position)
Create a new Point from an existing Point with its position changed to a given value.

Specified by:
setPosition in class Orientation
Parameters:
original - The Point whose position is to be modified.
position - The value to assign as the new position.
Returns:
The resulting Point.

getCursor

public java.awt.Cursor getCursor()
Get a cursor object pointing in the same direction as the orientation.

Specified by:
getCursor in class Orientation
Returns:
The resulting Cursor.

getStartArrowButton

public ArrowButton getStartArrowButton()
Get an arrow button pointing to the start of the orientation.

Specified by:
getStartArrowButton in class Orientation
Returns:
The resulting ArrowButton.

getEndArrowButton

public ArrowButton getEndArrowButton()
Get an arrow button pointing to the end of the orientation.

Specified by:
getEndArrowButton in class Orientation
Returns:
The resulting ArrowButton.


ArgoUML © 1996-2004 (20040306)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook