net.sourceforge.swtlayeredgraph
Class GCTransformer

java.lang.Object
  extended by net.sourceforge.swtlayeredgraph.GCTransformer
All Implemented Interfaces:
java.io.Serializable

public class GCTransformer
extends java.lang.Object
implements java.io.Serializable

This class provides for applying a coordinate system to a GC object. It provides functions that allow mapping from GC (device) to coordinate system (coordinate) coordinates as well as the reverse. NOTE: All translations are assumed to be given from the coordinate level, not from the device level.

Author:
davija
See Also:
Serialized Form

Field Summary
protected  org.eclipse.swt.graphics.Point dpi
           
protected  SwtGC gc
           
protected  java.lang.Integer height
           
protected  CoordinateType translateCoordinateType
           
protected  java.lang.Integer width
           
protected  java.lang.Double xScaleFactor
           
protected  java.lang.Double xTranslateFactor
           
protected  java.lang.Double yScaleFactor
           
protected  java.lang.Double yTranslateFactor
           
 
Constructor Summary
GCTransformer()
          Default constructor.
GCTransformer(java.lang.Double xScaleFactor, java.lang.Double yScaleFactor, java.lang.Double xTranslateFactor, java.lang.Double yTranslateFactor, CoordinateType translationSystem, java.lang.Integer width, java.lang.Integer height, SwtGC gc)
          Generates a usable transformer.
 
Method Summary
 org.eclipse.swt.graphics.Point coordinate2Device(GraphPoint coordinate)
          Converts from a GraphPoint to local device coordinate (for GC).
 GraphPoint device2Coordinate(java.lang.Integer x, java.lang.Integer y, CoordinateType type)
          Converts a given XY pair and coordinate type to it's correct graph point.
 GraphPoint device2Coordinate(org.eclipse.swt.graphics.Point point, CoordinateType type)
          Converts a given point and coordinate type to it's correct graph point.
 GraphPoint getDPI()
          Gets the transformed DPI for this canvas.
 SwtGC getGC()
          Gets the GC object for this transformer.
 java.lang.Integer getHeight()
           
 CoordinateType getTranslateCoordinateType()
          Gets the type of unit used for translation.
 java.lang.Integer getWidth()
           
 java.lang.Integer getXIncrement(GraphPoint point)
           
 java.lang.Double getXScaleFactor()
          Gets the scale factor for the X axis.
 java.lang.Double getXTranslateFactor()
          Gets the translation factor for the X axis.
 java.lang.Integer getYIncrement(GraphPoint point)
           
 java.lang.Double getYScaleFactor()
          Gets the scale factor for the Y axis.
 java.lang.Double getYTranslateFactor()
          Gets the translation factor for the Y axis.
 void setGC(SwtGC gc)
          Sets the GC object to use as the device.
 void setHeight(java.lang.Integer height)
          Sets the height of the viewable window in pixels.
 void setTranslateCoordinateType(CoordinateType type)
          Sets the coordinate system used for translation.
 void setWidth(java.lang.Integer width)
          Sets the width of the viewable window in pixels.
 void setXScaleFactor(java.lang.Double scaleFactor)
          Sets the scale factor for the X axis.
 void setXTranslateFactor(java.lang.Double translateFactor)
          Sets the translation factor for the X axis.
 void setYScaleFactor(java.lang.Double scaleFactor)
          Sets the scale factor for the Y axis.
 void setYTranslateFactor(java.lang.Double translateFactor)
          Sets the translation factor for the Y axis.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xScaleFactor

protected java.lang.Double xScaleFactor

yScaleFactor

protected java.lang.Double yScaleFactor

xTranslateFactor

protected java.lang.Double xTranslateFactor

yTranslateFactor

protected java.lang.Double yTranslateFactor

translateCoordinateType

protected CoordinateType translateCoordinateType

gc

protected SwtGC gc

width

protected java.lang.Integer width

height

protected java.lang.Integer height

dpi

protected org.eclipse.swt.graphics.Point dpi
Constructor Detail

GCTransformer

public GCTransformer()
Default constructor.


GCTransformer

public GCTransformer(java.lang.Double xScaleFactor,
                     java.lang.Double yScaleFactor,
                     java.lang.Double xTranslateFactor,
                     java.lang.Double yTranslateFactor,
                     CoordinateType translationSystem,
                     java.lang.Integer width,
                     java.lang.Integer height,
                     SwtGC gc)
