amber.client
Class RComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--amber.client.RComponent
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, BaseComponent, java.awt.event.ComponentListener, java.util.EventListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.event.KeyListener, MbInterface, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.awt.event.TextListener, java.awt.event.WindowListener
Direct Known Subclasses:
RBase, RLink

public class RComponent
extends java.applet.Applet
implements BaseComponent, java.awt.event.ActionListener, java.awt.event.TextListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.ItemListener, java.awt.event.WindowListener, java.awt.event.MouseMotionListener, java.awt.event.FocusListener, java.awt.event.ComponentListener

An extension to Applet which adds the basic functionality of the Amber system - spawning send and receive threads if this is applet zero on the page, communicating with the server and detecting and communicating with other applets that exist on the page and communicating with them. This component when it is the master (ID 0) starting up communicates with the Amber server sending a substantial amount of information about the system it is running on. This information includes:

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
ApplicationHandler, ComponentHandler, Serialized Form

Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  ConnectionModule connectionModule
          This is the handle of the primary connection module to the server.
protected  AmberInputStream dataDecoder
          The data decoding data stream that is used by all components to send information.
protected  AmberOutputStream dataEncoder
           
protected  java.awt.Font defaultFont
          Default font for the component.
protected  java.io.ByteArrayOutputStream encoderBytes
          The data encoding data stream that is used by all components to send information.
protected  boolean[] eventEnabled
          Array containing whether or not to ignore events.
static int InvalidPageSubId
           
 int num
           
protected  java.awt.Component visualObject
          The visual object which is displayed in the applet.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
RComponent()
          Base Constructor for the applet.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addBaseListeners(java.awt.Component source)
          This function adds the standard base listeners to the specified component.
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
 AmberInputStream createDataInput(Packet packet)
          This function creates a data input stream from the data in the packet.
 int displayMessage(java.lang.String title, java.lang.String caption, int type, boolean modal)
          This function creates and displays a MessageBox given the specified Title and caption.
 void displayUrl(java.lang.String url, java.lang.String location)
          This function gets an URL and displays it.
protected  void enableSpecifiedEvents(int eventMask)
          This function enables the events specified by the parameter EVENTMASK.
 BaseComponent findApplet(int id)
          This function hunts among the applets on the page looking for an Amber element which will respond to a specified ID.
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 void forwardPacket(Packet packet)
          Called by the ReceiveThread and any internal functions when a packet is to be sent to its required destination.
 java.lang.String getAppletInfo()
          Get Applet information
 AmberInputStream getDataInput()
          This function returns the current data input stream.
 short getId()
          Return the ID integer of this applet
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
          Get a parameter value
 java.lang.String getSessionId()
          Returns the session ID of the current Amber Session.
 void init()
          Main initialisation function for the applet.
 boolean isMyId(int id)
          This function returns true if the id handed to it is to be handled here.
 void itemStateChanged(java.awt.event.ItemEvent e)
           
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void processPacket(Packet packet)
          This routine contains the logic to parse a packet and perform actions based on the packet's contents.
 void sendEvent(java.util.EventObject e, int id)
          This function sends an event to the server.
 void setEnabled(boolean enabled)
          This function is called to enable or disable the control.
 void setId(short newId)
          Set the ID integer of this applet
 void setMessageBoxReturn(int value)
          This function is called by the RMessageBox to set a return result and unlock the mutex.
 void setSessionId(java.lang.String id)
          Sets the session ID of the current Amber Session.
 void setVisible(boolean visible)
          This function is called to show or hide the control.
 void textValueChanged(java.awt.event.TextEvent e)
           
 void waitForImage(java.awt.Image image)
          This function waits for the specified image to load.
protected  void waitForRegistration()
          This function waits for other applets to appear before continuing.
 void windowActivated(java.awt.event.WindowEvent e)
           
 void windowClosed(java.awt.event.WindowEvent e)
           
 void windowClosing(java.awt.event.WindowEvent e)
           
 void windowDeactivated(java.awt.event.WindowEvent e)
           
 void windowDeiconified(java.awt.event.WindowEvent e)
           
 void windowIconified(java.awt.event.WindowEvent e)
           
 void windowOpened(java.awt.event.WindowEvent e)
           
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface amber.client.BaseComponent
getAudioClip, getAudioClip, getCodeBase, getImage, getImage
 

Field Detail

eventEnabled

protected boolean[] eventEnabled
Array containing whether or not to ignore events. Must match the variable NumberOfEvents.

InvalidPageSubId

public static final int InvalidPageSubId

connectionModule

protected ConnectionModule connectionModule
This is the handle of the primary connection module to the server.

defaultFont

protected java.awt.Font defaultFont
Default font for the component.

dataDecoder

protected AmberInputStream dataDecoder
The data decoding data stream that is used by all components to send information. THIS MUST BE USED FOR DECODING INFORMATION FROM THE SERVER!! See the associated accessor/creator functions

encoderBytes

protected java.io.ByteArrayOutputStream encoderBytes
The data encoding data stream that is used by all components to send information. THIS MUST BE USED FOR ENCODING INFORMATION TO THE SERVER!!

dataEncoder

protected AmberOutputStream dataEncoder

num

public int num

visualObject

protected java.awt.Component visualObject
The visual object which is displayed in the applet.
Constructor Detail

RComponent

public RComponent()
Base Constructor for the applet.
Method Detail

getParameter

public java.lang.String getParameter(java.lang.String key,
                                     java.lang.String def)
