Class ChatGUI

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--ChatGUI

public class ChatGUI
extends javax.swing.JFrame
implements java.awt.event.ActionListener

This demo is prepared to demostrate how you can use OWRTI package. This is a Chat program based on interactions.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
(package private)  boolean advanceGranted
           
(package private)  java.util.Hashtable attributeName
           
(package private)  int chatterMsgTypeId
           
(package private)  java.lang.String chatterMsgTypeStr
           
(package private)  short chatterTypeId
           
(package private)  java.lang.String chatterTypeStr
           
(package private)  java.util.Hashtable className
          RTI Mappers
(package private)  javax.swing.JButton connect
           
(package private)  double currentTime
           
(package private)  javax.swing.JButton disconnect
           
(package private)  javax.swing.JButton exit
           
(package private)  javax.swing.JMenuItem exitItem
           
(package private)  java.lang.String ExitTxt
           
(package private)  java.lang.String fedCnfName
           
(package private)  short federateId
           
(package private)  java.lang.String fedName
           
(package private)  java.lang.Object guard
           
(package private)  java.util.Hashtable interactionName
           
(package private)  boolean isConnected
           
(package private)  javax.swing.JButton mail
           
(package private)  short myChatterId
           
(package private)  java.lang.String myChatterName
           
(package private)  java.io.PrintWriter myLog
          Log File
(package private)  org.omg.CORBA.ORB orb
           
(package private)  java.util.Hashtable parameterName
           
(package private)  javax.swing.JTextArea rcvMessages
           
(package private)  double requestTime
           
(package private)  RTIcap.RTIambassador rtiAmb
           
(package private)  javax.swing.JTextField sendMessage
           
(package private)  javax.swing.JMenuItem setNameItem
           
(package private)  java.lang.String SetNameTxt
           
(package private)  double timeStep
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, defaultCloseOperation, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
base, CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, frameSerializedDataVersion, HAND_CURSOR, icon, ICONIFIED, mbManagement, menuBar, MOVE_CURSOR, N_RESIZE_CURSOR, nameCounter, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, ownedWindows, resizable, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, serialVersionUID, state, SW_RESIZE_CURSOR, TEXT_CURSOR, title, W_RESIZE_CURSOR, WAIT_CURSOR, weakThis
 
Fields inherited from class java.awt.Window
active, base, focusMgr, inputContext, nameCounter, OPENED, ownedWindowList, serialVersionUID, state, warningString, weakThis, windowListener, windowSerializedDataVersion
 
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
ChatGUI(RTIcap.RTIambassador _rtiAmb, org.omg.CORBA.ORB _orb)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          ActionListener interface to collect the user events.
 void addMessage(byte[] receivedMsg)
           
 void addMessage(byte[] receivedMsg, java.awt.Color txtColor)
           
 void addMessage(java.lang.String receivedMsg, java.awt.Color txtColor)
           
(package private)  void doConnect()
          Connects for publishing.
(package private)  void doDisconnect()
          Disconnects from the Federation Execution.
(package private)  void doExit()
          Move the frame back, and destroy the execution.
(package private)  void doGetName()
           
(package private)  void doMail()
           
(package private)  void doRealyConnect()
          Connects to the Federation Execution
 short getChatterRTIMsgTypeId()
           
 short getChatterRTITypeId()
           
 java.net.URL getCodeBase()
           
(package private)  boolean getRtiIds()
          Gets the RTTI (Meta-Object Protocol MOP) handles.
(package private)  void giveError(java.lang.String mess)
          Displays the error message in the warning window.
 boolean isTimeAdvanceGranted()
           
(package private)  boolean joinFederationExecution(RTIcap.FederateAmbassador fedAmb)
          We want to join the Federation but we do not know its ID and whether it is on.
(package private)  void leaveFederationExecution()
          Before we leave the Federation 1.
 void mySleep(long aa)
           
(package private)  boolean publishSubscribe()
          Describe our interest for publishing objects and attributes.
 void resetTimeAdvanceGranted()
           
 void setCurrentTime(double _newTime)
           
 void setTimeAdvanceGranted()
          This method will be invoked by HwFededarateAmbassador object whenever timeAdvanceGrant timeConstrainedEnabled timeRegulationEnabled messages received.
 void tickRTI(long sleepTime)
          Ticks the RTIambassador.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, createRootPaneException, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
, addNotify, addToFrameList, constructComponentName, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, initIDs, isResizable, postProcessKeyEvent, readObject, remove, removeFromFrameList, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle, writeObject
 
Methods inherited from class java.awt.Window
addOwnedWindow, addWindowListener, applyResourceBundle, applyResourceBundle, connectOwnedWindow, dispatchEventImpl, dispose, eventEnabled, getFocusOwner, getInputContext, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isActive, isShowing, nextFocus, ownedInit, pack, postEvent, postWindowEvent, preProcessKeyEvent, processEvent, removeOwnedWindow, removeWindowListener, setFocusOwner, setWarningString, show, toBack, toFront, transferFocus
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyOrientation, countComponents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, paint, paintComponents, postsOldMouseEvents, preferredSize, print, printComponents, printOneComponent, processContainerEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
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, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

