Package ucar.unidata.idv
Class ControlDescriptor
java.lang.Object
ucar.unidata.idv.ControlDescriptor
This holds a description, derived from a controls.xml file,
of a
DisplayControl
. It provides facilities
for instantiating the DisplayControl it represents.- Author:
- IDV development team
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Xml "canstandalone" attribute name for the control descriptor xmlstatic final String
Xml "categories" attribute name for the control descriptor xmlstatic final String
Xml "class" attribute name for the control descriptor xmlstatic final String
Xml "code" attribute name for the control descriptor xmlstatic final String
Xml "description" attribute name for the control descriptor xmlstatic final String
Xml "displaycategory" attribute name for the control descriptor xmlstatic final String
static final String
Xml "icon" attribute name for the control descriptor xmlstatic final String
Xml "id" attribute name for the control descriptor xmlstatic final String
Xml "label" attribute name for the control descriptor xmlstatic final String
Xml "levels" attribute name for the control descriptor xmlstatic final String
Xml "name" attribute name for the display xmlstatic final String
Xml "properties" attribute name for the control descriptor xmlstatic final String
Xml "source" attribute name for the display xmlstatic final String
Xml "type" attribute name for the display xmlstatic final String
Xml "name" attribute value for the display xmlstatic final String
Xml "viewmanagers" attribute name for the control descriptor xmlboolean
If true the theDisplayControl
this descriptor represents can be created without any data choices.The name of theDisplayControl
class this descriptor representsstatic final String
The id in the controls.xml file for the map displayboolean
Does this control do levelsstatic final String
Special control descriptor ID for the display templatesstatic final String
Xml "label" attribute name for the control descriptor xmlstatic final String
Xml "control" tag name for the control descriptor xmlstatic final String
Xml "controls" tag name for the control descriptor xmlstatic final String
Xml "datachoice" tag name for the display xmlstatic final String
Xml "datasource" tag name for the display xmlstatic final String
Xml "display" tag name for the display xmlstatic final String
Xml "properties" attribute name for the control descriptor xml -
Constructor Summary
ConstructorsConstructorDescriptionParameterless constructor for xml encoding/decodingControlDescriptor
(IntegratedDataViewer idv, String displayTemplateFile, DisplayControl prototype) Constructor for when we are a wrapper around a display templateControlDescriptor
(IntegratedDataViewer idv, Element node) Create the descriptor -
Method Summary
Modifier and TypeMethodDescriptionboolean
applicableTo
(List categories) Go through the list of categories.boolean
applicableTo
(DataCategory category) Wrapper that calls applicableTo with a list that contains the given categoryboolean
applicableTo
(DataChoice dataChoice) Wrapper that calls applicableTo with the list of categories of the givenDataChoice
.boolean
Can this descriptor stand alonestatic void
createControlDescriptor
(IntegratedDataViewer idv, Element node) Create the control descriptor described by the given control nodestatic void
createControlDescriptors
(IntegratedDataViewer idv, Element root) Create the control descriptors described under the root xml element.boolean
Does levelsdoMakeDisplay
(List dataChoices, IntegratedDataViewer viewer, String argPropertiesString, DataSelection dataSelection, boolean initDisplayInThread) Instantiate the DisplayControl defined by the Class data member.doMakeDisplay
(List dataChoices, IntegratedDataViewer viewer, Hashtable argProperties, DataSelection dataSelection, boolean initDisplayInThread) Instantiate the DisplayControl defined by the Class data member.doMakeDisplay
(DataChoice dataChoice, IntegratedDataViewer viewer, String argProperties, DataSelection dataSelection) Wrapper method that makes a single element array of DataChoices with the given DataChoice parameter.static List
getApplicableControlDescriptors
(List categories, List descriptors) This finds and returns the set ofControlDescriptor
s, from the given descriptors list, that are applicable to any of theDataCategory
s in the given categories list.static List
getApplicableControlDescriptors
(List categories, List descriptors, boolean includeStandAlone, boolean includeIfEmpty) Find the list of control descriptors that are applicable applicable to the given data categories.Get the list ofDataCategory
sGet the control id Mostly used for xml encodingget the description Mostly used for xml encodingprotected void
Get the xml representation of the controls.xml nodeGet the display category.Get the DisplayTemplateFile property.getIcon()
Get the path to the icon used in the GUIgetLabel()
Get the label Mostly used for xml encodingGet the levelsGet the semi-color delimited list of name=value properties that is passed to the display controlGet the tooltip textvoid
initControl
(DisplayControl control, List newDataChoices, IntegratedDataViewer idv, String properties, DataSelection dataSelection) Initializes theDisplayControl
void
initControl
(DisplayControl control, List newDataChoices, IntegratedDataViewer idv, Hashtable newProperties, DataSelection dataSelection) Initializes theDisplayControl
protected static void
load
(IntegratedDataViewer idv, XmlResourceCollection resources) Iterate through the ControlDescriptor describing xml files defined by the given resources parameter and create the ControlDescriptor objectsstatic void
logException
(String msg, Throwable exc) Log the errorstatic void
processDisplayXml
(IntegratedDataViewer idv, String xml) Process the given display xml file.void
setCategories
(List categoryList) Set the list ofDataCategory
svoid
setDescription
(String description) Set the description Mostly used for xml encodingvoid
Set the display category.void
setDisplayTemplateFile
(String value) Set the DisplayTemplateFile property.void
Set the label Mostly used for xml encodingvoid
showHelp()
Show help for the display controltoString()
String representation of this object
-
Field Details
-
ID_DISPLAYTEMPLATE
Special control descriptor ID for the display templates- See Also:
-
DISPLAYID_MAP
The id in the controls.xml file for the map display- See Also:
-
TAG_CONTROLS
Xml "controls" tag name for the control descriptor xml- See Also:
-
TAG_CONTROL
Xml "control" tag name for the control descriptor xml- See Also:
-
ATTR_CATEGORIES
Xml "categories" attribute name for the control descriptor xml- See Also:
-
ATTR_DOESLEVELS
- See Also:
-
ATTR_DISPLAYCATEGORY
Xml "displaycategory" attribute name for the control descriptor xml- See Also:
-
ATTR_CLASS
Xml "class" attribute name for the control descriptor xml- See Also:
-
ATTR_DESCRIPTION
Xml "description" attribute name for the control descriptor xml- See Also:
-
ATTR_CODE
Xml "code" attribute name for the control descriptor xml- See Also:
-
ATTR_ICON
Xml "icon" attribute name for the control descriptor xml- See Also:
-
ATTR_ID
Xml "id" attribute name for the control descriptor xml- See Also:
-
ATTR_LABEL
Xml "label" attribute name for the control descriptor xml- See Also:
-
ATTR_LEVELS
Xml "levels" attribute name for the control descriptor xml- See Also:
-
TAG_PROPERTY
Xml "properties" attribute name for the control descriptor xml- See Also:
-
ATTR_PROPERTIES
Xml "properties" attribute name for the control descriptor xml- See Also:
-
ATTR_CANSTANDALONE
Xml "canstandalone" attribute name for the control descriptor xml- See Also:
-
ATTR_VIEWMANAGERS
Xml "viewmanagers" attribute name for the control descriptor xml- See Also:
-
TAG_DISPLAY
Xml "display" tag name for the display xml- See Also:
-
TAG_DATACHOICE
Xml "datachoice" tag name for the display xml- See Also:
-
TAG_DATASOURCE
Xml "datasource" tag name for the display xml- See Also:
-
ATTR_NAME
Xml "name" attribute name for the display xml- See Also:
-
ATTR_VALUE
Xml "name" attribute value for the display xml- See Also:
-
ATTR_SOURCE
Xml "source" attribute name for the display xml- See Also:
-
ATTR_TYPE
Xml "type" attribute name for the display xml- See Also:
-
PROP_DISPLAYNAME
Xml "label" attribute name for the control descriptor xml- See Also:
-
className
The name of theDisplayControl
class this descriptor represents -
canStandAlone
public boolean canStandAloneIf true the theDisplayControl
this descriptor represents can be created without any data choices. (e.g., radar rings) -
doesLevels
public boolean doesLevelsDoes this control do levels
-
-
Constructor Details
-
ControlDescriptor
public ControlDescriptor()Parameterless constructor for xml encoding/decoding -
ControlDescriptor
public ControlDescriptor(IntegratedDataViewer idv, String displayTemplateFile, DisplayControl prototype) Constructor for when we are a wrapper around a display template- Parameters:
idv
- The idvdisplayTemplateFile
- The template we are a wrapper around.prototype
- This is the prototype object that is created form the display template. we get it passed in here so we can grab some of its state (e.g., categories).
-
ControlDescriptor
Create the descriptor- Parameters:
idv
- The IDVnode
- The xml node that defines this descriptor- Throws:
ClassNotFoundException
- When the Class defined by the classname attribute cannot be found.
-
-
Method Details
-
getDescriptorXml
Get the xml representation of the controls.xml node- Parameters:
sb
- buffer to append to
-
load
Iterate through the ControlDescriptor describing xml files defined by the given resources parameter and create the ControlDescriptor objects- Parameters:
idv
- The IDVresources
- The collection of controls descriptor .xml files
-
createControlDescriptors
Create the control descriptors described under the root xml element.- Parameters:
idv
- The IDVroot
- The root of the control descriptor xml
-
processDisplayXml
Process the given display xml file.- Parameters:
idv
- The IDVxml
- The xml (e.g., from resources/controls.xml)
-
createControlDescriptor
Create the control descriptor described by the given control node- Parameters:
idv
- The IDVnode
- The control node
-
getApplicableControlDescriptors
This finds and returns the set ofControlDescriptor
s, from the given descriptors list, that are applicable to any of theDataCategory
s in the given categories list.- Parameters:
categories
- List ofDataCategory
sdescriptors
- List of control descriptors- Returns:
- List of applicable control descriptors
-
getApplicableControlDescriptors
public static List getApplicableControlDescriptors(List categories, List descriptors, boolean includeStandAlone, boolean includeIfEmpty) Find the list of control descriptors that are applicable applicable to the given data categories.- Parameters:
categories
- The categoriesdescriptors
- The descriptors to checkincludeStandAlone
- dittoincludeIfEmpty
- If we have no categories do we keep going- Returns:
- List of ControlDescriptors
-
showHelp
public void showHelp()Show help for the display control -
canStandAlone
public boolean canStandAlone()Can this descriptor stand alone- Returns:
- Can stand alone
-
getLevels
Get the levels- Returns:
- the levels
-
doesLevels
public boolean doesLevels()Does levels- Returns:
- does levels
-
getProperties
Get the semi-color delimited list of name=value properties that is passed to the display control- Returns:
- The properties string
-
getIcon
Get the path to the icon used in the GUI- Returns:
- The icon path
-
getCategories
Get the list ofDataCategory
s- Returns:
- List of data categories
-
setCategories
Set the list ofDataCategory
s- Parameters:
categoryList
- The new category list
-
applicableTo
Wrapper that calls applicableTo with the list of categories of the givenDataChoice
.- Parameters:
dataChoice
- The data choice we get the categories from- Returns:
- Is the display control applicable to any of DataCategory-s that describe the given DataChoice
-
applicableTo
Wrapper that calls applicableTo with a list that contains the given category- Parameters:
category
- The category to add into the list- Returns:
- Is the display control applicable to this DataCategory
-
applicableTo
Go through the list of categories. If any of the data categories for this object is applicable to any of the given categories then return true. Else return false;- Parameters:
categories
- The list ofDataCategory
s- Returns:
- Is the display control applicable to any of DataCategory-s in the list
-
doMakeDisplay
public DisplayControl doMakeDisplay(DataChoice dataChoice, IntegratedDataViewer viewer, String argProperties, DataSelection dataSelection) throws InstantiationException, VisADException, RemoteException, IllegalAccessException, InvocationTargetException Wrapper method that makes a single element array of DataChoices with the given DataChoice parameter. This just creates a list holding the given data choice and passes through to(List,IntegratedDataView,String,DataSelection)
- Parameters:
dataChoice
- The data choice to create the display withviewer
- The IDVargProperties
- Semi-colon separated name=value property stringdataSelection
- The data selection that the user may have defined for subsetting times, etc.- Returns:
- The newly create DisplayControl
- Throws:
IllegalAccessException
- When we cannot access the constructor through reflectionInstantiationException
- When something bad happens in the reflection based object creationInvocationTargetException
- When something bad happens in the reflection based object creationRemoteException
- When something bad happens in the instantiated DisplayControlVisADException
- When something bad happens in the instantiated DisplayControl
-
doMakeDisplay
public DisplayControl doMakeDisplay(List dataChoices, IntegratedDataViewer viewer, String argPropertiesString, DataSelection dataSelection, boolean initDisplayInThread) throws InstantiationException, VisADException, RemoteException, IllegalAccessException, InvocationTargetException Instantiate the DisplayControl defined by the Class data member. This clones the given dataChoices list and the data choices it contains, creates the DisplayControl via reflection and then initializes the control in a thread.- Parameters:
dataChoices
- List ofDataChoice
s to instantiate the display control with.viewer
- The IDVargPropertiesString
- Semi-colon separated name=value property stringdataSelection
- The data selection that the user may have defined for subsetting times, etc.initDisplayInThread
- If true then initialize the display in a thread, else do it here- Returns:
- The newly create DisplayControl
- Throws:
IllegalAccessException
- When we cannot access the constructor through reflectionInstantiationException
- When something bad happens in the reflection based object creationInvocationTargetException
- When something bad happens in the reflection based object creationRemoteException
- When something bad happens in the instantiated DisplayControlVisADException
- When something bad happens in the instantiated DisplayControl
-
doMakeDisplay
public DisplayControl doMakeDisplay(List dataChoices, IntegratedDataViewer viewer, Hashtable argProperties, DataSelection dataSelection, boolean initDisplayInThread) throws InstantiationException, VisADException, RemoteException, IllegalAccessException, InvocationTargetException Instantiate the DisplayControl defined by the Class data member. This clones the given dataChoices list and the data choices it contains, creates the DisplayControl via reflection and then initializes the control in a thread.- Parameters:
dataChoices
- List ofDataChoice
s to instantiate the display control with.viewer
- The IDVargProperties
- propertiesdataSelection
- The data selection that the user may have defined for subsetting times, etc.initDisplayInThread
- If true then initialize the display in a thread, else do it here- Returns:
- The newly create DisplayControl
- Throws:
IllegalAccessException
- When we cannot access the constructor through reflectionInstantiationException
- When something bad happens in the reflection based object creationInvocationTargetException
- When something bad happens in the reflection based object creationRemoteException
- When something bad happens in the instantiated DisplayControlVisADException
- When something bad happens in the instantiated DisplayControl
-
initControl
public void initControl(DisplayControl control, List newDataChoices, IntegratedDataViewer idv, String properties, DataSelection dataSelection) Initializes theDisplayControl
- Parameters:
control
- The control to initializenewDataChoices
- List ofDataChoice
s to pass to the display controlidv
- The idvproperties
- propertiesdataSelection
- The data selection that the user may have defined to hold data subsetting information (e.g., times) deprecated Use other initControl
-
initControl
public void initControl(DisplayControl control, List newDataChoices, IntegratedDataViewer idv, Hashtable newProperties, DataSelection dataSelection) Initializes theDisplayControl
- Parameters:
control
- The control to initializenewDataChoices
- List ofDataChoice
s to pass to the display controlidv
- The idvnewProperties
- Semi-colon delimited list of name=value propertiesdataSelection
- The data selection that the user may have defined to hold data subsetting information (e.g., times)
-
getLabel
Get the label Mostly used for xml encoding- Returns:
- The label
-
setLabel
Set the label Mostly used for xml encoding- Parameters:
label
- The label
-
getControlId
Get the control id Mostly used for xml encoding- Returns:
- The control id
-
getDescription
get the description Mostly used for xml encoding- Returns:
- The description
-
getToolTipText
Get the tooltip text- Returns:
- tooltip
-
setDescription
Set the description Mostly used for xml encoding- Parameters:
description
- The description
-
toString
String representation of this object -
logException
Log the error- Parameters:
msg
- error messageexc
- The exception
-
getDisplayCategory
Get the display category. Mostly used for xml encoding- Returns:
- The display category
-
setDisplayCategory
Set the display category. Mostly used for xml encoding- Parameters:
c
- The display category
-
setDisplayTemplateFile
Set the DisplayTemplateFile property.- Parameters:
value
- The new value for DisplayTemplateFile
-
getDisplayTemplateFile
Get the DisplayTemplateFile property.- Returns:
- The DisplayTemplateFile
-