|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdasher.net.NetDashConnectionHandler
public class NetDashConnectionHandler
Wraps an instance of NetDasher and passes commands to it when asked to by a DasherCommandInterpreterThread.
| Field Summary | |
|---|---|
private NetDasher |
Dasher
Dasher we are wrapping |
private boolean |
destroyed
Flag indicating if this Dasher has been destroyed by the GC thread. |
private long |
lastUsed
System time when this Dasher was last accessed; used to determine if this session is idle by NetDashGC |
private java.util.concurrent.locks.Lock |
myLock
Lock which is set when a thread is operating on this Dasher in some way. |
private NetScreen |
Screen
Screen attached to this Dasher |
private int |
sessID
Session identifier associated with this instance |
| Constructor Summary | |
|---|---|
NetDashConnectionHandler(int sessID,
int width,
int height,
java.lang.String dataLocation,
CAlphIO alphIO,
CColourIO colIO)
Creates and wraps a new instance of NetDasher and creates and registers our helper classes including a NetScreen for output and a NetInput for input. |
|
| Method Summary | |
|---|---|
void |
changeAlphabet(java.lang.String alph)
Changes the alphabet used by our wrapped Dasher. |
void |
changeColours(java.lang.String col)
Changes the colour scheme used by our wrapped Dasher. |
void |
Clicked(int x,
int y,
java.io.OutputStream output)
Reports a mouse click to our hosted Dasher; this should be called by the command interpreter when the client sends a document reporting a click. |
void |
destroy()
Invoked by the garbage collector thread to destory the Interface of our wrapped NetDasher, freeing the vast majority of memory used. |
void |
Draw(java.io.OutputStream output)
Forces Dasher to draw a frame to a given output stream immediately. |
java.util.concurrent.locks.Lock |
getLock()
Retrieves a reference to the Lock used to prevent concurrent modification of this instance of NetDasher. |
int |
getSessID()
Gets the session ID associated with this instance |
void |
HandleEvent(CEditEvent event)
Called by the wrapped NetDasher instance to report an EditEvent because the user has entered or left a node. |
boolean |
isDestroyed()
Reports whether this session has in fact been destroyed by the garbage collector thread; this is to guard against situations where a reference to a collected object has somehow been held. |
boolean |
isIdle()
Uses the lastUsed timestamp held internally to determine whether this session has been idle for 5 minutes or more. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private NetDasher Dasher
private NetScreen Screen
private long lastUsed
private int sessID
private boolean destroyed
private java.util.concurrent.locks.Lock myLock
| Constructor Detail |
|---|
public NetDashConnectionHandler(int sessID,
int width,
int height,
java.lang.String dataLocation,
CAlphIO alphIO,
CColourIO colIO)
sessID - Session identifer associated with this handlerwidth - Screen width to draw forheight - Screen height to draw fordataLocation - Where to look for alphabet and colour XML filesalphIO - AlphIO object holding alphabet datacolIO - ColourIO object holding colour data| Method Detail |
|---|
public void Clicked(int x,
int y,
java.io.OutputStream output)
Internally we pass the co-ordinates on using NetDasher's setCoordinates method, call KeyDown to report a click, set the Screen's OutputStream, and finally calls NewFrame so that a frame is drawn to NetScreen and passes out through the given OutputStream.
Finally, our internal lastUsed field is updated to note the time when the user last interacted with this session.
x - Mouse x co-ordinatey - Mouse y co-ordinateoutput - Stream to which drawn XML will be outputpublic void Draw(java.io.OutputStream output)
There is no need to call this when reporting a mouse-click as a frame will automatically be drawn as part of the process.
Finally, our internal lastUsed field is updated to note the time when the user last interacted with this session.
output - OutputStream to which we should output XMLpublic void HandleEvent(CEditEvent event)
This method just passes it on to the Screen to incorporate into the next frame -- given the timing of EditEvents during the drawing cycle, this will almost certainly be the same as the frame emitted in response to the user interaction which spawned the edit event in the first place, producing the illusion of almost-instantaneous response.
HandleEvent in interface DasherEditListenerevent - Event being reportedpublic boolean isIdle()
public boolean isDestroyed()
Any class which finds itself holding a destroyed reference should behave as if it failed to get the reference in the first place; typically it indicates a session expired whilst a thread was waiting on a lock.
public void destroy()
After destroying an instance, all references to it should be nulled to permit the Java garbage collector to reclaim this wrapper.
public int getSessID()
public java.util.concurrent.locks.Lock getLock()
public void changeAlphabet(java.lang.String alph)
This does not cause drawing automatically; Draw should be called afterwards if this is desired.
alph - Name of new alphabetpublic void changeColours(java.lang.String col)
This does not cause drawing automatically; Draw should be called afterwards if this is desired.
col - Name of new colour scheme
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||