oo
Class Flip

java.lang.Object
  extended by oo.Flip
Direct Known Subclasses:
FlipNULL, FlipPITCH, FlipROLL, FlipYAW

public abstract class Flip
extends java.lang.Object

A flip (a pitch, roll, yaw, or null flip having no effect) used by Mattress3's implementation.  

Each of its four subclasses implements its composeWith(Flip) method identically, by returning _other.composedWith(this).  This selects (at compile time) the appropriate composedWith method for composedWith's run-time argument: 

  1. composedWith(FlipNULL)
  2. composedWith(FlipPITCH)
  3. composedWith(FlipROLL)
  4. composedWith(FlipYAW)

Each subclass's four composedWith methods then simply returns the single possible result for the parameter type. 

The result of composing non-NULL flips A and B follows a simple pattern that can be verified by examining OO Examples Figure 2:

The two cases A composed with B
A == B NULL
A != B The other non-NULL flip

The figure also shows that composition of flips is commutative.

Of course, the NULL flip when composed with any other flip C is that same flip C (including the case where C is itself NULL). 


Field Summary
static FlipNULL NULL
          A null flip that does nothing to an orientation.
static FlipPITCH PITCH
          A pitch through a half turn (180°)
static FlipROLL ROLL
          A roll through a half turn (180°)
static FlipYAW YAW
          A yaw through a half turn (180°)
 
Constructor Summary
protected Flip()
          Protected default constructor, can only be called by subclasses of Flip.
 
Method Summary
(package private) abstract  Flip composedWith(FlipNULL _other)
          Package-private method composing this flip with a null flip.
(package private) abstract  Flip composedWith(FlipPITCH _other)
          Package-private method composing this flip with a FlipPITCH.
(package private) abstract  Flip composedWith(FlipROLL _other)
          Package-private method composing this flip with a FlipROLL.
(package private) abstract  Flip composedWith(FlipYAW _other)
          Package-private method composing this flip with a FlipYAW.
abstract  Flip composeWith(Flip _other)
          Composes this flip with _other, resulting in a flip. 
abstract  Orientation flip(Orientation _initial)
          Applies this flip to an orientation, producing an orientation. 
abstract  java.lang.String toString()
          The flip's name (null, pitch, roll, or yaw).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final FlipNULL NULL
A null flip that does nothing to an orientation.


PITCH

public static final FlipPITCH PITCH
A pitch through a half turn (180°)


ROLL

public static final FlipROLL ROLL
A roll through a half turn (180°)


YAW

public static final FlipYAW YAW
A yaw through a half turn (180°)

Constructor Detail

Flip

protected Flip()
Protected default constructor, can only be called by subclasses of Flip.

Method Detail

toString

public abstract java.lang.String toString()
The flip's name (null, pitch, roll, or yaw).

Overrides:
toString in class java.lang.Object

composedWith

abstract Flip composedWith(FlipNULL _other)
Package-private method composing this flip with a null flip.

Returns:
This flip.
Throws:
java.lang.NullPointerException - If _other is null.

composedWith

abstract Flip composedWith(FlipPITCH _other)
Package-private method composing this flip with a FlipPITCH.

Throws:
java.lang.NullPointerException - If _other is null.

composedWith

abstract Flip composedWith(FlipROLL _other)
Package-private method composing this flip with a FlipROLL.

Throws:
java.lang.NullPointerException - If _other is null.

composedWith

abstract Flip composedWith(FlipYAW _other)
Package-private method composing this flip with a FlipYAW.

Throws:
java.lang.NullPointerException - If _other is null.

composeWith

public abstract Flip composeWith(Flip _other)
Composes this flip with _other, resulting in a flip. 

Throws:
java.lang.NullPointerException - If _other is null.

flip

public abstract Orientation flip(Orientation _initial)
Applies this flip to an orientation, producing an orientation. 

Throws:
java.lang.NullPointerException - If _initial is null.