Author: kono
Date: 2010-09-17 18:29:02 -0700 (Fri, 17 Sep 2010)
New Revision: 21940

Added:
   core3/default-mappingcalculators/branches/vp-tree/
   
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractVisualMappingFunction.java
   
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
   
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
   
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
Removed:
   
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingFunction.java
   
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
   
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
   
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
Modified:
   core3/default-mappingcalculators/branches/vp-tree/pom.xml
   
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMappingPoint.java
   
core3/default-mappingcalculators/branches/vp-tree/src/test/java/org/cytoscape/vizmap/ColorVisualProperty.java
   
core3/default-mappingcalculators/branches/vp-tree/src/test/java/org/cytoscape/vizmap/DiscreteMappingTest.java
Log:
Visual Property Tree version of default mappings.

Copied: core3/default-mappingcalculators/branches/vp-tree (from rev 21529, 
core3/default-mappingcalculators/trunk)


Property changes on: core3/default-mappingcalculators/branches/vp-tree
___________________________________________________________________
Name: svn:ignore
   + .settings
target
.classpath
.project

Name: svn:mergeinfo
   + 

Modified: core3/default-mappingcalculators/branches/vp-tree/pom.xml
===================================================================
--- core3/default-mappingcalculators/trunk/pom.xml      2010-08-23 17:19:54 UTC 
(rev 21529)
+++ core3/default-mappingcalculators/branches/vp-tree/pom.xml   2010-09-18 
01:29:02 UTC (rev 21940)
@@ -104,6 +104,8 @@
                        <version>1.0-SNAPSHOT</version>
                </dependency>
 
+
+               <!-- Testing -->
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
@@ -117,5 +119,12 @@
                        <type>test-jar</type>
                        <scope>test</scope>
                </dependency>
+               
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>presentation-api</artifactId>
+                       <version>1.0-SNAPSHOT</version>
+                       <scope>test</scope>
+               </dependency>
        </dependencies>
 </project>

Deleted: 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingFunction.java
===================================================================
--- 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingFunction.java
        2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingFunction.java
     2010-09-18 01:29:02 UTC (rev 21940)
@@ -1,48 +0,0 @@
-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;
-       }
-}

Copied: 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractVisualMappingFunction.java
 (from rev 21529, 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractMappingFunction.java)
===================================================================
--- 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractVisualMappingFunction.java
                               (rev 0)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/AbstractVisualMappingFunction.java
       2010-09-18 01:29:02 UTC (rev 21940)
@@ -0,0 +1,42 @@
+package org.cytoscape.view.vizmap.mappings;
+
+import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.vizmap.VisualMappingFunction;
+
+public abstract class AbstractVisualMappingFunction<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.  This is mutable.
+       protected String attrName;
+       
+       // Type of attribute
+       protected final Class<K> attrType;
+
+       // Visual Property used in this mapping.
+       protected final VisualProperty<V> vp;
+
+       
+       public AbstractVisualMappingFunction(final String attrName, final 
Class<K> attrType,
+                       final VisualProperty<V> vp) {
+               this.attrType = attrType;
+               this.attrName = attrName;
+               this.vp = vp;
+       }
+
+       @Override public String getMappingAttributeName() {
+               return attrName;
+       }
+
+       
+       @Override public Class<K> getMappingAttributeType() {
+               return attrType;
+       }
+
+       @Override public VisualProperty<V> getVisualProperty() {
+               return vp;
+       }
+}

Deleted: 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
===================================================================
--- 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
      2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
   2010-09-18 01:29:02 UTC (rev 21940)
