Changeset 1797


Ignore:
Timestamp:
11/15/06 15:41:07 (13 years ago)
Author:
sorber
Message:

Added a curve length item to the statistics for OverlayFreeform. Deleted an extraneous print statement from previous revision.

Location:
trunk/loci/visbio/overlays
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/visbio/overlays/FreeformTool.java

    r1796 r1797  
    178178      if (tendril.nodal) { 
    179179        freeform.insertNode(tendril.start, c[0], c[1]); 
    180         printNodes(); 
    181180      } 
    182181    } 
     
    188187      editing = false; 
    189188      freeform.truncateNodeArray(); 
     189      freeform.computeLength(); 
    190190      freeform.updateBoundingBox(); 
    191191      freeform.computeGridParameters(); 
     
    291291          } 
    292292          editing = false; 
     293          freeform.computeLength(); 
    293294        }            
    294295      } // end reconnect logic 
     
    301302      if (dist > RECONNECT_THRESH) { 
    302303        freeform.setNextNode(x, y); 
     304        float len = freeform.getCurveLength(); 
     305        freeform.setCurveLength(len + (float) dist); 
    303306      } 
    304307    } else { 
  • trunk/loci/visbio/overlays/OverlayFreeform.java

    r1717 r1797  
    5656    numNodes = 1; 
    5757    computeGridParameters(); 
     58    computeLength(); 
    5859  } 
    5960 
     
    109110  public String getStatistics() { 
    110111    return "Bounds = (" + x1 + ", " + y1 + "), (" + x2 + ", " + y2 + ")\n" + 
    111       "Number of Nodes = " + numNodes + "\n"; 
     112      "Number of Nodes = " + numNodes + "\n" + 
     113      "Curve Length = " + curveLength + "\n"; 
    112114  } 
    113115 
  • trunk/loci/visbio/overlays/OverlayObject.java

    r1796 r1797  
    2828import java.util.Arrays; 
    2929import visad.*; 
     30import loci.visbio.util.MathUtil; 
    3031 
    3132/** OverlayObject is the superclass of all overlay objects. */ 
     
    8081  /** Number of horizontal and vertical dividing lines for selection grid. */ 
    8182  protected int horizGridCount, vertGridCount; 
     83 
     84  /** Length of curve of a noded object */ 
     85  protected float curveLength; 
    8286 
    8387  // -- Constructor -- 
     
    378382  /** Gets whether this overlay is still being initially drawn. */ 
    379383  public boolean isDrawing() { return drawing; } 
    380    
     384 
     385  /** Gets length of curve */ 
     386  public float getCurveLength() { return curveLength; } 
     387   
     388  /** Sets length of curve */ 
     389  public void setCurveLength(float len) { curveLength = len; } 
     390 
     391  /** Computes length of curve */ 
     392  public void computeLength() { 
     393    truncateNodeArray(); 
     394    double length = 0; 
     395    for (int i=0; i<numNodes-1; i++) { 
     396      double[] a = {(double) nodes[0][i], (double)nodes[1][i]}; 
     397      double[] b = {(double) nodes[0][i+1], (double) nodes[1][i+1]}; 
     398      length += MathUtil.getDistance(a, b); 
     399    } 
     400    this.curveLength = (float) length; 
     401  } 
     402  
    381403  // -- OverlayObject API Methods: node array mutators -- 
    382404  // note: call updateBoundingBox() after a series of changes to the node array 
     
    505527  protected abstract void computeGridParameters(); 
    506528 
     529   
    507530  /** Sets value of largest and smallest x, y values. */ 
    508531  protected void setBoundaries(float x, float y) { 
Note: See TracChangeset for help on using the changeset viewer.