Whiteboard example uses the shared objects. This example is different from the Chat and HelloWorld examples because each whiteboard user joins the execution when the program starts and each user can define number of objects (be the owner of number of objects). Therefore, Whiteboard federate simulates number of objects by creating, deleting, updating object's attributes.
User interface contains two action buttons:
Select | : | selects the object on the whiteboard if the user is the owner of this object, and |
Rect | : | introduces a new rectangle object on the whiteboard. When a new rectangle object is defined, its color is selected from the bottom right window and its size is adjusted with mouse drag. First click fixes the one corner and the drag operation changes its size and mouse release finishes the declaration of a new object. |
User can select an object on the whiteboard provided that this object defined by him/her and drag the object on the whiteboard.
Whiteboard assumes that the whole world is looking at the same whiteboard and each joining federate sees the same whiteboard. If there are already other users in the federate and they defined objects, the joining federate sees all this objects. (RTI sends a discoverObject, the federate decides whether it wants to know this object or not. If the federate wants to know more about this object, it asks RTI to give more information, then RTI sends a provideAttributeValues message to the owner(s) of this object. Owner federates publish the required attribute values and the initiating federate receives reflect messages belonging to this object's attributes.)
Whiteboard.xml in $(OWRTI_HOME)/xml directory contains the federation definition. It only defines a Rectangle object that has x,y,transx,transy, width, and height attributes.
JDK 1.2 or later release.
Makefile contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.mk configuration file. This file contains variables for:
These variables should be set to the proper directories.
make
compiles the codes.
Makefile.win contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.win configuration file. This file contains variables for:
These variables should be set to the proper directories.
nmake /f Makefile.win
compiles the codes.
JDK 1.2 or later release.
Makefile contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.mk configuration file. This file contains variables for:
These variables should be set to the proper directories.
Whiteboard.xml file is stored in $(OWRTI_HOME)/xml directory. This file should be placed in $(JWORB_HOME)/config directory since the JWORB actually starts up the OWRTI.
kernel.srv file contains machine name and port number pairs. These pairs are used to find a running JWORB server. Therefore, you should add your running JWORB's machine name and port number information into this file. Assume that your JWORB is running on herman.arl.mil port number 3142, then kernel.srv should contain
herman.arl.mil 3142During the runtime, system goes through the entries in order and uses the first JWORB that runs the OWRTI.
run
script starts up the GUI.
Makefile.win contains necessary compile parameters. It includes $(OWRTI_HOME)/mk/config.win configuration file. This file contains variables for:
These variables should be set to the proper directories.
Whiteboard.xml file is stored in $(OWRTI_HOME)/xml directory. This file should be placed in $(JWORB_HOME)/config directory since the JWORB actually starts up the OWRTI.
kernel.srv file contains machine name and port number pairs. These pairs are used to find a running JWORB server. Therefore, you should add your running JWORB's machine name and port number information into this file. Assume that your JWORB is running on herman.arl.mil port number 3142, then kernel.srv should contain
herman.arl.mil 3142During the runtime, system goes through the entries in order and uses the first JWORB that runs the OWRTI.
run
script starts up the GUI. (This is a .BAT file).
User interface contains two shapes and select button. Select button is used to move the locally defined object (Figure 1). Shape buttons (Rect and Circle) are used to draw a shape on the whiteboard (Figure 2,3,4,5).
![]() |
Figure 1. Select button. |
![]() |
Figure 2. Rect button. |
![]() |
Figure 3. Circle button. |
![]() |
Figure 4. Rectangle is drawn by clicking on the Rect button, then left mouse click denotes the left upper left corner. The right mouse button marks the other corner. |
![]() |
Figure 5. Circle is drawn by clicking on the Circle button, then left mouse click denotes the left upper left corner. The right mouse button marks the other corner. |
![]() |
Figure 6. Two whiteboards can see each other. The remote objects are drawn with red color. |
Package has the following subdirectories:
edu | : | source files. |
gif | : | images. |
jdocs | : | Javadoc outputs. |
![]() |
Figure . UML diagram for the objects in edu.dmi package. |
![]() |
Figure . UML diagram for the objects in edu.rti package. |
![]() |
Figure . UML diagram for the objects in edu package. |
"config.txt" file is used to import Visual components that can be used on the Whiteboard. The format of this file is:
sel,gif/sel.gif,edu.SelectThe first component is the name, the second component is the Image file name and the third one if the Java class implementing edu.Tool interface.
URL | getCodeBase() | : | returns the base url. |
Image | getImage(URL base, String fName) | : | loads the image from the base url. |
void | updateOccurred (UpdateEvent e) | : | a event call. |
void | addUpdateListener(UpdateListener ele) | : | adds an UpdateListener object. |
void | removeUpdateListener(UpdateListener ele) | : | removes an UpdateListener object. |
Rectangle | getBounds() | : | returns enclosing rectangle of this object. |
void | paint (Graphics g) | : | asks object to render itself on the Graphics object. |
void | commitTranslation(int dX, int dY) | : | tells object that drag operation is finished and it can updates itself. |
void | updateTranslation(int dX, int dY) | : | updates the translation parameter of the object during mouse drag. |
void | setUpdateListener(UpdateListener lis) | : | sets the UpdateListener object for this Element. It fires an UpdateEvent to inform this observer. |
boolean | isSelectable() | : | Is this Element dragged by a mouse?.(We do not want the networked objects to be dragged by the local client) |
Enumeration | getElements() | : | returns all the registered Element objects. |
void | addElement(Element ele) | : | adds one Element object. |
void | removeElement(Element ele) | : | removes one Element object. |
Component | getControls() | : | returns Component object which has a GUI for the Element authoring. |
void | processEvent (AWTEvent e) | : | a paint area forwards the AWTEvent s to the Tool. |
RTIObjectsContainer view is used by the WBFedAmb object to add/remove object instances to the EntityManager.
Any change in the container causes a firing of UpdateEvent, this event is delivered to the listeners. (UpdateBroadcaster)
ElementsContainer view is used by renderer and Tool objects to add a new Element. EntityManager automatically gets an RTI object instance id for this object. If it is remove operation, then it also sends a message to remove this object from the federation.
It contains a factory pattern registration for object types.
void registerObjectFactory(String rtiClassName, ObjFactory oFactory)
ObjFactory getObjectFactoryForRtiObjectClass(String rtiClassName)
Object which has RTI Object definition extends from this object and gives an implementation of some methods for attribute updates. Single inheritance in Java might cause some ad hoc solutions if the object can not be naturally extended from RTIObject. RTIObject handles publish/nonpublish options, hides the RTI instance id, hides the RTI attribute ids and presents an attribute name based communication pattern with its concrete class. The concrete class should provide the implementation of the following methods:
Properties getAttributes(boolean state) : asks the current value of the attributes. state is connected with turnUpdatesOn/Off in the FederationAmbassador interface. The concrete class is supposed to return a <attribute_name,attribute_value> pairs in the Properties object. The network representation of these values are left to the concrete class implementation. CDRCoderEncoder might be useful for basic common network representation.
void setAttributes(Properties props) : attribute updates are carried to the concrete class with this method. The Properties object stores <attribute_name,attribute_value> pairs. The network representation of these values are left to the concrete class implementation. CDRCoderEncoder might be useful for basic common network representation.
void reflectAttributes(Vector props) : asks the object to produce an update for the given attributes.
A Tool implementation for RectElement object. This object is responsible for providing GUI for the rectangle authoring such as its color. It brings up a pull-down list. This object is also responsible for handling mouse events coming from the paint area. The WBContainer object controls the input in the paint area and forwards the mouse events to the current Tool object. Tool implementations creates the object, drags it and resizes it.
In processEvent(), if the Mouse is pressed, it defines a new RectElement object and adds this object to the ElementsContainer object. If the Mouse is dragged while an object is already defined, this means that the user click on the first corner and tries to determine the second corner of the rectangle. Therefore, it sets the new coorinate values for the RectElement object. If the Mouse is released during the object definition, it updates the current coordinate values and prepares for the next object definition.
It has a reference to RTIAmbassador object. It receives the UpdateEvent through UpdateListener interface (updateOccured). It extracts the source object from the UpdateEvent (getSource) and if it is RTIObject and its is publishable then it extracts the RTIObject instance id and updated attribute values and sends them through the RTI (updateAttributeValues).
Contains a constructor definition for an Object definition. getNewInstance() method creates the instance of the object class by using the constructor definition.
Contains a constructor definition for an RTI Object definition.
A main Frame object.
constructor() : It reads the config.txt file to get the name of button, image of button, and the class name which implements the Tool interface. These buttons are placed on the left panel. The button name and class pairs are stored in a hashtable. actionPerformed() method access the Tool implementation name through the hashtable. It instantiate the Tool implementation. makes it the currentTool. Passes the EntityManager and WBContainer reference to the Tool implementation. Informs WBContainer about the currentTool.
===================================================================The End. Prepared by H. Timucin Ozdemir, August 8, 1999. E-mail : timucin@npac.syr.edu ===========================================================================