@@ -1,303 +0,0 @@
-/*
-  File: ContinuousMapping.java
-
-  Copyright (c) 2006, 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.
- */
-
-//----------------------------------------------------------------------------
-// $Revision: 13022 $
-// $Date: 2008-02-11 13:59:26 -0800 (Mon, 11 Feb 2008) $
-// $Author: mes $
-//----------------------------------------------------------------------------
-package org.cytoscape.view.vizmap.mappings;
-
-import java.awt.Color;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.cytoscape.model.CyRow;
-import org.cytoscape.model.GraphObject;
-import org.cytoscape.view.model.View;
-import org.cytoscape.view.model.VisualProperty;
-import org.cytoscape.view.vizmap.mappings.interpolators.FlatInterpolator;
-import org.cytoscape.view.vizmap.mappings.interpolators.Interpolator;
-import 
org.cytoscape.view.vizmap.mappings.interpolators.LinearNumberToColorInterpolator;
-import 
org.cytoscape.view.vizmap.mappings.interpolators.LinearNumberToNumberInterpolator;
-
-/**
- * Implements an interpolation table mapping data to values of a particular
- * class. The data value is extracted from a bundle of attributes by using a
- * specified data attribute name.
- * 
- * @param <V>
- *            Type of object Visual Property holds
- * 
- *            For refactoring changes in this class, please refer to:
- *            cytoscape.visual.mappings.continuous.README.txt.
- * 
- */
-public class ContinuousMapping<V> extends AbstractMappingFunction<Number, V> {
-
-       private Interpolator<Number, V> interpolator; // used to interpolate 
between
-                                                                               
                        // boundaries
-
-       // Contains List of Data Points
-       private List<ContinuousMappingPoint<V>> points;
-
-       public ContinuousMapping(final String attrName, final VisualProperty<V> 
vp) {
-               super(attrName, Number.class, vp);
-               this.points = new ArrayList<ContinuousMappingPoint<V>>();
-               
-               //TODO FIXME use factory here.
-               // Create Interpolator
-               if (Color.class.isAssignableFrom(vp.getType()))
-                       interpolator = (Interpolator<Number, V>) new 
LinearNumberToColorInterpolator();
-               else if (Number.class.isAssignableFrom(vp.getType()))
-                       interpolator = (Interpolator<Number, V>) new 
LinearNumberToNumberInterpolator();
-               else
-                       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;
-       }
-
-       /**
-        * Gets all Data Points.
-        * 
-        * @return List of ContinuousMappingPoint objects.
-        */
-       public List<ContinuousMappingPoint<V>> getAllPoints() {
-               return points;
-       }
-
-       /**
-        * Adds a New Data Point.
-        */
-       public void addPoint(double value, BoundaryRangeValues<V> brv) {
-               points.add(new ContinuousMappingPoint<V>(value, brv));
-       }
-
-       /**
-        * Removes a Point from the List.
-        */
-       public void removePoint(int index) {
-               points.remove(index);
-       }
-
-       /**
-        * Gets Total Point Count.
-        */
-       public int getPointCount() {
-               return points.size();
-       }
-
-       /**
-        * Gets Specified Point.
-        * 
-        * @param index
-        *            Index Value.
-        * @return ContinuousMappingPoint.
-        */
-       public ContinuousMappingPoint<V> getPoint(int index) {
-               return points.get(index);
-       }
-
-       /**
-        * DOCUMENT ME!
-        * 
-        * @param <V>
-        *            DOCUMENT ME!
-        * @param <V>
-        *            DOCUMENT ME!
-        * @param column
-        *            DOCUMENT ME!
-        * @param views
-        *            DOCUMENT ME!
-        */
-       public <G extends GraphObject> void apply(Collection<? extends View<G>> 
views) {
-               if (views == null || views.size() < 1)
-                       return; // empty list, nothing to do
-                               
-                       doMap(views); 
-       }
-
-       /**
-        * Read attribute from row, map it and apply it.
-        * 
-        * types are guaranteed to be correct (? FIXME: check this)
-        * 
-        * Putting this in a separate method makes it possible to make it
-        * type-parametric.
-        * 
-        * @param <V>
-        *            the type-parameter of the ViewColumn column
-        * @param <K>
-        *            the type-parameter of the domain of the mapping (the 
object
-        *            read as an attribute value has to be is-a K)
-        * @param <V>
-        *            the type-parameter of the View
-        */
-       private <G extends GraphObject> void doMap(
-                       final Collection<? extends View<G>> views) {
-               
-               CyRow row;
-               for (final View<G> view : views) {
-                       row = view.getModel().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
-                               
-                               // In all cases, attribute value should be a 
number for continuous mapping.
-                               final Number attrValue = 
view.getModel().attrs().get(attrName,attrType);
-                               final V value = getRangeValue(attrValue);
-                               view.setVisualProperty(vp, value);
-                       } else { // remove value so that default value will be 
used:
-                               view.setVisualProperty(vp, null);
-                       }
-               }
-       }
-
-       private V getRangeValue(Number domainValue) {
-               ContinuousMappingPoint<V> firstPoint = points.get(0);
-               Number minDomain = new Double(firstPoint.getValue());
-
-               // if given domain value is smaller than any in our list,
-               // return the range value for the smallest domain value we have.
-               int firstCmp = compareValues(domainValue, minDomain);
-
-               if (firstCmp <= 0) {
-                       BoundaryRangeValues<V> bv = firstPoint.getRange();
-
-                       if (firstCmp < 0)
-                               return bv.lesserValue;
-                       else
-
-                               return bv.equalValue;
-               }
-
-               // if given domain value is larger than any in our Vector,
-               // return the range value for the largest domain value we have.
-               ContinuousMappingPoint<V> lastPoint = points.get(points.size() 
- 1);
-               Number maxDomain = new Double(lastPoint.getValue());
-
-               if (compareValues(domainValue, maxDomain) > 0) {
-                       BoundaryRangeValues<V> bv = lastPoint.getRange();
-
-                       return bv.greaterValue;
-               }
-
-               // OK, it's somewhere in the middle, so find the boundaries and
-               // pass to our interpolator function. First check for a null
-               // interpolator function
-               if (this.interpolator == null)
-                       return null;
-
-               // Note that the list of Points is sorted.
-               // Also, the case of the inValue equalling the smallest key was
-               // checked above.
-               ContinuousMappingPoint<V> currentPoint;
-               int index = 0;
-
-               for (index = 0; index < points.size(); index++) {
-                       currentPoint = points.get(index);
-
-                       Double currentValue = new 
Double(currentPoint.getValue());
-                       int cmpValue = compareValues(domainValue, currentValue);
-
-                       if (cmpValue == 0) {
-                               BoundaryRangeValues<V> bv = 
currentPoint.getRange();
-
-                               return bv.equalValue;
-                       } else if (cmpValue < 0)
-                               break;
-               }
-
-               return getRangeValue(index, domainValue);
-       }
-
-       /**
-        * This is tricky. The desired domain value is greater than lowerDomain 
and
-        * less than upperDomain. Therefore, we want the "greater" field of the
-        * lower boundary value (because the desired domain value is greater) 
and
-        * the "lesser" field of the upper boundary value (semantic 
difficulties).
-        */
-       private V getRangeValue(int index, Number domainValue) {
-               // Get Lower Domain and Range
-               ContinuousMappingPoint<V> lowerBound = points.get(index - 1);
-               Number lowerDomain = new Double(lowerBound.getValue());
-               BoundaryRangeValues<V> lv = lowerBound.getRange();
-               V lowerRange = lv.greaterValue;
-
-               // Get Upper Domain and Range
-               ContinuousMappingPoint<V> upperBound = points.get(index);
-               Number upperDomain = new Double(upperBound.getValue());
-               BoundaryRangeValues<V> gv = upperBound.getRange();
-               V upperRange = gv.lesserValue;
-
-               return interpolator.getRangeValue(lowerDomain, lowerRange, 
upperDomain,
-                               upperRange, domainValue);
-       }
-
-       /**
-        * Helper function to compare Number objects. This is needed because 
Java
-        * doesn't allow comparing, for example, Integer objects to Double 
objects.
-        */
-       private int compareValues(Number probe, Number target) {
-               double d1 = probe.doubleValue();
-               double d2 = target.doubleValue();
-
-               if (d1 < d2)
-                       return -1;
-               else if (d1 > d2)
-                       return 1;
-               else
-                       return 0;
-       }
-}

