amber.client
Interface BaseComponent

All Superinterfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.KeyListener, MbInterface, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.TextListener, java.awt.event.WindowListener
All Known Implementing Classes:
RComponent

public interface BaseComponent
extends MbInterface, 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

This is an interface which is concerned with the basic messaging and event handling for the Amber system. For the system to function at some point in the hierarchy there should be a class which implements this interface.

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

Method Summary
 void addBaseListeners(java.awt.Component source)
          This function adds the standard base listeners to the specified component.
 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.
 void forwardPacket(Packet packet)
          Called by the ReceiveThread and any internal functions when a packet is to be sent to its required destination.
 java.applet.AudioClip getAudioClip(java.net.URL url)
          Returns the AudioClip object specified by the URL argument.
 java.applet.AudioClip getAudioClip(java.net.URL url, java.lang.String name)
          Returns the AudioClip object specified by the URL and name arguments.
 java.net.URL getCodeBase()
          Gets the base URL.
 AmberInputStream getDataInput()
          This function returns the current data input stream.
 short getId()
          Return the ID integer of this control.
 java.awt.Image getImage(java.net.URL url)
          Returns an Image object that can then be painted on the screen.
 java.awt.Image getImage(java.net.URL url, java.lang.String name)
          Returns an Image object that can then be painted on the screen.
 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 component.
 boolean isMyId(int id)
          This function returns true if the id handed to it is to be handled here.
 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 event, 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 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 waitForImage(java.awt.Image image)
          This function waits for the specified image to load.
 
Methods inherited from interface amber.client.MbInterface
setMessageBoxReturn
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 
Methods inherited from interface java.awt.event.TextListener
textValueChanged
 
Methods inherited from interface java.awt.event.KeyListener
keyPressed, keyReleased, keyTyped
 
Methods inherited from interface java.awt.event.MouseListener
mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
 
Methods inherited from interface java.awt.event.ItemListener
itemStateChanged
 
Methods inherited from interface java.awt.event.WindowListener
windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
 
Methods inherited from interface java.awt.event.MouseMotionListener
mouseDragged, mouseMoved
 
Methods inherited from interface java.awt.event.FocusListener
focusGained, focusLost
 

Method Detail

getParameter

public java.lang.String getParameter(java.lang.String key,
                                     java.lang.String def)
Get a parameter value
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 component.

addBaseListeners

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

getId

public short getId()
Return the ID integer of this control.

setId

public void setId(short newId)
Set the ID integer of this applet

isMyId

public boolean isMyId(int id)
This function returns true if the id handed to it is to be handled here.
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.
Parameters:
packet - Packet containing the information to send to the specified component.
Throws:
AmberException - containing any errors.

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.

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.
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

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.
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.
Parameters:
enabled - boolean true if the component is to be enabled.

createDataInput

public AmberInputStream createDataInput(Packet packet)
This function creates a data input stream from the data in the packet.
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.
Returns:
AmberInputStream object for the current packet data.

getCodeBase

public java.net.URL getCodeBase()
Gets the base URL. This is the URL of the component location itself.
Returns:
the java.net.URL location of the component.

getAudioClip

public java.applet.AudioClip getAudioClip(java.net.URL url)
Returns the AudioClip object specified by the URL argument.

This method always returns immediately, whether or not the audio clip exists. When this applet attempts to play the audio clip, the data will be loaded.

Parameters:
url - an absolute URL giving the location of the audio clip.
Returns:
the audio clip at the specified URL.
Since:
JDK1.0
See Also:
AudioClip

getAudioClip

public java.applet.AudioClip getAudioClip(java.net.URL url,
                                          java.lang.String name)
Returns the AudioClip object specified by the URL and name arguments.

This method always returns immediately, whether or not the audio clip exists. When this applet attempts to play the audio clip, the data will be loaded.

Parameters:
url - an absolute URL giving the base location of the audio clip.
name - the location of the audio clip, relative to the url argument.
Returns:
the audio clip at the specified URL.
Since:
JDK1.0
See Also:
AudioClip

getImage

public java.awt.Image getImage(java.net.URL url)
Returns an Image object that can then be painted on the screen. The url that is passed as an argument must specify an absolute URL.

This method always returns immediately, whether or not the image exists. When this applet attempts to draw the image on the screen, the data will be loaded. The graphics primitives that draw the image will incrementally paint on the screen.

Parameters:
url - an absolute URL giving the location of the image.
Returns:
the image at the specified URL.
See Also:
Image

getImage

public java.awt.Image getImage(java.net.URL url,
                               java.lang.String name)
Returns an Image object that can then be painted on the screen. The url argument must specify an absolute URL. The name argument is a specifier that is relative to the url argument.

This method always returns immediately, whether or not the image exists. When this applet attempts to draw the image on the screen, the data will be loaded. The graphics primitives that draw the image will incrementally paint on the screen.

Parameters:
url - an absolute URL giving the base location of the image.
name - the location of the image, relative to the url argument.
Returns:
the image at the specified URL.
See Also:
Image

waitForImage

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

displayUrl

public void displayUrl(java.lang.String url,
                       java.lang.String location)
This function gets an URL and displays it.
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.

sendEvent

public void sendEvent(java.util.EventObject event,
                      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.
Parameters:
event - EventObject to send.
id - int ID of the source of the event.

getSessionId

public java.lang.String getSessionId()
Returns the session ID of the current Amber Session.
Returns:
String containing the session ID.

setSessionId

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


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.