public class ALDParameterPanel extends ALDSwingValueChangeReporter implements ALDSwingValueChangeListener
This class provides a panel containing GUI elements to configure all parameters of a set provided at initialization. Note that parameter labels can be marked and unmarked externally. This feature is, e.g., be used during parameter validation.
This panel allows to validate its parameters, i.e. if a certain parameter is declared as required, but reading the parameter results in 'null', the parameter is marked in the GUI.
Modifier and Type | Field and Description |
---|---|
private HashMap<ALDParameterDescriptor,ALDSwingComponent> |
compMap
Maps a parameter descriptor to its component in the GUI.
|
private HashMap<ALDParameterDescriptor,ALDSwingComponent> |
compMapLinkBak
Maps a parameter to the component shown if parameter is linked (in Grappa).
|
private HashMap<ALDParameterDescriptor,Boolean> |
isParamLinked
Map keeping track if parameters are linked or not (in Grappa).
|
private HashMap<ALDParameterDescriptor,JLabel> |
labelMap
Maps a descriptor to its
JLabel component in the panel. |
private static org.slf4j.Logger |
logger
Slf4j logger.
|
private JPanel |
mainPanel
The main panel containing everything.
|
private boolean |
onlyDisplay
Flag to disable editability of GUI elements.
|
private HashMap<ALDParameterDescriptor,JPanel> |
panelMap
Maps a parameter descriptor to its panel in the GUI.
|
private ALDParameterPanelParent |
panelParent
Reference of parent panel to which this one belongs.
|
private LinkedList<? extends ALDParameterDescriptor> |
paramDescriptors
List of parameter descriptors managed by this panel.
|
private JPanel |
titlePanel
The panel containing the title label.
|
private String |
titleString
Optional title string for panel.
|
private boolean |
topLevelCall
Flag indicating if panel is used on top level or not.
|
listenerList
Constructor and Description |
---|
ALDParameterPanel(ALDParameterPanelParent pPanel,
LinkedList<? extends ALDParameterDescriptor> paramDescrips,
String title,
boolean topLevel,
boolean noEdit)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
buildInputPanel()
Builds up the input panel, only called on construction.
|
int |
changeViewMode(Parameter.ExpertMode mode)
Changes the view mode.
|
void |
copyConfiguration(ALDParameterPanel parameterPanel) |
void |
disableComponents()
Disables all components in this panel.
|
void |
dispose()
Disposes all components in this panel.
|
void |
enableComponents()
Enables all components in this panel.
|
JPanel |
getJPanel()
Method to access associated panel.
|
void |
handleValueChangeEvent(ALDSwingValueChangeEvent event)
Method which is called on event occurence.
|
void |
markParameter(ALDParameterDescriptor descr)
Sets label color of parameter to red (e.g. if validation failed).
|
void |
markParameterProbablyConf(ALDParameterDescriptor descr) |
Object |
readParameter(ALDParameterDescriptor descr)
Get value of given parameter from the GUI element.
|
private void |
registerGUIElement(ALDParameterDescriptor descr)
Adds a graphical component for the given parameter to the GUI.
|
void |
setEnabled(boolean b)
Function to enable or disable the panel.
|
void |
setParameter(ALDParameterDescriptor descr,
Object value)
Set value of given parameter, i.e. pass the value to GUI component.
|
boolean |
setParamExternallyConfigured(ALDParameterDescriptor desc,
String val) |
boolean |
setParamNotExternallyConfigured(ALDParameterDescriptor desc) |
void |
setVisible(boolean isVisible)
Set panel visible or invisible.
|
void |
unmarkAllParameters()
Sets label colors of all parameter to black and of all links to blue.
|
void |
unmarkParameter(ALDParameterDescriptor descr)
Sets label color of parameter to black or of link to blue (e.g. if
validation successful).
|
void |
updateOperatorDescriptors(LinkedList<ALDOpParameterDescriptor> newDescr)
Updates the set of parameter descriptors.
|
private void |
updateParameterGUIElements()
Adds the graphical components for current parameters to panel.
|
HashMap<ALDParameterDescriptor,String> |
validateParameters()
Check if all GUI elements can deliver a proper (non-null) value.
|
addValueChangeEventListener, fireALDSwingValueChangeEvent, removeValueChangeEventListener
private static org.slf4j.Logger logger
private ALDParameterPanelParent panelParent
private JPanel mainPanel
private boolean onlyDisplay
If the flag is set true
, parameter editing is not possible,
i.e. the graphical elements in the window are not editable.
private boolean topLevelCall
Using the panel on top-level refers to usage with operators directly executed, while non-top-level use refers to usage with operators passed as parameters to other operators. In the second case no deep validation is done, i.e. required parameters are allowed to have null values. Consequently missing parameters are only marked orange in the GUI.
private LinkedList<? extends ALDParameterDescriptor> paramDescriptors
private String titleString
private JPanel titlePanel
private HashMap<ALDParameterDescriptor,JLabel> labelMap
JLabel
component in the panel.private HashMap<ALDParameterDescriptor,ALDSwingComponent> compMap
private HashMap<ALDParameterDescriptor,ALDSwingComponent> compMapLinkBak
private HashMap<ALDParameterDescriptor,JPanel> panelMap
private HashMap<ALDParameterDescriptor,Boolean> isParamLinked
public ALDParameterPanel(ALDParameterPanelParent pPanel, LinkedList<? extends ALDParameterDescriptor> paramDescrips, String title, boolean topLevel, boolean noEdit)
pPanel
- Reference to the parent panel.paramDescrips
- List of parameter descriptors to manage.title
- Title of panel.topLevel
- If true, null returns are forbidden.noEdit
- If true, elements cannot be edited.private void buildInputPanel()
private void updateParameterGUIElements()
private void registerGUIElement(ALDParameterDescriptor descr)
The method checks if the parameter is already known, i.e., if graphical components, labels and panels have already been initialized before. If so, these elements are used, otherwise new components are initialized.
descr
- Descriptor of the parameter to be added to the GUI.public JPanel getJPanel()
public int changeViewMode(Parameter.ExpertMode mode)
There are the view modes 'standard' and 'advanced' available in the GUI. In standard mode only the parameters annotated as standard are visible, while in advanced mode all parameters are visible.
mode
- Desired display mode.public void setEnabled(boolean b)
b
- If true, panel is enabled, otherwise components are disabled.public void setVisible(boolean isVisible)
isVisible
- If true, panel is set visible.public void disableComponents()
public void enableComponents()
public void dispose()
public void updateOperatorDescriptors(LinkedList<ALDOpParameterDescriptor> newDescr)
newDescr
- Set of new descriptors.public Object readParameter(ALDParameterDescriptor descr) throws ALDDataIOProviderException
descr
- Descriptor of desired parameter.ALDDataIOException
ALDDataIOProviderException
public void setParameter(ALDParameterDescriptor descr, Object value) throws ALDDataIOProviderException
descr
- Descriptor of parameter to be updated.value
- New value of parameter to be displayed.ALDDataIOException
ALDDataIOProviderException
public boolean setParamExternallyConfigured(ALDParameterDescriptor desc, String val)
public boolean setParamNotExternallyConfigured(ALDParameterDescriptor desc)
public void markParameter(ALDParameterDescriptor descr)
descr
- Descriptor of parameter to mark.public void markParameterProbablyConf(ALDParameterDescriptor descr)
public void unmarkParameter(ALDParameterDescriptor descr)
descr
- Descriptor of parameter to unmark.public void unmarkAllParameters()
public HashMap<ALDParameterDescriptor,String> validateParameters()
Parameters delivering null as value are marked red or orange. Red color is used for panels used in top-level context, orange otherwise.
public void copyConfiguration(ALDParameterPanel parameterPanel) throws ALDDataIOException
ALDDataIOException
public void handleValueChangeEvent(ALDSwingValueChangeEvent event)
ALDSwingValueChangeListener
handleValueChangeEvent
in interface ALDSwingValueChangeListener
event
- Event to be handled.Copyright © 2010–2021 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.