Copied: 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
 (from rev 21756, 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java)
===================================================================
--- 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
                           (rev 0)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMapping.java
   2010-09-18 01:29:02 UTC (rev 21940)
@@ -0,0 +1,306 @@
+/*
+  File: ContinuousMapping.java
+
+  Copyright (c) 2006, 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.
+ */
+
+//----------------------------------------------------------------------------
+// $Revision: 13022 $
+// $Date: 2008-02-11 13:59:26 -0800 (Mon, 11 Feb 2008) $
+// $Author: mes $
+//----------------------------------------------------------------------------
+package org.cytoscape.view.vizmap.mappings;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.vizmap.mappings.interpolators.FlatInterpolator;
+import org.cytoscape.view.vizmap.mappings.interpolators.Interpolator;
+import 
org.cytoscape.view.vizmap.mappings.interpolators.LinearNumberToColorInterpolator;
+import 
org.cytoscape.view.vizmap.mappings.interpolators.LinearNumberToNumberInterpolator;
+
+/**
+ * Implements an interpolation table mapping data to values of a particular
+ * class. The data value is extracted from a bundle of attributes by using a
+ * specified data attribute name.
+ * 
+ * @param <V>
+ *            Type of object Visual Property holds
+ * 
+ *            For refactoring changes in this class, please refer to:
+ *            cytoscape.visual.mappings.continuous.README.txt.
+ * 
+ */
+public class ContinuousMapping<V> extends
+               AbstractVisualMappingFunction<Number, V> {
+
+       private Interpolator<Number, V> interpolator; // used to interpolate 
between
+                                                                               
                        // boundaries
+
+       // Contains List of Data Points
+       private List<ContinuousMappingPoint<V>> points;
+
+       public ContinuousMapping(final String attrName, final VisualProperty<V> 
vp) {
+               super(attrName, Number.class, vp);
+               this.points = new ArrayList<ContinuousMappingPoint<V>>();
+
+               // TODO FIXME use factory here.
+               // Create Interpolator
+               if (Color.class.isAssignableFrom(vp.getType()))
+                       interpolator = (Interpolator<Number, V>) new 
LinearNumberToColorInterpolator();
+               else if (Number.class.isAssignableFrom(vp.getType()))
+                       interpolator = (Interpolator<Number, V>) new 
LinearNumberToNumberInterpolator();
+               else
+                       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;
+       }
+
+       /**
+        * Gets all Data Points.
+        * 
+        * @return List of ContinuousMappingPoint objects.
+        */
+       public List<ContinuousMappingPoint<V>> getAllPoints() {
+               return points;
+       }
+
+       /**
+        * Adds a New Data Point.
+        */
+       public void addPoint(double value, BoundaryRangeValues<V> brv) {
+               points.add(new ContinuousMappingPoint<V>(value, brv));
+       }
+
+       /**
+        * Removes a Point from the List.
+        */
+       public void removePoint(int index) {
+               points.remove(index);
+       }
+
+       /**
+        * Gets Total Point Count.
+        */
+       public int getPointCount() {
+               return points.size();
+       }
+
+       /**
+        * Gets Specified Point.
+        * 
+        * @param index
+        *            Index Value.
+        * @return ContinuousMappingPoint.
+        */
+       public ContinuousMappingPoint<V> getPoint(int index) {
+               return points.get(index);
+       }
+
+       /**
+        * DOCUMENT ME!
+        * 
+        * @param <V>
+        *            DOCUMENT ME!
+        * @param <V>
+        *            DOCUMENT ME!
+        * @param column
+        *            DOCUMENT ME!
+        * @param views
+        *            DOCUMENT ME!
+        */
+       @Override
+       public void apply(final View<? extends CyTableEntry> view) {
+               if (view == null)
+                       return; // empty list, nothing to do
+
+               doMap(view);
+       }
+
+       /**
+        * Read attribute from row, map it and apply it.
+        * 
+        * types are guaranteed to be correct (? FIXME: check this)
+        * 
+        * Putting this in a separate method makes it possible to make it
+        * type-parametric.
+        * 
+        * @param <V>
+        *            the type-parameter of the ViewColumn column
+        * @param <K>
+        *            the type-parameter of the domain of the mapping (the 
object
+        *            read as an attribute value has to be is-a K)
+        * @param <V>
+        *            the type-parameter of the View
+        */
+       private void doMap(final View<? extends CyTableEntry> view) {
+
+               CyRow row = view.getModel().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
+
+                       // In all cases, attribute value should be a number for 
continuous
+                       // mapping.
+                       final Number attrValue = view.getModel().attrs()
+                                       .get(attrName, attrType);
+                       final V value = getRangeValue(attrValue);
+                       view.setVisualProperty(vp, value);
+               } else { // remove value so that default value will be used:
+                       view.setVisualProperty(vp, null);
+               }
+
+       }
+
+       private V getRangeValue(Number domainValue) {
+               ContinuousMappingPoint<V> firstPoint = points.get(0);
+               Number minDomain = new Double(firstPoint.getValue());
+
+               // if given domain value is smaller than any in our list,
+               // return the range value for the smallest domain value we have.
+               int firstCmp = compareValues(domainValue, minDomain);
+
+               if (firstCmp <= 0) {
+                       BoundaryRangeValues<V> bv = firstPoint.getRange();
+
+                       if (firstCmp < 0)
+                               return bv.lesserValue;
+                       else
+
+                               return bv.equalValue;
+               }
+
+               // if given domain value is larger than any in our Vector,
+               // return the range value for the largest domain value we have.
+               ContinuousMappingPoint<V> lastPoint = points.get(points.size() 
- 1);
+               Number maxDomain = new Double(lastPoint.getValue());
+
+               if (compareValues(domainValue, maxDomain) > 0) {
+                       BoundaryRangeValues<V> bv = lastPoint.getRange();
+
+                       return bv.greaterValue;
+               }
+
+               // OK, it's somewhere in the middle, so find the boundaries and
+               // pass to our interpolator function. First check for a null
+               // interpolator function
+               if (this.interpolator == null)
+                       return null;
+
+               // Note that the list of Points is sorted.
+               // Also, the case of the inValue equalling the smallest key was
+               // checked above.
+               ContinuousMappingPoint<V> currentPoint;
+               int index = 0;
+
+               for (index = 0; index < points.size(); index++) {
+                       currentPoint = points.get(index);
+
+                       Double currentValue = new 
Double(currentPoint.getValue());
+                       int cmpValue = compareValues(domainValue, currentValue);
+
+                       if (cmpValue == 0) {
+                               BoundaryRangeValues<V> bv = 
currentPoint.getRange();
+
+                               return bv.equalValue;
+                       } else if (cmpValue < 0)
+                               break;
+               }
+
+               return getRangeValue(index, domainValue);
+       }
+
+       /**
+        * This is tricky. The desired domain value is greater than lowerDomain 
and
+        * less than upperDomain. Therefore, we want the "greater" field of the
+        * lower boundary value (because the desired domain value is greater) 
and
+        * the "lesser" field of the upper boundary value (semantic 
difficulties).
+        */
+       private V getRangeValue(int index, Number domainValue) {
+               // Get Lower Domain and Range
+               ContinuousMappingPoint<V> lowerBound = points.get(index - 1);
+               Number lowerDomain = new Double(lowerBound.getValue());
+               BoundaryRangeValues<V> lv = lowerBound.getRange();
+               V lowerRange = lv.greaterValue;
+
+               // Get Upper Domain and Range
+               ContinuousMappingPoint<V> upperBound = points.get(index);
+               Number upperDomain = new Double(upperBound.getValue());
+               BoundaryRangeValues<V> gv = upperBound.getRange();
+               V upperRange = gv.lesserValue;
+
+               return interpolator.getRangeValue(lowerDomain, lowerRange, 
upperDomain,
+                               upperRange, domainValue);
+       }
+
+       /**
+        * Helper function to compare Number objects. This is needed because 
Java
+        * doesn't allow comparing, for example, Integer objects to Double 
objects.
+        */
+       private int compareValues(Number probe, Number target) {
+               double d1 = probe.doubleValue();
+               double d2 = target.doubleValue();
+
+               if (d1 < d2)
+                       return -1;
+               else if (d1 > d2)
+                       return 1;
+               else
+                       return 0;
+       }
+}

