ucar.unidata.idv
Class ControlDescriptor

java.lang.Object
  extended by ucar.unidata.idv.ControlDescriptor

public class ControlDescriptor
extends Object

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
static String ATTR_CANSTANDALONE
          Xml "canstandalone" attribute name for the control descriptor xml
static String ATTR_CATEGORIES
          Xml "categories" attribute name for the control descriptor xml
static String ATTR_CLASS
          Xml "class" attribute name for the control descriptor xml
static String ATTR_CODE
          Xml "code" attribute name for the control descriptor xml
static String ATTR_DESCRIPTION
          Xml "description" attribute name for the control descriptor xml
static String ATTR_DISPLAYCATEGORY
          Xml "displaycategory" attribute name for the control descriptor xml
static String ATTR_DOESLEVELS
           
static String ATTR_ICON
          Xml "icon" attribute name for the control descriptor xml
static String ATTR_ID
          Xml "id" attribute name for the control descriptor xml
static String ATTR_LABEL
          Xml "label" attribute name for the control descriptor xml
static String ATTR_NAME
          Xml "name" attribute name for the display xml
static String ATTR_PROPERTIES
          Xml "properties" attribute name for the control descriptor xml
static String ATTR_SOURCE
          Xml "source" attribute name for the display xml
static String ATTR_TYPE
          Xml "type" attribute name for the display xml
static String ATTR_VALUE
          Xml "name" attribute value for the display xml
static String ATTR_VIEWMANAGERS
          Xml "viewmanagers" attribute name for the control descriptor xml
 boolean canStandAlone
          If true the the DisplayControl this descriptor represents can be created without any data choices.
 String className
          The name of the DisplayControl class this descriptor represents
static String DISPLAYID_MAP
          The id in the controls.xml file for the map display
 boolean doesLevels
          Does this control do levels
static String ID_DISPLAYTEMPLATE
          Special control descriptor ID for the display templates
static String PROP_DISPLAYNAME
          Xml "label" attribute name for the control descriptor xml
static String TAG_CONTROL
          Xml "control" tag name for the control descriptor xml
static String TAG_CONTROLS
          Xml "controls" tag name for the control descriptor xml
static String TAG_DATACHOICE
          Xml "datachoice" tag name for the display xml
static String TAG_DATASOURCE
          Xml "datasource" tag name for the display xml
static String TAG_DISPLAY
          Xml "display" tag name for the display xml
static String TAG_PROPERTY
          Xml "properties" attribute name for the control descriptor xml
 
Constructor Summary
ControlDescriptor()
          Parameterless constructor for xml encoding/decoding
ControlDescriptor(IntegratedDataViewer idv, Element node)
          Create the descriptor
ControlDescriptor(IntegratedDataViewer idv, String displayTemplateFile, DisplayControl prototype)
          Constructor for when we are a wrapper around a display template
 
Method Summary
 boolean applicableTo(DataCategory category)
          Wrapper that calls applicableTo with a list that contains the given category
 boolean applicableTo(DataChoice dataChoice)
          Wrapper that calls applicableTo with the list of categories of the given DataChoice.
 boolean applicableTo(List categories)
          Go through the list of categories.
 boolean canStandAlone()
          Can this descriptor stand alone
static void createControlDescriptor(IntegratedDataViewer idv, Element node)
          Create the control descriptor described by the given control node
static void createControlDescriptors(IntegratedDataViewer idv, Element root)
          Create the control descriptors described under the root xml element.
 boolean doesLevels()
          Does levels
 DisplayControl doMakeDisplay(DataChoice dataChoice, IntegratedDataViewer viewer, String argProperties, DataSelection dataSelection)
          Wrapper method that makes a single element array of DataChoices with the given DataChoice parameter.
 DisplayControl doMakeDisplay(List dataChoices, IntegratedDataViewer viewer, Hashtable argProperties, DataSelection dataSelection, boolean initDisplayInThread)
          Instantiate the DisplayControl defined by the Class data member.
 DisplayControl doMakeDisplay(List dataChoices, IntegratedDataViewer viewer, String argPropertiesString, DataSelection dataSelection, boolean initDisplayInThread)
          Instantiate the DisplayControl defined by the Class data member.
static List getApplicableControlDescriptors(List categories, List descriptors)
          This finds and returns the set of ControlDescriptors, from the given descriptors list, that are applicable to any of the DataCategorys 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.
 List getCategories()
          Get the list of DataCategorys
 String getControlId()
          Get the control id Mostly used for xml encoding
 String getDescription()
          get the description Mostly used for xml encoding
protected  void getDescriptorXml(StringBuffer sb)
          Get the xml representation of the controls.xml node
 String getDisplayCategory()
          Get the display category.
 String getDisplayTemplateFile()
          Get the DisplayTemplateFile property.
 String getIcon()
          Get the path to the icon used in the GUI
 String getLabel()
          Get the label Mostly used for xml encoding
 Hashtable getProperties()
          Get the semi-color delimited list of name=value properties that is passed to the display control
 String getToolTipText()
          Get the tooltip text
 void initControl(DisplayControl control, List newDataChoices, IntegratedDataViewer idv, Hashtable newProperties, DataSelection dataSelection)
          Initializes the DisplayControl
 void initControl(DisplayControl control, List newDataChoices, IntegratedDataViewer idv, String properties, DataSelection dataSelection)
          Deprecated. Use other initControl
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 objects
static void logException(String msg, Throwable exc)
          Log the error