Get a parameter value
Specified by:
getParameter in interface BaseComponent
Parameters:
key - String containing the parameter key to search for.
def - String used as the default should the parameter not exist.
Returns:
String containing the parameter or the default should none exist.

init

public void init()
Main initialisation function for the applet.
Specified by:
init in interface BaseComponent
Overrides:
init in class java.applet.Applet

getSessionId

public java.lang.String getSessionId()
Returns the session ID of the current Amber Session.
Specified by:
getSessionId in interface BaseComponent
Returns:
String containing the session ID.

setSessionId

public void setSessionId(java.lang.String id)
Sets the session ID of the current Amber Session.
Specified by:
setSessionId in interface BaseComponent
Parameters:
id - String containing the session ID.

waitForRegistration

protected void waitForRegistration()
This function waits for other applets to appear before continuing. This is to avoid problems where the master applet initialises before other applets in the page. This means that messages could arrive for applets which do not exist yet. The applets are specified as a parameter: REGISTEREDIDS

enableSpecifiedEvents

protected void enableSpecifiedEvents(int eventMask)
This function enables the events specified by the parameter EVENTMASK. It converts the number into a booolean array of events.

addBaseListeners

public void addBaseListeners(java.awt.Component source)
This function adds the standard base listeners to the specified component.
Specified by:
addBaseListeners in interface BaseComponent
Parameters:
source - The component which will be the source of the events.

getAppletInfo

public java.lang.String getAppletInfo()
Get Applet information
Overrides:
getAppletInfo in class java.applet.Applet

getId

public final short getId()
Return the ID integer of this applet
Specified by:
getId in interface BaseComponent

setId

public void setId(short newId)
Set the ID integer of this applet
Specified by:
setId in interface BaseComponent

findApplet

public BaseComponent findApplet(int id)
This function hunts among the applets on the page looking for an Amber element which will respond to a specified ID. In the case of composite applets such as panels and frames this may be a member element.
Parameters:
id - int id to find.
Returns:
BaseComponent which responds to this message.

isMyId

public boolean isMyId(int id)
This function returns true if the id handed to it is to be handled here.
Specified by:
isMyId in interface BaseComponent
Parameters:
id - int containing the ID to check for.
Returns:
boolean true if this component handles this ID.

forwardPacket

public void forwardPacket(Packet packet)
                   throws AmberException
Called by the ReceiveThread and any internal functions when a packet is to be sent to its required destination. This function examines the packet and passes it to the appropriate applet.
Specified by:
forwardPacket in interface BaseComponent
Parameters:
packet - Packet containing the information to send to the specified component.

processPacket

public void processPacket(Packet packet)
This routine contains the logic to parse a packet and perform actions based on the packet's contents. In this class, does basic common tasks that all applets must implement. Override in the derived classes to do the magic.
Specified by:
processPacket in interface BaseComponent

displayUrl

public void displayUrl(java.lang.String url,
                       java.lang.String location)
This function gets an URL and displays it.
Specified by:
displayUrl in interface BaseComponent
Parameters:
url - String URL to display.
location - String location to display the URL in. It the string is null the function defaults to the current window.

displayMessage

public int displayMessage(java.lang.String title,
                          java.lang.String caption,
                          int type,
                          boolean modal)
This function creates and displays a MessageBox given the specified Title and caption.
Specified by:
displayMessage in interface BaseComponent
Parameters:
title - The String containing the title.
caption - The String containing the caption.
offset - int offset into the byte array.
type - int defining the type of message box to display.
modal - boolean true if the program is to block waiting for the reply

waitForImage

public void waitForImage(java.awt.Image image)
This function waits for the specified image to load.
Specified by:
waitForImage in interface BaseComponent
Parameters:
image - Image to wait for.

setVisible

public void setVisible(boolean visible)
This function is called to show or hide the control. Override it in derived components to make it do the appropriate things.
Specified by:
setVisible in interface BaseComponent
Overrides:
setVisible in class java.awt.Component
Parameters:
visible - boolean true if the component is to be visible.

setEnabled

public void setEnabled(boolean enabled)
This function is called to enable or disable the control. Override it in derived components to make it do the appropriate things. Enabled controls respond to events.
Specified by:
setEnabled in interface BaseComponent
Overrides:
setEnabled in class java.awt.Component
Parameters:
enabled - boolean true if the component is to be enabled.

setMessageBoxReturn

public void setMessageBoxReturn(int value)
This function is called by the RMessageBox to set a return result and unlock the mutex.
Specified by:
setMessageBoxReturn in interface MbInterface
Parameters:
value - The return value to send back from the message box to the server.

createDataInput

public AmberInputStream createDataInput(Packet packet)
This function creates a data input stream from the data in the packet.
Specified by:
createDataInput in interface BaseComponent
Parameters:
packet - Packet containing the data to decode.
Returns:
AmberInputStream object for the corresponding data.

getDataInput

public AmberInputStream getDataInput()
This function returns the current data input stream.
Specified by:
getDataInput in interface BaseComponent
Returns:
AmberInputStream object for the current packet data.

sendEvent

public void sendEvent(java.util.EventObject e,
                      int id)
This function sends an event to the server. It determines the type of event and calls the required transmission function to actually send the event.
Specified by:
sendEvent in interface BaseComponent
Parameters:
e - EventObject to send.
id - int ID of the source of the event.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

textValueChanged

public void textValueChanged(java.awt.event.TextEvent e)
Specified by:
textValueChanged in interface java.awt.event.TextListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Specified by:
windowClosing in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.