Modified: 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMappingPoint.java
===================================================================
--- 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMappingPoint.java
 2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/ContinuousMappingPoint.java
      2010-09-18 01:29:02 UTC (rev 21940)
@@ -100,7 +100,8 @@
         * Clones the object. (Deep Copy)
         * @return Cloned Object.
         */
-       public Object clone() {
+       @Override public Object clone() {
+               
                final BoundaryRangeValues<T> newRange = new 
BoundaryRangeValues<T>();
                newRange.lesserValue = range.lesserValue;
                newRange.equalValue = range.equalValue;

Deleted: 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
===================================================================
--- 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
        2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
     2010-09-18 01:29:02 UTC (rev 21940)
@@ -1,173 +0,0 @@
-/*
-  File: DiscreteMapping.java
-
-  Copyright (c) 2006, 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.
- */
-
-//----------------------------------------------------------------------------
-// $Revision: 13022 $
-// $Date: 2008-02-11 13:59:26 -0800 (Mon, 11 Feb 2008) $
-// $Author: mes $
-//----------------------------------------------------------------------------
-package org.cytoscape.view.vizmap.mappings;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.cytoscape.model.CyRow;
-import org.cytoscape.model.GraphObject;
-import org.cytoscape.view.model.View;
-import org.cytoscape.view.model.VisualProperty;
-
-/**
- * Implements a lookup table mapping data to values of a particular class. The
- * data value is extracted from a bundle of attributes by using a specified 
data
- * attribute name.
- */
-public class DiscreteMapping<K, V> extends AbstractMappingFunction<K, V> {
-       
-       // contains the actual map elements (sorted)
-       private final SortedMap<K, V> attribute2visualMap; 
-
-       
-       /**
-        * Constructor.
-        * 
-        * @param defObj
-        *            Default Object.
-        */
-       public DiscreteMapping(final String attrName, final Class<K> attrType, 
final VisualProperty<V> vp) {
-               super(attrName, attrType, vp);
-               attribute2visualMap = new TreeMap<K, V>();
-       }
-       
-       
-       @Override public String toString() {
-               return DISCRETE;
-       }
-
-       
-       public <G extends GraphObject> void apply(Collection<? extends View<G>> 
views) {
-               if (views == null || views.size() < 1)
-                       return; // empty list, nothing to do
-
-               applyDiscreteMapping(views);
-       }
-
-       /**
-        * Read attribute from row, map it and apply it.
-        * 
-        * types are guaranteed to be correct (? FIXME: check this)
-        * 
-        * Putting this in a separate method makes it possible to make it
-        * type-parametric.
-        * 
-        * @param <V>
-        *            the type-parameter of the ViewColumn column
-        * @param <K>
-        *            the type-parameter of the key stored in the mapping (the
-        *            object read as an attribute value has to be is-a K)
-        * @param <V>
-        *            the type-parameter of the View
-        */
-       private <G extends GraphObject> void applyDiscreteMapping(final 
Collection<? extends View<G>> views) {
-
-               CyRow row;
-               for (final View<G> view : views) {
-                       row = view.getModel().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 key = 
view.getModel().attrs().get(attrName, attrType);
-                               if (attribute2visualMap.containsKey(key)) {
-                                       final V value = 
attribute2visualMap.get(key);
-                                       // Assign value to view
-                                       view.setVisualProperty(vp, value);
-                               } else { // remove value so that default value 
will be used:
-                                       // Set default value
-                                       view.setVisualProperty(vp, null);
-                               }
-                       } else { // remove value so that default value will be 
used:
-                               view.setVisualProperty(vp, null);
-                       }
-               }
-       }
-
-       /**
-        * Gets Value for Specified Key.
-        * 
-        * @param key
-        *            String Key.
-        * @return Object.
-        */
-       public V getMapValue(K key) {
-               return attribute2visualMap.get(key);
-       }
-
-       /**
-        * Puts New Key/Value in Map.
-        * 
-        * @param key
-        *            Key Object.
-        * @param value
-        *            Value Object.
-        */
-       public void putMapValue(K key, V value) {
-               attribute2visualMap.put(key, value);
-               // fireStateChanged();
-       }
-
-
-       /**
-        * Adds All Members of Specified Map.
-        * 
-        * @param map
-        *            Map.
-        */
-       public void putAll(Map<K, V> map) {
-               attribute2visualMap.putAll(map);
-       }
-
-       /**
-        * gets all map values
-        * 
-        */
-       public Map<K, V> getAll() {
-               return attribute2visualMap;
-       }
-}

Copied: 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
 (from rev 21756, 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java)
===================================================================
--- 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
                             (rev 0)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/DiscreteMapping.java
     2010-09-18 01:29:02 UTC (rev 21940)
@@ -0,0 +1,169 @@
+/*
+  File: DiscreteMapping.java
+
+  Copyright (c) 2006, 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.
+ */
+
+//----------------------------------------------------------------------------
+// $Revision: 13022 $
+// $Date: 2008-02-11 13:59:26 -0800 (Mon, 11 Feb 2008) $
+// $Author: mes $
+//----------------------------------------------------------------------------
+package org.cytoscape.view.vizmap.mappings;
+
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.VisualProperty;
+
+/**
+ * Implements a lookup table mapping data to values of a particular class. The
+ * data value is extracted from a bundle of attributes by using a specified 
data
+ * attribute name.
+ */
+public class DiscreteMapping<K, V> extends AbstractVisualMappingFunction<K, V> 
{
+
+       // contains the actual map elements (sorted)
+       private final SortedMap<K, V> attribute2visualMap;
+
+       /**
+        * Constructor.
+        * 
+        * @param defObj
+        *            Default Object.
+        */
+       public DiscreteMapping(final String attrName, final Class<K> attrType,
+                       final VisualProperty<V> vp) {
+               super(attrName, attrType, vp);
+               attribute2visualMap = new TreeMap<K, V>();
+       }
+
+       @Override
+       public String toString() {
+               return DISCRETE;
+       }
+
+       @Override
+       public void apply(View<? extends CyTableEntry> view) {
+               if (view == null)
+                       return; // empty list, nothing to do
+
+               applyDiscreteMapping(view);
+       }
+
+       /**
+        * Read attribute from row, map it and apply it.
+        * 
+        * types are guaranteed to be correct (? FIXME: check this)
+        * 
+        * Putting this in a separate method makes it possible to make it
+        * type-parametric.
+        * 
+        * @param <V>
+        *            the type-parameter of the ViewColumn column
+        * @param <K>
+        *            the type-parameter of the key stored in the mapping (the
+        *            object read as an attribute value has to be is-a K)
+        * @param <V>
+        *            the type-parameter of the View
+        */
+       private void applyDiscreteMapping(final View<? extends CyTableEntry> 
view) {
+
+               final CyRow row = view.getModel().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 key = view.getModel().attrs().get(attrName, 
attrType);
+                       if (attribute2visualMap.containsKey(key)) {
+                               final V value = attribute2visualMap.get(key);
+                               // Assign value to view
+                               view.setVisualProperty(vp, value);
+                       } else { // remove value so that default value will be 
used:
+                               // Set default value
+                               view.setVisualProperty(vp, null);
+                       }
+               } else { // remove value so that default value will be used:
+                       view.setVisualProperty(vp, null);
+               }
+       }
+
+       /**
+        * Gets Value for Specified Key.
+        * 
+        * @param key
+        *            String Key.
+        * @return Object.
+        */
+       public V getMapValue(K key) {
+               return attribute2visualMap.get(key);
+       }
+
+       /**
+        * Puts New Key/Value in Map.
+        * 
+        * @param key
+        *            Key Object.
+        * @param value
+        *            Value Object.
+        */
+       public void putMapValue(K key, V value) {
+               attribute2visualMap.put(key, value);
+               // fireStateChanged();
+       }
+
+       /**
+        * Adds All Members of Specified Map.
+        * 
+        * @param map
+        *            Map.
+        */
+       public void putAll(Map<K, V> map) {
+               attribute2visualMap.putAll(map);
+       }
+
+       /**
+        * gets all map values
+        * 
+        */
+       public Map<K, V> getAll() {
+               return attribute2visualMap;
+       }
+}

