org.tigris.swidgets

Class Vertical


public class Vertical
extends Orientation

Various utilities to aid components that are aware of their horizontal/vertical orientation. The Singleton pattern is used to ensure that only one instance of a horizontal and one instance of a vertical Orientation exist.

Operations performed using length or breadth are transposed to width and height depending on whether this is a vertical or horizontal orientation.

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

Vertical treats length as height, breadth as width and position as y.

    HORIZONTAL                                          VERTICAL

                                                    A
                                                    |
                                                 position = y
                                                    |
                                                    V
                +-------------+   A                 +-------------+   A
                |             |   |                 |             |   |
 <--position--> |             | breadth = height    |             | length =
    = x         |             |   |                 |             |   |height
                +-------------+   V                 +-------------+   V
                 <-- length-->                       <--breadth-->
                    = width                             = width
Author:
Bob Tarling

Constructor Summary

Vertical()

Method Summary

Dimension
addLength(Dimension original, int add)
Create a new Dimension from an existing Dimension with its length increased by a given value.
Point
addToPosition(Point original, int add)
Create a new Point from an existing Point with its position increased by a given value.
int
getBreadth(Component comp)
Get the breadth of a Component.
int
getBreadth(Dimension dim)
Get the breadth of a Dimension.
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(Container cont)
Determines the first usable offset in a Container.
static Orientation
getInstance()
Get an instance of an Orientation object.
int
getLastUsablePosition(Container cont)
Determines the last usable position in a Container.
int
getLength(Component comp)
Get the length of a Component.
int
getLength(Dimension dim)
Get the length of a Dimension.
int
getLengthMinusInsets(Container cont)
Get the usable length of a Container minus its insets.
int
getOffset(Point point)
Get the offset of a Point.
Orientation
getPerpendicular()
Get an instance of an Orientation perpendicular to this instance.
int
getPosition(Component comp)
Get the position of a Component.
int
getPosition(MouseEvent me)
Get the position of a MouseEvent.
int
getPosition(Point point)
Get the position of a Point.
ArrowButton
getStartArrowButton()
Get an arrow button pointing to the start of the orientation.
Point
newPoint(int position, int offset)
Generate a new Point object from position and offset values.
Dimension
setBreadth(Dimension original, Dimension breadth)
Create a new Dimension from an existing Dimension with its breadth changed to the breadth of another given Dimension.
Dimension
setBreadth(Dimension original, int breadth)
Create a new Dimension from an existing Dimension with its breadth changed to a given value.
Dimension
setLength(Dimension original, Dimension length)
Create a new Dimension from an existing Dimension with its length changed to the length of another given Dimension.
Dimension
setLength(Dimension original, int length)
Create a new Dimension from an existing Dimension with its length changed to a given value.
Point
setPosition(Point original, int position)
Create a new Point from an existing Point with its position changed to a given value.

Methods inherited from class org.tigris.swidgets.Orientation

addLength, addLength, addLength, addToPosition, addToPosition, addToPosition, getBreadth, getBreadth, getCursor, getEndArrowButton, getFirstUsableOffset, getLastUsablePosition, getLength, getLength, getLengthMinusInsets, getOffset, getPerpendicular, getPosition, getPosition, getPosition, getStartArrowButton, newPoint, setBreadth, setBreadth, setLength, setLength, setPosition, subtractFromPosition, subtractFromPosition, subtractFromPosition, subtractLength, subtractLength, subtractLength

Constructor Details

Vertical

protected Vertical()

Method Details

addLength

public Dimension addLength(Dimension original,
                           int add)
Create a new Dimension from an existing Dimension with its length increased by a given value.
Overrides:
addLength in interface Orientation
Returns:
The resulting Dimension.

addToPosition

public Point addToPosition(Point original,
                           int add)
Create a new Point from an existing Point with its position increased by a given value.
Overrides:
addToPosition in interface Orientation
Returns:
The resulting Point.

getBreadth

public int getBreadth(Component comp)
Get the breadth of a Component.
Overrides:
getBreadth in interface Orientation
Returns:
The breadth of the Component.

