net.xoetrope.optional.layout
Class Guide

java.lang.Object
  extended by net.xoetrope.optional.layout.Guide
All Implemented Interfaces:
java.lang.Comparable

public class Guide
extends java.lang.Object
implements java.lang.Comparable

A container fro information about an individual guide

Copyright (c) Xoetrope Ltd., 2002-2005

$Revision: 1.5 $

License: see License.txt


Field Summary
static int ABSOLUTE_COORDINATES
          The coordinate is specified in absolute terms (pixels)
static int ABSOLUTE_POSITION
          The position is specified in terms of the parent's size
protected  int coordinates
          the type of coordinate system used
protected  int id
          the id of this guide
protected  boolean isVertical
          Is the guie vertical?
protected  int maxExtent
          the maximum absolute position
protected  double maxPosition
          the max allowable position
protected  double minPosition
          the minimum allowed position
protected  double position
          the position value
protected  int positioning
          the type of positioning used
protected  Guide previousGuide
          a reference to a previous guide
static int RELATIVE_COORDINATES
          The coordinate is specified in relative terms (percentage of the parent's size)
static int RELATIVE_POSITION
          The position is specified as a distance from the previous guide
protected  int snapRange
          the range within which snapping to this guide occurs
 
Constructor Summary
Guide(double pos, int guideId, int max, boolean isVert)
          Creates a new instance of XGuide using relative coordinates
Guide(int pos, int guideId, int max, boolean isVert)
          Creates a new instance of XGuide using relative coordinates
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares to objects
 boolean equals(java.lang.Object obj)
          Check for equality
 int getAbsoluteCoordinates()
          Get the coordinates in absolute coordinates
 int getAbsolutePosition()
          Get the absolute position in absolute coordinates
 int getCoordinates()
          Get the flag indicating the type of coordinate system used
 int getId()
          Get the ID of this guide
 boolean getIsVertical()
          Get the flag indicating the orientation of this guide
 int getMaxExtent()
          Get the maximum absolute position of the guide or the dimension against which scaling ratios are calculated
 double getMaxPosition()
          Get the maimum allowable position of the guide.
 double getMinPosition()
          Get the minimum allowable location of the guide
 double getPosition()
          Get the position or offset of the guide, depending on the type of positioning.
 int getPositioning()
          Get the position of this component
 Guide getPreviousGuide()
          Get the previous guide.
 int getSnapRange()
          Get the pixel range within which a component will snap to the guide
 void setAbsolutePosition(int newPos)
          Set the new position of the guide
 void setCoordinates(int c)
          Set the flag indicating the type of coordinate system used
 void setId(int i)
          Set the ID of this guide
 void setMaxExtent(int extent)
          Set the maximum absolute position of the guide or the dimension against which scaling ratios are calculated
 void setPosition(double pos)
          Set the position or offset of the guide, depending on the type of positioning.
 void setPositioning(int p)
          Set the position of this component
 void setPreviousGuide(Guide prevGuide)
          Set the previous guide.
 void useAbsolutePosition()
          Get the absolute position in absolute coordinates
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ABSOLUTE_COORDINATES

public static final int ABSOLUTE_COORDINATES
The coordinate is specified in absolute terms (pixels)

See Also:
Constant Field Values

RELATIVE_COORDINATES

public static final int RELATIVE_COORDINATES
The coordinate is specified in relative terms (percentage of the parent's size)

See Also:
Constant Field Values

ABSOLUTE_POSITION

public static final int ABSOLUTE_POSITION
The position is specified in terms of the parent's size

See Also:
Constant Field Values

RELATIVE_POSITION

public static final int RELATIVE_POSITION
The position is specified as a distance from the previous guide

See Also:
Constant Field Values

isVertical

protected boolean isVertical
Is the guie vertical?


positioning

protected int positioning
the type of positioning used


coordinates

protected int coordinates
the type of coordinate system used


position

protected double position
the position value


minPosition

protected double minPosition
the minimum allowed position


maxPosition

protected double maxPosition
the max allowable position


maxExtent

protected int maxExtent
the maximum absolute position


snapRange

protected int snapRange
the range within which snapping to this guide occurs


id

protected int id
the id of this guide


previousGuide

protected Guide previousGuide
a reference to a previous guide

Constructor Detail

Guide

public Guide(int pos,
             int guideId,
             int max,
             boolean isVert)
Creates a new instance of XGuide using relative coordinates

Parameters:
guideId - the id
max - the maximum position
isVert - true if the guide is vertical
pos - the relative coordinate/offset

Guide

public Guide(double pos,
             int guideId,
             int max,
             boolean isVert)
Creates a new instance of XGuide using relative coordinates

Parameters:
guideId - the guide id
max - the maximum position
isVert - true if the guide is vertical
pos - the relative coordinate/offset
Method Detail

setPreviousGuide

public void setPreviousGuide(Guide prevGuide)
Set the previous guide.

Parameters:
prevGuide - the previous guide reference

getPreviousGuide

public Guide getPreviousGuide()
Get the previous guide.

Returns:
returns null if there is no previous guide

getAbsoluteCoordinates

public int getAbsoluteCoordinates()
Get the coordinates in absolute coordinates

Returns:
the absolute position of this guide

getAbsolutePosition

public int getAbsolutePosition()
Get the absolute position in absolute coordinates

Returns:
the absolute position

setAbsolutePosition

public void setAbsolutePosition(int newPos)
Set the new position of the guide

Parameters:
newPos - the new absolute position in absolute coordinates

useAbsolutePosition

public void useAbsolutePosition()
Get the absolute position in absolute coordinates


equals

public boolean equals(java.lang.Object obj)
Check for equality

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare
Returns:
true if the two objects are equal

compareTo

public int compareTo(java.lang.Object obj)
Compares to objects

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the object to compare
Returns:
returns -1 if the comparison object is logically less that this object, 0 if they are equal and otherwise 1

getIsVertical

public boolean getIsVertical()
Get the flag indicating the orientation of this guide

Returns:
true for a vertical guides, otherwise false

getPositioning

public int getPositioning()
Get the position of this component

Returns:
ABSOLUTE_POSITION for an absolute position in pixels or RELATIVE_POSITION for a position relative to some other guide

getCoordinates

public int getCoordinates()
Get the flag indicating the type of coordinate system used

Returns:
ABSOLUTE_COORDINATES for coordinates in pixels, or RELATIVE_COORDINATES for coordinates expressed in terms of the page size (width or height)

getPosition

public double getPosition()
Get the position or offset of the guide, depending on the type of positioning. For relative positioning this is the offset from the previous guide

Returns:
location or offset of the guide

getMinPosition

public double getMinPosition()
Get the minimum allowable location of the guide

Returns:
not yet implemented

getMaxPosition

public double getMaxPosition()
Get the maimum allowable position of the guide.

Returns:
not yet implemented

getMaxExtent

public int getMaxExtent()
Get the maximum absolute position of the guide or the dimension against which scaling ratios are calculated

Returns:
the maximum dimension (size or width normally)

getSnapRange

public int getSnapRange()
Get the pixel range within which a component will snap to the guide

Returns:
true for a vertical guides, otherwise false

getId

public int getId()
Get the ID of this guide

Returns:
the id

setPosition

public void setPosition(double pos)
Set the position or offset of the guide, depending on the type of positioning. For relative positioning this is the offset from the previous guide

Parameters:
pos - location or offset of the guide

setPositioning

public void setPositioning(int p)
Set the position of this component

Parameters:
p - ABSOLUTE_POSITION for an absolute position in pixels or RELATIVE_POSITION for a position relative to some other guide

setCoordinates

public void setCoordinates(int c)
Set the flag indicating the type of coordinate system used

Parameters:
c - ABSOLUTE_COORDINATES for coordinates in pixels, or RELATIVE_COORDINATES for coordinates expressed in terms of the page size (width or height)

setId

public void setId(int i)
Set the ID of this guide

Parameters:
i - the id

setMaxExtent

public void setMaxExtent(int extent)
Set the maximum absolute position of the guide or the dimension against which scaling ratios are calculated

Parameters:
extent - the maximum dimension (size or width normally)