Deleted: 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
===================================================================
--- 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
     2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
  2010-09-18 01:29:02 UTC (rev 21940)
@@ -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.Collection;
-
-import org.cytoscape.model.CyRow;
-import org.cytoscape.model.GraphObject;
-import org.cytoscape.view.model.View;
-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(
-                       final Collection<? extends View<G>> views) {
-               if (views == null || views.size() < 1)
-                       return; // empty list, nothing to do
-
-               CyRow row;
-               K value;
-
-               for (View<G> view : views) {
-
-                       row = view.getModel().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
-                               value = row.get(attrName, attrType);
-                               final V converted = convertToValue(value);
-                               
-                               view.setVisualProperty(vp, converted);
-                       } else { // remove value so that default value will be 
used:
-                               view.setVisualProperty(vp, null);
-                       }
-               }
-
-       }
-
-       
-       // TODO: make this converter pluggable
-       private V convertToValue(final K key) {
-               try {
-                       return (V) key;
-               } catch (Exception e) {
-                       return null;
-               }
-               
-       }
-}

Copied: 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
 (from rev 21756, 
core3/default-mappingcalculators/trunk/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java)
===================================================================
--- 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
                          (rev 0)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/mappings/PassthroughMapping.java
  2010-09-18 01:29:02 UTC (rev 21940)
