relativelayout
Class RelativePosition

java.lang.Object
  extended by relativelayout.RelativePosition

public class RelativePosition
extends Object

Represents the position of an edge at some offset from another edge. RelativePositions are designed to be reused in multiple Bindings using the Binding.Binding(RelativePosition, java.awt.Component) constructor. If you don't need reusability, you can also construct a Binding without having to create a RelativePosition by using the Binding.Binding(Edge, int, Direction, Edge, java.awt.Component) constructor.

RelativePositions are immutable; that is, once constructed, they cannot be changed.

Author:
Brian Ellis (firebird@andrew.cmu.edu)

Constructor Summary
RelativePosition(Edge myEdge, int distance, Direction direction, Edge fixedEdge)
          Constructs an RelativePosition with the given parameters.
 
Method Summary
 Direction getDirection()
          Accessor method for direction, as set in the constructor.
 int getDistance()
          Accessor method for distance, as set in the constructor.
 Edge getFixedEdge()
          Accessor method for fixedEdge, as set in the constructor.
 Edge getMyEdge()
          Accessor method for myEdge, as set in the constructor.
 boolean isValid()
          Returns true if this RelativePosition is "valid" -- that is, does not result in a nonsensical relationship.
 String toString()
          Returns a human readable String representation of this RelativePosition.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RelativePosition

public RelativePosition(Edge myEdge,
                        int distance,
                        Direction direction,
                        Edge fixedEdge)
Constructs an RelativePosition with the given parameters. See Binding.Binding(Edge, int, Direction, Edge, java.awt.Component) for more information.

Parameters:
myEdge - The edge of a component that will be defined by this RelativePosition.
distance - How far that edge will be from the edge of some fixed component, in pixels.
direction - The direction the edge will be in from the edge of some fixed component.
fixedEdge - The edge of some fixed component from which the distance should be measured.
See Also:
Binding.Binding(Edge, int, Direction, Edge, java.awt.Component)
Method Detail

getDirection

public Direction getDirection()
Accessor method for direction, as set in the constructor.

Returns:
the value of direction

getDistance

public int getDistance()
Accessor method for distance, as set in the constructor.

Returns:
the value of distance

getFixedEdge

public Edge getFixedEdge()
Accessor method for fixedEdge, as set in the constructor.

Returns:
the value of fixedEdge

getMyEdge

public Edge getMyEdge()
Accessor method for myEdge, as set in the constructor.

Returns:
the value of myEdge

isValid

public boolean isValid()
Returns true if this RelativePosition is "valid" -- that is, does not result in a nonsensical relationship. See InvalidBindingException for a more formal definition of what this means.

Returns:
true if the RelativePosition is valid, false otherwise.

toString

public String toString()
Returns a human readable String representation of this RelativePosition. Useful for debugging and troubleshooting.

Overrides:
toString in class Object
See Also:
Object.toString()