fedName

java.lang.String fedName

fedCnfName

java.lang.String fedCnfName

federateId

short federateId

orb

org.omg.CORBA.ORB orb

chatterTypeStr

java.lang.String chatterTypeStr

chatterMsgTypeStr

java.lang.String chatterMsgTypeStr

SetNameTxt

java.lang.String SetNameTxt

ExitTxt

java.lang.String ExitTxt

chatterTypeId

short chatterTypeId

chatterMsgTypeId

int chatterMsgTypeId

guard

java.lang.Object guard

className

java.util.Hashtable className
RTI Mappers

attributeName

java.util.Hashtable attributeName

interactionName

java.util.Hashtable interactionName

parameterName

java.util.Hashtable parameterName

rtiAmb

RTIcap.RTIambassador rtiAmb

advanceGranted

boolean advanceGranted

currentTime

double currentTime

timeStep

double timeStep

requestTime

double requestTime

myLog

java.io.PrintWriter myLog
Log File

connect

javax.swing.JButton connect

mail

javax.swing.JButton mail

disconnect

javax.swing.JButton disconnect

exit

javax.swing.JButton exit

rcvMessages

javax.swing.JTextArea rcvMessages

sendMessage

javax.swing.JTextField sendMessage

myChatterId

short myChatterId

isConnected

boolean isConnected

myChatterName

java.lang.String myChatterName

setNameItem

javax.swing.JMenuItem setNameItem

exitItem

javax.swing.JMenuItem exitItem
Constructor Detail

ChatGUI

public ChatGUI(RTIcap.RTIambassador _rtiAmb,
               org.omg.CORBA.ORB _orb)
Method Detail

getCodeBase

public java.net.URL getCodeBase()

getRtiIds

boolean getRtiIds()
Gets the RTTI (Meta-Object Protocol MOP) handles. Ask RTI about the class indentifier of each object, attribute, interaction and parameter. So that we can define, subscribe, publish, and interpret these attributes/objects.

publishSubscribe

boolean publishSubscribe()
Describe our interest for publishing objects and attributes. Describe our interest for receiving objects and attributes. Describe our interest for publishing interations and parameters. Describe our interest for receiving interations and parameters.

joinFederationExecution

boolean joinFederationExecution(RTIcap.FederateAmbassador fedAmb)
We want to join the Federation but we do not know its ID and whether it is on. Therefore, we first try to create this Federation. If this federation is already exists, we will receive the exception. If not, it will be created for us. Then we need to join this execution and get ourself a federate id.

leaveFederationExecution

void leaveFederationExecution()
Before we leave the Federation 1. Delete all the object that we are suppose(promised) to simulate. 2. resign from the federation. 3. Try to destroy the federation execution. Note that if there are still federates in the Federation, the federation execution won't be stopped. Only, we resign it.

resetTimeAdvanceGranted

public void resetTimeAdvanceGranted()

setTimeAdvanceGranted

public void setTimeAdvanceGranted()
This method will be invoked by HwFededarateAmbassador object whenever timeAdvanceGrant timeConstrainedEnabled timeRegulationEnabled messages received.

isTimeAdvanceGranted

public boolean isTimeAdvanceGranted()

setCurrentTime

public void setCurrentTime(double _newTime)

mySleep

public final void mySleep(long aa)

tickRTI

public void tickRTI(long sleepTime)
Ticks the RTIambassador. This will cause the delivery of waiting events in the Receive Order Queue.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
ActionListener interface to collect the user events.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - ActionEvent

doExit

void doExit()
Move the frame back, and destroy the execution.

doRealyConnect

void doRealyConnect()
Connects to the Federation Execution

doConnect

void doConnect()
Connects for publishing.

doDisconnect

void doDisconnect()
Disconnects from the Federation Execution.

doMail

void doMail()

doGetName

void doGetName()

giveError

void giveError(java.lang.String mess)
Displays the error message in the warning window.
Parameters:
mess - Error message.

getChatterRTITypeId

public short getChatterRTITypeId()
Returns:
 

getChatterRTIMsgTypeId

public short getChatterRTIMsgTypeId()
Returns:
 

addMessage

public void addMessage(byte[] receivedMsg)
Parameters:
receivedMsg -  

addMessage

public void addMessage(byte[] receivedMsg,
                       java.awt.Color txtColor)
Parameters:
receivedMsg -  
txtColor -  

addMessage

public void addMessage(java.lang.String receivedMsg,
                       java.awt.Color txtColor)
Parameters:
receivedMsg -  
txtColor -