public abstract class SimpleWidget extends java.lang.Object implements Widget
An abstract class to relate widget variables and invisible variables (such as temporary files).
This class extends the widget class by adding support for the 'name' parameter of variables. Each variable should have an internal name, which may be used for command line substitution.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
name
The PCD variable name (this name can be referenced in the command
using the % symbol; for example, if the name value was set to "A",
the value of this widget could be accessed by using %A% (lower or
upper-case) within the PCD menu command string.
|
Constructor and Description |
---|
SimpleWidget(java.lang.String name)
Creates a new instance of the abstract class SimpleWidget
|
Modifier and Type | Method and Description |
---|---|
java.awt.Component |
displayEdit(javax.swing.JFrame mainFrame)
Displays the current widget in an editor panel.
|
static void |
editImage(javax.swing.JLabel lbl,
javax.swing.JPanel panel)
Utility method to generate the image object representing
the current content of the widget.
|
abstract java.awt.event.ActionListener |
editWindow(java.awt.Container dest)
Populates a container with the component objects
necessary for editing the current widget's properties.
|
void |
pcdOut(int scope,
java.lang.Appendable out)
Writes the BioPCD representation of the menu widget to a writer object
(see BioLegato's BioPCD editor for more details)
|
static void |
recursiveDraw(java.awt.Component comp,
java.awt.Graphics gfx)
Utility method to recursively draw every subcomponent in a Component
object onto a graphics object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
display, getInstance, setValue
protected java.lang.String name
public SimpleWidget(java.lang.String name)
name
- the PCD variable name (this name can be referenced
in the command using the % symbol; for example,
if the name value was set to "A", the value of this
widget could be accessed by using %A% (lower or
upper-case) within the PCD menu command string.public void pcdOut(int scope, java.lang.Appendable out) throws java.io.IOException
pcdOut
in interface Widget
scope
- the level of scope to write the menu widget. In the case
of PCD, the scope of each line is indicated by the number
of spaced preceding the line. Every 4 spaces count as
one level of scope (any number not divisible by 4 is
considered an error), thus if a line is preceded by 4
spaces, its scope level is considered to be 1out
- the Appendable object to output the BioPCD code.java.io.IOException
public abstract java.awt.event.ActionListener editWindow(java.awt.Container dest)
Populates a container with the component objects necessary for editing the current widget's properties.
This method takes the Container 'dest' and populates it with components which can change the properties of the current widget. In other words, this is the window which pops up when you double click on a widget in the PCD editor. For instance, if you place a text box in a PCD menu, then double click on it, you can set its internal PCD 'name' and default value, among other things.
This method returns an action listener, which is called when the widget should update. The reason for this is class extension. To allow sub-classes to use the same method ('editWindow') with only one button, and without re-writing code, an ActionListener object can be passed downwards to the child class. The child class may add code to call its parent class's ActionListener.
Please note that the ActionListener will likely be used by a calling method to create an "Update" button.
dest
- the destination Container object; this is where the
'editWindow' function will add add all of the Components
necessary for editing the Widget parameters (NOTE: this
class implements the Widget interface).public java.awt.Component displayEdit(javax.swing.JFrame mainFrame)
displayEdit
in interface Widget
mainFrame
- a JFrame object for adding modality to any dialog
boxes, which are created by this function.public static void editImage(javax.swing.JLabel lbl, javax.swing.JPanel panel)
lbl
- the destination label object to generate the image onpanel
- the panel containing the widget to draw the editImage forpublic static void recursiveDraw(java.awt.Component comp, java.awt.Graphics gfx)
comp
- the Component object to recursively drawgfx
- the Graphics object to output the image toCopyright © 2008-2022 University of Manitoba.