jview
Class BasicTransform

java.lang.Object
  extended by jview.AbstractFormattingTransform
      extended by jview.BasicTransform
All Implemented Interfaces:
CoordinateTransforming, DeltaFormattedTransforming, DeltaTransforming, FormattedTransforming, InvertableTransforming
Direct Known Subclasses:
SelectTransform

public class BasicTransform
extends AbstractFormattingTransform
implements CoordinateTransforming, DeltaTransforming, InvertableTransforming

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  double ax
          For logarithmic means, we pre-calculate this.
private  double axf
          For logarithmic means, we pre-calculate this.
private  double ay
          For logarithmic means, we pre-calculate this.
private  double ayf
          For logarithmic means, we pre-calculate this.
private  double kx
          For logarithmic means, we pre-calculate this.
private  double ky
          For logarithmic means, we pre-calculate this.
private  Rectangle2D map
          All parameters can be piped into a single rectangle.
private  boolean xdate
          If true, x scale is a date in ms.
private  boolean xflip
          If true, x-values are flipped.
private  boolean xlog
          If true, x scales logarithmic.
private  boolean ydate
          If true, y scale is a date in ms.
private  boolean yflip
          If true, y-values are flipped (thus showing a mathematical system).
private  boolean ylog
          If true, y scales logarithmic.
 
Constructor Summary
BasicTransform(double xsize, double ysize)
          Constructs a new basic morpher with a given range in x and y direction.
BasicTransform(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.
BasicTransform(Rectangle2D rect)
          Constructs a new basic morpher with the basic conversion rectangle.
 
Method Summary
private  Format deduceFormat(double size, boolean date)
          From a given size, we try to deduce a good format.
 Format estimateX(double xstep)
          Tries to approximate an formatter for x, giving a typical length scale.
 Format estimateY(double ystep)
          Tries to approximate an formatter for x, giving a typical length scale.
 Rectangle2D getDefiningRectangle()
          Returns the defining rectangle of this morpher.
 Point2D invertUserXY(Vector2D xy)
          Invertable transform means the x coordinate in the argument translates to an x in normalized coordinates.
 boolean setDateX(boolean date)
          Sets the x-scale to transform dates.
 boolean setDateY(boolean date)
          Sets the y-scale to transform dates.
 boolean setFlipX(boolean flip)
          Sets the flip state in the x coordinate.
 boolean setFlipY(boolean flip)
          Sets the flip state in the y coordinate.
 boolean setLogarithmicX(boolean log)
          Sets the x-scale to transform logarithmically.
 boolean setLogarithmicY(boolean log)
          Sets the y-scale to transform logarithmically.
 Point2D toNormalizedDistance(VectorG ignore, VectorG delta)
          In the this simple case, a delta transformation is simply scaled by the boxing rectangle size.
 Point2D toNormalizedSpace(VectorG xy)
          We map x/y into pixel coordinates, normalized to a top-left point 0,0 and a plottable size of 1x1.
 String toString()
          Returns the parameter that govern this morpher.
 VectorG toUserDistance(Rectangle2D delta)
          In the this simple case, a delta transformation is simply scaled by the boxing rectangle size.
 VectorG toUserSpace(Point2D ab)
          This is the inverse to toNormalizedSpace(vec_math.VectorG).
 void useEstimatedFormats(Rectangle2D view, int xp, int yp)
          Estimates the decimal formatter to use on the axis.
 
Methods inherited from class jview.AbstractFormattingTransform
deltaFormatUserSpaceX, deltaFormatUserSpaceY, formatUserCoordinates, formatUserSpaceX, formatUserSpaceY, getFormatUserX, getFormatUserY, setDeltaFormatUserX, setDeltaFormatUserY, setFormatUserX, setFormatUserY
 
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.


kx

private double kx
For logarithmic means, we pre-calculate this.


ky

private double ky
For logarithmic means, we pre-calculate this.


ax

private double ax
For logarithmic means, we pre-calculate this.


ay

private double ay
For logarithmic means, we pre-calculate this.


axf

private double axf
For logarithmic means, we pre-calculate this.


ayf

private double ayf
For logarithmic means, we pre-calculate this.


xflip

private boolean xflip
If true, x-values are flipped.


yflip

private boolean yflip
If true, y-values are flipped (thus showing a mathematical system).


xlog

private boolean xlog
If true, x scales logarithmic.


ylog

private boolean ylog
If true, y scales logarithmic.


xdate

private boolean xdate
If true, x scale is a date in ms.


ydate

private boolean ydate
If true, y scale is a date in ms.

Constructor Detail

BasicTransform

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


BasicTransform

public BasicTransform(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.


BasicTransform

public BasicTransform(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

setFlipX

public boolean setFlipX(boolean flip)
Sets the flip state in the x coordinate.


setFlipY

public boolean setFlipY(boolean flip)
Sets the flip state in the y coordinate.


setLogarithmicX

public boolean setLogarithmicX(boolean log)
Sets the x-scale to transform logarithmically.


setLogarithmicY

public boolean setLogarithmicY(boolean log)
Sets the y-scale to transform logarithmically.


setDateX

public boolean setDateX(boolean date)
Sets the x-scale to transform dates.


setDateY

public boolean setDateY(boolean date)
Sets the y-scale to transform dates.


invertUserXY

public Point2D invertUserXY(Vector2D xy)
Invertable transform means the x coordinate in the argument translates to an x in normalized coordinates. We simply call toNormalizedSpace(vec_math.VectorG) here.

Specified by:
invertUserXY in interface InvertableTransforming

toNormalizedSpace

public Point2D toNormalizedSpace(VectorG 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:
toNormalizedSpace in interface CoordinateTransforming
Parameters:
xy - A vector of user coordinates.
Returns:
A point in normalized screen coordinate, with 0≤x,y≤1

toUserSpace

public VectorG toUserSpace(Point2D ab)
This is the inverse to toNormalizedSpace(vec_math.VectorG). 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:
toUserSpace in interface CoordinateTransforming
Parameters:
ab - A pixel in normalized coordinates.
Returns:
A vector in user space, never null

toUserDistance

public VectorG toUserDistance(Rectangle2D delta)
In the this simple case, a delta transformation is simply scaled by the boxing rectangle size.

Specified by:
toUserDistance in interface DeltaTransforming

toNormalizedDistance

public Point2D toNormalizedDistance(VectorG ignore,
                                    VectorG delta)
In the this simple case, a delta transformation is simply scaled by the boxing rectangle size.

Specified by:
toNormalizedDistance in interface DeltaTransforming

useEstimatedFormats

public void useEstimatedFormats(Rectangle2D view,
                                int xp,
                                int yp)
Estimates the decimal formatter to use on the axis.

Specified by:
useEstimatedFormats in interface FormattedTransforming
Overrides:
useEstimatedFormats in class AbstractFormattingTransform

estimateX

public Format estimateX(double xstep)
Tries to approximate an formatter for x, giving a typical length scale.

Specified by:
estimateX in interface FormattedTransforming

estimateY

public Format estimateY(double ystep)
Tries to approximate an formatter for x, giving a typical length scale.

Specified by:
estimateY in interface FormattedTransforming

getDefiningRectangle

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


toString

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

Overrides:
toString in class Object

deduceFormat

private Format deduceFormat(double size,
                            boolean date)
From a given size, we try to deduce a good format.