Author: kono
Date: 2011-11-15 13:18:16 -0800 (Tue, 15 Nov 2011)
New Revision: 27478
Removed:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/GenerateSeriesAction.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/GenerateValueAction.java
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/CyActivator.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/EditSelectedCellAction.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTask.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/mapgenerator/NumberSeriesMappingGenerator.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/mapgenerator/RandomNumberMappingGenerator.java
Log:
Some missing value generators had been implemented.
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/CyActivator.java
2011-11-15 21:17:11 UTC (rev 27477)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/CyActivator.java
2011-11-15 21:18:16 UTC (rev 27478)
@@ -49,9 +49,11 @@
import org.cytoscape.view.vizmap.gui.internal.theme.IconManager;
import org.cytoscape.view.vizmap.gui.internal.util.DefaultVisualStyleBuilder;
import org.cytoscape.view.vizmap.gui.internal.util.VizMapperUtil;
+import
org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.NumberSeriesMappingGenerator;
import
org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RainbowColorMappingGenerator;
import
org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RainbowOscColorMappingGenerator;
import
org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RandomColorMappingGenerator;
+import
org.cytoscape.view.vizmap.gui.internal.util.mapgenerator.RandomNumberMappingGenerator;
import org.cytoscape.view.vizmap.gui.util.DiscreteMappingGenerator;
import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.swing.DialogTaskManager;
@@ -121,9 +123,13 @@
CopyVisualStyleTaskFactory copyVisualStyleTaskFactory = new
CopyVisualStyleTaskFactory(vmmServiceRef,visualStyleFactoryServiceRef,selectedVisualStyleManager,vizMapperUtil,vizMapperMainPanel);
CreateLegendTaskFactory createLegendTaskFactory = new
CreateLegendTaskFactory(selectedVisualStyleManager,vizMapperMainPanel);
DeleteMappingFunctionTaskFactory
deleteMappingFunctionTaskFactory = new
DeleteMappingFunctionTaskFactory(propertySheetPanel,selectedVisualStyleManager,cyApplicationManagerServiceRef);
+
RainbowColorMappingGenerator rainbowGenerator = new
RainbowColorMappingGenerator(Color.class);
RainbowOscColorMappingGenerator rainbowOscGenerator = new
RainbowOscColorMappingGenerator(Color.class);
RandomColorMappingGenerator randomColorGenerator = new
RandomColorMappingGenerator(Color.class);
+ NumberSeriesMappingGenerator<Number> seriesGenerator = new
NumberSeriesMappingGenerator<Number>(Number.class);
+ RandomNumberMappingGenerator randomNumberGenerator = new
RandomNumberMappingGenerator();
+
DefaultTableCellRenderer emptyBoxRenderer = new
DefaultTableCellRenderer();
DefaultTableCellRenderer filledBoxRenderer = new
DefaultTableCellRenderer();
VizMapEventHandlerManagerImpl vizMapEventHandlerManager = new
VizMapEventHandlerManagerImpl(selectedVisualStyleManager,editorManager,vizMapPropertySheetBuilder,propertySheetPanel,vizMapperMainPanel,cyNetworkTableManagerServiceRef,cyApplicationManagerServiceRef,attributeSetManager,vizMapperUtil);
@@ -201,9 +207,22 @@
Properties randomColorGeneratorProps = new Properties();
randomColorGeneratorProps.setProperty("service.type","vizmapUI.contextMenu");
- randomColorGeneratorProps.setProperty("title","Random");
+ randomColorGeneratorProps.setProperty("title","Random Color");
randomColorGeneratorProps.setProperty("menu","context");
registerService(bc,randomColorGenerator,DiscreteMappingGenerator.class,
randomColorGeneratorProps);
+
+ Properties numberSeriesGeneratorProps = new Properties();
+
numberSeriesGeneratorProps.setProperty("service.type","vizmapUI.contextMenu");
+ numberSeriesGeneratorProps.setProperty("title","Number Series");
+ numberSeriesGeneratorProps.setProperty("menu","context");
+
registerService(bc,seriesGenerator,DiscreteMappingGenerator.class,
numberSeriesGeneratorProps);
+
+ Properties randomNumberGeneratorProps = new Properties();
+
randomNumberGeneratorProps.setProperty("service.type","vizmapUI.contextMenu");
+ randomNumberGeneratorProps.setProperty("title","Random
Numbers");
+ randomNumberGeneratorProps.setProperty("menu","context");
+ registerService(bc, randomNumberGenerator,
DiscreteMappingGenerator.class, randomNumberGeneratorProps);
+
registerAllServices(bc,nodeSizeDep, new Properties());
EditSelectedCellAction editAction = new
EditSelectedCellAction(editorManager, cyApplicationManagerServiceRef,
selectedVisualStyleManager, propertySheetPanel);
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/EditSelectedCellAction.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/EditSelectedCellAction.java
2011-11-15 21:17:11 UTC (rev 27477)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/EditSelectedCellAction.java
2011-11-15 21:18:16 UTC (rev 27478)
@@ -66,7 +66,7 @@
private final EditorManager editorManager;
public EditSelectedCellAction(final EditorManager editorManager, final
CyApplicationManager appManager, final SelectedVisualStyleManager
selectedVSManager, final PropertySheetPanel propertySheetPanel) {
- super("Edit selected cells", appManager, propertySheetPanel);
+ super("Edit all selected cells", appManager,
propertySheetPanel);
this.selectedVSManager = selectedVSManager;
this.editorManager = editorManager;
}
Deleted:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/GenerateSeriesAction.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/GenerateSeriesAction.java
2011-11-15 21:17:11 UTC (rev 27477)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/GenerateSeriesAction.java
2011-11-15 21:18:16 UTC (rev 27478)
@@ -1,141 +0,0 @@
-/*
- Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-package org.cytoscape.view.vizmap.gui.internal.action;
-
-import java.awt.event.ActionEvent;
-
-import org.cytoscape.application.CyApplicationManager;
-import org.cytoscape.model.CyNetwork;
-
-import com.l2fprod.common.propertysheet.PropertySheetPanel;
-
-/**
- *
- */
-// TODO: this function is broken.
-public class GenerateSeriesAction extends AbstractVizMapperAction {
-
- private final static long serialVersionUID = 121374883715581L;
-
- public GenerateSeriesAction(CyApplicationManager appManager, final
PropertySheetPanel propertySheetPanel) {
- super("Generate Series", appManager, propertySheetPanel);
- }
-
- private <K, V extends Number> void generate(CyNetwork targetNetwork) {
-
-// VisualProperty<V> vp = (VisualProperty<V>) vizMapperUtil
-// .getSelectedVisualProperty(propertySheetPanel);
-// DiscreteMapping<K, V> oMap = (DiscreteMapping<K, V>)
vizMapperUtil.getSelectedProperty(
-// this.vizMapperMainPanel.getDefaultVisualStyle(),
-// propertySheetPanel);
-//
-// if (vp != null && oMap != null) {
-//
-// final CyTable attr =
tableMgr.getTableMap(vp.getObjectType(),targetNetwork).get(
-// CyNetwork.DEFAULT_ATTRS);
-//
-// final Set<K> attrSet = new TreeSet<K>(
-//
attr.getColumnValues(oMap.getMappingAttributeName(), attr
-// .getColumnTypeMap().get(
-//
oMap.getMappingAttributeName())));
-//
-// final String start = JOptionPane.showInputDialog(
-// propertySheetPanel,
-// "Please enter start value (1st number
in the series)", "0");
-// final String increment = JOptionPane.showInputDialog(
-// propertySheetPanel, "Please enter
increment", "1");
-//
-// if ((increment == null) || (start == null))
-// return;
-//
-// V inc;
-// Float st;
-//
-// try {
-// inc = (V) Float.valueOf(increment);
-// st = Float.valueOf(start);
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// inc = null;
-// st = null;
-// }
-//
-// if ((inc == null) || (inc.floatValue() < 0) || (st ==
null) || (st == null)) {
-// return;
-// }
-//
-// Map<K, V> valueMap = new HashMap<K, V>();
-// if (vp.getType() == Number.class) {
-// for (K key : attrSet) {
-// valueMap.put(key, (V) st);
-// st = st.floatValue() + inc.floatValue();
-// }
-// }
-//
-// oMap.putAll(valueMap);
-//
-// propertySheetPanel.removeProperty(prop);
-//
-// final VizMapperProperty<?> newRootProp = new
VizMapperProperty();
-//
-// if (vp.getObjectType().equals(NODE))
-//
vizMapPropertySheetBuilder.getPropertyBuilder().buildProperty(
-// oMap, newRootProp,
vp.getObjectType(),
-// propertySheetPanel);
-// else
-//
vizMapPropertySheetBuilder.getPropertyBuilder().buildProperty(
-// oMap, newRootProp,
-//
VizMapperMainPanel.EDGE_VISUAL_MAPPING,
-// propertySheetPanel);
-//
-// vizMapPropertySheetBuilder.removeProperty(prop);
-// vizMapPropertySheetBuilder.getPropertyMap().get(
-//
vmm.getVisualStyle().getName()).add(newRootProp);
-//
-//
vizMapPropertySheetBuilder.expandLastSelectedItem(type.getName());
-// } else {
-// System.out.println("Invalid.");
-// }
-
- }
-
- /**
- * User wants to Seed the Discrete Mapper with Random Color Values.
- */
- public void actionPerformed(ActionEvent e) {
- final CyNetwork targetNetwork =
applicationManager.getCurrentNetwork();
- generate(targetNetwork);
- }
-}
Deleted:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/GenerateValueAction.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/GenerateValueAction.java
2011-11-15 21:17:11 UTC (rev 27477)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/action/GenerateValueAction.java
2011-11-15 21:18:16 UTC (rev 27478)
@@ -1,205 +0,0 @@
-/*
- Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.cytoscape.view.vizmap.gui.internal.action;
-
-import java.awt.event.ActionEvent;
-
-import org.cytoscape.application.CyApplicationManager;
-import org.cytoscape.model.CyTableManager;
-import org.cytoscape.view.vizmap.gui.util.DiscreteMappingGenerator;
-import org.cytoscape.view.vizmap.mappings.DiscreteMapping;
-
-import com.l2fprod.common.propertysheet.PropertySheetPanel;
-
-/**
- *
- *
- * @param <T>
- * Type of attribute values.
- */
-public class GenerateValueAction<K, V> extends AbstractVizMapperAction {
-
- private CyTableManager tableMgr;
- /**
- * Creates a new GenerateValueAction object.
- */
- public GenerateValueAction(CyApplicationManager applicationManager,
final PropertySheetPanel propertySheetPanel) {
- super("generate", applicationManager, propertySheetPanel);
- this.tableMgr = tableMgr;
- }
-
- private final static long serialVersionUID = 1213748836986412L;
- private DiscreteMappingGenerator<K> generator;
- private DiscreteMapping<K, V> dm;
-
- /**
- * User wants to Seed the Discrete Mapper with Random Color Values.
- */
- public void actionPerformed(ActionEvent e) {
- // Check Selected property
- final int selectedRow =
propertySheetPanel.getTable().getSelectedRow();
-// FIXME
-// if (selectedRow < 0)
-// return;
-//
-// final Item item = (Item)
propertySheetPanel.getTable().getValueAt(
-// selectedRow, 0);
-// final VizMapperProperty<?> prop = (VizMapperProperty<?>) item
-// .getProperty();
-// Object hidden = prop.getHiddenObject();
-//
-// if (hidden instanceof VisualProperty) {
-// final CyNetworkView targetNetworkView = cyNetworkManager
-// .getCurrentNetworkView();
-//
-// final VisualProperty<?> type = (VisualProperty<?>)
hidden;
-//
-// Map valueMap = new HashMap();
-// final long seed = System.currentTimeMillis();
-// final Random rand = new Random(seed);
-//
-// final CyTable attr;
-//
-// attr = tableMgr.getTableMap(type.getObjectType(),
cyNetworkManager.getCurrentNetwork()).get(CyNetwork.DEFAULT_ATTRS);
-//
-// final VisualMappingFunction oMap = vmm.getVisualStyle(
-//
targetNetworkView).getVisualMappingFunction(type);
-// // This function is for discrete mapping only.
-// if ((oMap instanceof DiscreteMapping) == false)
-// return;
-//
-// dm = (DiscreteMapping) oMap;
-//
-// final Set<Object> attrSet = new TreeSet<Object>(attr
-//
.getColumnValues(oMap.getMappingAttributeName(), attr
-// .getColumnTypeMap().get(
-//
oMap.getMappingAttributeName())));
-//
-// // Show error if there is no attribute value.
-// if (attrSet.size() == 0) {
-//
JOptionPane.showMessageDialog(vizMapperMainPanel,
-// "No attribute value is
available.",
-// "Cannot generate values",
JOptionPane.ERROR_MESSAGE);
-// }
-//
-// // /*
-// // * Create random colors
-// // */
-// // final float increment = 1f / ((Number)
-// // attrSet.size()).floatValue();
-// //
-// // float hue = 0;
-// // float sat = 0;
-// // float br = 0;
-// //
-// // if (type.getType() == Color.class) {
-// // int i = 0;
-// //
-// // if (functionType == RAINBOW1) {
-// // for (Object key : attrSet) {
-// // hue = hue + increment;
-// // valueMap.put(key,
-// // new Color(Color.HSBtoRGB(hue, 1f, 1f)));
-// // }
-// // } else if (functionType == RAINBOW2) {
-// // for (Object key : attrSet) {
-// // hue = hue + increment;
-// // sat = (Math.abs(((Number) Math.cos((8 * i)
-// // / (2 * Math.PI))).floatValue()) * 0.7f) + 0.3f;
-// // br = (Math.abs(((Number) Math.sin(((i) / (2 *
Math.PI))
-// // + (Math.PI / 2))).floatValue()) * 0.7f) + 0.3f;
-// // valueMap.put(key, new Color(Color
-// // .HSBtoRGB(hue, sat, br)));
-// // i++;
-// // }
-// // } else {
-// // for (Object key : attrSet)
-// // valueMap.put(key, new Color(
-// // ((Number) (rand.nextFloat() * MAX_COLOR))
-// // .intValue()));
-// // }
-// // } else if ((type.getType() == Number.class)
-// // && (functionType == RANDOM)) {
-// // final String range = JOptionPane.showInputDialog(
-// // visualPropertySheetPanel,
-// // "Please enter the value range (example: 30-100)",
-// // "Assign Random Numbers", JOptionPane.PLAIN_MESSAGE);
-// //
-// // String[] rangeVals = range.split("-");
-// //
-// // if (rangeVals.length != 2)
-// // return;
-// //
-// // Float min = Float.valueOf(rangeVals[0]);
-// // Float max = Float.valueOf(rangeVals[1]);
-// // Float valueRange = max - min;
-// //
-// // for (Object key : attrSet)
-// // valueMap.put(key, (rand.nextFloat() * valueRange) +
min);
-// // }
-// valueMap = generator.generateMap(attrSet);
-//
-// dm.putAll(valueMap);
-// // vmm.setNetworkView(targetNetworkView);
-// // Cytoscape.redrawGraph(targetNetworkView);
-// propertySheetPanel.removeProperty(prop);
-//
-// // final VizMapperProperty newRootProp = new
VizMapperProperty();
-// //
-// // if (type.getObjectType().equals(VisualProperty.NODE))
-// // buildProperty(visualMappingManager.getVisualStyle()
-// // .getNodeAppearanceCalculator().getCalculator(type),
-// // newRootProp, NODE_VISUAL_MAPPING);
-// // else
-// // buildProperty(vmm.getVisualStyle()
-// // .getEdgeAppearanceCalculator().getCalculator(type),
-// // newRootProp, EDGE_VISUAL_MAPPING);
-// //
-// // removeProperty(prop);
-// // System.out.println("asdf pre vs name");
-// // System.out.println("asdf vs name" +
-// // vmm.getVisualStyle().getName());
-// //
propertyMap.get(vmm.getVisualStyle().getName()).add(newRootProp);
-// //
-// // expandLastSelectedItem(type.getName());
-// // } else {
-// // System.out.println("Invalid.");
-// // }
-// //
-// // return;
-// }
- }
-}
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTask.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTask.java
2011-11-15 21:17:11 UTC (rev 27477)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/generators/GenerateValuesTask.java
2011-11-15 21:18:16 UTC (rev 27478)
@@ -54,18 +54,16 @@
final Item value = (Item)
table.getTable().getValueAt(selectedRow, 0);
if (value.isProperty()) {
- final VizMapperProperty<?, ?, ?> prop =
(VizMapperProperty<?, ?, ?>) value
- .getProperty();
+ final VizMapperProperty<?, ?, ?> prop =
(VizMapperProperty<?, ?, ?>) value.getProperty();
if (prop.getCellType() ==
CellType.VISUAL_PROPERTY_TYPE) {
final VisualProperty<?> vp =
(VisualProperty<?>) prop.getKey();
-
- if (vp.getRange().getType()
-
.isAssignableFrom(generator.getDataType())) {
-
+ final Class<?> vpValueType =
vp.getRange().getType();
+ final Class<?> generatorType =
generator.getDataType();
+
+ // TODO: is this safe?
+ if (generatorType.isAssignableFrom(vpValueType)
|| vpValueType.isAssignableFrom(generatorType))
generateMapping(prop,
prop.getValue().toString(), vp);
-
- }
}
}
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/mapgenerator/NumberSeriesMappingGenerator.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/mapgenerator/NumberSeriesMappingGenerator.java
2011-11-15 21:17:11 UTC (rev 27477)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/mapgenerator/NumberSeriesMappingGenerator.java
2011-11-15 21:18:16 UTC (rev 27478)
@@ -1,18 +1,57 @@
package org.cytoscape.view.vizmap.gui.internal.util.mapgenerator;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-public class NumberSeriesMappingGenerator extends
AbstractDiscreteMappingGenerator<Number> {
+import javax.swing.JOptionPane;
- public NumberSeriesMappingGenerator(final Class<Number> type) {
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NumberSeriesMappingGenerator<V extends Number> extends
AbstractDiscreteMappingGenerator<V> {
+
+ private static final Logger logger =
LoggerFactory.getLogger(NumberSeriesMappingGenerator.class);
+
+ public NumberSeriesMappingGenerator(final Class<V> type) {
super(type);
}
@Override
- public <T> Map<T, Number> generateMap(Set<T> attributeSet) {
- // TODO Auto-generated method stub
- return null;
+ public <T> Map<T, V> generateMap(final Set<T> attributeSet) {
+
+ final Map<T, V> valueMap = new HashMap<T, V>();
+
+ // Error check
+ if (attributeSet == null || attributeSet.size() == 0)
+ return valueMap;
+
+ final String start = JOptionPane.showInputDialog(null, "Enter
start value (1st number of the series)", "0");
+ final String increment = JOptionPane.showInputDialog(null,
"Enter increment", "1");
+
+ if ((increment == null) || (start == null))
+ return valueMap;
+
+ Double inc;
+ Double st;
+ try {
+ inc = Double.valueOf(increment);
+ st = Double.valueOf(start);
+ } catch (Exception ex) {
+ logger.error("Invalid value.", ex);
+ inc = null;
+ st = null;
+ }
+
+ if ((inc == null) || (inc.doubleValue() < 0) || (st == null))
+ return null;
+
+ for (T key : attributeSet) {
+ valueMap.put(key, (V) st);
+ st = st + inc;
+ }
+
+ return valueMap;
}
}
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/mapgenerator/RandomNumberMappingGenerator.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/mapgenerator/RandomNumberMappingGenerator.java
2011-11-15 21:17:11 UTC (rev 27477)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/mapgenerator/RandomNumberMappingGenerator.java
2011-11-15 21:18:16 UTC (rev 27478)
@@ -44,11 +44,10 @@
/**
*
*/
-public class RandomNumberMappingGenerator extends
- AbstractDiscreteMappingGenerator<Number> {
-
- public RandomNumberMappingGenerator(Class<Number> type) {
- super(type);
+public class RandomNumberMappingGenerator extends
AbstractDiscreteMappingGenerator<Number> {
+
+ public RandomNumberMappingGenerator() {
+ super(Number.class);
}
/**
@@ -60,28 +59,29 @@
* @return DOCUMENT ME!
*/
public <T> Map<T, Number> generateMap(Set<T> attributeSet) {
+
+ final Map<T, Number> valueMap = new HashMap<T, Number>();
+
// Error if attributeSet is empty or null
if ((attributeSet == null) || (attributeSet.size() == 0))
- return null;
+ return valueMap;
// Ask user to input number range
- final String range = JOptionPane.showInputDialog(null,
- "Please enter the value range (example:
30-100)",
+ final String range = JOptionPane.showInputDialog(null, "Please
enter the value range (example: 30-100)",
"Assign Random Numbers",
JOptionPane.PLAIN_MESSAGE);
String[] rangeVals = range.split("-");
if (rangeVals.length != 2)
- return null;
+ return valueMap;
final long seed = System.currentTimeMillis();
final Random rand = new Random(seed);
- final Map<T, Number> valueMap = new HashMap<T, Number>();
+
+ Double min = Double.valueOf(rangeVals[0]);
+ Double max = Double.valueOf(rangeVals[1]);
+ Double valueRange = max - min;
- Float min = Float.valueOf(rangeVals[0]);
- Float max = Float.valueOf(rangeVals[1]);
- Float valueRange = max - min;
-
for (T key : attributeSet)
valueMap.put(key, (rand.nextFloat() * valueRange) +
min);
--
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.