Author: kono
Date: 2010-12-09 14:18:00 -0800 (Thu, 09 Dec 2010)
New Revision: 23152
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperProperty.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTask.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTaskFactory.java
Log:
Performance problem in Property Sheet update function had been fixed.
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
2010-12-09 22:03:37 UTC (rev 23151)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
2010-12-09 22:18:00 UTC (rev 23152)
@@ -190,7 +190,7 @@
throw new NullPointerException("Title metadata is
missing.");
// Create mapping generator task factory
- final GenerateValuesTaskFactory taskFactory = new
GenerateValuesTaskFactory(generator, panel.getTable(), manager, appManager);
+ final GenerateValuesTaskFactory taskFactory = new
GenerateValuesTaskFactory(generator, panel, manager, appManager);
// Add new menu to the pull-down
final JMenuItem menuItem = new JMenuItem(title.toString());
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperProperty.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperProperty.java
2010-12-09 22:03:37 UTC (rev 23151)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperProperty.java
2010-12-09 22:18:00 UTC (rev 23152)
@@ -39,6 +39,27 @@
}
/**
+ * Copy constructor
+ * @param original
+ */
+ public VizMapperProperty(final VizMapperProperty<K, V, T> original) {
+ super();
+ if(original == null)
+ throw new NullPointerException("Original value cannot
be null.");
+
+ this.cellType = original.getCellType();
+ this.key = original.getKey();
+
+ super.setName(key.toString());
+ super.setType(original.getType());
+
+ super.setValue(original.getValue());
+ this.internalValue = original.getInternalValue();
+
+
+ }
+
+ /**
* Make name immutable.
*/
@Override public void setName(String name) {
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTask.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTask.java
2010-12-09 22:03:37 UTC (rev 23151)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTask.java
2010-12-09 22:18:00 UTC (rev 23152)
@@ -1,8 +1,8 @@
package org.cytoscape.view.vizmap.gui.internal.task.generators;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.view.model.CyNetworkView;
@@ -18,41 +18,41 @@
import org.cytoscape.work.TaskMonitor;
import com.l2fprod.common.propertysheet.Property;
-import com.l2fprod.common.propertysheet.PropertySheetTable;
+import com.l2fprod.common.propertysheet.PropertySheetPanel;
import com.l2fprod.common.propertysheet.PropertySheetTableModel.Item;
public class GenerateValuesTask extends AbstractTask {
private final DiscreteMappingGenerator<?> generator;
- private final PropertySheetTable table;
+ private final PropertySheetPanel table;
private final SelectedVisualStyleManager manager;
private final CyApplicationManager appManager;
-
- //private final CyTableManager tableManager;
+ // private final CyTableManager tableManager;
+
public GenerateValuesTask(final DiscreteMappingGenerator<?> generator,
- final PropertySheetTable table,
+ final PropertySheetPanel table,
final SelectedVisualStyleManager manager,
final CyApplicationManager appManager) {
this.generator = generator;
this.appManager = appManager;
this.manager = manager;
this.table = table;
- //this.tableManager = tableManager;
+
}
@Override
public void run(TaskMonitor monitor) throws Exception {
System.out.println("Running task...");
-
- int selectedRow = table.getSelectedRow();
+ int selectedRow = table.getTable().getSelectedRow();
+
// If not selected, do nothing.
if (selectedRow < 0)
return;
- final Item value = (Item) table.getValueAt(selectedRow, 0);
+ final Item value = (Item)
table.getTable().getValueAt(selectedRow, 0);
if (value.isProperty()) {
final VizMapperProperty<?, ?, ?> prop =
(VizMapperProperty<?, ?, ?>) value
@@ -61,62 +61,64 @@
if (prop.getCellType() ==
CellType.VISUAL_PROPERTY_TYPE) {
final VisualProperty<?> vp =
(VisualProperty<?>) prop.getKey();
System.out.println("Type of VP: " +
vp.getRange().getType());
-
-
if(vp.getRange().getType().isAssignableFrom(generator.getDataType())) {
- System.out.println("This is compatible:
" + generator.getDataType());
+
+ if (vp.getRange().getType()
+
.isAssignableFrom(generator.getDataType())) {
+ System.out.println("This is compatible:
"
+ +
generator.getDataType());
generateMapping(prop,
prop.getValue().toString(), vp);
-
+
}
-
-
}
}
+
+ value.toggle();
}
-
- private void generateMapping(final VizMapperProperty<?, ?, ?> prop,
final String attrName, final VisualProperty<?> vp ) {
+
+ private void generateMapping(final VizMapperProperty<?, ?, ?> prop,
+ final String attrName, final VisualProperty<?> vp) {
System.out.println("Target Attr name = " + attrName);
-
-
+
final Property[] subProps = prop.getSubProperties();
final VisualStyle style = manager.getCurrentVisualStyle();
- final VisualMappingFunction<?, ?> mapping =
style.getVisualMappingFunction(vp);
-
- if(mapping == null)
+ final VisualMappingFunction<?, ?> mapping = style
+ .getVisualMappingFunction(vp);
+
+ if (mapping == null)
return;
-
- final DiscreteMapping<Object, Object> discMapping =
(DiscreteMapping)mapping;
-
- final Set<Object> keySet = new HashSet<Object>();
- for(Property p: subProps) {
- final VizMapperProperty<?, ?, ?> vmp =
(VizMapperProperty<?, ?, ?>)p;
- if(vmp.getCellType().equals(CellType.DISCRETE)) {
- System.out.print("Key = " + vmp.getKey());
- System.out.print(" Key Class = " +
vmp.getKey().getClass());
- System.out.println(" Val = " + vmp.getValue());
+
+ final DiscreteMapping<Object, Object> discMapping =
(DiscreteMapping) mapping;
+
+ final SortedSet<Object> keySet = new TreeSet<Object>();
+
+ for (Property p : subProps) {
+ final VizMapperProperty<?, ?, ?> vmp =
(VizMapperProperty<?, ?, ?>) p;
+ if (vmp.getCellType().equals(CellType.DISCRETE)) {
keySet.add(vmp.getKey());
}
}
-
+
Map<Object, ?> map = generator.generateMap(keySet);
-
+
discMapping.putAll(map);
-
+
final CyNetworkView networkView =
appManager.getCurrentNetworkView();
style.apply(networkView);
networkView.updateView();
-
- for(Property p: subProps) {
- final VizMapperProperty<?, ?, ?> vmp =
(VizMapperProperty<?, ?, ?>)p;
- if(vmp.getCellType().equals(CellType.DISCRETE)) {
-
- System.out.print("New Key = " + vmp.getKey());
- System.out.print(" New Key Class = " +
vmp.getKey().getClass());
-
+
+ table.removeProperty(prop);
+ prop.clearSubProperties();
+
+ for (Property p : subProps) {
+ final VizMapperProperty<?, ?, ?> vmp =
(VizMapperProperty<?, ?, ?>) p;
+ if (vmp.getCellType().equals(CellType.DISCRETE)) {
vmp.setValue(discMapping.getMapValue(vmp.getKey()));
- System.out.println(" New Val = " +
vmp.getValue());
}
}
+ prop.addSubProperties(subProps);
+ table.addProperty(prop);
+ table.repaint();
}
}
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTaskFactory.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTaskFactory.java
2010-12-09 22:03:37 UTC (rev 23151)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTaskFactory.java
2010-12-09 22:18:00 UTC (rev 23152)
@@ -6,18 +6,19 @@
import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.TaskIterator;
+import com.l2fprod.common.propertysheet.PropertySheetPanel;
import com.l2fprod.common.propertysheet.PropertySheetTable;
public class GenerateValuesTaskFactory implements TaskFactory {
private final DiscreteMappingGenerator<?> generator;
- private final PropertySheetTable table;
+ private final PropertySheetPanel table;
private final SelectedVisualStyleManager manager;
private final CyApplicationManager appManager;
public GenerateValuesTaskFactory(
final DiscreteMappingGenerator<?> generator,
- final PropertySheetTable table,
+ final PropertySheetPanel table,
final SelectedVisualStyleManager manager,
final CyApplicationManager appManager) {
this.generator = generator;
--
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.