equip.city
Class Dub

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--equip.city.Ana
                                |
                                +--equip.city.Dub
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.lang.Runnable, java.io.Serializable

public class Dub
extends Ana
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

applet delivering content for WWW visitors (dub)

this class communicates with the EQUIP City proxy, sending position ($P), orientation ($C) and user ($U) messages, and expecting user positions ($V) and refresh messages ($R) in response (all optional), followed by stop message ($S)

converts pixels to metres (based on applet parameters) and sends position data consistent with ultrasonic positioning messages (alternative would be to transform pixel values server-side)

mouse behaviour is as follows: click moves visitor to clickloc and sets position; orientation is determined from previous mouseup to most recent mouseup; possible extensions are press-drag-release and keypress movement

See Also:
CityProxy, City protocol, Serialized Form

Inner Class Summary
protected  class Dub.Visitor
          encapsulates data received about a visitor
 
Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  float a
          accuracy of our position data
protected  java.awt.image.BufferedImage bi
          offscreen drawing buffer
protected  java.awt.Graphics2D big
          offscreen drawing context
protected  int dragX
          previous mouse x coordinate for drag
protected  int dragY
          previous mouse y coordinate for drag
protected  int head
          room orientation
protected  int lastX
          previous mouse x coordinate for orientation
protected  int lastY
          previous mouse y coordinate for orientation
protected  java.awt.Image map
          background image for display
protected  java.text.MessageFormat mfc
          format for sending orientation to proxy
protected  java.text.MessageFormat mfp
          format for sending position to proxy
protected  java.text.MessageFormat mfv
          format for position received from proxy
protected  int mouseX
          mouse x coordinate
protected  int mouseY
          mouse y coordinate
protected  int offsetX
          positioning reference offset from graphics origin (pixels)
protected  int offsetY
          positioning reference offset from graphics origin (pixels)
protected  float scale
          pixels per meter (parameter is 10x for netscape bug)
protected  int sentH
          last orientation sent to equip
protected  int sentX
          previous mouse x coordinate sent to equip (minimising sending)
protected  int sentY
          previous mouse y coordinate sent to equip (minimising sending)
protected  java.util.Vector visitors
          visitor data received from proxy for display
protected  float z
          (fixed) height value
 
Fields inherited from class equip.city.Ana
contentFrame, DEBUG, device, equip, host, in, initTime, listFrame, mfu, name, out, port, socket, updater
 
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
Dub()
           
 
Method Summary
 void init()
          initialises proxy connection, double buffer, listeners and formatters
 void mouseClicked(java.awt.event.MouseEvent e)
          stores mouse position and updates display
 void mouseDragged(java.awt.event.MouseEvent e)
          does nothing
 void mouseEntered(java.awt.event.MouseEvent e)
          does nothing
 void mouseExited(java.awt.event.MouseEvent e)
          does nothing
 void mouseMoved(java.awt.event.MouseEvent e)
          does nothing
 void mousePressed(java.awt.event.MouseEvent e)
          does nothing
 void mouseReleased(java.awt.event.MouseEvent e)
          does nothing
 void paint(java.awt.Graphics g)
           
 void paintVisitor(int h, int x, int y, java.awt.Color c, java.awt.Graphics2D g2d)
          paints a visitor at (x,y) with orientation h (using AffineTransform) and color c
 void run()
          sends messages, (optionally) receives visitors and refresh from proxy then sleeps for 1000ms
 void update(java.awt.Graphics g)
          draws map and visitors to buffer and then to screen (Graphics2D)
 void updatePosition(java.awt.event.MouseEvent e)
          responds to mouse event by updating position and orientation variables and display
 
Methods inherited from class equip.city.Ana
destroy, elapsedTime, handleRefresh, sendUser, start, stop
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

map

protected java.awt.Image map
background image for display

values (MAP):


bi

protected java.awt.image.BufferedImage bi
offscreen drawing buffer

big

protected java.awt.Graphics2D big
offscreen drawing context

scale

protected float scale
pixels per meter (parameter is 10x for netscape bug)

values (SCALE):


mouseX

protected int mouseX
mouse x coordinate

initial values (XINITIAL):


mouseY

protected int mouseY
mouse y coordinate

initial values (YINITIAL):


offsetX

protected int offsetX
positioning reference offset from graphics origin (pixels)

values (XOFFSET):


offsetY

protected int offsetY
positioning reference offset from graphics origin (pixels)

values (YOFFSET):


sentX

protected int sentX
previous mouse x coordinate sent to equip (minimising sending)

sentY

protected int sentY
previous mouse y coordinate sent to equip (minimising sending)

lastX

protected int lastX
previous mouse x coordinate for orientation

lastY

protected int lastY
previous mouse y coordinate for orientation

dragX

protected int dragX
previous mouse x coordinate for drag

dragY

protected int dragY
previous mouse y coordinate for drag

z

protected float z
(fixed) height value

head

protected int head
room orientation

values (HEADING):


sentH

protected int sentH
last orientation sent to equip

a

protected float a
accuracy of our position data

mfp

protected java.text.MessageFormat mfp
format for sending position to proxy

mfv

protected java.text.MessageFormat mfv
format for position received from proxy

mfc

protected java.text.MessageFormat mfc
format for sending orientation to proxy

visitors

protected java.util.Vector visitors
visitor data received from proxy for display
Constructor Detail

Dub

public Dub()
Method Detail

init

public void init()
initialises proxy connection, double buffer, listeners and formatters
Overrides:
init in class Ana

updatePosition

public void updatePosition(java.awt.event.MouseEvent e)
responds to mouse event by updating position and orientation variables and display
Parameters:
e - mouse event providing x and y for update

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
does nothing
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
does nothing
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
stores mouse position and updates display
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
does nothing
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
does nothing
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
does nothing
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
does nothing
Specified by:
mouseExited in interface java.awt.event.MouseListener

run

public void run()
sends messages, (optionally) receives visitors and refresh from proxy then sleeps for 1000ms
Overrides:
run in class Ana

paintVisitor

public void paintVisitor(int h,
                         int x,
                         int y,
                         java.awt.Color c,
                         java.awt.Graphics2D g2d)
paints a visitor at (x,y) with orientation h (using AffineTransform) and color c
Parameters:
h - visitor orientation (cartesian)
x - visitor x coordinate
y - visitor y coordinate
c - visitor color
g2d - drawing context

update

public void update(java.awt.Graphics g)
draws map and visitors to buffer and then to screen (Graphics2D)
Overrides:
update in class java.awt.Container
Parameters:
g - graphics context for drawing

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Container