Babylon Java Chat

Class BabylonImageTransfer

java.lang.Object
  extended by java.lang.Thread
      extended by BabylonImageTransfer
All Implemented Interfaces:
java.lang.Runnable

public class BabylonImageTransfer
extends java.lang.Thread

A class for transferring canvas images by the client or server as a separate thread. The benefit here being that the data can be sent in atomic blocks instead of one large command. This is also necessary for large images because as of protocol 2.2, connections will terminate if new commands are not received for a few seconds, and a large image from the 2.1 protocol can monopolize the stream for a considerable time.

Author:
Andy McLaughlin

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected static int DEFAULT_BLOCKSIZE
           
protected  int fromId
           
protected  boolean gotAll
           
protected  java.lang.String imageName
           
protected  boolean priv
           
protected  boolean stop
           
protected  short xCoord
           
protected  short yCoord
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BabylonImageTransfer(int f, java.lang.String n, short x, short y, int ts, int tb, int bs, java.util.Vector tc, int[] r, BabylonPanel p, BabylonProgressDialog pd)
           
 
Method Summary
protected  byte[] getImageAll()
          Get the whole image as a single byte array.
protected  void putImageAll(byte[] data)
          Store the whole image, broken up into blocks.
protected  void putImageBlock(int blockNumber, byte[] data)
          Store the requested block.
 void run()
          Sends image data out to any recipients when it has all been collected, and if we are a client receiving the image, paste it onto the canvas.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_BLOCKSIZE

protected static final int DEFAULT_BLOCKSIZE
See Also:
Constant Field Values

fromId

protected int fromId

imageName

protected java.lang.String imageName

xCoord

protected short xCoord

yCoord

protected short yCoord

stop

protected boolean stop

gotAll

protected boolean gotAll

priv

protected boolean priv
Constructor Detail

BabylonImageTransfer

public BabylonImageTransfer(int f,
                            java.lang.String n,
                            short x,
                            short y,
                            int ts,
                            int tb,
                            int bs,
                            java.util.Vector tc,
                            int[] r,
                            BabylonPanel p,
                            BabylonProgressDialog pd)
Method Detail

run

public void run()
Sends image data out to any recipients when it has all been collected, and if we are a client receiving the image, paste it onto the canvas.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

putImageBlock

protected void putImageBlock(int blockNumber,
                             byte[] data)
                      throws java.lang.IndexOutOfBoundsException
Store the requested block.

Throws:
java.lang.IndexOutOfBoundsException

putImageAll

protected void putImageAll(byte[] data)
Store the whole image, broken up into blocks.


getImageAll

protected byte[] getImageAll()
                      throws java.lang.IndexOutOfBoundsException
Get the whole image as a single byte array.

Throws:
java.lang.IndexOutOfBoundsException

Babylon Java Chat