view
Class BasicMorpher

java.lang.Object
  extended by view.BasicMorpher
All Implemented Interfaces:
DeltaFormattingMorphing, FormattingMorphing, Morphing

public class BasicMorpher
extends Object
implements FormattingMorphing, DeltaFormattingMorphing

This class is a basic morpher in the way that it comprises a linear mapping in x and y to pixel space starting at 0,0 with an extend of 1x1. It can be constructed either giving the extend of the true coordinate space or the true coordinate space with an offset. The default formatting is done with the default number format instances, as returned by NumberFormat.getNumberInstance(). It may be changed with a call to the appropriate set...Format methods.


Field Summary
private  NumberFormat dxprim
          A formatter for primary x distances.
private  NumberFormat dxsec
          A formatter for secondary x distances.
private  NumberFormat dyprim
          A formatter for primary y distances.
private  NumberFormat dysec
          A formatter for secondary y distances.
private  Rectangle2D map
          All parameters can be piped into a single rectangle.
private  NumberFormat xprim
          A formatter for primary x coordinates.
private  NumberFormat xsec
          A formatter for secondary x coordinates.
private  NumberFormat yprim
          A formatter for primary y coordinates.
private  NumberFormat ysec
          A formatter for secondary y coordinates.
 
Constructor Summary
BasicMorpher(double xsize, double ysize)
          Constructs a new basic morpher with a given range in x and y direction.
BasicMorpher(double xoff, double yoff, double xsize, double ysize)
          Constructs a new basic morpher with a given range in x and y direction and appropriate offsets for the 0,0 point.
BasicMorpher(Rectangle2D rect)
          Constructs a new basic morpher with the basic conversion rectangle.
 
Method Summary
 String deltaFormatPrimaryX(double dxprimary)
          Formats the x-coordinate difference of a primary x-distance.
 String deltaFormatPrimaryY(double dyprimary)
          Formats the y-coordinate difference of a primary y-distance.
 String deltaFormatSecondaryX(double dxsecondary)
          Formats the x-coordinate difference of a secondary x-distance.
 String deltaFormatSecondaryY(double dysecondary)
          Formats the y-coordinate difference of a secondary y-distance.
 String formatPrimaryX(double xprimary)
          Formats the x-coordinate of a primary x-coordinate.
 String formatPrimaryY(double yprimary)
          Formats the y-coordinate of a primary y-coordinate.
 String formatSecondaryX(double xsecondary)
          Formats the x-coordinate of a secondary x-coordinate.
 String formatSecondaryY(double ysecondary)
          Formats the y-coordinate of a secondary y-coordinate.
 Rectangle2D getDefiningRectangle()
          Returns the defining rectangle of this morpher.
 NumberFormat getFormatPrimaryX()
          Gets the formatter assigned to the primary x coordinate.
 NumberFormat getFormatPrimaryY()
          Changes the default formatting for the primary y coordinate.
 NumberFormat getFormatSecondaryX()
          Changes the default formatting for the secondary x coordinate.
 NumberFormat getFormatSecondaryY()
          Changes the default formatting for the secondary x coordinate.
 void setDeltaFormatPrimaryX(NumberFormat nf)
          Changes the default formatting for the primary x distance.
 void setDeltaFormatPrimaryY(NumberFormat nf)
          Changes the default formatting for the primary y distance.
 void setDeltaFormatSecondaryX(NumberFormat nf)
          Changes the default formatting for the secondary x distance.
 void setDeltaFormatSecondaryY(NumberFormat nf)
          Changes the default formatting for the secondary y distance.
 void setFormatPrimaryX(NumberFormat nf)
          Changes the default formatting for the primary x coordinate.
 void setFormatPrimaryY(NumberFormat nf)
          Changes the default formatting for the primary y coordinate.
 void setFormatSecondaryX(NumberFormat nf)
          Changes the default formatting for the secondary x coordinate.
 void setFormatSecondaryY(NumberFormat nf)
          Changes the default formatting for the secondary x coordinate.
 Point2D toPrimary(Point2D xy)
          We map x/y into pixel coordinates, normalized to a top-left point 0,0 and a plottable size of 1x1.
 Point2D toSecondary(Point2D ab)
          This is the inverse to toPrimary(java.awt.geom.Point2D).
 String toString()
          Returns the parameter that govern this morpher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

map

private Rectangle2D map
All parameters can be piped into a single rectangle.


xprim

private NumberFormat xprim
A formatter for primary x coordinates.


yprim

private NumberFormat yprim
A formatter for primary y coordinates.


xsec

private NumberFormat xsec
A formatter for secondary x coordinates.


ysec

private NumberFormat ysec
A formatter for secondary y coordinates.


dxprim

private NumberFormat dxprim
A formatter for primary x distances.


dyprim

private NumberFormat dyprim
A formatter for primary y distances.


dxsec

private NumberFormat dxsec
A formatter for secondary x distances.


dysec

private NumberFormat dysec
A formatter for secondary y distances.

Constructor Detail

BasicMorpher

public BasicMorpher(double xsize,
                    double ysize)
Constructs a new basic morpher with a given range in x and y direction.


BasicMorpher

public BasicMorpher(double xoff,
                    double yoff,
                    double xsize,
                    double ysize)
Constructs a new basic morpher with a given range in x and y direction and appropriate offsets for the 0,0 point.


BasicMorpher

public BasicMorpher(Rectangle2D rect)
Constructs a new basic morpher with the basic conversion rectangle. The upper left point of the rectangle corresponds to the pixel 0,0. Thus these points are the offset in coordinate-space. The width and height of the rectangle are the extension for a size of 1x1.

Method Detail

toPrimary

