org.jscience.architecture.traffic
Class View

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by org.jscience.architecture.traffic.View
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.Observer, javax.accessibility.Accessible, XMLSerializable
Direct Known Subclasses:
MainView

public abstract class View
extends java.awt.Canvas
implements java.util.Observer, XMLSerializable

A View is a graphical representation of an infrastructure.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.image.BufferedImage buffer
          The back buffer
protected  int bufferMinimumOverflow
          Number of pixels the buffer always overflows
protected  int bufferOverflow
          Number of pixels added to viewport for buffer
protected  java.awt.Point bufferPosition
          Position of the buffer in zoomed view coords
protected  java.awt.Dimension bufferSize
          Size of the buffer in pixels
protected  java.awt.geom.AffineTransform bufferTransform
          The transform used to transform coordinates from infra to buffer space
protected  java.awt.Dimension infraSize
          Size of the infrastructure
protected  java.util.LinkedList overlays
          List of all overlays
protected  java.awt.Point viewportPosition
          Position of the viewport in zoomed view coords
protected  java.awt.Dimension viewportSize
          Size of the viewport in pixels
protected  java.awt.Point viewPosition
          Position of this view in the infrastructure in infra coords
protected  java.awt.Dimension viewSize
          Size of this view in in pixels
protected  java.awt.geom.AffineTransform viewTransform
          The transform used to transform coordinates from infra to view space
protected  float zoomFactor
          The current zoom factor
protected  float[] zoomFactors
          A list of all possible zoom factors
protected  int zoomIndex
          The index of the current zoom factor into the zoom factor list
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
View()
          Creates a new View object.
View(java.awt.Dimension infras)
          Creates a new View object.
 
Method Summary
 void addOverlay(Overlay ol)
          Adds an overlay to this view.
protected abstract  void fillBuffer(java.awt.Graphics2D g)
          DOCUMENT ME!
 int getBufferOverflow()
          DOCUMENT ME!
 java.awt.Point getBufferPosition()
          DOCUMENT ME!
 java.awt.Dimension getBufferSize()
          DOCUMENT ME!
 java.awt.Dimension getInfraSize()
          DOCUMENT ME!
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of this view.
 java.awt.Point getViewportPosition()
          DOCUMENT ME!
 java.awt.Dimension getViewportSize()
          DOCUMENT ME!
 java.awt.Point getViewPosition()
          DOCUMENT ME!
 java.awt.Dimension getViewSize()
          DOCUMENT ME!
 java.lang.String getXMLName()
          DOCUMENT ME!
 float getZoomFactor()
          Returns the current zoom factor
 int getZoomIndex()
          Returns the current zoom index
 void load(XMLElement myElement, XMLLoader loader)
          Load this XMLSerializable
 void paint(java.awt.Graphics gr)
          DOCUMENT ME!
protected  void redraw()
          DOCUMENT ME!
 void remOverlay(Overlay ol)
          Removes an overlay from this view.
 void resizeInfra(java.awt.Dimension d)
          Resizes the infrastructure
 void resizeViewport(java.awt.Dimension d)
          Resizes the viewport to the given size
 void saveChilds(XMLSaver saver)
          DOCUMENT ME!
 XMLElement saveSelf()
          DOCUMENT ME!
 void scrollViewport(java.awt.Point p)
          Scrolls the viewport to the specified view point
 void setBufferOverflow(int bo)
          DOCUMENT ME!
 void setBufferPosition(java.awt.Point p)
          DOCUMENT ME!
 void setBufferSize(java.awt.Dimension d)
          DOCUMENT ME!
 void setInfraSize(java.awt.Dimension d)
          DOCUMENT ME!
 void setParentName(java.lang.String parentName)
          DOCUMENT ME!
 void setViewportPosition(java.awt.Point p)
          DOCUMENT ME!
 void setViewportSize(java.awt.Dimension d)
          DOCUMENT ME!
 void setViewPosition(java.awt.Point p)
          DOCUMENT ME!
 void setViewSize(java.awt.Dimension d)
          DOCUMENT ME!
 void setZoomFactor(float z)
          Sets the current zoom factor
 void setZoomIndex(int i)
          Sets the current zoom index
 java.awt.Point toInfra(java.awt.Point p)
          Converts the given point from view to infrastructure coordinate space
 java.awt.Point toView(java.awt.Point p)
          Converts the given point from infrastructure to view coordinate space
 void update(java.awt.Graphics g)
          DOCUMENT ME!
 void update(java.util.Observable o, java.lang.Object arg)
           
 void zoomIn()
          Increases the zoom factor
 void zoomOut()
          Decreases the zoom factor.
 void zoomTo(int index)
          Sets the zoom factor for this View.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buffer