Generates a usable transformer.

Parameters:
xScaleFactor - Scale factor for the X axis.
yScaleFactor - Scale factor for the Y axis.
xTranslateFactor - Translation factor for the X axis.
yTranslateFactor - Translation factor for the Y axis.
translationSystem - The coordinate system the translation is in.
width - The width of the viewable window
height - The height of the viewable window.
gc - The GC proxy object to use as the device system.
Method Detail

coordinate2Device

public org.eclipse.swt.graphics.Point coordinate2Device(GraphPoint coordinate)
Converts from a GraphPoint to local device coordinate (for GC).

Parameters:
coordinate - GraphPoint to convert.
Returns:
Returns a Point that is converted to local device points.

device2Coordinate

public GraphPoint device2Coordinate(java.lang.Integer x,
                                    java.lang.Integer y,
                                    CoordinateType type)
Converts a given XY pair and coordinate type to it's correct graph point.

Parameters:
x - The X coordinate value.
y - The Y coordinate value.
type - The coordinate type to use.
Returns:
Returns a GraphPoint converted from the specified gc.

device2Coordinate

public GraphPoint device2Coordinate(org.eclipse.swt.graphics.Point point,
                                    CoordinateType type)
Converts a given point and coordinate type to it's correct graph point.

Parameters:
point - The point to convert from.
type - The coordinate type to use.
Returns:
Returns a GraphPoint converted from the specified gc.

getGC

public SwtGC getGC()
Gets the GC object for this transformer.

Returns:
Returns the GC object for this transformer.

getHeight

public java.lang.Integer getHeight()

getTranslateCoordinateType

public CoordinateType getTranslateCoordinateType()
Gets the type of unit used for translation.

Returns:
Returns the type of unit used for translation.

getWidth

public java.lang.Integer getWidth()

getXIncrement

public java.lang.Integer getXIncrement(GraphPoint point)

getXScaleFactor

public java.lang.Double getXScaleFactor()
Gets the scale factor for the X axis.

Returns:
the xScaleFactor

getXTranslateFactor

public java.lang.Double getXTranslateFactor()
Gets the translation factor for the X axis.

Returns:
the xTranslateFactor

getYIncrement

public java.lang.Integer getYIncrement(GraphPoint point)

getYScaleFactor

public java.lang.Double getYScaleFactor()
Gets the scale factor for the Y axis.

Returns:
the yScaleFactor

getYTranslateFactor

public java.lang.Double getYTranslateFactor()
Gets the translation factor for the Y axis.

Returns:
the yTranslateFactor

setGC

public void setGC(SwtGC gc)
Sets the GC object to use as the device.

Parameters:
gc - The gc proxy to use for the device. Cannot be null.

setHeight

public void setHeight(java.lang.Integer height)
Sets the height of the viewable window in pixels.

Parameters:
height - Number of vertical viewable pixels.

setTranslateCoordinateType

public void setTranslateCoordinateType(CoordinateType type)
Sets the coordinate system used for translation.

Parameters:
type - The type of coordinate system used for translation.

setWidth

public void setWidth(java.lang.Integer width)
Sets the width of the viewable window in pixels.

Parameters:
width - Number of horizontal viewable pixels.

setXScaleFactor

public void setXScaleFactor(java.lang.Double scaleFactor)
Sets the scale factor for the X axis.

Parameters:
scaleFactor - the xScaleFactor to set

setXTranslateFactor

public void setXTranslateFactor(java.lang.Double translateFactor)
Sets the translation factor for the X axis.

Parameters:
translateFactor - the xTranslateFactor to set

setYScaleFactor

public void setYScaleFactor(java.lang.Double scaleFactor)
Sets the scale factor for the Y axis.

Parameters:
scaleFactor - the yScaleFactor to set

setYTranslateFactor

public void setYTranslateFactor(java.lang.Double translateFactor)
Sets the translation factor for the Y axis.

Parameters:
translateFactor - the yTranslateFactor to set

getDPI

public GraphPoint getDPI()
Gets the transformed DPI for this canvas.

Returns:
Returns the transformed DPI for this canvas.


Copyright © 2009. All Rights Reserved.