amber.client.panel
Class BasePanel

java.lang.Object
  |
  +--amber.client.panel.BaseControl
        |
        +--amber.client.panel.BasePanel
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, RContainer, java.awt.event.TextListener, java.awt.event.WindowListener
Direct Known Subclasses:
PFrame, PScrollPanel, PTabPanel

public class BasePanel
extends BaseControl
implements RContainer

Extension to BaseControl that presents the user with very extensible backdrop for a new set of components which do not have to message in any way but get this panel to do the messaging for them. The panel acts like a holding area for a number of components. Each component held in the panel has a unique ID in a similar way to the normal Remote Components. In this case however the component ID is used when generating messages. The panel itself has an ID which is used for messaging to the panel itself. As this appears to be a series of normal components to the server it is important that none of the ID's interfere with the those of any other component or subcomponent. For this reason there is an additional layer of processing for all the events handled by this panel before they are passed onto the Base Component. The panel is capable of instantiating a component which extends the BaseControl class.

See Also:
ApplicationHandler, ComponentHandler, BaseComponent

Field Summary
protected  java.util.Vector components
           
protected  int[] coordinates
           
protected  DrawPanel panel
           
protected  XYLayout xyLayout
           
 
Fields inherited from class amber.client.panel.BaseControl
dataDecoder, dataEncoder, encoderBytes, eventEnabled, mainEventHandler, nonVisualObject, panelParent, visualObject
 
Constructor Summary
BasePanel()
           
 
Method Summary
 void addComponent(Packet packet)
          This function is used to add a component to the panel.
protected  void addComponentToPanel(BaseControl item, int[] data, boolean doTheLayout)
          This function adds the instantiated component to the panel in the location and size specified by locationData.
 void addListeners(BaseComponent listener)
           
