amber.client.panel
Class BaseControl

java.lang.Object
  |
  +--amber.client.panel.BaseControl
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ComponentListener, 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
Direct Known Subclasses:
BasePanel, PAudio, PButton, PCheckbox, PCheckboxPanel, PChoice, PComplexList, PFloatButton, PImage, PLabel, PList, PMenu, PTextComponent, PTreeList

public abstract class BaseControl
extends java.lang.Object
implements MbInterface, java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.TextListener, java.awt.event.FocusListener, java.awt.event.MouseMotionListener, java.awt.event.WindowListener, java.awt.event.ComponentListener

A base class which adds required processing functions to a standard AWT component to handle the requirements of Panels.

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

Field Summary
protected  AmberInputStream dataDecoder
          The data decoding data stream that is used by all components to send information.
protected  AmberOutputStream dataEncoder
           
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.
protected  BaseComponent mainEventHandler
           
protected  java.lang.Object nonVisualObject
           
protected  RContainer panelParent
           
protected  java.awt.Component visualObject
           
 
Constructor Summary
BaseControl()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addListeners(BaseComponent listener)
           
 boolean canAdd()
          This function tells the parent container whether it is safe to add this component to the container.
 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.
 BaseComponent findBaseComponent()
          This function is used to get to the parent applet.
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 void forwardPacket(Packet packet)
          This function just gets the parent to send the packet for us.
protected  AmberInputStream getDataInput()
          This function returns the current data input stream.
 short getId()
           
 short getIdFromInternalObject(java.lang.Object source)
          This function returns the ID of an object given the corresponding Visual Object returns -1 if no match.
 java.awt.Image getImage(java.lang.String urlName)
          This function gets the image specified by the input URL.
 java.lang.Object getNonVisualObject()
          This function is similar in form to the getVisualObject function however it is used for components which do not derive from Component.
 RContainer getParent()
          Returns the parent of this particular panel component.
 java.awt.Component getVisualObject()
          This function returns the object which is the visible part of an Amber panel component.
 void init(RContainer mainParent, int[] data, java.lang.String parameters)
          This is the main initialisation function for this class.
 boolean isEventEnabled(int eventId)
          Returns whether this component is listening to the specified event type.
 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)
           
abstract  void parseParameters(java.lang.String parameter)
           
 void processPacket(Packet packet)
          This routine contains the logic to parse a packet and perform actions based on the packet's contents.
 void setEnabled(boolean enabled)
          This function is called to enable or disable the control.
 void setId(short newId)
           
 void setMessageBoxReturn(int value)
          This function is called by the RMessageBox to set a return result and unlock the mutex.
 void setParent(RContainer newParent)
          Sets the parent of this particular panel component.
 void setVisible(boolean visible)
          This function is called to show or hide the control.
 void textValueChanged(java.awt.event.TextEvent e)
           
 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.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventEnabled

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

panelParent

protected RContainer panelParent

visualObject

protected java.awt.Component visualObject

nonVisualObject

protected java.lang.Object nonVisualObject

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

mainEventHandler

protected BaseComponent mainEventHandler
Constructor Detail

BaseControl

public BaseControl()
Method Detail

init

public void init(RContainer mainParent,
                 int[] data,
                 java.lang.String parameters)
This is the main initialisation function for this class. This is needed as the way we instantiate these classes mandates that only the default constructor can be used. For this reason we must have a separate initialisation function.
Parameters:
mainParent - RContainer handle to the panel this is a component of.
data - int [6] containing information useful to the component in the order ID, eventMask, x, y, w, h.
parameters - String containing any required parameters separated by '|'

parseParameters

public abstract void parseParameters(java.lang.String parameter)

addListeners

public void addListeners(BaseComponent listener)

getIdFromInternalObject

public short getIdFromInternalObject(java.lang.Object source)
This function returns the ID of an object given the corresponding Visual Object returns -1 if no match.
Parameters:
source - Object handle to the object which fired the event.
Returns:
short containing the ID of the corresponding Panel or -1 if this component is not contained here.

getVisualObject

public java.awt.Component getVisualObject()
This function returns the object which is the visible part of an Amber panel component.
Returns:
Component which is the visual Object.

getNonVisualObject

public java.lang.Object getNonVisualObject()
This function is similar in form to the getVisualObject function however it is used for components which do not derive from Component.
Returns:
Object which is the non visual Object.

setParent

public void setParent(RContainer newParent)
Sets the parent of this particular panel component.
Parameters:
newParent - RContainer which is the parent holder.

getParent

public RContainer getParent()
Returns the parent of this particular panel component.
Returns:
RContainer which is the parent holder.

getImage

public java.awt.Image getImage(java.lang.String urlName)
This function gets the image specified by the input URL. It WILL wait for the image to be loaded.
Parameters:
urlName - String name of the URL.
Returns:
Image which has been loaded or null if an error occurred.

isEventEnabled

public boolean isEventEnabled(int eventId)
Returns whether this component is listening to the specified event type.
Parameters:
eventId - int which matches one of the event IDs specified in RConstants.
Returns:
boolean true if the event type is enabled.
See Also:
RConstants

getId

public short getId()

setId

public void setId(short newId)

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.

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.

forwardPacket

public void forwardPacket(Packet packet)
                   throws AmberException
This function just gets the parent to send the packet for us.
Parameters:
packet - Packet to be sent.
Throws:
AmberException - containing error information.

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.

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.

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.

canAdd

public boolean canAdd()
This function tells the parent container whether it is safe to add this component to the container.
Returns:
boolean true if this object should be added.

getDataInput

protected AmberInputStream getDataInput()
This function returns the current data input stream.
Returns:
AmberInputStream object for the current packet data.

findBaseComponent

public BaseComponent findBaseComponent()
This function is used to get to the parent applet. This is required by some of the components to get the applet functions.
Returns:
BaseComponent handle to use or null if the applet cannot be found.

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

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.

actionPerformed

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

itemStateChanged

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

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

textValueChanged

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

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

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

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.