Class ComplDemo.ComplexWrapper

java.lang.Object
  extended by ComplDemo.ComplexWrapper
All Implemented Interfaces:
Comparable<ComplDemo.ComplexWrapper>
Enclosing class:
ComplDemo

public class ComplDemo.ComplexWrapper
extends Object
implements Comparable<ComplDemo.ComplexWrapper>

Wrapper for Complex with pixel coordinates and comparison.

An oOject of this class wraps a Complex object, adapts it to the interface Comparable and adds pixel coordinates and painting in a specified colour

Hint: A ComplDemo object makes just three such wrappers: two for operands and one for the result.

Version:
see enclosing class
Author:
Albrecht Weinert

Field Summary
 Color color
          Painting colour for the complex vector.
 Complex cp
          The complex number wrapped.
 int lp
          Pixel norm.
 boolean noShow
          Do not paint.
 byte stat
          State.
 int xp
          Pixel coordinates.
 int yp
          Pixel coordinates.
 
Constructor Summary
ComplDemo.ComplexWrapper(Color color)
          Make a wrapper.
 
Method Summary
 int compareTo(ComplDemo.ComplexWrapper other)
          Compare the absolute values.
 void consist()
          Make pixel and complex values consistent.
 void doThePaint(Graphics g)
          Paint as vector.
 void set(Complex cp)
          Set the Complex.
 void set(double re, double im)
          Set by real and imaginary part.
 void set(int xp, int yp)
          Set by pixel coordinates x, y.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cp

public Complex cp
The complex number wrapped.

Must never be null.


color

public Color color
Painting colour for the complex vector.

Must never be null.


xp

public int xp
Pixel coordinates.


yp

public int yp
Pixel coordinates.


lp

public int lp
Pixel norm.

I.e the square of the length.


stat

public byte stat
State.

Consistency between cp and (xp, yp}.


noShow

public boolean noShow
Do not paint.

If true, doThePaint(Graphics) does nothing.

Constructor Detail

ComplDemo.ComplexWrapper

public ComplDemo.ComplexWrapper(Color color)
Make a wrapper.

Parameters:
color - the colour for painting the vector (never null!).
Method Detail

set

public void set(Complex cp)
Set the Complex.


set

public void set(double re,
                double im)
Set by real and imaginary part.


set

public void set(int xp,
                int yp)
Set by pixel coordinates x, y.


consist

public void consist()
Make pixel and complex values consistent.


compareTo

public int compareTo(ComplDemo.ComplexWrapper other)
Compare the absolute values.

Comparable implementation.

Specified by:
compareTo in interface Comparable<ComplDemo.ComplexWrapper>

doThePaint

public void doThePaint(Graphics g)
Paint as vector.

This method requires g.translate(); that means the Zero of g must be the coordinates origin in the complex plane.

If g is null or noShow is true, nothing will be done.