org.tigris.swidgets

Class 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
Author:
Bob Tarling

Constructor Summary

Horizontal()

Method Summary

Dimension
addLength(Dimension original, Component add)
Create a new Dimension from an existing Dimension with its length increased by the length of a Component.
Dimension
addLength(Dimension original, Dimension add)
Create a new Dimension from an existing Dimension with its length increased by the length of another Dimension.
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, Component add)
Create a new Point from an existing Point with its length increased by the length of a Component.
Point
addToPosition(Point original, Dimension add)
Create a new Point from an existing Point with its length increased by the length of a Dimension.
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 a Horizontal 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 Component.
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.
Point
subtractFromPosition(Point original, Component subtract)
Create a new Point from an existing Point with its length decreased by the length of a Component.
Point
subtractFromPosition(Point original, Dimension subtract)
Create a new Point from an existing Point with its length decreased by the length of a Dimension.
Point
subtractFromPosition(Point original, int subtract)
Create a new Point from an existing Point with its position decreased by a given value.
Dimension
subtractLength(Dimension original, Component subtract)
Create a new Dimension from an existing Dimension with its length decreased by the length of a Component.
Dimension
subtractLength(Dimension original, Dimension subtract)
Create a new Dimension from an existing Dimension with its length decreased by the length of another Dimension.
Dimension
subtractLength(Dimension original, int subtract)
Create a new Dimension from an existing Dimension with its length decreased by 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

Horizontal

protected Horizontal()

Method Details

addLength

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

addLength

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

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,
                           Component add)
Create a new Point from an existing Point with its length increased by the length of a Component.
Overrides:
addToPosition in interface Orientation
Returns:
The resulting Point.

addToPosition

public Point addToPosition(Point original,
                           Dimension add)
Create a new Point from an existing Point with its length increased by the length of a Dimension.
Overrides:
addToPosition in interface Orientation
Returns:
The resulting Point.

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 a Horizontal 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 Component.
Overrides:
getOffset in interface Orientation
Returns:
The position of the Component.

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.

subtractFromPosition

public Point subtractFromPosition(Point original,
                                  Component subtract)
Create a new Point from an existing Point with its length decreased by the length of a Component.
Overrides:
subtractFromPosition in interface Orientation
Returns:
The resulting Point.

subtractFromPosition

public Point subtractFromPosition(Point original,
                                  Dimension subtract)
Create a new Point from an existing Point with its length decreased by the length of a Dimension.
Overrides:
subtractFromPosition in interface Orientation
Returns:
The resulting Point.

subtractFromPosition

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

subtractLength

public Dimension subtractLength(Dimension original,
                                Component subtract)
Create a new Dimension from an existing Dimension with its length decreased by the length of a Component.
Overrides:
subtractLength in interface Orientation
Returns:
The resulting Dimension.

subtractLength

public Dimension subtractLength(Dimension original,
                                Dimension subtract)
Create a new Dimension from an existing Dimension with its length decreased by the length of another Dimension.
Overrides:
subtractLength in interface Orientation
Returns:
The resulting Dimension.

subtractLength

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