static void processDisplayXml(IntegratedDataViewer idv, String xml)
          Process the given display xml file.
 void setCategories(List categoryList)
          Set the list of DataCategorys
 void setDescription(String description)
          Set the description Mostly used for xml encoding
 void setDisplayCategory(String c)
          Set the display category.
 void setDisplayTemplateFile(String value)
          Set the DisplayTemplateFile property.
 void setLabel(String label)
          Set the label Mostly used for xml encoding
 void showHelp()
          Show help for the display control
 String toString()
          String representation of this object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ID_DISPLAYTEMPLATE

public static final String ID_DISPLAYTEMPLATE
Special control descriptor ID for the display templates

See Also:
Constant Field Values

DISPLAYID_MAP

public static final String DISPLAYID_MAP
The id in the controls.xml file for the map display

See Also:
Constant Field Values

TAG_CONTROLS

public static final String TAG_CONTROLS
Xml "controls" tag name for the control descriptor xml

See Also:
Constant Field Values

TAG_CONTROL

public static final String TAG_CONTROL
Xml "control" tag name for the control descriptor xml

See Also:
Constant Field Values

ATTR_CATEGORIES

public static final String ATTR_CATEGORIES
Xml "categories" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_DOESLEVELS

public static final String ATTR_DOESLEVELS
See Also:
Constant Field Values

ATTR_DISPLAYCATEGORY

public static final String ATTR_DISPLAYCATEGORY
Xml "displaycategory" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_CLASS

public static final String ATTR_CLASS
Xml "class" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_DESCRIPTION

public static final String ATTR_DESCRIPTION
Xml "description" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_CODE

public static final String ATTR_CODE
Xml "code" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_ICON

public static final String ATTR_ICON
Xml "icon" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_ID

public static final String ATTR_ID
Xml "id" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_LABEL

public static final String ATTR_LABEL
Xml "label" attribute name for the control descriptor xml

See Also:
Constant Field Values

TAG_PROPERTY

public static final String TAG_PROPERTY
Xml "properties" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_PROPERTIES

public static final String ATTR_PROPERTIES
Xml "properties" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_CANSTANDALONE

public static final String ATTR_CANSTANDALONE
Xml "canstandalone" attribute name for the control descriptor xml

See Also:
Constant Field Values

ATTR_VIEWMANAGERS

public static final String ATTR_VIEWMANAGERS
Xml "viewmanagers" attribute name for the control descriptor xml

See Also:
Constant Field Values

TAG_DISPLAY

public static final String TAG_DISPLAY
Xml "display" tag name for the display xml

See Also:
Constant Field Values

TAG_DATACHOICE

public static final String TAG_DATACHOICE
Xml "datachoice" tag name for the display xml

See Also:
Constant Field Values

TAG_DATASOURCE

public static final String TAG_DATASOURCE
Xml "datasource" tag name for the display xml

See Also:
Constant Field Values

ATTR_NAME

public static final String ATTR_NAME
Xml "name" attribute name for the display xml

See Also:
Constant Field Values

ATTR_VALUE

public static final String ATTR_VALUE
Xml "name" attribute value for the display xml

See Also:
Constant Field Values

ATTR_SOURCE

public static final String ATTR_SOURCE
Xml "source" attribute name for the display xml

See Also:
Constant Field Values

ATTR_TYPE

public static final String ATTR_TYPE
Xml "type" attribute name for the display xml

See Also:
Constant Field Values

PROP_DISPLAYNAME

public static final String PROP_DISPLAYNAME
Xml "label" attribute name for the control descriptor xml

See Also:
Constant Field Values

className

public String className
The name of the DisplayControl class this descriptor represents


canStandAlone

public boolean canStandAlone
If true the the DisplayControl this descriptor represents can be created without any data choices. (e.g., radar rings)


doesLevels

public boolean doesLevels
Does this control do levels

Constructor Detail

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 idv
displayTemplateFile - 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

public ControlDescriptor(IntegratedDataViewer idv,
                         Element node)
                  throws ClassNotFoundException
Create the descriptor

Parameters:
idv - The IDV
node - The xml node that defines this descriptor
Throws:
ClassNotFoundException - When the Class defined by the classname attribute cannot be found.
Method Detail

getDescriptorXml

protected void getDescriptorXml(StringBuffer sb)
Get the xml representation of the controls.xml node

Parameters:
sb - buffer to append to

load

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 objects

Parameters:
idv - The IDV
resources - The collection of controls descriptor .xml files

createControlDescriptors

public static void createControlDescriptors(IntegratedDataViewer idv,
                                            Element root)
