edu.nrao.sss.webapp.faces.component
Class GraphicalSelectorUIComponent

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIOutput
              extended by javax.faces.component.UIInput
                  extended by edu.nrao.sss.webapp.faces.component.GraphicalSelectorUIComponent
All Implemented Interfaces:
EditableValueHolder, StateHolder, ValueHolder

public class GraphicalSelectorUIComponent
extends UIInput

Renders a component that allows a user to select a set of rectangles.

These rectangles will be arranged with absolute positioning inside a div that can be styled with css. A typical usage may be to set the width, height, and background image of the div and position the rectangles over pertinent areas of the image. Selecting a rectangle would denote selecting the object under that rectangle in the image.

The positions of the rectangles are determined by an xml configuration file. Currently that file must contain all configurations that this component will be used for. The file must be at the root of the class path and be named graphicalSelector.cfg.xml. The simple schema for these files is below:

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <!-- Restricts names to being alphanumeric (with underscores). no spaces, min length 1 -->
        <xs:simpleType name="nameType">
                <xs:restriction base="xs:string">
                        <xs:pattern value="[a-zA-Z0-9_]+"/>
                </xs:restriction>
        </xs:simpleType>
 
        <xs:complexType name="regionType">
                <xs:attribute name="name" type="nameType" use="required"/>
                <xs:attribute name="x" type="xs:int" use="required"/>
                <xs:attribute name="y" type="xs:int" use="required"/>
                <xs:attribute name="width" type="xs:int" use="required"/>
                <xs:attribute name="height" type="xs:int" use="required"/>
        </xs:complexType>
 
        <xs:element name="selector-configuration">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="region-map" minOccurs="1" maxOccurs="unbounded">
                                        <xs:complexType>
                                                <xs:sequence>
                                                        <xs:element name="region" type="regionType" minOccurs="1" maxOccurs="unbounded"/>
                                                </xs:sequence>
                                                <xs:attribute name="name" type="nameType" use="required"/>
                                        </xs:complexType>
                                </xs:element>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
 </xs:schema>
 


Nested Class Summary
protected static class GraphicalSelectorUIComponent.CsvConverter
          Converts from a comma separated value String to a List of Strings and back.
 
Field Summary
 
Fields inherited from class javax.faces.component.UIInput
COMPONENT_FAMILY, COMPONENT_TYPE, CONVERSION_MESSAGE_ID, REQUIRED_MESSAGE_ID
 
Constructor Summary
GraphicalSelectorUIComponent()
           
 
Method Summary
 void decode(FacesContext context)
           
 void encodeBegin(FacesContext context)
          renders a div containing div's and hidden input fields for each defined rectangle in the chosen map.
 void encodeChildren(FacesContext context)
          Overridden to be empty.
 void encodeEnd(FacesContext context)
          Overridden to be empty.
 Converter getConverter()
          Overridden to provide an appropriate CSV to List converter for our value.
 String getMap()
           
 void restoreState(FacesContext context, Object state)
           
 Object saveState(FacesContext context)
           
 void setMap(String map)
           
 
Methods inherited from class javax.faces.component.UIInput
addValidator, addValueChangeListener, broadcast, compareValues, getConvertedValue, getFamily, getSubmittedValue, getValidator, getValidators, getValueChangeListener, getValueChangeListeners, isImmediate, isLocalValueSet, isRequired, isValid, processDecodes, processUpdates, processValidators, removeValidator, removeValueChangeListener, setImmediate, setLocalValueSet, setRequired, setSubmittedValue, setValid, setValidator, setValue, setValueChangeListener, updateModel, validate, validateValue
 
Methods inherited from class javax.faces.component.UIOutput
getLocalValue, getValue, setConverter
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.ValueHolder
getLocalValue, getValue, setConverter
 

Constructor Detail

GraphicalSelectorUIComponent

public GraphicalSelectorUIComponent()
Method Detail

encodeBegin

public void encodeBegin(FacesContext context)
                 throws IOException
renders a div containing div's and hidden input fields for each defined rectangle in the chosen map. If map is null, no rectangles are rendered. We also render javascript to highlight and select each rectangle.

Overrides:
encodeBegin in class UIComponentBase
Throws:
IOException

encodeEnd

public void encodeEnd(FacesContext context)
               throws IOException
Overridden to be empty.

Overrides:
encodeEnd in class UIComponentBase
Throws:
IOException

encodeChildren

public void encodeChildren(FacesContext context)
                    throws IOException
Overridden to be empty.

Overrides:
encodeChildren in class UIComponentBase
Throws:
IOException

decode

public void decode(FacesContext context)
Overrides:
decode in class UIInput

getMap

public String getMap()

setMap

public void setMap(String map)

saveState

public Object saveState(FacesContext context)
Specified by:
saveState in interface StateHolder
Overrides:
saveState in class UIInput

restoreState

public void restoreState(FacesContext context,
                         Object state)
Specified by:
restoreState in interface StateHolder
Overrides:
restoreState in class UIInput

getConverter

public Converter getConverter()
Overridden to provide an appropriate CSV to List converter for our value.

Specified by:
getConverter in interface ValueHolder
Overrides:
getConverter in class UIOutput


Copyright © 2009. All Rights Reserved.