public Point2D toPrimary(Point2D xy)
We map x/y into pixel coordinates, normalized to a top-left point 0,0 and a plottable size of 1x1. This is a linear transformation, thus we compute pixel coordinates a,b from x,y via
       a = (x-xoff)/width
       b = (y-yoff)/height,
       
where xoff and yoff are the upper left coordinates of the underlying rectangle, width and height is the size.

Specified by:
toPrimary in interface Morphing
Parameters:
xy - A point in the secondary system.
Returns:
Pixel coordinates.

toSecondary

public Point2D toSecondary(Point2D ab)
This is the inverse to toPrimary(java.awt.geom.Point2D). Here we transform pixel coordinates a/b, which must be normalized to a top-left point 0,0 and a plottable size of 1x1, into x/y of the underlying system.
       x = xoff+width*a
       y = yoff+height*b,
       
where xoff and yoff are the upper left coordinates of the underlying rectangle, width and height is the size.

Specified by:
toSecondary in interface Morphing
Parameters:
ab - The image coordinates.
Returns:
A Point in the secondary system, e.g. ra/dec

getDefiningRectangle

public Rectangle2D getDefiningRectangle()
Returns the defining rectangle of this morpher.


formatSecondaryX

public String formatSecondaryX(double xsecondary)
Formats the x-coordinate of a secondary x-coordinate. Should be called with the Point2D.getX() from the toSecondary(java.awt.geom.Point2D) return.

Specified by:
formatSecondaryX in interface FormattingMorphing
Returns:
A formatted version of the argument.

formatSecondaryY

public String formatSecondaryY(double ysecondary)
Formats the y-coordinate of a secondary y-coordinate. Should be called with the Point2D.getY() from the toSecondary(java.awt.geom.Point2D) return.

Specified by:
formatSecondaryY in interface FormattingMorphing
Returns:
A formatted version of the argument.

formatPrimaryX

public String formatPrimaryX(double xprimary)
Formats the x-coordinate of a primary x-coordinate. Should be called with the Point2D.getX() from the toPrimary(java.awt.geom.Point2D) return.

Specified by:
formatPrimaryX in interface FormattingMorphing
Returns:
A formatted version of the argument.

formatPrimaryY

public String formatPrimaryY(double yprimary)
Formats the y-coordinate of a primary y-coordinate. Should be called with the Point2D.getY() from the toPrimary(java.awt.geom.Point2D) return.

Specified by:
formatPrimaryY in interface FormattingMorphing
Returns:
A formatted version of the argument.

deltaFormatSecondaryX

public String deltaFormatSecondaryX(double dxsecondary)
Formats the x-coordinate difference of a secondary x-distance. Should be called with the Point2D.getX() difference from two toSecondary(java.awt.geom.Point2D) calls.

Specified by:
deltaFormatSecondaryX in interface DeltaFormattingMorphing
Returns:
A formatted version of the argument.

deltaFormatSecondaryY

public String deltaFormatSecondaryY(double dysecondary)
Formats the y-coordinate difference of a secondary y-distance. Should be called with the Point2D.getY() difference from two toPrimary(java.awt.geom.Point2D) calls.

Specified by:
deltaFormatSecondaryY in interface DeltaFormattingMorphing
Returns:
A formatted version of the argument.

deltaFormatPrimaryX

public String deltaFormatPrimaryX(double dxprimary)
Formats the x-coordinate difference of a primary x-distance. Should be called with the Point2D.getX() difference from two toPrimary(java.awt.geom.Point2D) calls.

Specified by:
deltaFormatPrimaryX in interface DeltaFormattingMorphing
Returns:
A formatted version of the argument.

deltaFormatPrimaryY

public String deltaFormatPrimaryY(double dyprimary)
Formats the y-coordinate difference of a primary y-distance. Should be called with the Point2D.getY() difference from two toPrimary(java.awt.geom.Point2D) calls.

Specified by:
deltaFormatPrimaryY in interface DeltaFormattingMorphing
Returns:
A formatted version of the argument.

setFormatPrimaryX

public void setFormatPrimaryX(NumberFormat nf)
Changes the default formatting for the primary x coordinate.


getFormatPrimaryX

public NumberFormat getFormatPrimaryX()
Gets the formatter assigned to the primary x coordinate.


setFormatPrimaryY

public void setFormatPrimaryY(NumberFormat nf)
Changes the default formatting for the primary y coordinate.


getFormatPrimaryY

public NumberFormat getFormatPrimaryY()
Changes the default formatting for the primary y coordinate.


setFormatSecondaryX

public void setFormatSecondaryX(NumberFormat nf)
Changes the default formatting for the secondary x coordinate.


getFormatSecondaryX

public NumberFormat getFormatSecondaryX()
Changes the default formatting for the secondary x coordinate.


setFormatSecondaryY

public void setFormatSecondaryY(NumberFormat nf)
Changes the default formatting for the secondary x coordinate.


getFormatSecondaryY

public NumberFormat getFormatSecondaryY()
Changes the default formatting for the secondary x coordinate.


setDeltaFormatPrimaryX

public void setDeltaFormatPrimaryX(NumberFormat nf)
Changes the default formatting for the primary x distance.


setDeltaFormatPrimaryY

public void setDeltaFormatPrimaryY(NumberFormat nf)
Changes the default formatting for the primary y distance.


setDeltaFormatSecondaryX

public void setDeltaFormatSecondaryX(NumberFormat nf)
Changes the default formatting for the secondary x distance.


setDeltaFormatSecondaryY

public void setDeltaFormatSecondaryY(NumberFormat nf)
Changes the default formatting for the secondary y distance.


toString

public String toString()
Returns the parameter that govern this morpher.

Overrides:
toString in class Object