static java.lang.String coordToString(int offset, int[] data)
          This function converts the specified int array to the corresponding String form (i.e.
protected  BaseControl createAndAddComponent(java.lang.String className, int[] data, java.lang.String parameters, boolean doTheLayout)
          Create the component and add to the panel.
protected  int[] createArray()
          This function reads an int array from the data input stream.
protected  java.lang.Object createObject(int[] drawInfo)
          This function takes the drawInfo and reads the input stream for a string depending on the operation this function converts it into the correct type.
 BaseControl findById(int id)
          This function locates a component within the panel.
 java.awt.Container getContainer()
          This function returns the container which holds the child objects.
 short getIdFromInternalObject(java.lang.Object source)
          This function returns the ID of an object given the corresponding Visual Object returns -1 if no match.
 void init(RContainer mainParent, int[] data, java.lang.String parameters)
          This is the main initialisation function for this class.
 void internalProcessPacket(Packet packet)
          This function is to directly process the commands.
 boolean isMyId(int id)
          This function returns true if the id handed to it is to be handled here.
 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 removeAllComponents()
          This function is used to remove all sub components from the panel.
 void removeComponent(Packet packet)
          This function is used to remove a component from the panel.
protected  void removeControl(BaseControl component)
          This function removes the specified component from the screen.
 void setComponentBounds(Packet packet)
          This function sets the location or size of the component.
 
Methods inherited from class amber.client.panel.BaseControl
actionPerformed, canAdd, componentHidden, componentMoved, componentResized, componentShown, createDataInput, displayMessage, findBaseComponent, focusGained, focusLost, forwardPacket, getDataInput, getId, getImage, getNonVisualObject, getParent, getVisualObject, isEventEnabled, itemStateChanged, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, setEnabled, setId, setMessageBoxReturn, setParent, setVisible, textValueChanged, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface amber.client.RContainer
findBaseComponent, forwardPacket, getId, getNonVisualObject, getVisualObject, setEnabled, setVisible
 

Field Detail

panel

protected DrawPanel panel

xyLayout

protected XYLayout xyLayout

components

protected java.util.Vector components

coordinates

protected int[] coordinates
Constructor Detail

BasePanel

public BasePanel()
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.
Overrides:
init in class BaseControl
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 void parseParameters(java.lang.String parameter)
Overrides:
parseParameters in class BaseControl

addListeners

public void addListeners(BaseComponent listener)
Overrides:
addListeners in class BaseControl

createAndAddComponent

protected BaseControl createAndAddComponent(java.lang.String className,
                                            int[] data,
                                            java.lang.String parameters,
                                            boolean doTheLayout)
Create the component and add to the panel.
Parameters:
className - String containing the name of the class to add.
data - int array [ 6 ] containing the coordinates of the component id, eventmask, x, y, w, h
parameters - String containing any parameters.
doTheLayout - boolean, true if the layout is to occur after adding the component.
Returns:
BaseControl which was created.

addComponentToPanel

protected void addComponentToPanel(BaseControl item,
                                   int[] data,
                                   boolean doTheLayout)
This function adds the instantiated component to the panel in the location and size specified by locationData.
Parameters:
item - BaseControl to be added to the panel.
data - int array [ 6 ] containing the location and size of the component in the panel. The data is in the form id, eventmask, x,y,w,h
doTheLayout - boolean, true if the layout is to occur after adding the component.

coordToString

public static java.lang.String coordToString(int offset,
                                             int[] data)
This function converts the specified int array to the corresponding String form (i.e. n,n,n...).
Parameters:
offset - int containing the offset into the array to start.
data - int array containing the data to convert.
Returns:
String containing the converted data.

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 RContainer
Overrides:
processPacket in class BaseControl
Following copied from interface: amber.client.RContainer
Parameters:
packet - Incoming Packet containing the command and all required parameters.

internalProcessPacket

public void internalProcessPacket(Packet packet)
Description copied from interface: RContainer
This function is to directly process the commands. No redirection will take place and the destination ID is considered irrelevant.
Specified by:
internalProcessPacket in interface RContainer
Following copied from interface: amber.client.RContainer
Parameters:
packet - Incoming Packet containing the command and all required parameters.

createArray

protected int[] createArray()
                     throws java.io.IOException,
                            AmberException
This function reads an int array from the data input stream.
Returns:
int array containing the array.
Throws:
java.io.IOException - with any decoding errors.
AmberException - if there is no array.

createObject

protected java.lang.Object createObject(int[] drawInfo)
                                 throws java.io.IOException
This function takes the drawInfo and reads the input stream for a string depending on the operation this function converts it into the correct type. This could be a String, Color or Image.
Parameters:
drawInfo - int array with the drawing information.
Returns:
Object which was created for this drawing operation.
Throws:
java.io.IOException - with any decoding errors.

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 RContainer
Overrides:
isMyId in class BaseControl
Parameters:
id - int containing the ID to check for.
Returns:
boolean true if this component handles this ID.

findById

public BaseControl findById(int id)
This function locates a component within the panel.
Parameters:
id - The component ID to find.
Returns:
BaseControl found or null.

addComponent

public void addComponent(Packet packet)
This function is used to add a component to the panel. Packet structure: int id, int eventmask, int x, int y, int w, int h, string class, string parameters
Specified by:
addComponent in interface RContainer
Parameters:
packet - Packet containing the required information.

setComponentBounds

public void setComponentBounds(Packet packet)
This function sets the location or size of the component. Packet structure: int id, int type, int x (width), int y (height), (int width, int height) bracketed objects optional types which are dependant on the type field.
Specified by:
setComponentBounds in interface RContainer
Parameters:
packet - Packet containing the required information.

removeComponent

public void removeComponent(Packet packet)
This function is used to remove a component from the panel. Packet structure contains the short id of the component to remove.
Specified by:
removeComponent in interface RContainer
Parameters:
packet - Packet containing the required information.

removeControl

protected void removeControl(BaseControl component)
This function removes the specified component from the screen.
Parameters:
component - BaseControl to remove.

removeAllComponents

public void removeAllComponents()
This function is used to remove all sub components from the panel.
Specified by:
removeAllComponents in interface RContainer

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. This function overrides the default function in BaseControl to allow the concept of child objects.
Overrides:
getIdFromInternalObject in class BaseControl
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.
See Also:
BaseControl

getContainer

public java.awt.Container getContainer()
This function returns the container which holds the child objects.
Specified by:
getContainer in interface RContainer
Returns:
Container which holds the child objects.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.