Author: kono
Date: 2010-10-01 16:56:15 -0700 (Fri, 01 Oct 2010)
New Revision: 22132
Modified:
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertyBuilder.java
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetBuilder.java
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/AttributeComboBoxPropertyEditor.java
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/event/CellEditorEventHandler.java
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/event/VizMapEventHandlerManagerImpl.java
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/VizMapperUtil.java
Log:
Start converting Actions to general Task framework.
Modified:
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertyBuilder.java
===================================================================
---
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertyBuilder.java
2010-10-01 23:55:42 UTC (rev 22131)
+++
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertyBuilder.java
2010-10-01 23:56:15 UTC (rev 22132)
@@ -76,9 +76,10 @@
* 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;
@@ -102,85 +103,89 @@
* data type of Visual Property.
*
*/
- protected <K, V> VizMapperProperty<VisualProperty<V>> buildProperty(
+ public <K, V> VizMapperProperty<VisualProperty<V>> buildProperty(
final VisualMappingFunction<K, V> visualMapping,
- final VisualProperty<Visualizable> rootObjectCategory,
+ final VisualProperty<?> rootObjectCategory,
final PropertySheetPanel propertySheetPanel) {
-
+
logger.debug("\n\n\nbuildProp called!");
-
+
// Mapping is empty
if (visualMapping == null)
throw new NullPointerException("Mapping is null.");
+ if (rootObjectCategory == 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>> calculatorTypeProp =
new VizMapperProperty<VisualProperty<V>>();
+ final VizMapperProperty<VisualProperty<V>> topProperty = new
VizMapperProperty<VisualProperty<V>>();
// Build Property object
-
calculatorTypeProp.setCategory(rootObjectCategory.getDisplayName());
- calculatorTypeProp.setDisplayName(vp.getDisplayName());
- calculatorTypeProp.setHiddenObject(vp);
- calculatorTypeProp.setName(vp.getIdString());
+ topProperty.setCategory(rootObjectCategory.getDisplayName());
+ topProperty.setDisplayName(vp.getDisplayName());
+ topProperty.setHiddenObject(vp);
+ topProperty.setName(vp.getIdString());
+
final String attrName = visualMapping.getMappingAttributeName();
final VizMapperProperty<VisualMappingFunction<K, V>>
mappingHeader = new VizMapperProperty<VisualMappingFunction<K, V>>();
if (attrName == null) {
- calculatorTypeProp.setValue("Select Value");
+ topProperty.setValue("Select Value");
((PropertyRendererRegistry)
propertySheetPanel.getTable()
-
.getRendererFactory()).registerRenderer(calculatorTypeProp,
+
.getRendererFactory()).registerRenderer(topProperty,
emptyBoxRenderer);
} else {
- calculatorTypeProp.setValue(attrName);
+ topProperty.setValue(attrName);
((PropertyRendererRegistry)
propertySheetPanel.getTable()
-
.getRendererFactory()).registerRenderer(calculatorTypeProp,
- filledBoxRenderer);
+
.getRendererFactory()).registerRenderer(topProperty, filledBoxRenderer);
}
// TODO: is this correct?
mappingHeader.setDisplayName("Mapping Type");
mappingHeader.setName("Mapping Type");
-
+
// Set mapping type as string.
mappingHeader.setValue(visualMapping.toString());
mappingHeader.setHiddenObject(visualMapping);
// Set parent-child relationship
- mappingHeader.setParentProperty(calculatorTypeProp);
- calculatorTypeProp.addSubProperty(mappingHeader);
+ mappingHeader.setParentProperty(topProperty);
+ topProperty.addSubProperty(mappingHeader);
+
// TODO: Should refactor factory.
((PropertyEditorRegistry) propertySheetPanel.getTable()
.getEditorFactory()).registerEditor(mappingHeader,
editorFactory.getDefaultComboBoxEditor("mappingTypeEditor"));
-
-
final Set<CyNetwork> networks =
cyNetworkManager.getNetworkSet();
-
final Set<CyTableEntry> graphObjectSet = new
HashSet<CyTableEntry>();
- for(CyNetwork targetNetwork: networks) {
+ for (CyNetwork targetNetwork : networks) {
Iterator<? extends CyTableEntry> it = null;
- final CyTable attr =
tableMgr.getTableMap(rootObjectCategory.getIdString(), targetNetwork).get(
- CyNetwork.DEFAULT_ATTRS);
+
if (rootObjectCategory.getIdString().equals(NODE)) {
it = targetNetwork.getNodeList().iterator();
((PropertyEditorRegistry)
propertySheetPanel.getTable()
-
.getEditorFactory()).registerEditor(calculatorTypeProp,
+
.getEditorFactory()).registerEditor(topProperty,
editorFactory.getDataTableComboBoxEditor(NODE));
} else if
(rootObjectCategory.getIdString().equals(EDGE)) {
it = targetNetwork.getEdgeList().iterator();
((PropertyEditorRegistry)
propertySheetPanel.getTable()
-
.getEditorFactory()).registerEditor(calculatorTypeProp,
+
.getEditorFactory()).registerEditor(topProperty,
editorFactory.getDataTableComboBoxEditor(EDGE));
} else {
it =
cyNetworkManager.getNetworkSet().iterator();
((PropertyEditorRegistry)
propertySheetPanel.getTable()
-
.getEditorFactory()).registerEditor(calculatorTypeProp,
-
editorFactory.getDataTableComboBoxEditor(CyTableEntry.NETWORK));
+ .getEditorFactory())
+ .registerEditor(
+ topProperty,
+ editorFactory
+
.getDataTableComboBoxEditor(CyTableEntry.NETWORK));
}
-
- while(it.hasNext())
+
+ while (it.hasNext())
graphObjectSet.add(it.next());
}
@@ -188,26 +193,27 @@
* Discrete Mapping
*/
if (visualMapping instanceof DiscreteMapping && (attrName !=
null)) {
-// final Map<K, V> discMapping = ((DiscreteMapping<K, V>)
visualMapping)
-// .getAll();
-//
-// // Extract key attribute values.
-// Class<K> attrDataType = null;
-//
-// try {
-// attrDataType = (Class<K>)
attr.getColumnTypeMap().get(attrName);
-// } catch (Exception e) {
-// throw new IllegalArgumentException(
-// "Attribute is not compatible
data type.");
-// }
-//
-// final SortedSet<K> attrSet = new
TreeSet<K>(attr.getColumnValues(
-// attrName, attrDataType));
-//
-// // FIXME
-// setDiscreteProps(vp, discMapping, attrSet, editorFactory
-// .getVisualPropertyEditor(vp),
calculatorTypeProp,
-// propertySheetPanel);
+ // final Map<K, V> discMapping = ((DiscreteMapping<K,
V>)
+ // visualMapping)
+ // .getAll();
+ //
+ // // Extract key attribute values.
+ // Class<K> attrDataType = null;
+ //
+ // try {
+ // attrDataType = (Class<K>)
attr.getColumnTypeMap().get(attrName);
+ // } catch (Exception e) {
+ // throw new IllegalArgumentException(
+ // "Attribute is not compatible data type.");
+ // }
+ //
+ // final SortedSet<K> attrSet = new
TreeSet<K>(attr.getColumnValues(
+ // attrName, attrDataType));
+ //
+ // // FIXME
+ // setDiscreteProps(vp, discMapping, attrSet,
editorFactory
+ // .getVisualPropertyEditor(vp), calculatorTypeProp,
+ // propertySheetPanel);
} else if (visualMapping instanceof ContinuousMapping
&& (attrName != null)) {
int wi = propertySheetPanel.getTable().getCellRect(0,
1, true).width;
@@ -217,55 +223,59 @@
graphicalView
.setDisplayName(AbstractVizMapperPanel.GRAPHICAL_MAP_VIEW);
graphicalView.setName(vp.getDisplayName());
- graphicalView.setParentProperty(calculatorTypeProp);
- calculatorTypeProp.addSubProperty(graphicalView);
+ graphicalView.setParentProperty(topProperty);
+ topProperty.addSubProperty(graphicalView);
// FIXME
// TableCellRenderer crenderer = editorFactory
//
.getVisualPropertyEditor(vp).getContinuousMappingEditor();
- //
+ //
// ((PropertyRendererRegistry)
propertySheetPanel.getTable()
//
.getRendererFactory()).registerRenderer(graphicalView,
// crenderer);
- } else if (visualMapping instanceof PassthroughMapping
- && (attrName != null)) {
+ } else if (visualMapping instanceof PassthroughMapping &&
(attrName != null)) {
// Passthrough
Object id;
Object value;
String stringVal;
-
+
VizMapperProperty<K> oneProperty;
- for(CyTableEntry go: graphObjectSet) {
- Class<?> attrClass =
go.attrs().getDataTable().getColumnTypeMap().get(attrName);
+ for (CyTableEntry go : graphObjectSet) {
+ Class<?> attrClass = go.attrs().getDataTable()
+
.getColumnTypeMap().get(attrName);
+
id = go.attrs().get("name", String.class);
+
+ if(attrName.equals("SUID"))
+ value = go.getSUID();
+ else
+ value = go.attrs().get(attrName,
attrClass);
-
- value = go.attrs().get(attrName, attrClass);
- if(value != null)
+ if (value != null)
stringVal = value.toString();
else
stringVal = null;
-
+
oneProperty = new VizMapperProperty<K>();
oneProperty.setValue(stringVal);
oneProperty.setName(id.toString());
-
+
// This prop. should not be editable!
oneProperty.setEditable(false);
-
oneProperty.setParentProperty(calculatorTypeProp);
+ oneProperty.setParentProperty(topProperty);
oneProperty.setDisplayName(id.toString());
oneProperty.setType(String.class);
- calculatorTypeProp.addSubProperty(oneProperty);
+ topProperty.addSubProperty(oneProperty);
}
}
- propertySheetPanel.addProperty(0, calculatorTypeProp);
+ propertySheetPanel.addProperty(0, topProperty);
propertySheetPanel
.setRendererFactory(((PropertyRendererRegistry)
propertySheetPanel
.getTable().getRendererFactory()));
@@ -273,10 +283,9 @@
.setEditorFactory(((PropertyEditorRegistry)
propertySheetPanel
.getTable().getEditorFactory()));
- return calculatorTypeProp;
+ return topProperty;
}
-
/*
* Set value, title, and renderer for each property in the category.
This
* list should be created against all available attribute values.
Modified:
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetBuilder.java
===================================================================
---
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetBuilder.java
2010-10-01 23:55:42 UTC (rev 22131)
+++
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetBuilder.java
2010-10-01 23:56:15 UTC (rev 22132)
@@ -255,7 +255,7 @@
}
- private List<Property> setProps(final VisualStyle style, final
VisualProperty<Visualizable> cat, final Collection<VisualProperty<?>> vpSet) {
+ private List<Property> setProps(final VisualStyle style, final
VisualProperty<?> cat, final Collection<VisualProperty<?>> vpSet) {
final List<Property> props = new ArrayList<Property>();
final Collection<VisualMappingFunction<?, ?>> mappings = style
@@ -439,22 +439,23 @@
/*
* Remove an entry in the browser.
*/
- public void removeProperty(final Property prop, VisualStyle style) {
+ public void removeProperty(final Property prop, final VisualStyle
style) {
- if (propertyMap.get(style) == null)
+ final List<Property> props = propertyMap.get(style);
+ if (props == null)
return;
- List<Property> targets = new ArrayList<Property>();
- final List<Property> props = propertyMap.get(style);
-
+ final List<Property> targets = new ArrayList<Property>();
+
for (Property p : props) {
+ if(p.getDisplayName() == null)
+ continue;
if (p.getDisplayName().equals(prop.getDisplayName()))
targets.add(p);
}
- for (Property p : targets) {
+ for (Property p : targets)
props.remove(p);
- }
}
// TODO: this should be gone
Modified:
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
===================================================================
---
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
2010-10-01 23:55:42 UTC (rev 22131)
+++
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
2010-10-01 23:56:15 UTC (rev 22132)
@@ -109,7 +109,7 @@
* @param <syncronized>
*/
public class VizMapperMainPanel extends AbstractVizMapperPanel implements
- VisualStyleCreatedListener, PopupMenuListener,
NetworkViewAddedListener, NetworkAddedListener {
+ VisualStyleCreatedListener, PopupMenuListener,
NetworkViewAddedListener, NetworkAddedListener {
private final static long serialVersionUID = 1202339867854959L;
@@ -675,9 +675,37 @@
}
- public void handleEvent(VisualStyleCreatedEvent e) {
+
+ /**
+ * Update GUI components when new Visual Style is created.
+ */
+ @Override public void handleEvent(final VisualStyleCreatedEvent e) {
+ final VisualStyle newStyle = e.getCreatedVisualStyle();
+ if(newStyle == null)
+ return;
+
+ this.vsComboBoxModel.addElement(newStyle);
+
+ // Set selected style
+ setSelectedVisualStyle(newStyle);
+ final CyNetworkView currentView =
this.cyNetworkManager.getCurrentNetworkView();
+
+ if (currentView != null)
+ vmm.setVisualStyle(newStyle, currentView);
- this.vsComboBoxModel.addElement(e.getCreatedVisualStyle());
+ // Update default panel
+ final Component defPanel =
defViewEditor.getDefaultView(newStyle);
+ final CyNetworkView view = (CyNetworkView)
((DefaultViewPanelImpl) defPanel).getView();
+ final Dimension panelSize = getDefaultPanel().getSize();
+
+ if (view != null) {
+ logger.debug("Creating Default Image for new visual
style "
+ + newStyle.getTitle());
+ updateDefaultImage(newStyle, view, panelSize);
+
setDefaultViewImagePanel(getDefaultImageManager().get(newStyle));
+ }
+
+ switchVS(newStyle);
}
@Override
Modified:
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
===================================================================
---
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
2010-10-01 23:55:42 UTC (rev 22131)
+++
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
2010-10-01 23:56:15 UTC (rev 22132)
@@ -1,15 +1,39 @@
package org.cytoscape.view.vizmap.gui.internal;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.util.Map;
import javax.swing.JMenu;
+import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import org.cytoscape.view.vizmap.gui.action.VizMapUIAction;
import org.cytoscape.view.vizmap.gui.internal.theme.IconManager;
+import org.cytoscape.work.Task;
+import org.cytoscape.work.TaskFactory;
+import org.cytoscape.work.TaskIterator;
+import org.cytoscape.work.TaskManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+/**
+ * Manager for all Vizmap-local tasks (commands).
+ *
+ * @author kono
+ *
+ */
public class VizMapperMenuManager {
+
+ private static final Logger logger =
LoggerFactory.getLogger(VizMapperMenuManager.class);
+
+ // Metadata
+ private static final String METADATA_MENU_KEY = "menu";
+ private static final String METADATA_TITLE_KEY = "title";
+
+ private static final String MAIN_MENU = "main";
+ private static final String CONTEXT_MENU = "context";
// Menu items under the tool button
private JPopupMenu mainMenu;
@@ -30,6 +54,24 @@
private JMenu modifyValues;
+
+ private final TaskManager taskManager;
+
+ public VizMapperMenuManager(final TaskManager taskManager) {
+ this.taskManager = taskManager;
+
+ // Will be shown under the button next to Visual Style Name
+ mainMenu = new JPopupMenu();
+
+ // Context menu
+ rightClickMenu = new JPopupMenu();
+
+
+ //modifyValues = new JMenu(modifyMenuLabel);
+ }
+
+
+
public void setIconManager(IconManager iconManager) {
this.iconManager = iconManager;
}
@@ -42,18 +84,8 @@
this.generateIconId = generateIconId;
}
- public VizMapperMenuManager() {
+
- // Will be shown under the button next to Visual Style Name
- mainMenu = new JPopupMenu();
-
- // Context menu
- rightClickMenu = new JPopupMenu();
-
-
- //modifyValues = new JMenu(modifyMenuLabel);
- }
-
public JPopupMenu getMainMenu() {
return mainMenu;
}
@@ -88,4 +120,38 @@
public void onUnbind(VizMapUIAction service, Map properties) {
}
+
+
+ /**
+ *
+ * @param taskFactory
+ * @param properties
+ */
+ public void addTaskFactory(final TaskFactory taskFactory, Map
properties) {
+ final Object serviceType = properties.get(METADATA_MENU_KEY);
+ if( serviceType != null &&
serviceType.toString().equals(MAIN_MENU)) {
+ // This is a menu item for Main Command Button.
+ final Object title = properties.get(METADATA_TITLE_KEY);
+ if(title == null)
+ throw new NullPointerException("Title metadata
is missing.");
+
+
+ // Add new menu to the pull-down
+ final JMenuItem menuItem = new
JMenuItem(title.toString());
+ //menuItem.setIcon(iconManager.getIcon(iconId));
+ menuItem.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
taskManager.execute(taskFactory.getTaskIterator());
+ }
+ });
+
+ mainMenu.add(menuItem);
+ }
+ }
+
+ public void removeTaskFactory(final TaskFactory taskFactory, Map
properties) {
+
+ }
}
Modified:
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/AttributeComboBoxPropertyEditor.java
===================================================================
---
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/AttributeComboBoxPropertyEditor.java
2010-10-01 23:55:42 UTC (rev 22131)
+++
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/AttributeComboBoxPropertyEditor.java
2010-10-01 23:56:15 UTC (rev 22132)
@@ -19,6 +19,9 @@
import org.cytoscape.session.CyNetworkManager;
import org.cytoscape.session.events.NetworkAddedEvent;
import org.cytoscape.session.events.NetworkAddedListener;
+import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.model.Visualizable;
+import org.cytoscape.view.presentation.property.TwoDVisualLexicon;
import org.cytoscape.view.vizmap.gui.editor.ListEditor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,6 +48,8 @@
private final Set<CyTable> targetTables;
private final SortedSet<String> attrNames;
+
+ private VisualProperty<Visualizable> category;
public AttributeComboBoxPropertyEditor(final String name,
final CyTableManager tableMgr, final CyNetworkManager
networkMgr) {
@@ -75,7 +80,22 @@
final JComboBox box = (JComboBox) editor;
for (String attrName : attrNames)
box.addItem(attrName);
+
+ assignCategory();
}
+
+ private void assignCategory() {
+ if(name.equals(CyTableEntry.NODE))
+ category = TwoDVisualLexicon.NODE;
+ else if(name.equals(CyTableEntry.EDGE))
+ category = TwoDVisualLexicon.EDGE;
+ else if(name.equals(CyTableEntry.NETWORK))
+ category = TwoDVisualLexicon.NETWORK;
+ }
+
+ public VisualProperty<Visualizable> getCategory() {
+ return this.category;
+ }
@Override
public void handleEvent(ColumnDeletedEvent e) {
Modified:
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/event/CellEditorEventHandler.java
===================================================================
---
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/event/CellEditorEventHandler.java
2010-10-01 23:55:42 UTC (rev 22131)
+++
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/event/CellEditorEventHandler.java
2010-10-01 23:56:15 UTC (rev 22132)
@@ -43,15 +43,21 @@
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyTableManager;
+import org.cytoscape.session.CyNetworkManager;
import org.cytoscape.view.model.VisualProperty;
import org.cytoscape.view.vizmap.VisualMappingFunction;
+import org.cytoscape.view.vizmap.VisualMappingManager;
import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.gui.event.VizMapEventHandler;
import org.cytoscape.view.vizmap.gui.internal.AbstractVizMapperPanel;
+import org.cytoscape.view.vizmap.gui.internal.VizMapPropertySheetBuilder;
import org.cytoscape.view.vizmap.gui.internal.VizMapperMainPanel;
import org.cytoscape.view.vizmap.gui.internal.VizMapperProperty;
import
org.cytoscape.view.vizmap.gui.internal.editor.propertyeditor.AttributeComboBoxPropertyEditor;
import org.cytoscape.view.vizmap.mappings.ContinuousMapping;
import org.cytoscape.view.vizmap.mappings.DiscreteMapping;
+import org.cytoscape.view.vizmap.mappings.PassthroughMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,7 +70,7 @@
/**
*
*/
-public class CellEditorEventHandler extends AbstractVizMapEventHandler {
+public class CellEditorEventHandler implements VizMapEventHandler {
private static final Logger logger = LoggerFactory
.getLogger(CellEditorEventHandler.class);
@@ -72,118 +78,139 @@
// Keeps current discrete mappings. NOT PERMANENT
private final Map<String, Map<Object, Object>> discMapBuffer;
+ private final CyTableManager tableMgr;
+
+ protected VizMapPropertySheetBuilder vizMapPropertySheetBuilder;
+ protected VisualMappingManager vmm;
+ protected VizMapperMainPanel vizMapperMainPanel;
+ protected PropertySheetPanel propertySheetPanel;
+ protected CyNetworkManager cyNetworkManager;
+
/**
* Creates a new CellEditorEventHandler object.
*/
public CellEditorEventHandler(final PropertySheetPanel
propertySheetPanel,
- final VizMapperMainPanel vizMapperMainPanel) {
+ final VizMapperMainPanel vizMapperMainPanel,
+ final CyTableManager tableMgr, final CyNetworkManager
networkMgr,
+ final VizMapPropertySheetBuilder
vizMapPropertySheetBuilder) {
discMapBuffer = new HashMap<String, Map<Object, Object>>();
this.propertySheetPanel = propertySheetPanel;
this.vizMapperMainPanel = vizMapperMainPanel;
+ this.tableMgr = tableMgr;
+ this.cyNetworkManager = networkMgr;
+ this.vizMapPropertySheetBuilder = vizMapPropertySheetBuilder;
}
- private void switchControllingAttr(final
AttributeComboBoxPropertyEditor editor, final VizMapperProperty<?> prop, final
String ctrAttrName) {
-
- final VisualStyle currentStyle =
this.vizMapperMainPanel.getSelectedVisualStyle();
-
+ private <K, V> void switchControllingAttr(
+ final AttributeComboBoxPropertyEditor editor,
+ VizMapperProperty<?> prop, final String ctrAttrName) {
+
+ final VisualStyle currentStyle = this.vizMapperMainPanel
+ .getSelectedVisualStyle();
+
final Object hidden = prop.getHiddenObject();
-
- if(hidden instanceof VisualProperty<?> == false) {
+
+ if (hidden instanceof VisualProperty<?> == false) {
logger.debug("Hidden object is not VP.");
return;
}
-
- final VisualProperty<?> vp = (VisualProperty<?>) hidden;
- final VisualMappingFunction<?, ?> mapping =
currentStyle.getVisualMappingFunction(vp);
-
+
+ final VisualProperty<V> vp = (VisualProperty<V>) hidden;
+ final VisualMappingFunction<K, V> mapping =
(VisualMappingFunction<K, V>) currentStyle
+ .getVisualMappingFunction(vp);
+
logger.debug("!!!!!!! Got Mapping: " + mapping);
-
+
// If same, do nothing.
if (ctrAttrName.equals(mapping.getMappingAttributeName())) {
- logger.debug("Same controlling attr. Do nothing for: "
+ ctrAttrName);
+ logger.debug("Same controlling attr. Do nothing for: "
+ + ctrAttrName);
return;
}
+
+ /*
+ * Ignore if not compatible.
+ */
+ final CyTable attrForTest = tableMgr.getTableMap(
+ editor.getTargetObjectName(),
+ cyNetworkManager.getCurrentNetwork()).get(
+ CyNetwork.DEFAULT_ATTRS);
+
+ final Class<K> dataType = (Class<K>)
attrForTest.getColumnTypeMap()
+ .get(ctrAttrName);
+
+ VisualMappingFunction<K, V> newMapping = null;
+ if (mapping instanceof PassthroughMapping) {
+ // Create new Passthrough mapping and register to
current style.
+ newMapping = new PassthroughMapping<K, V>(ctrAttrName,
dataType, vp);
+ currentStyle.addVisualMappingFunction(newMapping);
+ logger.debug("Changed to new Map from "
+ + mapping.getMappingAttributeName() + "
to "
+ + newMapping.getMappingAttributeName());
+ } else if (mapping instanceof ContinuousMapping) {
+ if ((dataType == Double.class) || (dataType ==
Integer.class)) {
+ // Do nothing
+ } else {
+ JOptionPane
+ .showMessageDialog(
+
vizMapperMainPanel,
+ "Continuous
Mapper can be used with Numbers only.\nPlease select numerical attributes.",
+ "Incompatible
Mapping Type!",
+
JOptionPane.INFORMATION_MESSAGE);
+
+ return;
+ }
+
+ } else if (mapping instanceof DiscreteMapping) {
+ // final String curMappingName = mapping.toString() +
"-"
+ // + mapping.getMappingAttributeName();
+ // final String newMappingName = mapping.toString() +
"-"
+ // + ctrAttrName;
+ // final Map saved = discMapBuffer.get(newMappingName);
+ //
+ // if (saved == null) {
+ // discMapBuffer.put(curMappingName,
+ // ((DiscreteMapping) mapping).getAll());
+ // mapping.(ctrAttrName);
+ // } else if (saved != null) {
+ // // Mapping exists
+ // discMapBuffer.put(curMappingName,
+ // ((DiscreteMapping) mapping).getAll());
+ // mapping.setControllingAttributeName(ctrAttrName);
+ // ((DiscreteMapping) mapping).putAll(saved);
+ // }
+ }
+
+ // Remove old property
+ propertySheetPanel.removeProperty(prop);
+
+ // Create new one.
+ final VizMapperProperty<?> newRootProp = new
VizMapperProperty<V>();
+
+ logger.debug("Creating new prop sheet objects for "
+ + newMapping.getMappingAttributeName() + ", "
+ + vp.getDisplayName());
+ vizMapPropertySheetBuilder.getPropertyBuilder().buildProperty(
+ newMapping, editor.getCategory(),
propertySheetPanel);
+
+ logger.debug("!!!!!!! Removing Prop: " + prop);
- logger.debug("Need to change from " +
mapping.getMappingAttributeName() + " to " + ctrAttrName);
-
-
-// /*
-// * Ignore if not compatible.
-// */
-// final CyTable attrForTest =
tableMgr.getTableMap(type.getObjectType(),cyNetworkManager.getCurrentNetwork()).get(CyNetwork.DEFAULT_ATTRS);
-//
-// final Class<?> dataType =
attrForTest.getColumnTypeMap().get(
-// ctrAttrName);
-//
-// // This part is for Continuous Mapping.
-// if (mapping instanceof ContinuousMapping) {
-// if ((dataType == Double.class) || (dataType ==
Integer.class)) {
-// // Do nothing
-// } else {
-// JOptionPane
-// .showMessageDialog(
-//
vizMapperMainPanel,
-//
"Continuous Mapper can be used with Numbers only.\nPlease select numerical
attributes.",
-//
"Incompatible Mapping Type!",
-//
JOptionPane.INFORMATION_MESSAGE);
-//
-// return;
-// }
-// }
+ vizMapPropertySheetBuilder.removeProperty(prop, currentStyle);
-
+ if
(vizMapPropertySheetBuilder.getPropertyMap().get(currentStyle) != null)
+
vizMapPropertySheetBuilder.getPropertyMap().get(currentStyle)
+ .add(newRootProp);
-// // Buffer current discrete mapping
-// if (mapping instanceof DiscreteMapping) {
-// final String curMappingName =
mapping.toString() + "-"
-// +
mapping.getMappingAttributeName();
-// final String newMappingName =
mapping.toString() + "-"
-// + ctrAttrName;
-// final Map saved =
discMapBuffer.get(newMappingName);
-//
-// if (saved == null) {
-// discMapBuffer.put(curMappingName,
-// ((DiscreteMapping)
mapping).getAll());
-// mapping.(ctrAttrName);
-// } else if (saved != null) {
-// // Mapping exists
-// discMapBuffer.put(curMappingName,
-// ((DiscreteMapping)
mapping).getAll());
-//
mapping.setControllingAttributeName(ctrAttrName);
-// ((DiscreteMapping)
mapping).putAll(saved);
-// }
-// } else {
-//
mapping.setControllingAttributeName(ctrAttrName);
-// }
-//
-// propertySheetPanel.removeProperty(typeRootProp);
-//
-// final VizMapperProperty<?> newRootProp = new
VizMapperProperty<>();
-// final VisualStyle targetVS =
vmm.getVisualStyle(cyNetworkManager.getCurrentNetworkView());
-//
-//
vizMapPropertySheetBuilder.getPropertyBuilder().buildProperty(
-//
targetVS.getVisualMappingFunction(type), newRootProp,
-// type.getObjectType(),
-// propertySheetPanel);
-//
-//
-// vizMapPropertySheetBuilder.removeProperty(typeRootProp);
-//
-// if (vizMapPropertySheetBuilder.getPropertyMap().get(
-// targetVS) != null)
-// vizMapPropertySheetBuilder.getPropertyMap().get(
-// targetVS).add(newRootProp);
-//
-// typeRootProp = null;
-//
-//
vizMapPropertySheetBuilder.expandLastSelectedItem(type.getIdString());
-// vizMapPropertySheetBuilder.updateTableView();
-//
-// // Finally, update graph view and focus.
-// //
vmm.setNetworkView(cyNetworkManager.getCurrentNetworkView());
-// //
Cytoscape.redrawGraph(cyNetworkManager.getCurrentNetworkView());
-// return;
-//
+ prop = null;
+
+
vizMapPropertySheetBuilder.expandLastSelectedItem(vp.getIdString());
+ vizMapPropertySheetBuilder.updateTableView();
+
+ // Finally, update graph view and focus.
+ currentStyle.apply(cyNetworkManager.getCurrentNetworkView());
+ cyNetworkManager.getCurrentNetworkView().updateView();
+ return;
+
}
/**
Modified:
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/event/VizMapEventHandlerManagerImpl.java
===================================================================
---
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/event/VizMapEventHandlerManagerImpl.java
2010-10-01 23:55:42 UTC (rev 22131)
+++
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/event/VizMapEventHandlerManagerImpl.java
2010-10-01 23:56:15 UTC (rev 22132)
@@ -6,6 +6,8 @@
import java.util.HashMap;
import java.util.Map;
+import org.cytoscape.model.CyTableManager;
+import org.cytoscape.session.CyNetworkManager;
import org.cytoscape.view.vizmap.gui.editor.EditorManager;
import org.cytoscape.view.vizmap.gui.event.VizMapEventHandler;
import org.cytoscape.view.vizmap.gui.event.VizMapEventHandlerManager;
@@ -24,23 +26,28 @@
private static final Logger logger = LoggerFactory
.getLogger(VizMapEventHandlerManagerImpl.class);
- private Map<String, AbstractVizMapEventHandler> eventHandlers;
+ private Map<String, VizMapEventHandler> eventHandlers;
private final EditorManager editorManager;
private final VizMapperMainPanel gui;
private VizMapPropertySheetBuilder vizMapPropertySheetBuilder;
+
+ private final CyTableManager tableMgr;
+ private final CyNetworkManager networkMgr;
public VizMapEventHandlerManagerImpl(final EditorManager editorManager,
final VizMapPropertySheetBuilder
vizMapPropertySheetBuilder,
- final PropertySheetPanel propertySheetPanel, final
VizMapperMainPanel gui) {
+ final PropertySheetPanel propertySheetPanel, final
VizMapperMainPanel gui, final CyTableManager tableMgr, final CyNetworkManager
networkMgr) {
this.vizMapPropertySheetBuilder = vizMapPropertySheetBuilder;
this.editorManager = editorManager;
this.gui = gui;
+ this.tableMgr = tableMgr;
+ this.networkMgr = networkMgr;
registerCellEditorListeners();
- eventHandlers = new HashMap<String,
AbstractVizMapEventHandler>();
+ eventHandlers = new HashMap<String, VizMapEventHandler>();
createHandlers(propertySheetPanel);
@@ -68,7 +75,7 @@
eventHandlers.put(Cytoscape.NETWORK_LOADED, attrHandler);
eventHandlers.put("VALUE", new CellEditorEventHandler(
- propertySheetPanel, gui));
+ propertySheetPanel, gui, tableMgr, networkMgr,
vizMapPropertySheetBuilder));
}
Modified:
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/VizMapperUtil.java
===================================================================
---
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/VizMapperUtil.java
2010-10-01 23:55:42 UTC (rev 22131)
+++
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/VizMapperUtil.java
2010-10-01 23:56:15 UTC (rev 22132)
@@ -38,7 +38,7 @@
*
* @return DOCUMENT ME!
*/
- public String getStyleName(Component parentComponent, VisualStyle vs) {
+ public String getStyleName(Component parentComponent, final VisualStyle
vs) {
String suggestedName = null;
List<String> vsNames = getVisualStyleNames();
--
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.