Class BorderedInfiniteCanvas

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

public class BorderedInfiniteCanvas
extends InfiniteCanvas

A BorderedInfiniteCanvas provides an infinitely extending X Canvas that includes borders on the left and bottom. Unknowing clients of this see a GWindow that occupies only part of an actual GWindow (bordered space), and paint in infinite canvas coordinates (unlimited x). Knowing clients can paint items into the border if they like (unbordered space) and do so in GWindow space (limited x).


Constructor Summary
BorderedInfiniteCanvas(java.lang.String name, int width, int height)
          Constructs using default left and bottom border size.
BorderedInfiniteCanvas(java.lang.String name, int width, int height, int leftBorderSz, int bottomBorderSz)
          Constructs as above, but also using specified border sizes.
 
Method Summary
 boolean add(uwcse.graphics.Shape s)
          Adds the specified into the bordered space
protected  boolean addToBorderedSpace(uwcse.graphics.Shape s)
          Adds given shape to enclosed bordered space.
 boolean addToUnborderedSpace(uwcse.graphics.Shape s)
          Adds the given shape to the set of shapes drawn in the borders.
 void cleanBorders()
          Wipes clean anything in the borders and refills with current color.
protected  void clearBorders()
          Wipes clean anything in the borders.
 uwcse.graphics.Line drawBottomBorder()
          Draws the bottom border on the screen.
 uwcse.graphics.Line drawLeftBorder()
          Draws the left border on the screen.
protected  void fillBorders()
          Fills the borders according to the current border color.
protected  void fillBorders(java.awt.Color c)
          Fills the borders according to the given color.
 int getBottomBorderWidth()
          Gets the size of the bottom border.
 int getLeftBorderWidth()
          Gets the size of the left border.
protected  int getOriginX()
          Computes the x position of the logical origin of the GWindow along x.
protected  int getUnborderedWindowHeight()
          Finds the true window height, accounting for borders.
protected  int getUnborderedWindowWidth()
          Finds the true window width, accounting for borders.
 int getWindowHeight()
          Gets the window height not counting the bottom bordered space.
 int getWindowWidth()
          Gets the window width not counting the left bordered space.
protected  boolean insideBottomBorder(int y)
          Determines if a given y value is in the bottom border
