Author: kono
Date: 2011-06-17 13:00:32 -0700 (Fri, 17 Jun 2011)
New Revision: 25795
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertyBuilder.java
Log:
Source code format was broken and had been re-formatted. NO FUNCTIONAL CHANGE.
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertyBuilder.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertyBuilder.java
2011-06-17 19:58:54 UTC (rev 25794)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertyBuilder.java
2011-06-17 20:00:32 UTC (rev 25795)
@@ -71,281 +71,281 @@
* Create property for the Property Sheet object.
*/
public class VizMapPropertyBuilder {
- private static final Logger logger =
LoggerFactory.getLogger(VizMapPropertyBuilder.class);
+ private static final Logger logger =
LoggerFactory.getLogger(VizMapPropertyBuilder.class);
- private DefaultTableCellRenderer emptyBoxRenderer;
- private DefaultTableCellRenderer filledBoxRenderer;
+ private DefaultTableCellRenderer emptyBoxRenderer;
+ private DefaultTableCellRenderer filledBoxRenderer;
- private EditorManager editorManager;
+ private EditorManager editorManager;
- private CyNetworkManager cyNetworkManager;
- private CyTableManager tableMgr;
+ private CyNetworkManager cyNetworkManager;
+ private CyTableManager tableMgr;
- public VizMapPropertyBuilder(CyNetworkManager cyNetworkManager,
EditorManager editorManager, CyTableManager tableMgr) {
- this.cyNetworkManager = cyNetworkManager;
- this.editorManager = editorManager;
- this.tableMgr = tableMgr;
- }
+ public VizMapPropertyBuilder(CyNetworkManager cyNetworkManager,
EditorManager editorManager, CyTableManager tableMgr) {
+ this.cyNetworkManager = cyNetworkManager;
+ this.editorManager = editorManager;
+ this.tableMgr = tableMgr;
+ }
- /**
- * Build one property for one visual property.
- *
- * @param <K>
- * data type of attribute to be mapped.
- * @param <V>
- * data type of Visual Property.
- *
- */
- public <K, V> VizMapperProperty<VisualProperty<V>, String,
VisualMappingFunctionFactory> buildProperty(
- final VisualMappingFunction<K, V> visualMapping, final String
categoryName,
- final PropertySheetPanel propertySheetPanel, final
VisualMappingFunctionFactory factory) {
+ /**
+ * Build one property for one visual property.
+ *
+ * @param <K>
+ * data type of attribute to be mapped.
+ * @param <V>
+ * data type of Visual Property.
+ *
+ */
+ public <K, V> VizMapperProperty<VisualProperty<V>, String,
VisualMappingFunctionFactory> buildProperty(
+ final VisualMappingFunction<K, V> visualMapping, final
String categoryName,
+ final PropertySheetPanel propertySheetPanel, final
VisualMappingFunctionFactory factory) {
- logger.debug("\n\n\n************************* buildProp called: Root VP
= " + categoryName);
+ logger.debug("\n\n\n************************* buildProp called:
Root VP = " + categoryName);
- // Mapping is empty
- if (visualMapping == null)
- throw new NullPointerException("Mapping is null.");
- if (categoryName == null)
- throw new NullPointerException(
- "Category is null. It should be one of the following:
NODE, EDGE, or NETWORK.");
- if (propertySheetPanel == null)
- throw new NullPointerException("PropertySheet is null.");
+ // Mapping is empty
+ if (visualMapping == null)
+ throw new NullPointerException("Mapping is null.");
+ if (categoryName == null)
+ throw new NullPointerException(
+ "Category is null. It should be one of
the following: NODE, EDGE, or NETWORK.");
+ if (propertySheetPanel == null)
+ throw new NullPointerException("PropertySheet is
null.");
- final VisualProperty<V> vp = visualMapping.getVisualProperty();
- final VizMapperProperty<VisualProperty<V>, String,
VisualMappingFunctionFactory> topProperty = new
VizMapperProperty<VisualProperty<V>, String, VisualMappingFunctionFactory>(
- CellType.VISUAL_PROPERTY_TYPE, vp, String.class);
+ final VisualProperty<V> vp = visualMapping.getVisualProperty();
+ final VizMapperProperty<VisualProperty<V>, String,
VisualMappingFunctionFactory> topProperty = new
VizMapperProperty<VisualProperty<V>, String, VisualMappingFunctionFactory>(
+ CellType.VISUAL_PROPERTY_TYPE, vp,
String.class);
- // Build Property object
- topProperty.setCategory(categoryName);
- topProperty.setDisplayName(vp.getDisplayName());
- topProperty.setInternalValue(factory);
+ // Build Property object
+ topProperty.setCategory(categoryName);
+ topProperty.setDisplayName(vp.getDisplayName());
+ topProperty.setInternalValue(factory);
- final String attrName = visualMapping.getMappingAttributeName();
- final VizMapperProperty<String, VisualMappingFunctionFactory,
VisualMappingFunction<K, V>> mappingHeader = new VizMapperProperty<String,
VisualMappingFunctionFactory, VisualMappingFunction<K, V>>(
- CellType.MAPPING_TYPE, "Mapping Type",
VisualMappingFunctionFactory.class);
+ final String attrName = visualMapping.getMappingAttributeName();
+ final VizMapperProperty<String, VisualMappingFunctionFactory,
VisualMappingFunction<K, V>> mappingHeader = new VizMapperProperty<String,
VisualMappingFunctionFactory, VisualMappingFunction<K, V>>(
+ CellType.MAPPING_TYPE, "Mapping Type",
VisualMappingFunctionFactory.class);
- if (attrName == null) {
- topProperty.setValue("Select Attribute");
- ((PropertyRendererRegistry)
propertySheetPanel.getTable().getRendererFactory()).registerRenderer(
- topProperty, emptyBoxRenderer);
- } else {
- topProperty.setValue(attrName);
- ((PropertyRendererRegistry)
propertySheetPanel.getTable().getRendererFactory()).registerRenderer(
- topProperty, filledBoxRenderer);
- }
+ if (attrName == null) {
+ topProperty.setValue("Select Attribute");
+ ((PropertyRendererRegistry)
propertySheetPanel.getTable().getRendererFactory()).registerRenderer(
+ topProperty, emptyBoxRenderer);
+ } else {
+ topProperty.setValue(attrName);
+ ((PropertyRendererRegistry)
propertySheetPanel.getTable().getRendererFactory()).registerRenderer(
+ topProperty, filledBoxRenderer);
+ }
- mappingHeader.setDisplayName("Mapping Type");
+ mappingHeader.setDisplayName("Mapping Type");
- // Set mapping type as string.
- mappingHeader.setValue(factory);
- mappingHeader.setInternalValue(visualMapping);
+ // Set mapping type as string.
+ mappingHeader.setValue(factory);
+ mappingHeader.setInternalValue(visualMapping);
- // Set parent-child relationship
- mappingHeader.setParentProperty(topProperty);
- topProperty.addSubProperty(mappingHeader);
+ // Set parent-child relationship
+ mappingHeader.setParentProperty(topProperty);
+ topProperty.addSubProperty(mappingHeader);
- // TODO: Should refactor factory.
- ((PropertyEditorRegistry)
propertySheetPanel.getTable().getEditorFactory()).registerEditor(mappingHeader,
- editorManager.getDefaultComboBoxEditor("mappingTypeEditor"));
+ // TODO: Should refactor factory.
+ ((PropertyEditorRegistry)
propertySheetPanel.getTable().getEditorFactory()).registerEditor(mappingHeader,
+
editorManager.getDefaultComboBoxEditor("mappingTypeEditor"));
- final Set<CyNetwork> networks = cyNetworkManager.getNetworkSet();
+ final Set<CyNetwork> networks =
cyNetworkManager.getNetworkSet();
- final Set<CyTableEntry> graphObjectSet = new HashSet<CyTableEntry>();
- for (CyNetwork targetNetwork : networks) {
- Iterator<? extends CyTableEntry> it = null;
+ final Set<CyTableEntry> graphObjectSet = new
HashSet<CyTableEntry>();
+ for (CyNetwork targetNetwork : networks) {
+ Iterator<? extends CyTableEntry> it = null;
- ((PropertyEditorRegistry)
propertySheetPanel.getTable().getEditorFactory()).registerEditor(topProperty,
- editorManager.getDataTableComboBoxEditor((Class<? extends
CyTableEntry>) vp.getTargetDataType()));
- if (vp.getTargetDataType().equals(CyNode.class)) {
- it = targetNetwork.getNodeList().iterator();
- } else if (vp.getTargetDataType().equals(CyEdge.class)) {
- it = targetNetwork.getEdgeList().iterator();
- } else if (vp.getTargetDataType().equals(CyNetwork.class)) {
- it = cyNetworkManager.getNetworkSet().iterator();
- } else {
- throw new IllegalArgumentException("Data type not supported: "
+ vp.getTargetDataType());
- }
+ ((PropertyEditorRegistry)
propertySheetPanel.getTable().getEditorFactory()).registerEditor(topProperty,
+
editorManager.getDataTableComboBoxEditor((Class<? extends CyTableEntry>)
vp.getTargetDataType()));
+ if (vp.getTargetDataType().equals(CyNode.class)) {
+ it = targetNetwork.getNodeList().iterator();
+ } else if (vp.getTargetDataType().equals(CyEdge.class))
{
+ it = targetNetwork.getEdgeList().iterator();
+ } else if
(vp.getTargetDataType().equals(CyNetwork.class)) {
+ it =
cyNetworkManager.getNetworkSet().iterator();
+ } else {
+ throw new IllegalArgumentException("Data type
not supported: " + vp.getTargetDataType());
+ }
- while (it.hasNext())
- graphObjectSet.add(it.next());
- }
+ while (it.hasNext())
+ graphObjectSet.add(it.next());
+ }
- final VisualPropertyEditor<V> vpEditor =
editorManager.getVisualPropertyEditor(vp);
- logger.debug("vpEditor is " + vpEditor);
+ final VisualPropertyEditor<V> vpEditor =
editorManager.getVisualPropertyEditor(vp);
+ logger.debug("vpEditor is " + vpEditor);
- if (visualMapping instanceof DiscreteMapping && (attrName != null)) {
- // Discrete Mapping
- final SortedSet<K> attrSet = new TreeSet<K>();
+ if (visualMapping instanceof DiscreteMapping && (attrName !=
null)) {
+ // Discrete Mapping
+ final SortedSet<K> attrSet = new TreeSet<K>();
- for (CyTableEntry go : graphObjectSet) {
- final CyRow row = go.getCyRow();
- final CyTable table = row.getTable();
- final CyColumn column = table.getColumn(attrName);
+ for (CyTableEntry go : graphObjectSet) {
+ final CyRow row = go.getCyRow();
+ final CyTable table = row.getTable();
+ final CyColumn column =
table.getColumn(attrName);
- if (column != null) {
- final Class<?> attrClass = column.getType();
+ if (column != null) {
+ final Class<?> attrClass =
column.getType();
- if (attrClass.isAssignableFrom(List.class)) {
- List<?> list = row.getList(attrName,
column.getListElementType());
- if (list != null) {
- for (Object item : list) {
- if (item != null)
- attrSet.add((K) item);
- }
+ if
(attrClass.isAssignableFrom(List.class)) {
+ List<?> list =
row.getList(attrName, column.getListElementType());
+ if (list != null) {
+ for (Object item :
list) {
+ if (item !=
null)
+
attrSet.add((K) item);
+ }
+ }
+ } else {
+ Object id = row.get(attrName,
attrClass);
+
+ if (id != null)
+ attrSet.add((K) id);
+ }
+ }
}
- } else {
- Object id = row.get(attrName, attrClass);
- if (id != null)
- attrSet.add((K) id);
- }
- }
- }
+ // FIXME
+ setDiscreteProps(vp, visualMapping, attrSet, vpEditor,
topProperty, propertySheetPanel);
- // FIXME
- setDiscreteProps(vp, visualMapping, attrSet, vpEditor, topProperty,
propertySheetPanel);
+ } else if (visualMapping instanceof ContinuousMapping &&
(attrName != null)) {
- } else if (visualMapping instanceof ContinuousMapping && (attrName !=
null)) {
+ final VizMapperProperty<String, String,
VisualMappingFunction<K, V>> graphicalView = new VizMapperProperty<String,
String, VisualMappingFunction<K, V>>(
+ CellType.CONTINUOUS,
AbstractVizMapperPanel.GRAPHICAL_MAP_VIEW, String.class);
+ graphicalView.setValue(visualMapping);
+
graphicalView.setDisplayName(AbstractVizMapperPanel.GRAPHICAL_MAP_VIEW);
+ graphicalView.setParentProperty(topProperty);
+ topProperty.addSubProperty(graphicalView);
- final VizMapperProperty<String, String, VisualMappingFunction<K,
V>> graphicalView = new VizMapperProperty<String, String,
VisualMappingFunction<K, V>>(
- CellType.CONTINUOUS,
AbstractVizMapperPanel.GRAPHICAL_MAP_VIEW, String.class);
- graphicalView.setValue(visualMapping);
-
graphicalView.setDisplayName(AbstractVizMapperPanel.GRAPHICAL_MAP_VIEW);
- graphicalView.setParentProperty(topProperty);
- topProperty.addSubProperty(graphicalView);
+ // FIXME
+ final TableCellRenderer continuousRenderer =
vpEditor.getContinuousTableCellRenderer();
- // FIXME
- final TableCellRenderer continuousRenderer =
vpEditor.getContinuousTableCellRenderer();
+ final PropertySheetTable table =
propertySheetPanel.getTable();
+ ((PropertyRendererRegistry)
table.getRendererFactory()).registerRenderer(graphicalView, continuousRenderer);
- final PropertySheetTable table = propertySheetPanel.getTable();
- ((PropertyRendererRegistry)
table.getRendererFactory()).registerRenderer(graphicalView, continuousRenderer);
+ final PropertyEditorRegistry cellEditorFactory =
(PropertyEditorRegistry) table.getEditorFactory();
+ final PropertyEditor continuousCellEditor =
editorManager.getVisualPropertyEditor(vp)
+ .getContinuousMappingEditor();
- final PropertyEditorRegistry cellEditorFactory =
(PropertyEditorRegistry) table.getEditorFactory();
- final PropertyEditor continuousCellEditor =
editorManager.getVisualPropertyEditor(vp)
- .getContinuousMappingEditor();
+ if (continuousCellEditor != null)
+ cellEditorFactory.registerEditor(graphicalView,
continuousCellEditor);
- if (continuousCellEditor != null)
- cellEditorFactory.registerEditor(graphicalView,
continuousCellEditor);
+ } else if (visualMapping instanceof PassthroughMapping &&
(attrName != null)) {
+ String id;
+ Object value;
+ String stringVal;
- } else if (visualMapping instanceof PassthroughMapping && (attrName !=
null)) {
- String id;
- Object value;
- String stringVal;
+ for (CyTableEntry go : graphObjectSet) {
+ CyColumn column =
go.getCyRow().getTable().getColumn(attrName);
- for (CyTableEntry go : graphObjectSet) {
- CyColumn column = go.getCyRow().getTable().getColumn(attrName);
+ if (column != null) {
+ Class<?> attrClass = column.getType();
- if (column != null) {
- Class<?> attrClass = column.getType();
+ id =
go.getCyRow().get(CyTableEntry.NAME, String.class);
- id = go.getCyRow().get(CyTableEntry.NAME, String.class);
+ if (attrName.equals("SUID"))
+ value = go.getSUID();
+ else if
(attrClass.isAssignableFrom(List.class))
+ value =
go.getCyRow().getList(attrName, column.getListElementType());
+ else
+ value =
go.getCyRow().get(attrName, attrClass);
- if (attrName.equals("SUID"))
- value = go.getSUID();
- else if (attrClass.isAssignableFrom(List.class))
- value = go.getCyRow().getList(attrName,
column.getListElementType());
- else
- value = go.getCyRow().get(attrName, attrClass);
+ if (value != null)
+ stringVal = value.toString();
+ else
+ stringVal = null;
- if (value != null)
- stringVal = value.toString();
- else
- stringVal = null;
+ if (value != null) {
+ final VizMapperProperty<String,
V, VisualMappingFunction<K, V>> oneProperty = new VizMapperProperty<String, V,
VisualMappingFunction<K, V>>(
+
CellType.DISCRETE, id, (Class<V>) value.getClass());
+
oneProperty.setInternalValue(visualMapping);
+ oneProperty.setValue(stringVal);
- if (value != null) {
- final VizMapperProperty<String, V,
VisualMappingFunction<K, V>> oneProperty = new VizMapperProperty<String, V,
VisualMappingFunction<K, V>>(
- CellType.DISCRETE, id, (Class<V>)
value.getClass());
- oneProperty.setInternalValue(visualMapping);
- oneProperty.setValue(stringVal);
+ // This prop. should not be
editable!
+ oneProperty.setEditable(false);
- // This prop. should not be editable!
- oneProperty.setEditable(false);
+
oneProperty.setParentProperty(topProperty);
+ oneProperty.setDisplayName(id);
- oneProperty.setParentProperty(topProperty);
- oneProperty.setDisplayName(id);
+
topProperty.addSubProperty(oneProperty);
+ }
+ }
+ }
- topProperty.addSubProperty(oneProperty);
- }
+ } else {
+ throw new IllegalArgumentException("Unsupported mapping
type: " + visualMapping);
}
- }
- } else {
- throw new IllegalArgumentException("Unsupported mapping type: " +
visualMapping);
+ propertySheetPanel.addProperty(0, topProperty);
+
+ return topProperty;
}
- propertySheetPanel.addProperty(0, topProperty);
+ /*
+ * Set value, title, and renderer for each property in the category.
This
+ * list should be created against all available attribute values.
+ */
+ private <K, V> void setDiscreteProps(VisualProperty<V> vp,
VisualMappingFunction<K, V> mapping,
+ SortedSet<K> attrSet, VisualPropertyEditor<V>
visualPropertyEditor, DefaultProperty parent,
+ PropertySheetPanel propertySheetPanel) {
+ if (attrSet == null)
+ return;
- return topProperty;
- }
+ final Map<K, V> discMapping = ((DiscreteMapping<K, V>)
mapping).getAll();
- /*
- * Set value, title, and renderer for each property in the category. This
- * list should be created against all available attribute values.
- */
- private <K, V> void setDiscreteProps(VisualProperty<V> vp,
VisualMappingFunction<K, V> mapping,
- SortedSet<K> attrSet, VisualPropertyEditor<V> visualPropertyEditor,
DefaultProperty parent,
- PropertySheetPanel propertySheetPanel) {
- if (attrSet == null)
- return;
+ V val = null;
+ VizMapperProperty<K, V, VisualMappingFunction<K, V>> valProp;
+ String strVal;
- final Map<K, V> discMapping = ((DiscreteMapping<K, V>)
mapping).getAll();
+ final List<VizMapperProperty<K, V, VisualMappingFunction<K,
V>>> children = new ArrayList<VizMapperProperty<K, V, VisualMappingFunction<K,
V>>>();
+ final PropertySheetTable table = propertySheetPanel.getTable();
+ final PropertyRendererRegistry cellRendererFactory =
(PropertyRendererRegistry) table.getRendererFactory();
+ final PropertyEditorRegistry cellEditorFactory =
(PropertyEditorRegistry) table.getEditorFactory();
- V val = null;
- VizMapperProperty<K, V, VisualMappingFunction<K, V>> valProp;
- String strVal;
+ for (K key : attrSet) {
- final List<VizMapperProperty<K, V, VisualMappingFunction<K, V>>>
children = new ArrayList<VizMapperProperty<K, V, VisualMappingFunction<K,
V>>>();
- final PropertySheetTable table = propertySheetPanel.getTable();
- final PropertyRendererRegistry cellRendererFactory =
(PropertyRendererRegistry) table.getRendererFactory();
- final PropertyEditorRegistry cellEditorFactory =
(PropertyEditorRegistry) table.getEditorFactory();
+ valProp = new VizMapperProperty<K, V,
VisualMappingFunction<K, V>>(CellType.DISCRETE, key, mapping
+
.getVisualProperty().getRange().getType());
+ strVal = key.toString();
+ valProp.setDisplayName(strVal);
+ valProp.setParentProperty(parent);
- for (K key : attrSet) {
+ // Get the mapped value
- valProp = new VizMapperProperty<K, V, VisualMappingFunction<K,
V>>(CellType.DISCRETE, key, mapping
- .getVisualProperty().getRange().getType());
- strVal = key.toString();
- valProp.setDisplayName(strVal);
- valProp.setParentProperty(parent);
+ // TODO: Is there a way to fix it when opening 2.x
sessions?
+ // Even if the CyColumn type is a List of Numbers or
Booleans, the
+ // Visual Style Serializer might have built the
discrete mapping
+ // with keys as Strings!
+ // In 2.x the session_vizmap.props format does not
specify the type
+ // of the List-type attributes.
+ // Example:
+ // "nodeLabelColor.MyStyle-Node Label Color-Discrete
Mapper.mapping.controllerType=-2"
+ // In that case "controllerType=-2" means that the
attribute type is
+ // List, but we don't know the
+ // type of the list items.
+ if (mapping.getMappingAttributeType() == String.class
&& !(key instanceof String))
+ val = discMapping.get(key.toString());
+ else
+ val = discMapping.get(key);
- // Get the mapped value
+ if (val != null)
+ valProp.setType(val.getClass());
- // TODO: Is there a way to fix it when opening 2.x sessions?
- // Even if the CyColumn type is a List of Numbers or Booleans, the
- // Visual Style Serializer might have built the discrete mapping
- // with keys as Strings!
- // In 2.x the session_vizmap.props format does not specify the type
- // of the List-type attributes.
- // Example:
- // "nodeLabelColor.MyStyle-Node Label Color-Discrete
Mapper.mapping.controllerType=-2"
- // In that case "controllerType=-2" means that the attribute type is
- // List, but we don't know the
- // type of the list items.
- if (mapping.getMappingAttributeType() == String.class && !(key
instanceof String))
- val = discMapping.get(key.toString());
- else
- val = discMapping.get(key);
+ children.add(valProp);
+ final VisualPropertyEditor<V> editor =
editorManager.getVisualPropertyEditor(vp);
+ if (editor != null) {
+ final TableCellRenderer renderer =
editor.getDiscreteTableCellRenderer();
+ if (renderer != null)
+
cellRendererFactory.registerRenderer(valProp, renderer);
+ }
+ final PropertyEditor cellEditor =
editorManager.getVisualPropertyEditor(vp).getPropertyEditor();
- if (val != null)
- valProp.setType(val.getClass());
+ if (cellEditor != null)
+ cellEditorFactory.registerEditor(valProp,
cellEditor);
- children.add(valProp);
- final VisualPropertyEditor<V> editor =
editorManager.getVisualPropertyEditor(vp);
- if (editor != null) {
- final TableCellRenderer renderer =
editor.getDiscreteTableCellRenderer();
- if (renderer != null)
- cellRendererFactory.registerRenderer(valProp, renderer);
- }
- final PropertyEditor cellEditor =
editorManager.getVisualPropertyEditor(vp).getPropertyEditor();
+ valProp.setValue(val);
+ valProp.setInternalValue(mapping);
+ }
- if (cellEditor != null)
- cellEditorFactory.registerEditor(valProp, cellEditor);
-
- valProp.setValue(val);
- valProp.setInternalValue(mapping);
+ // Add all children.
+ parent.addSubProperties(children);
}
- // Add all children.
- parent.addSubProperties(children);
- }
-
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.