sub_arctic.lib
Class interactor_canvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--sub_arctic.lib.interactor_canvas

public class interactor_canvas
extends java.awt.Canvas

This is the "glue" which will stick a sub_arctic interface inside an AWT interface. You can put a sub_arctic top_level inside this object with set_top_level and you are in business.

You have to provide a size for this object when you create it. If you would like to derive a size from your sub_arctic interface, use interactor_canvas.size_from_top_level().

See Also:
Serialized Form

Field Summary
protected  int _forced_height
          The height part of the size the user sets.
protected  int _forced_width
          The width part of the size the user sets.
protected  top_level _top_interactor
          This holds the top_level which is sitting inside this component.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
interactor_canvas(int width, int height)
          Constructor an interactor_canvas.
 
Method Summary
 void finalize()
          Clean up when we are about to go away.
 java.awt.Dimension minimumSize()
          This function is part of the AWT world.
 void paint(java.awt.Graphics g)
          This is the redraw part of the AWT interface.
 java.awt.Dimension preferredSize()
          This function is part of the AWT world.
 void processEvent(java.awt.AWTEvent e)
          This is where we catch the AWT events and turn them into SubArctic events.
 void remove_top_interactor()
          Remove the top_level from being used by this canvas.
 void set_top_interactor(top_level top)
          Set the top_level associated with this canvas.
 void setBounds(int x, int y, int width, int height)
          We override reshape to catch size changes and propagate those to top level interactor.
static java.awt.Dimension size_from_top_level(top_level tl)
          From a toplevel, determine a dimension.
 top_level top_interactor()
          Access the top_level inside this component.
 void update(java.awt.Graphics g)
          This is the redraw part of the AWT interface.
 
Methods inherited from class java.awt.Canvas
addNotify
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_forced_width

protected int _forced_width
The width part of the size the user sets.

_forced_height

protected int _forced_height
The height part of the size the user sets.

_top_interactor

protected top_level _top_interactor
This holds the top_level which is sitting inside this component.
Constructor Detail

interactor_canvas

public interactor_canvas(int width,
                         int height)
Constructor an interactor_canvas. This registers the component with the manager.
Parameters:
int - width the width of the canvas
int - height the height of the canvas
Method Detail

finalize

public void finalize()
Clean up when we are about to go away. This unregisters the component with the manager.
Overrides:
finalize in class java.lang.Object

top_interactor

public top_level top_interactor()
Access the top_level inside this component.
Returns:
top_level the top_level of this canvas

set_top_interactor

public void set_top_interactor(top_level top)
Set the top_level associated with this canvas.
Parameters:
top_level - top the new top_level for this canvas.

remove_top_interactor

public void remove_top_interactor()
Remove the top_level from being used by this canvas. This will leave this canvas with no top_level associated with it.

update

public void update(java.awt.Graphics g)
This is the redraw part of the AWT interface. This function begins the drawing traversal of the sub_arctic interface.
Parameters:
Graphics - g the graphics object to do the drawing on.
Overrides:
update in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
This is the redraw part of the AWT interface. This function begins the drawing traversal of the sub_arctic interface. This really should never get called (update() should be called instead), but apparently Netscape calls it direct in certain cases, so we just do the same as update (we don't just call update() since in the superclass update() calls paint(), and update() can call super.update()).
Parameters:
Graphics - g the graphics object to do the drawing on.
Overrides:
paint in class java.awt.Canvas

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
We override reshape to catch size changes and propagate those to top level interactor. Thus, the top_level always is the same size and shape as the surrounding component (this canvas).
Parameters:
int - x the new X position of the object
int - y the new Y position of the object
int - w the new width of the object
int - h the new height of the object
Overrides:
setBounds in class java.awt.Component

processEvent

public void processEvent(java.awt.AWTEvent e)
This is where we catch the AWT events and turn them into SubArctic events.
Overrides:
processEvent in class java.awt.Component

preferredSize

public java.awt.Dimension preferredSize()
This function is part of the AWT world. It is supposed to be called by layout manager's to ask us how big we would like to be. We just tell it our minimum size. Its not clear when, where, why, or if this function will actually be called by a layout manager. If you put an interactor_canvas in a frame it clearly is not called.
Returns:
Dimension the dimensions we prefer for this canvas
Overrides:
preferredSize in class java.awt.Component

minimumSize

public java.awt.Dimension minimumSize()
This function is part of the AWT world. It is supposed to be called by layout manager's to ask how what the minimal amount of screen space we can live with is.We return the size that the user initially gave us when this object was created. Its not clear when, where, why, or if this function will actually be called by a layout manager. If you put an interactor_canvas in a frame it clearly is not called.
Returns:
Dimension the minimum dimension we can live with
Overrides:
minimumSize in class java.awt.Component

size_from_top_level

public static java.awt.Dimension size_from_top_level(top_level tl)
From a toplevel, determine a dimension. This can be used for sizing a canvas (or frame) to your toplevel's size. This is especially useful for inside-out layouts. Note: If you use this function and your toplevel has constraints on it, they will be removed. This is because toplevel's sizes are connected (directly) to the canvas/applet in which they live. Thus, if the user resized your window, they would get an error for assigning to a constrained value. Thus, you can look at constraints on a top_level as a "one-shot" deal; use them to calculate your interface's initial size and then they go away.
Parameters:
top_level - tl the top_level whose size you want
Returns:
Dimension the size (width/height) of this canvas.