getBreadth

public int getBreadth(Dimension dim)
Get the breadth of a Dimension.
Overrides:
getBreadth in interface Orientation
Returns:
The breadth of the Dimension.

getCursor

public Cursor getCursor()
Get a cursor object pointing in the same direction as the orientation.
Overrides:
getCursor in interface Orientation
Returns:
The resulting Cursor.

getEndArrowButton

public ArrowButton getEndArrowButton()
Get an arrow button pointing to the end of the orientation.
Overrides:
getEndArrowButton in interface Orientation
Returns:
The resulting ArrowButton.

getFirstUsableOffset

public int getFirstUsableOffset(Container cont)
Determines the first usable offset in a Container. This takes into account the Insets of the Container.
Overrides:
getFirstUsableOffset in interface Orientation
Returns:
The offset of the Container.

getInstance

public static Orientation getInstance()
Get an instance of an Orientation object.
Returns:
An instance of Orientation.

getLastUsablePosition

public int getLastUsablePosition(Container cont)
Determines the last usable position in a Container. This takes into account the Insets of the Container.
Overrides:
getLastUsablePosition in interface Orientation
Returns:
The offset of the Container.

getLength

public int getLength(Component comp)
Get the length of a Component.
Overrides:
getLength in interface Orientation
Returns:
The length of the Component.

getLength

public int getLength(Dimension dim)
Get the length of a Dimension.
Overrides:
getLength in interface Orientation
Returns:
The length of the Dimension.

getLengthMinusInsets

public int getLengthMinusInsets(Container cont)
Get the usable length of a Container minus its insets.
Overrides:
getLengthMinusInsets in interface Orientation
Returns:
The length of the Component.

getOffset

public int getOffset(Point point)
Get the offset of a Point.
Overrides:
getOffset in interface Orientation
Returns:
The position of the Point.

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.

Overrides:
getPerpendicular in interface Orientation
Returns:
A vertical or horizontal orientation.

getPosition

public int getPosition(Component comp)
Get the position of a Component.
Overrides:
getPosition in interface Orientation
Returns:
The position of the Component.

getPosition

public int getPosition(MouseEvent me)
Get the position of a MouseEvent.
Overrides:
getPosition in interface Orientation
Returns:
The position of the MouseEvent.

getPosition

public int getPosition(Point point)
Get the position of a Point.
Overrides:
getPosition in interface Orientation
Returns:
The position of the Point.

getStartArrowButton

public ArrowButton getStartArrowButton()
Get an arrow button pointing to the start of the orientation.
Overrides:
getStartArrowButton in interface Orientation
Returns:
The resulting ArrowButton.

newPoint

public Point newPoint(int position,
                      int offset)
Generate a new Point object from position and offset values.
Overrides:
newPoint in interface Orientation
Returns:
The newly created Point object.

setBreadth

public Dimension setBreadth(Dimension original,
                            Dimension breadth)
Create a new Dimension from an existing Dimension with its breadth changed to the breadth of another given Dimension.
Overrides:
setBreadth in interface Orientation
Returns:
The resulting Dimension.

setBreadth

public Dimension setBreadth(Dimension original,
                            int breadth)
Create a new Dimension from an existing Dimension with its breadth changed to a given value.
Overrides:
setBreadth in interface Orientation
Returns:
The resulting Dimension.

setLength

public Dimension setLength(Dimension original,
                           Dimension length)
Create a new Dimension from an existing Dimension with its length changed to the length of another given Dimension.
Overrides:
setLength in interface Orientation
Returns:
The resulting Dimension.

setLength

public Dimension setLength(Dimension original,
                           int length)
Create a new Dimension from an existing Dimension with its length changed to a given value.
Overrides:
setLength in interface Orientation
Returns:
The resulting Dimension.

setPosition

public Point setPosition(Point original,
                         int position)
Create a new Point from an existing Point with its position changed to a given value.
Overrides:
setPosition in interface Orientation
Returns:
The resulting Point.