Changeset 2408

Show
Ignore:
Timestamp:
08/15/08 16:11:12 (3 months ago)
Author:
mwlinnem
Message:

Changed functionality to match the name. Now you can actually extract "below" a value, not just "below or equal to" a value.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugins/preprocessing/edu.iu.nwb.preprocessing.extractnodesandedges/OSGI-INF/metatype/METADATA.XML

    r2407 r2408  
    3232                 description="Extract all edges with an attribute above a certain number"> 
    3333                <AD name="Extract from this number" id="fromThisNum" type="Double" description="Extracts all edges above or below this attribute value" default="1"/> 
    34                 <AD name="Invert?" id="invert" type="Boolean" description="Extract edges below or equal to this value instead?" default="false"/> 
     34                <AD name="Below?" id="belowInstead" type="Boolean" description="Extract edges below this value instead of above?" default="false"/> 
    3535                <AD name="Numeric Attribute" id="numericAttribute" type="String" description="The attribute which the edges will be sorted by" default=""/> 
    3636        </OCD> 
  • trunk/plugins/preprocessing/edu.iu.nwb.preprocessing.extractnodesandedges/src/edu/iu/nwb/preprocessing/extractnodesandedges/extractedges/abovebelow/EdgeNumericDecorationFilter.java

    r2162 r2408  
    22 
    33import edu.uci.ics.jung.graph.Edge; 
    4 import edu.uci.ics.jung.graph.filters.GeneralEdgeAcceptFilter; 
    54 
    6 public class EdgeNumericDecorationFilter extends GeneralEdgeAcceptFilter { 
     5public class EdgeNumericDecorationFilter extends EdgeThresholdFilter { 
    76 
    8         private Object decoratorKey; 
    9         private double threshold = 0.0; 
    10          
    117        public boolean acceptEdge(Edge e) { 
    12                 if (decoratorKey != null) { 
    13                         Object value = e.getUserDatum(decoratorKey); 
     8                if (getDecorationKey() != null) { 
     9                        Object value = e.getUserDatum(getDecorationKey()); 
    1410                        if (value instanceof Number) { 
    1511                                Number numericValue = (Number) value; 
    1612                                double doubleValue = numericValue.doubleValue(); 
    17                                 return doubleValue > threshold
     13                                return doubleValue > getThreshold()
    1814                        } else { 
    1915                                return true; 
     
    2218                return true; 
    2319        } 
    24          
    25         public void setDecorationKey(Object decoratorKey) { 
    26                 this.decoratorKey = decoratorKey; 
    27         } 
    28          
    29         public void setThreshold(double threshold) { 
    30                 this.threshold = threshold; 
    31         } 
    3220 
    3321        public String getName() { 
    34                 return "Edge Numeric Decoration Filter"; 
     22                return "Edge Threshold Filter"; 
    3523        } 
    36  
    3724} 
  • trunk/plugins/preprocessing/edu.iu.nwb.preprocessing.extractnodesandedges/src/edu/iu/nwb/preprocessing/extractnodesandedges/extractedges/abovebelow/ExtractEdgesAboveBelowAlgorithm.java

    r2162 r2408  
    1616 
    1717    private Double fromThisNum; 
    18     private Boolean invert
     18    private Boolean belowInstead
    1919    private String numericAttribute; 
    2020     
     
    3333        } 
    3434        this.fromThisNum = (Double) parameters.get("fromThisNum"); 
    35         this.invert = (Boolean) parameters.get("invert"); 
     35        this.belowInstead = (Boolean) parameters.get("belowInstead"); 
    3636        this.numericAttribute = (String) parameters.get("numericAttribute"); 
    3737    } 
     
    5555    //returns a new graph that contains all the nodes whose attribute is either above or below a given threshold 
    5656    private Graph filter(Graph originalGraph) { 
    57         EdgeNumericDecorationFilter filter = null; 
    58         if (invert.booleanValue() == false) { 
     57        EdgeThresholdFilter filter = null; 
     58        if (belowInstead.booleanValue() == false) { 
    5959                filter = new EdgeNumericDecorationFilter(); 
    6060        } else { 
     
    7171        StringBuilder label = new StringBuilder(); 
    7272        label.append ("all edges with " + this.numericAttribute); 
    73         if (this.invert.booleanValue() == false) { 
     73        if (this.belowInstead.booleanValue() == false) { 
    7474                label.append(" above "); 
    7575        } else { 
    76                 label.append(" below or equal to "); 
     76                label.append(" below "); 
    7777        } 
    7878        label.append("" + this.fromThisNum); 
  • trunk/plugins/preprocessing/edu.iu.nwb.preprocessing.extractnodesandedges/src/edu/iu/nwb/preprocessing/extractnodesandedges/extractedges/abovebelow/InverseEdgeNumericDecorationFilter.java

    r2162 r2408  
    22 
    33import edu.uci.ics.jung.graph.Edge; 
     4import edu.uci.ics.jung.graph.filters.GeneralEdgeAcceptFilter; 
    45 
    5 public class InverseEdgeNumericDecorationFilter extends EdgeNumericDecorationFilter { 
    6                 public boolean acceptEdge(Edge e) { 
    7                         return ! super.acceptEdge(e); 
     6public class InverseEdgeNumericDecorationFilter extends EdgeThresholdFilter { 
     7         
     8        public boolean acceptEdge(Edge e) { 
     9                if (getDecorationKey() != null) { 
     10                        Object value = e.getUserDatum(getDecorationKey()); 
     11                        if (value instanceof Number) { 
     12                                Number numericValue = (Number) value; 
     13                                double doubleValue = numericValue.doubleValue(); 
     14                                return doubleValue < getThreshold(); 
     15                        } else { 
     16                                return true; 
     17                        } 
    818                } 
     19                return true; 
     20        } 
    921 
    10                public String getName() { 
    11                        return "Inverse Edge Numeric Decoration Filter"; 
    12                
     22        public String getName() { 
     23                return "Below Edge Threshold Filter"; 
     24       
    1325}