protected  boolean insideLeftBorder(int x)
          Determines if a given x value is in the left hand border
 void moveAllBy(int x, int y)
          Moves to a position in bordered infinite /** Moves all of the items in bordered space while leaving unbordered space untouched.
protected  void moveBordersBy(int x, int y)
          Adjusts the position of the borders and their contents.
protected  boolean outsideBorderedSpace(int x, int y)
          Determines if a given position is beyond the borders.
 boolean remove(uwcse.graphics.Shape s)
           
 boolean removeFromUnborderedSpace(uwcse.graphics.Shape s)
          Removes a given shape which has been draw in the borders.
 
Methods inherited from class InfiniteCanvas
addToWindow, fixLabel, getLeftHandX, setLeftHandX, useColumnarLayout
 
Methods inherited from class uwcse.graphics.GWindow
addEventHandler, display, dispose, doRepaint, erase, getEventHandler, getImage, getImage, getImageFromFilename, getImageFromURL, intersects, main, print, 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

BorderedInfiniteCanvas

public BorderedInfiniteCanvas(java.lang.String name,
                              int width,
                              int height)
Constructs using default left and bottom border size.

Parameters:
name - canvas name
width - width of canvas in pixels
height - of canvas in pixels

BorderedInfiniteCanvas

public BorderedInfiniteCanvas(java.lang.String name,
                              int width,
                              int height,
                              int leftBorderSz,
                              int bottomBorderSz)
Constructs as above, but also using specified border sizes.

Parameters:
name - canvas name
width - width of canvas in pixels
height - of canvas in pixels
leftBorderSz - size of left border
bottomBorderSz - size of right border
Method Detail

add

public boolean add(uwcse.graphics.Shape s)
Adds the specified into the bordered space

Overrides:
add in class InfiniteCanvas
Parameters:
s - shape to be added (in infinite canvas coordinates)
Returns:
true if successful, falseotherwise.

moveAllBy

public void moveAllBy(int x,
                      int y)
Moves to a position in bordered infinite /** Moves all of the items in bordered space while leaving unbordered space untouched.

Overrides:
moveAllBy in class uwcse.graphics.GWindow

remove

public boolean remove(uwcse.graphics.Shape s)
Overrides:
remove in class uwcse.graphics.GWindow

getWindowWidth

public int getWindowWidth()
Gets the window width not counting the left bordered space.

Overrides:
getWindowWidth in class uwcse.graphics.GWindow

getWindowHeight

public int getWindowHeight()
Gets the window height not counting the bottom bordered space.

Overrides:
getWindowHeight in class uwcse.graphics.GWindow

getUnborderedWindowWidth

protected int getUnborderedWindowWidth()
Finds the true window width, accounting for borders.

Returns:
true window width, including border.

getUnborderedWindowHeight

protected int getUnborderedWindowHeight()
Finds the true window height, accounting for borders.

Returns:
true window height, including border.

getLeftBorderWidth

public int getLeftBorderWidth()
Gets the size of the left border.

Returns:
left border width in pixels

getOriginX

protected int getOriginX()
Description copied from class: InfiniteCanvas
Computes the x position of the logical origin of the GWindow along x.

Overrides:
getOriginX in class InfiniteCanvas

getBottomBorderWidth

public int getBottomBorderWidth()
Gets the size of the bottom border.

Returns:
bottom border width in pixels

outsideBorderedSpace

protected boolean outsideBorderedSpace(int x,
                                       int y)
Determines if a given position is beyond the borders.

Parameters:
x - position (in infinite coordinates)
y - position
Returns:
true if beyond the borders

insideLeftBorder

protected boolean insideLeftBorder(int x)
Determines if a given x value is in the left hand border

Parameters:
x - position (in infinite coordinates)
Returns:
true if in left border.

insideBottomBorder

protected boolean insideBottomBorder(int y)
Determines if a given y value is in the bottom border

Parameters:
y - position (in infinite coordinates)
Returns:
true if in bottom border.

drawLeftBorder

public uwcse.graphics.Line drawLeftBorder()
Draws the left border on the screen.

Returns:
the line which is the left border marker.

drawBottomBorder

public uwcse.graphics.Line drawBottomBorder()
Draws the bottom border on the screen.

Returns:
the line which is the bottom border marker.

addToUnborderedSpace

public boolean addToUnborderedSpace(uwcse.graphics.Shape s)
Adds the given shape to the set of shapes drawn in the borders.

Parameters:
s - the shape
Returns:
true if the shape could be added.

removeFromUnborderedSpace

public boolean removeFromUnborderedSpace(uwcse.graphics.Shape s)
Removes a given shape which has been draw in the borders.

Parameters:
s - shape
Returns:
true if the shape could be removed.

addToBorderedSpace

protected boolean addToBorderedSpace(uwcse.graphics.Shape s)
Adds given shape to enclosed bordered space.

Parameters:
s - shape to be added, expressed in infinite coordinates.
Returns:
true if successful.

fillBorders

protected void fillBorders()
Fills the borders according to the current border color.


fillBorders

protected void fillBorders(java.awt.Color c)
Fills the borders according to the given color. As a side effect, sets the default fill color.

Parameters:
c - color to fill with, becomes default color for next fill.

cleanBorders

public void cleanBorders()
Wipes clean anything in the borders and refills with current color.


clearBorders

protected void clearBorders()
Wipes clean anything in the borders.


moveBordersBy

protected void moveBordersBy(int x,
                             int y)
Adjusts the position of the borders and their contents. Counteracts a moveAllBy applied to the entire canvas.

Parameters:
x - amount to move in the x direction
y - amount to move in the y direction