Search this API

y.layout
Class Direction

java.lang.Object
  extended by y.layout.Direction

public final class Direction
extends java.lang.Object

Direction provides four main directions and some methods to work with them.

 
There is exactly one immutable object for each direction.
 

Field Summary
static Direction DOWN
          Decodes the down direction.
static Direction LEFT
          Decodes the left direction.
static Direction RIGHT
          Decodes the right direction.
static Direction UP
          Decodes the up direction.
 
Method Summary
 int getDirection()
          Returns the direction encoded as an integer value.
 Direction getMirror()
          Returns the mirror direction.
 Direction getTurnCCW()
          Returns the direction that follows this direction in counterclockwise order.
 Direction getTurnCW()
          Returns the direction that follows this direction in clockwise order.
 boolean isHorizontal()
          Returns whether or not this direction is horizontal (RIGHT or LEFT).
 boolean isVertical()
          Returns whether or not this direction is vertical (UP or DOWN).
 java.lang.String toString()
          Returns a string representation of the direction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UP

public static final Direction UP
Decodes the up direction.


RIGHT

public static final Direction RIGHT
Decodes the right direction.


DOWN

public static final Direction DOWN
Decodes the down direction.


LEFT

public static final Direction LEFT
Decodes the left direction.

Method Detail

getTurnCW

public Direction getTurnCW()
Returns the direction that follows this direction in clockwise order.

The new direction is turned 90 degrees in clockwise direction compared to this instance.

Returns:
the turned direction
Throws:
java.lang.IllegalArgumentException - if the current direction value is invalid

getTurnCCW

public Direction getTurnCCW()
Returns the direction that follows this direction in counterclockwise order.

The new direction is turned 90 degrees in counterclockwise direction compared to this instance.

Returns:
the turned direction
Throws:
java.lang.IllegalArgumentException - if the current direction value is invalid

getMirror

public Direction getMirror()
Returns the mirror direction.

The new direction is turned 180 degrees compared to this instance.

Returns:
the mirrored direction
Throws:
java.lang.IllegalArgumentException - if the current direction value is invalid

isHorizontal

public boolean isHorizontal()
Returns whether or not this direction is horizontal (RIGHT or LEFT).

Returns:
true if this direction is horizontal, false otherwise

isVertical

public boolean isVertical()
Returns whether or not this direction is vertical (UP or DOWN).

Returns:
true if this direction is vertical, false otherwise

getDirection

public int getDirection()
Returns the direction encoded as an integer value.

Returns:
0 for direction UP, 1 for RIGHT, 2 for DOWN, and 3 for LEFT

toString

public java.lang.String toString()
Returns a string representation of the direction.

Overrides:
toString in class java.lang.Object
Returns:
^ for UP, > for RIGHT, v for DOWN, and < for LEFT.
Throws:
java.lang.IllegalArgumentException - if the current direction value is invalid

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.