@@ -0,0 +1,101 @@
+/*
+ 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 org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.VisualProperty;
+
+/**
+ */
+public class PassthroughMapping<K, V> extends
+               AbstractVisualMappingFunction<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!
+        */
+       @Override
+       public void apply(final View<? extends CyTableEntry> view) {
+               if (view == null)
+                       return; // empty list, nothing to do
+
+               final CyRow row = view.getModel().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);
+                       final V converted = convertToValue(value);
+
+                       view.setVisualProperty(vp, converted);
+               } else {
+                       // remove value, so that default value will be used:
+                       view.setVisualProperty(vp, null);
+               }
+       }
+
+       // TODO: make this converter pluggable
+       private V convertToValue(final K key) {
+               try {
+                       return (V) key;
+               } catch (Exception e) {
+                       return null;
+               }
+
+       }
+}

Modified: 
core3/default-mappingcalculators/branches/vp-tree/src/test/java/org/cytoscape/vizmap/ColorVisualProperty.java
===================================================================
--- 
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/ColorVisualProperty.java
  2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/test/java/org/cytoscape/vizmap/ColorVisualProperty.java
       2010-09-18 01:29:02 UTC (rev 21940)
@@ -6,9 +6,9 @@
 
 public class ColorVisualProperty extends AbstractVisualProperty<Color> {
 
-       public ColorVisualProperty(final String type, final Color defaultValue,
+       public ColorVisualProperty(final Color defaultValue,
                        final String id, final String name) {
-               super(type, defaultValue, id, name);
+               super(defaultValue, id, name, null);
        }
 
        public Color parseSerializableString(final String text) {

Modified: 
core3/default-mappingcalculators/branches/vp-tree/src/test/java/org/cytoscape/vizmap/DiscreteMappingTest.java
===================================================================
--- 
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/DiscreteMappingTest.java
  2010-08-23 17:19:54 UTC (rev 21529)
+++ 
core3/default-mappingcalculators/branches/vp-tree/src/test/java/org/cytoscape/vizmap/DiscreteMappingTest.java
       2010-09-18 01:29:02 UTC (rev 21940)
@@ -1,30 +1,36 @@
 package org.cytoscape.vizmap;
 
+import static org.junit.Assert.*;
+
 import java.awt.Color;
 
-import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.presentation.property.TwoDVisualLexicon;
 import org.cytoscape.view.vizmap.mappings.DiscreteMapping;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Test;
 
-public class DiscreteMappingTest extends
-               AbstractVisualMappingFunctionTest<String, Color> {
-       
-       private CyNetworkView networkView;
+public class DiscreteMappingTest {
 
        @Before
        public void setUp() throws Exception {
-               attrName = "sample attr 1";
-               attrType = String.class;
-               vp = new ColorVisualProperty("NODE", Color.red, "colorVP", 
"Color Visual Property");
-               
-               mapping = new DiscreteMapping<String, Color>(attrName, 
attrType, vp);
        }
 
        @After
        public void tearDown() throws Exception {
        }
        
+       @Test
+       public void testDiscreteMapping() {
+               final String attrName = "sample attr 1";
+               final Class<String> type = String.class;
+               
+               final DiscreteMapping<String, Color> mapping = new 
DiscreteMapping<String, Color>(attrName, type, TwoDVisualLexicon.NODE_COLOR);
+               
+               assertEquals(attrName, mapping.getMappingAttributeName());
+               assertEquals(type, mapping.getMappingAttributeType());
+               assertEquals(TwoDVisualLexicon.NODE_COLOR, 
mapping.getVisualProperty());
+                               
+       }
        
-       
 }

-- 
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.

Reply via email to