protected java.awt.image.BufferedImage buffer
The back buffer


bufferTransform

protected java.awt.geom.AffineTransform bufferTransform
The transform used to transform coordinates from infra to buffer space


viewTransform

protected java.awt.geom.AffineTransform viewTransform
The transform used to transform coordinates from infra to view space


viewPosition

protected java.awt.Point viewPosition
Position of this view in the infrastructure in infra coords


bufferPosition

protected java.awt.Point bufferPosition
Position of the buffer in zoomed view coords


viewportPosition

protected java.awt.Point viewportPosition
Position of the viewport in zoomed view coords


viewSize

protected java.awt.Dimension viewSize
Size of this view in in pixels


viewportSize

protected java.awt.Dimension viewportSize
Size of the viewport in pixels


bufferSize

protected java.awt.Dimension bufferSize
Size of the buffer in pixels


infraSize

protected java.awt.Dimension infraSize
Size of the infrastructure


bufferOverflow

protected int bufferOverflow
Number of pixels added to viewport for buffer


bufferMinimumOverflow

protected int bufferMinimumOverflow
Number of pixels the buffer always overflows


zoomFactor

protected float zoomFactor
The current zoom factor


zoomFactors

protected final float[] zoomFactors
A list of all possible zoom factors


zoomIndex

protected int zoomIndex
The index of the current zoom factor into the zoom factor list


overlays

protected java.util.LinkedList overlays
List of all overlays

Constructor Detail

View

public View(java.awt.Dimension infras)
Creates a new View object.

Parameters:
infras - DOCUMENT ME!

View

public View()
Creates a new View object.

Method Detail

getZoomFactor

public float getZoomFactor()
Returns the current zoom factor

Returns:
DOCUMENT ME!

setZoomFactor

public void setZoomFactor(float z)
Sets the current zoom factor

Parameters:
z - DOCUMENT ME!

getZoomIndex

public int getZoomIndex()
Returns the current zoom index

Returns:
DOCUMENT ME!

setZoomIndex

public void setZoomIndex(int i)
Sets the current zoom index

Parameters:
i - DOCUMENT ME!

getViewPosition

public java.awt.Point getViewPosition()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setViewPosition

public void setViewPosition(java.awt.Point p)
DOCUMENT ME!

Parameters:
p - DOCUMENT ME!

getViewportPosition

public java.awt.Point getViewportPosition()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setViewportPosition

public void setViewportPosition(java.awt.Point p)
DOCUMENT ME!

Parameters:
p - DOCUMENT ME!

getBufferPosition

public java.awt.Point getBufferPosition()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setBufferPosition

public void setBufferPosition(java.awt.Point p)
DOCUMENT ME!

Parameters:
p - DOCUMENT ME!

getViewSize

public java.awt.Dimension getViewSize()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setViewSize

