Author: kono
Date: 2009-05-28 13:48:27 -0700 (Thu, 28 May 2009)
New Revision: 16835
Added:
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingFunction.java
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
Removed:
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingCalculator.java
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMappingCalculator.java
Modified:
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
Log:
Modified for VizMap GUI.
Deleted:
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingCalculator.java
===================================================================
---
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingCalculator.java
2009-05-28 20:47:56 UTC (rev 16834)
+++
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingCalculator.java
2009-05-28 20:48:27 UTC (rev 16835)
@@ -1,44 +0,0 @@
-package org.cytoscape.view.vizmap.mappings;
-
-import org.cytoscape.view.model.VisualProperty;
-import org.cytoscape.view.vizmap.VisualMappingFunction;
-
-public abstract class AbstractMappingCalculator<K, V> implements
- VisualMappingFunction<K, V> {
-
- // Mapping attribute name.
- protected String attrName;
-
- // Type of attribute
- protected Class<K> attrType;
-
- // Visual Property used in this mapping.
- protected VisualProperty<V> vp;
-
- public AbstractMappingCalculator(final String attrName, final Class<K>
attrType,
- final VisualProperty<V> vp) {
- this.attrType = attrType;
- this.attrName = attrName;
- this.vp = vp;
- }
-
- public String getMappingAttributeName() {
- return attrName;
- }
-
- public Class<K> getMappingAttributeType() {
- return attrType;
- }
-
- public VisualProperty<V> getVisualProperty() {
- return vp;
- }
-
- public void setMappingAttributeName(String attrName) {
- this.attrName = attrName;
- }
-
- public void setVisualProperty(VisualProperty<V> vp) {
- this.vp = vp;
- }
-}
Copied:
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingFunction.java
(from rev 16641,
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingCalculator.java)
===================================================================
---
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingCalculator.java
2009-04-20 22:29:46 UTC (rev 16641)
+++
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingFunction.java
2009-05-28 20:48:27 UTC (rev 16835)
@@ -0,0 +1,48 @@
+package org.cytoscape.view.vizmap.mappings;
+
+import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.vizmap.VisualMappingFunction;
+
+public abstract class AbstractMappingFunction<K, V> implements
+ VisualMappingFunction<K, V> {
+
+ public static final String DISCRETE = "Discrete Mapping";
+ public static final String CONTINUOUS = "Continuous Mapping";
+ public static final String PASSTHROUGH = "Passthrough Mapping";
+
+ // Mapping attribute name.
+ protected String attrName;
+
+ // Type of attribute
+ protected Class<K> attrType;
+
+ // Visual Property used in this mapping.
+ protected VisualProperty<V> vp;
+
+ public AbstractMappingFunction(final String attrName, final Class<K>
attrType,
+ final VisualProperty<V> vp) {
+ this.attrType = attrType;
+ this.attrName = attrName;
+ this.vp = vp;
+ }
+
+ public String getMappingAttributeName() {
+ return attrName;
+ }
+
+ public Class<K> getMappingAttributeType() {
+ return attrType;
+ }
+
+ public VisualProperty<V> getVisualProperty() {
+ return vp;
+ }
+
+ public void setMappingAttributeName(String attrName) {
+ this.attrName = attrName;
+ }
+
+ public void setVisualProperty(VisualProperty<V> vp) {
+ this.vp = vp;
+ }
+}
Modified:
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
===================================================================
---
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
2009-05-28 20:47:56 UTC (rev 16834)
+++
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
2009-05-28 20:48:27 UTC (rev 16835)
@@ -70,7 +70,7 @@
* cytoscape.visual.mappings.continuous.README.txt.
*
*/
-public class ContinuousMapping<V> extends AbstractMappingCalculator<Number, V>
{
+public class ContinuousMapping<V> extends AbstractMappingFunction<Number, V> {
private Interpolator<Number, V> interpolator; // used to interpolate
between
// boundaries
@@ -78,16 +78,9 @@
// Contains List of Data Points
private List<ContinuousMappingPoint<V>> points;
- /**
- * Constructor.
- *
- * @param defaultObj
- * default object to map to
- */
public ContinuousMapping(String attrName, VisualProperty<V> vp) {
super(attrName, Number.class, vp);
this.points = new ArrayList<ContinuousMappingPoint<V>>();
-
// Create Interpolator
if (Color.class.isAssignableFrom(vp.getType()))
interpolator = (Interpolator<Number, V>) new
LinearNumberToColorInterpolator();
@@ -97,8 +90,20 @@
interpolator = (Interpolator<Number, V>) new
FlatInterpolator();
}
+ /**
+ * Constructor.
+ *
+ * @param defaultObj
+ * default object to map to
+ */
+ public ContinuousMapping(String attrName, VisualProperty<V> vp,
Interpolator<Number, V> it) {
+ super(attrName, Number.class, vp);
+ this.points = new ArrayList<ContinuousMappingPoint<V>>();
+ this.interpolator = it;
+ }
+
@Override public String toString() {
- return "Continuous Mapping";
+ return CONTINUOUS;
}
/**
Modified:
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
===================================================================
---
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
2009-05-28 20:47:56 UTC (rev 16834)
+++
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
2009-05-28 20:48:27 UTC (rev 16835)
@@ -60,7 +60,7 @@
* data value is extracted from a bundle of attributes by using a specified
data
* attribute name.
*/
-public class DiscreteMapping<K, V> extends AbstractMappingCalculator<K, V> {
+public class DiscreteMapping<K, V> extends AbstractMappingFunction<K, V> {
// contains the actual map elements (sorted)
private SortedMap<K, V> treeMap;
@@ -79,7 +79,7 @@
}
@Override public String toString() {
- return "Discrete Mapping";
+ return DISCRETE;
}
public <G extends GraphObject> void apply(ViewColumn<V> column,
Copied:
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
(from rev 16627,
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMappingCalculator.java)
===================================================================
---
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMappingCalculator.java
2009-04-18 01:39:19 UTC (rev 16627)
+++
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
2009-05-28 20:48:27 UTC (rev 16835)
@@ -0,0 +1,108 @@
+/*
+ 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.mappings;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.cytoscape.model.CyRow;
+import org.cytoscape.model.GraphObject;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.ViewColumn;
+import org.cytoscape.view.model.VisualProperty;
+
+/**
+ */
+public class PassthroughMapping<K, V> extends
+ AbstractMappingFunction<K, V> {
+
+ /**
+ * dataType is the type of the _attribute_ !! currently we force that
to be
+ * the same as the VisualProperty; FIXME: allow different once? but how
to
+ * coerce?
+ */
+ public PassthroughMapping(final String attrName,final Class<K> attrType,
+ final VisualProperty<V> vp) {
+ super(attrName, attrType, vp);
+ }
+
+ @Override public String toString() {
+ return PASSTHROUGH;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param v
+ * DOCUMENT ME!
+ */
+ public <G extends GraphObject> void apply(ViewColumn<V> column,
+ List<? extends View<G>> views) {
+ if(views == null || views.size() < 1)
+ return; // empty list, nothing to do
+
+ CyRow row;
+
+ // FIXME: also check that column's vp is internally-stored vp!
+ if (vp.getType().isAssignableFrom(attrType)) { // can simply
copy object
+
// without any conversion
+ // aggregate changes to be made in these:
+ final Map<View<G>, K> valuesToSet = new
HashMap<View<G>, K>();
+ final List<View<G>> valuesToClear = new
ArrayList<View<G>>();
+
+ for (View<G> v : views) {
+ row = v.getSource().attrs();
+ if (row.contains(attrName, attrType)) {
+ // skip Views where source attribute is
not defined;
+ // ViewColumn will automatically
substitute the per-VS or
+ // global default, as appropriate
+ final K value = row.get(attrName,
attrType);
+ valuesToSet.put(v, value);
+ } else { // remove value so that default value
will be used:
+ valuesToClear.add(v);
+ }
+ }
+ column.setValues((Map<? extends View<?>, V>)
valuesToSet, valuesToClear);
+ } else {
+ throw new IllegalArgumentException("Mapping " +
toString()
+ + " can't map from attribute type " +
attrType
+ + " to VisualProperty " + vp + " of
type " + vp.getType());
+ }
+ // FIXME: handle List & Map
+ }
+}
Deleted:
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMappingCalculator.java
===================================================================
---
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMappingCalculator.java
2009-05-28 20:47:56 UTC (rev 16834)
+++
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMappingCalculator.java
2009-05-28 20:48:27 UTC (rev 16835)
@@ -1,108 +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.mappings;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.cytoscape.model.CyRow;
-import org.cytoscape.model.GraphObject;
-import org.cytoscape.view.model.View;
-import org.cytoscape.view.model.ViewColumn;
-import org.cytoscape.view.model.VisualProperty;
-
-/**
- */
-public class PassthroughMappingCalculator<K, V> extends
- AbstractMappingCalculator<K, V> {
-
- /**
- * dataType is the type of the _attribute_ !! currently we force that
to be
- * the same as the VisualProperty; FIXME: allow different once? but how
to
- * coerce?
- */
- public PassthroughMappingCalculator(final String attrName,final
Class<K> attrType,
- final VisualProperty<V> vp) {
- super(attrName, attrType, vp);
- }
-
- @Override public String toString() {
- return "Passthrough Mapping";
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param v
- * DOCUMENT ME!
- */
- public <G extends GraphObject> void apply(ViewColumn<V> column,
- List<? extends View<G>> views) {
- if(views == null || views.size() < 1)
- return; // empty list, nothing to do
-
- CyRow row;
-
- // FIXME: also check that column's vp is internally-stored vp!
- if (vp.getType().isAssignableFrom(attrType)) { // can simply
copy object
-
// without any conversion
- // aggregate changes to be made in these:
- final Map<View<G>, K> valuesToSet = new
HashMap<View<G>, K>();
- final List<View<G>> valuesToClear = new
ArrayList<View<G>>();
-
- for (View<G> v : views) {
- row = v.getSource().attrs();
- if (row.contains(attrName, attrType)) {
- // skip Views where source attribute is
not defined;
- // ViewColumn will automatically
substitute the per-VS or
- // global default, as appropriate
- final K value = row.get(attrName,
attrType);
- valuesToSet.put(v, value);
- } else { // remove value so that default value
will be used:
- valuesToClear.add(v);
- }
- }
- column.setValues((Map<? extends View<?>, V>)
valuesToSet, valuesToClear);
- } else {
- throw new IllegalArgumentException("Mapping " +
toString()
- + " can't map from attribute type " +
attrType
- + " to VisualProperty " + vp + " of
type " + vp.getType());
- }
- // FIXME: handle List & Map
- }
-}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---