Create the control descriptors described under the root xml element.

Parameters:
idv - The IDV
root - The root of the control descriptor xml

processDisplayXml

public static void processDisplayXml(IntegratedDataViewer idv,
                                     String xml)
Process the given display xml file.

Parameters:
idv - The IDV
xml - The xml (e.g., from resources/controls.xml)

createControlDescriptor

public static void createControlDescriptor(IntegratedDataViewer idv,
                                           Element node)
Create the control descriptor described by the given control node

Parameters:
idv - The IDV
node - The control node

getApplicableControlDescriptors

public static List getApplicableControlDescriptors(List categories,
                                                   List descriptors)
This finds and returns the set of ControlDescriptors, from the given descriptors list, that are applicable to any of the DataCategorys in the given categories list.

Parameters:
categories - List of DataCategorys
descriptors - 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 categories
descriptors - The descriptors to check
includeStandAlone - ditto
includeIfEmpty - 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

doesLevels

public boolean doesLevels()
Does levels

Returns:
does levels

getProperties

public Hashtable getProperties()
Get the semi-color delimited list of name=value properties that is passed to the display control

Returns:
The properties string

getIcon

public String getIcon()
Get the path to the icon used in the GUI

Returns:
The icon path

getCategories

public List getCategories()
Get the list of DataCategorys

Returns:
List of data categories

setCategories

public void setCategories(List categoryList)
Set the list of DataCategorys

Parameters:
categoryList - The new category list

applicableTo

public boolean applicableTo(DataChoice dataChoice)
Wrapper that calls applicableTo with the list of categories of the given DataChoice.

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

public boolean applicableTo(DataCategory category)
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

public boolean applicableTo(List categories)
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 of DataCategorys
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 with
viewer - The IDV
argProperties - Semi-colon separated name=value property string
dataSelection - 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 reflection
InstantiationException - When something bad happens in the reflection based object creation
InvocationTargetException - When something bad happens in the reflection based object creation
RemoteException - When something bad happens in the instantiated DisplayControl
VisADException - 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 of DataChoices to instantiate the display control with.
viewer - The IDV
argPropertiesString - Semi-colon separated name=value property string
dataSelection - 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 reflection
InstantiationException - When something bad happens in the reflection based object creation
InvocationTargetException - When something bad happens in the reflection based object creation
RemoteException - When something bad happens in the instantiated DisplayControl
VisADException - 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 of DataChoices to instantiate the display control with.
viewer - The IDV
argProperties - properties
dataSelection - 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 reflection
InstantiationException - When something bad happens in the reflection based object creation
InvocationTargetException - When something bad happens in the reflection based object creation
RemoteException - When something bad happens in the instantiated DisplayControl
VisADException - When something bad happens in the instantiated DisplayControl

initControl

public void initControl(DisplayControl control,
                        List newDataChoices,
                        IntegratedDataViewer idv,
                        String properties,
                        DataSelection dataSelection)
Deprecated. Use other initControl

Initializes the DisplayControl

Parameters:
control - The control to initialize
newDataChoices - List of DataChoices to pass to the display control
idv - The idv
properties - properties
dataSelection - The data selection that the user may have defined to hold data subsetting information (e.g., times)

initControl

public void initControl(DisplayControl control,
                        List newDataChoices,
                        IntegratedDataViewer idv,
                        Hashtable newProperties,
                        DataSelection dataSelection)
Initializes the DisplayControl

Parameters:
control - The control to initialize
newDataChoices - List of DataChoices to pass to the display control
idv - The idv
newProperties - Semi-colon delimited list of name=value properties
dataSelection - The data selection that the user may have defined to hold data subsetting information (e.g., times)

getLabel

public String getLabel()
Get the label Mostly used for xml encoding

Returns:
The label

setLabel

public void setLabel(String label)
Set the label Mostly used for xml encoding

Parameters:
label - The label

getControlId

public String getControlId()
Get the control id Mostly used for xml encoding

Returns:
The control id

getDescription

public String getDescription()
get the description Mostly used for xml encoding

Returns:
The description

getToolTipText

public String getToolTipText()
Get the tooltip text

Returns:
tooltip

setDescription

public void setDescription(String description)
Set the description Mostly used for xml encoding

Parameters:
description - The description

toString

public String toString()
String representation of this object

Overrides:
toString in class Object
Returns:
The label

logException

public static void logException(String msg,
                                Throwable exc)
Log the error

Parameters:
msg - error message
exc - The exception

getDisplayCategory

public String getDisplayCategory()
Get the display category. Mostly used for xml encoding

Returns:
The display category

setDisplayCategory

public void setDisplayCategory(String c)
Set the display category. Mostly used for xml encoding

Parameters:
c - The display category

setDisplayTemplateFile

public void setDisplayTemplateFile(String value)
Set the DisplayTemplateFile property.

Parameters:
value - The new value for DisplayTemplateFile

getDisplayTemplateFile

public String getDisplayTemplateFile()
Get the DisplayTemplateFile property.

Returns:
The DisplayTemplateFile