public void setViewSize(java.awt.Dimension d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!

getViewportSize

public java.awt.Dimension getViewportSize()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setViewportSize

public void setViewportSize(java.awt.Dimension d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!

getBufferSize

public java.awt.Dimension getBufferSize()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setBufferSize

public void setBufferSize(java.awt.Dimension d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!

getInfraSize

public java.awt.Dimension getInfraSize()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setInfraSize

public void setInfraSize(java.awt.Dimension d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!

getBufferOverflow

public int getBufferOverflow()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setBufferOverflow

public void setBufferOverflow(int bo)
DOCUMENT ME!

Parameters:
bo - DOCUMENT ME!

addOverlay

public void addOverlay(Overlay ol)
Adds an overlay to this view. An overlay has one of two types: buffer or view. A buffer overlay is painted directly on the back buffer, a view overlay on the front buffer.

Parameters:
ol - The overlay to add

remOverlay

public void remOverlay(Overlay ol)
Removes an overlay from this view.

Parameters:
ol - The overlay to remove.

zoomIn

public void zoomIn()
Increases the zoom factor


zoomOut

public void zoomOut()
Decreases the zoom factor.


zoomTo

public void zoomTo(int index)
Sets the zoom factor for this View.

Parameters:
index - The index of the new zoom factor.

scrollViewport

public void scrollViewport(java.awt.Point p)
Scrolls the viewport to the specified view point

Parameters:
p - The point in view coordinate space to scroll to

resizeViewport

public void resizeViewport(java.awt.Dimension d)
Resizes the viewport to the given size

Parameters:
d - DOCUMENT ME!

resizeInfra

public void resizeInfra(java.awt.Dimension d)
Resizes the infrastructure

Parameters:
d - DOCUMENT ME!

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

redraw

protected void redraw()
DOCUMENT ME!


fillBuffer

protected abstract void fillBuffer(java.awt.Graphics2D g)
DOCUMENT ME!

Parameters:
g - DOCUMENT ME!

update

public void update(java.awt.Graphics g)
DOCUMENT ME!

Overrides:
update in class java.awt.Canvas
Parameters:
g - DOCUMENT ME!

paint

public void paint(java.awt.Graphics gr)
DOCUMENT ME!

Overrides:
paint in class java.awt.Canvas
Parameters:
gr - DOCUMENT ME!

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of this view. Used by ScrollPane.

Overrides:
getPreferredSize in class java.awt.Component
Returns:
DOCUMENT ME!

load

public void load(XMLElement myElement,
                 XMLLoader loader)
          throws XMLTreeException,
                 java.io.IOException,
                 XMLInvalidInputException
Description copied from interface: XMLSerializable
Load this XMLSerializable

Specified by:
load in interface XMLSerializable
Parameters:
myElement - The XMLElement which represents this object in the XML tree. It can contain attributes which hold information about the object.
loader - The XMLLoader which this XMLSerializable can use to load child objects.
Throws:
XMLTreeException - The parser can throw this exception if it is called by the XMLSerializable. The XMLSerializable should NOT throw this exception by itself and preferrably not catch it too.
java.io.IOException - Thrown in case of an read error in the XML file.
XMLInvalidInputException - The XMLSerializable can throw this exception if it cannot load itself or one of its child objects for whatever reason.

saveSelf

public XMLElement saveSelf()
                    throws XMLCannotSaveException
DOCUMENT ME!

Specified by:
saveSelf in interface XMLSerializable
Returns:
DOCUMENT ME!
Throws:
XMLCannotSaveException - DOCUMENT ME!

saveChilds

public void saveChilds(XMLSaver saver)
                throws XMLTreeException,
                       java.io.IOException,
                       XMLCannotSaveException
DOCUMENT ME!

Specified by:
saveChilds in interface XMLSerializable
Parameters:
saver - DOCUMENT ME!
Throws:
XMLTreeException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
XMLCannotSaveException - DOCUMENT ME!

getXMLName

public java.lang.String getXMLName()
DOCUMENT ME!

Specified by:
getXMLName in interface XMLSerializable
Returns:
DOCUMENT ME!

setParentName

public void setParentName(java.lang.String parentName)
                   throws XMLTreeException
DOCUMENT ME!

Specified by:
setParentName in interface XMLSerializable
Parameters:
parentName - DOCUMENT ME!
Throws:
XMLTreeException - DOCUMENT ME!

toView

public java.awt.Point toView(java.awt.Point p)
Converts the given point from infrastructure to view coordinate space

Parameters:
p - DOCUMENT ME!
Returns:
DOCUMENT ME!

toInfra

public java.awt.Point toInfra(java.awt.Point p)
Converts the given point from view to infrastructure coordinate space

Parameters:
p - DOCUMENT ME!
Returns:
DOCUMENT ME!