simulator
Class Client

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--simulator.Client

abstract class Client
extends java.applet.Applet

This is an abstract class that performe the basic function of a client applet. You must derive this class and implement your personal function. It's important know that your applet and the vrml view must be in the same page to work correct, so the html page will be like this:


  <HTML>
  <HEAD>
  <TITLE>Client Applet
  </HEAD>

  <BODY>
  <EMBED SRC="World.wrl" WIDTH=400 HEIGHT=300 NAME="wrl">
  <APPLET code="MyClient.class" width=511 height=377 MAYSCRIPT>
  <PARAM name=port value=6472>
  <PARAM name=host value=localhost>
  <PARAM name=showRoundTrip value=false>
  </APPLET>
  </BODY>
 

The World.wrl vrml file will be like this:

  #VRML V2.0 utf8

  DEF World Group {
    children [
      Viewpoint {
        position 10 30 -10
        orientation 1 0 0 -1.5707
        description "Up View"
      },
      Viewpoint {
        position 10,5,10
        description "Front View"
      },
      DEF Room Group {
        children [
          Transform {
            translation 10,0.005,-10
            children [
              DEF Floor Shape {
                geometry Box {
                  size 20,.01,20
                }
              }
            ]
          }
        ]
      }
    ]
  }
 

In this examples was create a world containing a room and a shape, and two viepoints. You can create all you need using the vrml syntax, but the DEF world Group { must be present for the correct use of the program.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
static java.lang.String about
          This contains an text that shows who has create the client.
(package private)  vrml.external.Browser browser
          Contains the instance to the Browser class.
static java.lang.String DEFAULT_HOST
           
static int DEFAULT_PORT
           
static boolean DEFAULT_SHOWROUNDTRIP
           
protected  java.lang.String host
          This is the string that contains the host information
static java.util.Random idGen
          Create a new random number generator.
protected  int istance_ID
          The identifier ID of current instance
protected  Listener listener
          Contains the instance of Listener class
static int MAX_CHARS
          Max number of char that the TextArea may contain.
protected  int maxChars
           
(package private)  java.util.Hashtable nodesList
          Contains a list of vrml nodes add to the VRML browser
protected  int port
          Contains the port number used by the socket
protected  java.lang.String remote_name
          Contains the information like 'login@machine'
protected  java.net.Socket s
          Contains the socket to comunicate with the server
(package private)  java.awt.Checkbox showRoundTripCheck
          This is the control to choose if you want to show the RTT.
protected  boolean showRoundTripInitial
          Indicate if a RTT will be visible
protected  java.util.Hashtable tableMFNode
          Contains the tokens available for MFNode VRML field
protected  java.util.Hashtable tableSFBool
          Contains the tokens available for SFBool VRML field
protected  java.util.Hashtable tableSFColor
          Contains the tokens available for SFColor VRML field
protected  java.util.Hashtable tableSFFloat
          Contains the tokens available for SFFloat VRML field
protected  java.util.Hashtable tableSFInt32
          Contains the tokens available for SFInt32 VRML field
protected  java.util.Hashtable tableSFNode
          Contains the tokens available for SFNode VRML field
protected  java.util.Hashtable tableSFRotation
          Contains the tokens available for SFRotation VRML field
protected  java.util.Hashtable tableSFTime
          Contains the tokens available for SFTime VRML field
protected  java.util.Hashtable tableSFVec2f
          Contains the tokens available for SFVec2f VRML field
protected  java.util.Hashtable tableSFVec3f
          Contains the tokens available for SFVec3F VRML field
(package private)  java.awt.Label typePrompt
          This Label is used with the TextField and it used only by graphicAppletInit method.
protected  Typist typist
          Contains the instance of Typist class
(package private)  java.awt.TextArea winAll
          This is the area used to write the information that the server send us.
(package private)  java.awt.TextField winLocal
          This is the control used to insert information to send to the server.
 
Fields inherited from class java.applet.Applet
serialVersionUID, stub
 
Fields inherited from class java.awt.Panel
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
(package private) Client()
           
 
Method Summary
protected  void buildFieldTable()
          Builds the tables used to find rapidally if a field is of VRML type
 void cleanUp()
          Clean all the active processes before exiting
 void destroy()
          destroy()
 void finalize()
          finalize()
 java.lang.String getAppletInfo()
          return the information about the autor of the client
 java.lang.String[][] getParameterInfo()
          Specify the type of parameter that the applet want
 void graphAppletInit()
          Initilize graphic object in the applet.
 void init()
          Initialize the applet.
 void insertText(java.lang.String t)
          Insert a text in the applet text window and resize it if buffer length is over maxChars chars.
 boolean keyUp(java.awt.Event e, int key)
          If RETURN key was pressed, the contents of TextArea is send to the server.
 void paint(java.awt.Graphics g)
          Draw a graphics message about server connection not available
 void runCommand(java.lang.String s)
          Parse a string command send by server for executing some commands to the virtual world and to the relative structures.
 void start()
          this method activate a connection with the server, then initilize the graph of the applet and last activate the threads Listener and Typist
 void stop()
          This is called by the applet when it stops
 
Methods inherited from class java.applet.Applet
getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printOneComponent, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, update, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, 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, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

about

public static java.lang.String about
This contains an text that shows who has create the client. It must be initialize by you in you init method.

DEFAULT_PORT

public static final int DEFAULT_PORT

DEFAULT_HOST

public static final java.lang.String DEFAULT_HOST

DEFAULT_SHOWROUNDTRIP

public static final boolean DEFAULT_SHOWROUNDTRIP

MAX_CHARS

public static final int MAX_CHARS
Max number of char that the TextArea may contain. After this value the old will be cut from the head

idGen

public static java.util.Random idGen
Create a new random number generator. This may used by the instances of the applet to create a unique identifier.

listener

protected Listener listener
Contains the instance of Listener class

typist

protected Typist typist
Contains the instance of Typist class

port

protected int port
Contains the port number used by the socket

host

protected java.lang.String host
This is the string that contains the host information

maxChars

protected int maxChars

s

protected java.net.Socket s
Contains the socket to comunicate with the server

remote_name

protected java.lang.String remote_name
Contains the information like 'login@machine'

istance_ID

protected int istance_ID
The identifier ID of current instance

showRoundTripInitial

protected boolean showRoundTripInitial
Indicate if a RTT will be visible

winLocal

java.awt.TextField winLocal
This is the control used to insert information to send to the server. It must be present in your applet graphical interface for a correct use of this applet.

typePrompt

java.awt.Label typePrompt
This Label is used with the TextField and it used only by graphicAppletInit method.

winAll

java.awt.TextArea winAll
This is the area used to write the information that the server send us. It must be present in your applet graphical interface for a correct use of this applet.

showRoundTripCheck

java.awt.Checkbox showRoundTripCheck
This is the control to choose if you want to show the RTT. If you don't want this feature you can not use this control, but you must initialize the showRoundTripInitial correctly.

browser

vrml.external.Browser browser
Contains the instance to the Browser class. This class is used to comunicate between your applet and an VRML browser only if these are in the same HTML page.

nodesList

java.util.Hashtable nodesList
Contains a list of vrml nodes add to the VRML browser

tableSFVec3f

protected java.util.Hashtable tableSFVec3f
Contains the tokens available for SFVec3F VRML field

tableSFColor

protected java.util.Hashtable tableSFColor
Contains the tokens available for SFColor VRML field

tableSFRotation

protected java.util.Hashtable tableSFRotation
Contains the tokens available for SFRotation VRML field

tableSFFloat

protected java.util.Hashtable tableSFFloat
Contains the tokens available for SFFloat VRML field

tableSFBool

protected java.util.Hashtable tableSFBool
Contains the tokens available for SFBool VRML field

tableSFVec2f

protected java.util.Hashtable tableSFVec2f
Contains the tokens available for SFVec2f VRML field

tableSFNode

protected java.util.Hashtable tableSFNode
Contains the tokens available for SFNode VRML field

tableMFNode

protected java.util.Hashtable tableMFNode
Contains the tokens available for MFNode VRML field

tableSFTime

protected java.util.Hashtable tableSFTime
Contains the tokens available for SFTime VRML field

tableSFInt32

protected java.util.Hashtable tableSFInt32
Contains the tokens available for SFInt32 VRML field
Constructor Detail

Client

Client()
Method Detail

getParameterInfo

public java.lang.String[][] getParameterInfo()
Specify the type of parameter that the applet want
Overrides:
getParameterInfo in class java.applet.Applet

getAppletInfo

public java.lang.String getAppletInfo()
return the information about the autor of the client
Returns:
a text helped string
Overrides:
getAppletInfo in class java.applet.Applet

init

public void init()
Initialize the applet. Your class must extend this method to initialize the undefined variables, after you can call this with super.
Overrides:
init in class java.applet.Applet

destroy

public void destroy()
destroy()
Overrides:
destroy in class java.applet.Applet

finalize

public void finalize()
              throws java.lang.Throwable
finalize()
Overrides:
finalize in class java.lang.Object

graphAppletInit

public void graphAppletInit()
Initilize graphic object in the applet. You can overwrite by extension this method, but you must init the TextField and TextArea, and optionally the CheckBox for RTT.

start

public void start()
this method activate a connection with the server, then initilize the graph of the applet and last activate the threads Listener and Typist
Overrides:
start in class java.applet.Applet
See Also:
Listener, Typist

stop

public void stop()
This is called by the applet when it stops
Overrides:
stop in class java.applet.Applet

cleanUp

public void cleanUp()
Clean all the active processes before exiting

keyUp

public boolean keyUp(java.awt.Event e,
                     int key)
If RETURN key was pressed, the contents of TextArea is send to the server. This type of solution is deprecated but it is not converted to actual solution becouse when the Swing become real in SUN JDK 1.2, some features of Client class probably will to be adapted to the new filosofy again.
Parameters:
e - the event that occurs
key - the key pressed
Overrides:
keyUp in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Draw a graphics message about server connection not available
Parameters:
g - the window of applet where draw in graphics
Overrides:
paint in class java.awt.Container

insertText

public void insertText(java.lang.String t)
Insert a text in the applet text window and resize it if buffer length is over maxChars chars.
Parameters:
t - the string to insert in window

buildFieldTable

protected void buildFieldTable()
Builds the tables used to find rapidally if a field is of VRML type

runCommand

public void runCommand(java.lang.String s)
Parse a string command send by server for executing some commands to the virtual world and to the relative structures. In this implementation is not possible to a programmer to extends the classes of command to performes without modify this method (or overwriting all the method), becouse we thinks that when all VRML2.0 features are coded in this method, no further adjustement seems to be neccessary. If next version of VRML use other useful commands or you need another features not implemented, you must modify this method. (however actualy not all VRML2.0 features are coded, becouse they are not used until now).

Available commands are:

Parameters:
s - the text string with command