Document Actions

Fathom.java

Retrieve points from simplification tree

Click here to get the file

Size 1.4 kB - File type text/plain

File contents

// Name: Fathom.java
// Intent: retrieve points from simplification tree
// Programmer: John P. Kavanagh  #2748 2405
// Date Modified: 10 May 2002
// Audit: Clifford Meyers (cmeyers@buffalo.edu)

public class Fathom {
	
	private LineTree hierarchy;
	private double criterion;
	private String matches = "";  // contains all matching node points
		
	// Initialize point retrieval
	public Fathom(LineTree cromley, String bandwidth) { 
		hierarchy = cromley;
		criterion = new Double(bandwidth.trim()).doubleValue();
		evaluateTreeNode(hierarchy.getRoot());	
		
		// All set! Show matching points!
		System.out.println("\n\nPoints retrieved: " + matches);		
	}
	
	private void evaluateTreeNode(TreeNode nodePoint){

		if (nodePoint.getPoint() != null){
			// evaluate node bandwidth to fit criterion
			if (nodePoint.getBandwidth() > criterion){
				// add matching node points to string
				matches = matches + " \n(" + nodePoint.getPoint().getXvalue() + "," + nodePoint.getPoint().getYvalue() + ")";
			}
		}
		
		// evaluate left node
		if (nodePoint.getLeftNode() != null){		
			evaluateTreeNode(nodePoint.getLeftNode());
		}
		
		// evaluate right node
		if (nodePoint.getRightNode() != null){				
			evaluateTreeNode(nodePoint.getRightNode());			
		}
		
	}
	
	// accessor
	public double getCriterion(){
		return criterion;
	}
	
	// accessor
	public LineTree getHierarchy(){
		return hierarchy;
	}
}
www.flickr.com