Class InfiniteCanvas

java.lang.Object
  |
  +--uwcse.graphics.GWindow
        |
        +--InfiniteCanvas
Direct Known Subclasses:
BorderedInfiniteCanvas

public class InfiniteCanvas
extends uwcse.graphics.GWindow

An InfiniteCanvas automatically scrolls left so that points can be continually added and displayed. Clients of an InfiniteCanvas need only be concerned about scaling in the y direction. Whenever a shape having an x-value that would fall off the right of the current window on canvas is added, InfiniteCanvas autoscrolls to the left, dropping any unpaintable objects.
This class makes the assumption that x-values are generally increasing (or more specifically, that they do not decrease to a value less than that displayed on the left hand side of the canvas.


Constructor Summary
InfiniteCanvas(java.lang.String name, int width, int height)
          Sole constructor.
 
Method Summary
 boolean add(uwcse.graphics.Shape s)
          Adds a shape to the infinite canvas at the x-coordinate specified by the shape in infinite x-space.
 boolean addToWindow(uwcse.graphics.Shape s)
          Adds the given shape to the window in native window coordinates.
 void fixLabel(java.lang.String s, java.awt.Color c)
          Fixes a label somewhere convenient on the screen.
 int getLeftHandX()
          Gets the x-value associated with the left most visible point.
protected  int getOriginX()
          Computes the x position of the logical origin of the GWindow along x.
 void setLeftHandX(int x)
          Sets the value of left most visible point.
protected  boolean useColumnarLayout()
          Specifies whether to lay labels out in columns or rows.
 
Methods inherited from class uwcse.graphics.GWindow
addEventHandler, display, dispose, doRepaint, erase, getEventHandler, getImage, getImage, getImageFromFilename, getImageFromURL, getWindowHeight, getWindowWidth, intersects, main, moveAllBy, print, remove, resumeRepaints, setExitOnClose, showColorTable, startTimerEvents, stopTimerEvents, suspendRepaints, toString, version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InfiniteCanvas

public InfiniteCanvas(java.lang.String name,
                      int width,
                      int height)
Sole constructor.

Parameters:
name - of the canvas
width - initial width
height - initial height
Method Detail

getLeftHandX

public int getLeftHandX()
Gets the x-value associated with the left most visible point.

Returns:
smallest visible x-value

setLeftHandX

public void setLeftHandX(int x)
Sets the value of left most visible point.

Parameters:
x - value of the left most visible point.

add

public boolean add(uwcse.graphics.Shape s)
Adds a shape to the infinite canvas at the x-coordinate specified by the shape in infinite x-space.

Overrides:
add in class uwcse.graphics.GWindow
Parameters:
s - the shape to be added.
Returns:
true if the shape could be added. otherwise false.

addToWindow

public boolean addToWindow(uwcse.graphics.Shape s)
Adds the given shape to the window in native window coordinates. Useful to clients who understand that we're moving things around

Parameters:
s - shape to add (in true GWindow coordiantes)
Returns:
trueif shape could be added.

useColumnarLayout

protected boolean useColumnarLayout()
Specifies whether to lay labels out in columns or rows.

Returns:
true to use columns, false for rows.

fixLabel

public void fixLabel(java.lang.String s,
                     java.awt.Color c)
Fixes a label somewhere convenient on the screen. A fixed label is always visible, regardless of any scrolling. In general, labels are displayed in columns starting at the right hand side.

Parameters:
s - the label.

getOriginX

protected int getOriginX()
Computes the x position of the logical origin of the GWindow along x.