jimmc.treepar
Class LayoutGraphics

java.lang.Object
  |
  +--jimmc.treepar.LayoutGraphics

public class LayoutGraphics
extends java.lang.Object

LayoutGraphics holds a Graphics object and a transformation between the Layout and the window in which it is being drawn.


Field Summary
protected  java.awt.Graphics graphics
          Our Graphics object.
protected  java.awt.Rectangle layoutBounds
          The bounds of the layout we are drawing.
protected  java.awt.Rectangle windowBounds
          The bounds of the window area we are drawing into.
protected  int xScaleDown
          Denominator of scaling fraction for x.
protected  int xScaleUp
          Numerator of scaling fraction for x.
protected  int xTranslate
          Post-scaling translation for x.
protected  int yScaleDown
          Denominator of scaling fraction for y.
protected  int yScaleUp
          Numerator of scaling fraction for y.
protected  int yTranslate
          Post-scaling translation for y.
 
Constructor Summary
LayoutGraphics(java.awt.Graphics graphics)
          Create a new LayoutGraphics.
 
Method Summary
protected  void calculateTransform()
          Calculate the transformation we use on points to take them from the Layout coordinate system to the window coordinate system.
 void drawBox(java.awt.Point origin, java.awt.Dimension size)
          Draw the outline of a box.
 void drawLine(int x0, int y0, int x1, int y1)
          Draw a line.
 void drawLine(java.awt.Point p0, java.awt.Point p1)
          Draw a line between two points.
 void drawString(java.lang.String text, int x, int y)
          Draw some text.
 void drawString(java.lang.String text, java.awt.Point p)
          Draw some text.
protected  int reverseTransformX(int x)
          Reverse-transform an X value to convert screen coordinates to layout coordinates.
protected  int reverseTransformY(int y)
          Reverse-transform a Y value to convert screen coordinates to layout coordinates.
 void setFont(int lineHeight)
          Set a font to render character the right size.
 void setLayoutBounds(java.awt.Rectangle r)
          Set the bounds of the Layout we are drawing.
 void setWindowBounds(java.awt.Rectangle r)
          Set the bounds of the window into which we are drawing.
 void setWindowSize(java.awt.Dimension d)
          Set the size of the window into which we are drawing.
protected  int transformX(int x)
          Transform an X value through our coordinate transform.
protected  int transformY(int y)
          Transform an Y value through our coordinate transform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graphics

protected java.awt.Graphics graphics
Our Graphics object.

layoutBounds

protected java.awt.Rectangle layoutBounds
The bounds of the layout we are drawing.

windowBounds

protected java.awt.Rectangle windowBounds
The bounds of the window area we are drawing into.

xScaleUp

protected int xScaleUp
Numerator of scaling fraction for x.

xScaleDown

protected int xScaleDown
Denominator of scaling fraction for x.

xTranslate

protected int xTranslate
Post-scaling translation for x.

yScaleUp

protected int yScaleUp
Numerator of scaling fraction for y.

yScaleDown

protected int yScaleDown
Denominator of scaling fraction for y.

yTranslate

protected int yTranslate
Post-scaling translation for y.
Constructor Detail

LayoutGraphics

public LayoutGraphics(java.awt.Graphics graphics)
Create a new LayoutGraphics.
Method Detail

setWindowSize

public void setWindowSize(java.awt.Dimension d)
Set the size of the window into which we are drawing.
Parameters:
sz - the size of the window; we use the whole window for drawing.

setWindowBounds

public void setWindowBounds(java.awt.Rectangle r)
Set the bounds of the window into which we are drawing.
Parameters:
r - the region of the window into which we should draw.

setLayoutBounds

public void setLayoutBounds(java.awt.Rectangle r)
Set the bounds of the Layout we are drawing.
Parameters:
r - the bounds of the layout.

calculateTransform

protected void calculateTransform()
Calculate the transformation we use on points to take them from the Layout coordinate system to the window coordinate system.

setFont

public void setFont(int lineHeight)
Set a font to render character the right size.

transformX

protected int transformX(int x)
Transform an X value through our coordinate transform.

transformY

protected int transformY(int y)
Transform an Y value through our coordinate transform.

reverseTransformX

protected int reverseTransformX(int x)
Reverse-transform an X value to convert screen coordinates to layout coordinates.

reverseTransformY

protected int reverseTransformY(int y)
Reverse-transform a Y value to convert screen coordinates to layout coordinates.

drawLine

public void drawLine(java.awt.Point p0,
                     java.awt.Point p1)
Draw a line between two points.

drawLine

public void drawLine(int x0,
                     int y0,
                     int x1,
                     int y1)
Draw a line.

drawBox

public void drawBox(java.awt.Point origin,
                    java.awt.Dimension size)
Draw the outline of a box.

drawString

public void drawString(java.lang.String text,
                       java.awt.Point p)
Draw some text.

drawString

public void drawString(java.lang.String text,
                       int x,
                       int y)
Draw some text.