Changeset 2912


Ignore:
Timestamp:
06/26/07 19:52:28 (12 years ago)
Author:
sorber
Message:

Style checks.

Location:
trunk/loci/visbio
Files:
24 edited

Legend:

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

    r2909 r2912  
    2828import visad.util.CursorUtil; 
    2929 
    30 /**  
    31  * The FreeformExtension class wraps information for the temporary section of a  
     30/** 
     31 * The FreeformExtension class wraps information for the temporary section of a 
    3232 * freeform, which appears like a tendril on screen, created during an edit 
    33  * of an existing freeform.  
     33 * of an existing freeform. 
    3434 * The FreeformTool uses this information to modify the freeform if the 
    3535 * edit is successful, or to remove the freeform extension if the edit is 
     
    3838 * The section of the freeform represented by a freeform extension is actually a 
    3939 * loop, but it's thin (both sides overlap exactly) so it appears like a single 
    40  * line.  
     40 * line. 
    4141 * The loop has two parts, between start and tip and between tip and stop. 
    4242 * If an edit is completed, half of the freeform extension is deleted along 
    43  * with the subtended section of the original freeform.  As a result, the  
    44  * tendril appears to be spliced into the old freeform.  
     43 * with the subtended section of the original freeform.  As a result, the 
     44 * tendril appears to be spliced into the old freeform. 
    4545 */ 
    4646public class FreeformExtension { 
    47    
     47 
    4848  // -- Static Fields -- 
    4949 
    50   /** Smoothing factor for "single exponential smoothing" */ 
     50  /** Smoothing factor for "single exponential smoothing". */ 
    5151  protected static final float SMOOTHING_FACTOR = (float) 
    5252    OverlayNumericStrategy.getSmoothingFactor(); 
     
    7575 
    7676  /** The index of the last node of the freeform extension. */ 
    77   protected int stop;  
     77  protected int stop; 
    7878 
    7979  /** The index of the tip node of the freeform extension. */ 
     
    8383  protected float[][] pre, post; 
    8484 
    85   /**  
     85  /** 
    8686   * Whether this freeform extension began on a node or in the middle of a 
    87    * segment.  
     87   * segment. 
    8888   */ 
    8989  protected boolean nodal; 
     
    9393  /** Constructs a new freeform extension. */ 
    9494  public FreeformExtension(OverlayFreeform freeform, int start, int stop, 
    95       boolean nodal) { 
     95      boolean nodal) 
     96  { 
    9697    this.freeform = freeform; 
    9798    this.start = start; 
     
    101102    this.tip = -1; 
    102103 
    103     if (nodal) splitNodes (freeform, start - 1, stop + 1); 
    104     else splitNodes (freeform, start, stop + 1); 
     104    if (nodal) splitNodes(freeform, start - 1, stop + 1); 
     105    else splitNodes(freeform, start, stop + 1); 
    105106  } 
    106107 
    107108  // -- Object API Methods -- 
    108    
     109 
    109110  /** Whether this extension has begun or remains in the initial state. */ 
    110111  public boolean hasBegun() { return (tip >=0); } 
    111112 
    112   /** Extends the extension, reconnecting it with the curve proper if  
     113  /** Extends the extension, reconnecting it with the curve proper if 
    113114   *  appropriate. */ 
    114115  public boolean extendOrReconnect(DisplayImpl display, float dx, float dy, int 
    115       px, int py, boolean shift) { 
     116      px, int py, boolean shift) 
     117  { 
    116118    boolean reconnected = false; 
    117119 
     
    140142      if (dragDist > DRAW_THRESH) { 
    141143        float[] prev = getTipCoords(); 
    142         float[] s = OverlayUtil.smooth (new float[] {dx, dy}, prev, 
     144        float[] s = OverlayUtil.smooth(new float[] {dx, dy}, prev, 
    143145            SMOOTHING_FACTOR); 
    144146        extend(s); 
     
    164166  /** Computes distance between a point and a section of the freeform. */ 
    165167  public double[] getDistanceToSection(float[][] section, DisplayImpl display, 
    166       double dpx, double dpy) { 
     168      double dpx, double dpy) 
     169  { 
    167170    double[][] dbl = OverlayUtil.floatsToPixelDoubles(display, section); 
    168171    double[] distSegWt = MathUtil.getDistSegWt(dbl, dpx, dpy); 
     
    232235 
    233236  /** Returns the coordinates of the extension's tip or start node. */ 
    234   public float[] getTipCoords() {  
     237  public float[] getTipCoords() { 
    235238    float[] prev; 
    236239    if (tip >= 0) { 
     
    244247    return prev; 
    245248  } 
    246    
    247   /**  
    248    * Simultaneously increments all extension pointers into node array,  
    249    * to adjust for the insertion of a node before the base of the extension.  
     249 
     250  /** 
     251   * Simultaneously increments all extension pointers into node array, 
     252   * to adjust for the insertion of a node before the base of the extension. 
    250253   */ 
    251254  public void incrementAll() { 
     
    259262   * a[index-1], the second from a[index2] to a[a.length -1]. 
    260263   */ 
    261   private void splitNodes(OverlayFreeform freeform, int index, int index2) { 
     264  private void splitNodes(OverlayFreeform f, int index, int index2) { 
    262265    // splits the array a into two (before the index specified) 
    263     float[][] a = freeform.getNodes(); 
     266    float[][] a = f.getNodes(); 
    264267    // print these guys 
    265268    int depth = a.length; 
  • trunk/loci/visbio/overlays/FreeformTool.java

    r2909 r2912  
    2424package loci.visbio.overlays; 
    2525 
     26import java.awt.event.InputEvent; 
     27import java.util.Vector; 
    2628import loci.visbio.data.TransformEvent; 
    2729import loci.visbio.util.MathUtil; 
    28 import java.awt.event.InputEvent; 
    29 import java.util.Vector; 
    3030import visad.DisplayEvent; 
    3131import visad.DisplayImpl; 
    3232import visad.util.CursorUtil; 
    3333 
    34 //goals: 
    35 // eliminate errors in code 
    36 // make code readable 
    37 // consolidate code where possible 
    38  
    3934/** FreeformTool is the tool for creating freeform objects. */ 
    4035public class FreeformTool extends OverlayTool { 
     
    5146  /** 
    5247   * How close a mouseDrag event must be to a node 
    53    * in order to erase it 
     48   * in order to erase it. 
    5449   */ 
    5550  protected static final double ERASE_THRESH = 
     
    6762    OverlayNumericStrategy.getReconnectThreshold(); 
    6863 
    69   /** How close mouse must be to end node to resume drawing */ 
     64  /** How close mouse must be to end node to resume drawing. */ 
    7065  protected static final double RESUME_THRESH = 
    7166    OverlayNumericStrategy.getResumeThreshold(); 
    7267 
    73   /** Smoothing factor for "single exponential smoothing" */ 
     68  /** Smoothing factor for "single exponential smoothing". */ 
    7469  protected static final float S = (float) 
    7570    OverlayNumericStrategy.getSmoothingFactor(); 
     
    8782  protected static final int EDIT = 2; 
    8883 
    89   /** Constant for "init" mode */ 
     84  /** Constant for "init" mode. */ 
    9085  protected static final int INIT = 3; 
    9186 
     
    9590  protected OverlayFreeform freeform; 
    9691 
    97   /** Other freeforms on the canvas */ 
     92  /** Other freeforms on the canvas. */ 
    9893  protected Vector otherFreefs; 
    9994 
    100   /** FreeformExtension wraps info about an edit to a curve */ 
     95  /** FreeformExtension wraps info about an edit to a curve. */ 
    10196  protected FreeformExtension freeformExtension; 
    10297 
    103   /** Stores the current mode (INIT, ERASE, CHILL, DRAW, EDIT) */ 
     98  /** Stores the current mode (INIT, ERASE, CHILL, DRAW, EDIT). */ 
    10499  protected int mode; 
    105100 
     
    131126    // if ctl, erase 
    132127    // else if near edit 
    133      
     128 
    134129    if (ctl) { 
    135130      setMode(ERASE); 
     
    231226 
    232227    if (ctl && mode == DRAW) { 
    233         freeform.truncateNodeArray(); 
    234         setMode(ERASE); 
     228      freeform.truncateNodeArray(); 
     229      setMode(ERASE); 
    235230    } 
    236231 
     
    270265        // DISTANCE COMPUTATION: compare floats and ints 
    271266        float[] last = {freeform.getLastNodeX(), freeform.getLastNodeY()}; 
    272         double distPxl = getPixelDistanceToClick(display, last,  
     267        double distPxl = getPixelDistanceToClick(display, last, 
    273268            new int[]{px, py}); 
    274269 
     
    314309  /** Instructs this tool to respond to a mouse release. */ 
    315310  public void mouseUp(DisplayEvent e, int px, int py, 
    316       float dx, float dy, int[] pos, int mods) { 
     311      float dx, float dy, int[] pos, int mods) 
     312  { 
    317313    if (mode == DRAW) { 
    318314      freeform.truncateNodeArray(); 
     
    335331  // -- Helper methods for mouse methods 
    336332 
    337  
    338333  /** Compiles a list of other freeforms at the current dimensional position. */ 
    339334  protected Vector getFreeforms(boolean includeThis) { 
     
    341336    otherFreefs = new Vector(10); 
    342337    for (int i=0; i<objs.length; i++) { 
    343       if (objs[i] instanceof OverlayFreeform &&  
    344           (includeThis || objs[i] != freeform)) { 
     338      if (objs[i] instanceof OverlayFreeform && 
     339          (includeThis || objs[i] != freeform)) 
     340      { 
    345341        otherFreefs.add(objs[i]); 
    346342      } 
     
    436432    if (closest != null) { 
    437433      OverlayFreeform[] children = closest.removeNode(minIndex); 
    438       // remove freeforms with 1 or 0 nodes that result  
     434      // remove freeforms with 1 or 0 nodes that result 
    439435      if (closest.getNumNodes() <= 1) overlay.removeObject(closest); 
    440436      removeEmptyFreeforms(children); 
     
    442438  } 
    443439 
    444   /** Removes any freeforms with one or fewer nodes */ 
     440  /** Removes any freeforms with one or fewer nodes. */ 
    445441  protected void removeEmptyFreeforms(OverlayFreeform[] objs) { 
    446442    for (int i=0; i<objs.length; i++) { 
     
    451447 
    452448  /** Returns the closest (subject to a threshhold) OverlayFreeform object to 
    453    *  the given point 
     449   *  the given point. 
    454450   */ 
    455451  protected DistanceQuery getClosestFreeform(DisplayImpl display, double dpx, 
    456       double dpy, double thresh) { 
     452      double dpy, double thresh) 
     453  { 
    457454    // returns only objects at the current dimensional position 
    458455    OverlayObject[] objects = overlay.getObjects(); 
     
    489486  /** Gets distance in pixels between a click and a point in domain coords. */ 
    490487  private double getPixelDistanceToClick(DisplayImpl display, float[] p, int[] 
    491       click) { 
     488      click) 
     489  { 
    492490    // TODO Make this work for N-D arguments (not just 2D) 
    493491    double[] pDbl = new double[] {(double) p[0], (double) p[1]}; 
     
    526524  } 
    527525 
    528   // -- Inner Class --  
    529  
    530   /**  
    531    * Wraps information about the distance from a point to a freeform object.  
    532    * The nearest point is expressed in terms of its location on the freeform  
     526  // -- Inner Class -- 
     527 
     528  /** 
     529   * Wraps information about the distance from a point to a freeform object. 
     530   * The nearest point is expressed in terms of its location on the freeform 
    533531   * using two variables: 
    534532   * <code>seg</code> the segment on which the closest point lies, between 
     
    541539    // -- Fields -- 
    542540 
    543     /** The index of the first node of the closest segment */  
     541    /** The index of the first node of the closest segment. */ 
    544542    public int seg; 
    545543 
    546544    /** 
    547      * The weight, between 0.0 and 1.0, representing the relative distance  
     545     * The weight, between 0.0 and 1.0, representing the relative distance 
    548546     * along the segment (seg, seg+1) that must be traveled from the node at 
    549547     * index seg to reach the closest point on the curve. 
    550      */  
     548     */ 
    551549    public double wt; 
    552550 
     
    557555    public OverlayFreeform freeform; 
    558556 
    559     // -- Constructor --  
    560      
     557    // -- Constructor -- 
     558 
    561559    /** Constructs a DistanceQuery object. */ 
    562560    public DistanceQuery(double[] distSegWt, OverlayFreeform f) { 
     
    567565    } 
    568566 
    569     // -- Methods --  
    570      
     567    // -- Methods -- 
     568 
    571569    /** Whether the nearest node is an end node. */ 
    572570    public boolean isNearEndNode() { 
  • trunk/loci/visbio/overlays/OverlayArrow.java

    r2910 r2912  
    3535  // -- Static Fields -- 
    3636 
    37   /** The names of the statistics this object reports */ 
     37  /** The names of the statistics this object reports. */ 
    3838  protected static final String TIP = "Tip Coordinates"; 
    3939  protected static final String ANGLE = "Angle"; 
     
    5959  // -- Static methods -- 
    6060 
    61   /** Returns the names of the statistics this object reports */ 
    62   public static String[] getStatTypes() {return STAT_TYPES;} 
     61  /** Returns the names of the statistics this object reports. */ 
     62  public static String[] getStatTypes() { return STAT_TYPES; } 
    6363 
    6464  // -- OverlayObject API methods -- 
     
    128128  } 
    129129 
    130   /** Returns a specific statistic of this object */ 
     130  /** Returns a specific statistic of this object. */ 
    131131  public String getStat(String name) { 
    132132    if (name.equals(TIP)) { 
     
    159159  // -- Helper methods -- 
    160160 
    161   /** Computes the angle of this arrow */ 
     161  /** Computes the angle of this arrow. */ 
    162162  protected float getAngle() { 
    163163    float xx = x2 - x1; 
     
    169169  } 
    170170 
    171   /** Computes the length of this arrow */ 
     171  /** Computes the length of this arrow. */ 
    172172  protected float getLength() { 
    173173    float xx = x2 - x1; 
  • trunk/loci/visbio/overlays/OverlayBox.java

    r2910 r2912  
    3434  // -- Static Fields -- 
    3535 
    36   /** The names of the statistics this object reports */ 
     36  /** The names of the statistics this object reports. */ 
    3737  protected static final String COORDS = "Coordinates"; 
    3838  protected static final String CTR = "Center"; 
     
    6262  // -- Static methods -- 
    6363 
    64   /** Returns the names of the statistics this object reports */ 
    65   public static String[] getStatTypes() {return STAT_TYPES;} 
     64  /** Returns the names of the statistics this object reports. */ 
     65  public static String[] getStatTypes() { return STAT_TYPES; } 
    6666 
    6767  // -- OverlayObject API methods -- 
     
    135135  } 
    136136 
    137   /** Returns a specific statistic of this object*/ 
     137  /** Returns a specific statistic of this object. */ 
    138138  public String getStat(String name) { 
    139139    float xx = x2 - x1; 
     
    148148    if (name.equals(COORDS)) { 
    149149      return "(" + x1 + ", " + y1 + ")-(" + x2 + ", " + y2 + ")"; 
    150     } else if (name.equals(CTR)){ 
     150    } 
     151    else if (name.equals(CTR)) { 
    151152      return "(" + centerX + ", " + centerY + ")"; 
    152153    } 
  • trunk/loci/visbio/overlays/OverlayFreeform.java

    r2725 r2912  
    4242  } 
    4343 
    44   /** Constructs a freeform from an array of nodes */ 
     44  /** Constructs a freeform from an array of nodes. */ 
    4545  public OverlayFreeform(OverlayTransform overlay, float[][] nodes) { 
    4646    super(overlay, nodes); 
  • trunk/loci/visbio/overlays/OverlayIO.java

    r2823 r2912  
    118118        return null; 
    119119 
    120       } else if (event == INIT) { 
     120      } 
     121      else if (event == INIT) { 
    121122        if (state == TABLE) { 
    122123          StringTokenizer st = new StringTokenizer("#" + line + "#", "\t"); 
     
    164165          } 
    165166 
    166         } else if (state == NODES) { 
     167        } 
     168        else if (state == NODES) { 
    167169          if (numberOfNodedObjectsRead == loadedNodedObjects.size()) { 
    168             String s = "more \"Noded Object\" (Freeforms, Polylines) node" 
    169               + " lists " + "than Noded Objects (" + numberOfNodedObjectsRead 
    170               + ") specified in table"; 
     170            String s = "more \"Noded Object\" (Freeforms, Polylines) node" + 
     171              " lists " + "than Noded Objects (" + numberOfNodedObjectsRead + 
     172              ") specified in table"; 
    171173            displayErrorMsg(owner, lineNum, s); 
    172174            return null; 
     
    186188          nodesChanged = true; 
    187189        } 
    188  
    189       } else if (event == PARSE) { 
     190      } 
     191      else if (event == PARSE) { 
    190192        if (state == TABLE) { 
    191193          StringTokenizer st = new StringTokenizer("#" + line + "#", "\t"); 
     
    213215                pos[i] = p-1; // shift from external to internal indexing 
    214216                tok++; 
    215               } else { 
     217              } 
     218              else { 
    216219                pos = null; 
    217220                break; 
     
    257260          try { 
    258261            color = ColorUtil.hexToColor(st.nextToken()); 
    259           } catch (NumberFormatException exc) { 
     262          } 
     263          catch (NumberFormatException exc) { 
    260264            displayErrorMsg(owner, lineNum, "line has invalid color value"); 
    261265            continue; 
     
    308312          loadedOverlays[r].add(obj); 
    309313          foundOverlays = true; 
    310         } else if (state == NODES) { 
    311  
    312           String[] toks = trim.split("\\s");// split on whitespace 
     314        } 
     315        else if (state == NODES) { 
     316 
     317          String[] toks = trim.split("\\s"); // split on whitespace 
    313318 
    314319          float x, y; 
     
    497502  } 
    498503 
    499   /** Saves overlays to a .xls workbook */ 
    500   public static HSSFWorkbook exportOverlays (OverlayTransform overlay) { 
     504  /** Saves overlays to a .xls workbook. */ 
     505  public static HSSFWorkbook exportOverlays(OverlayTransform overlay) { 
    501506    String[] dims = overlay.getDimTypes(); 
    502507    int[] lengths = overlay.getLengths(); 
     
    546551    short numColsToMerge = 12; // number of columns in overlay table header 
    547552 
    548     Region mergedCells = new Region (0, (short) 0, 0, numColsToMerge); 
     553    Region mergedCells = new Region(0, (short) 0, 0, numColsToMerge); 
    549554    s.addMergedRegion(mergedCells); 
    550555 
     
    690695      arrows, polylines}; 
    691696    String[] titles = OverlayUtil.getOverlayTypes(); 
    692     for (int v=0; v<vectors.length ; v++) { 
     697    for (int v=0; v<vectors.length; v++) { 
    693698      if (vectors[v].size() > 0) { 
    694699        rownum += 2; 
     
    877882        state = WAIT; event = BARF; 
    878883      } 
    879     } else if (current == TABLE) { 
     884    } 
     885    else if (current == TABLE) { 
    880886      if (input.equals("")) { 
    881887        state = TABLE; event = IGNORE; 
    882888      } 
    883       else if (input.matches("# Freeform \\d+ nodes:") 
    884           || input.matches("# Polyline \\d+ nodes:")) 
     889      else if (input.matches("# Freeform \\d+ nodes:") || 
     890          input.matches("# Polyline \\d+ nodes:")) 
    885891      { 
    886892        state = NODES; event = INIT; 
    887893      } 
    888       else if (input.startsWith("Line") || input.startsWith("Freeform") 
    889           || input.startsWith("Marker") || input.startsWith("Text") || 
     894      else if (input.startsWith("Line") || input.startsWith("Freeform") || 
     895          input.startsWith("Marker") || input.startsWith("Text") || 
    890896          input.startsWith("Oval") || input.startsWith("Box") || 
    891           input.startsWith("Arrow") || input.startsWith("Polyline")) { 
     897          input.startsWith("Arrow") || input.startsWith("Polyline")) 
     898      { 
    892899        state = TABLE; event = PARSE; 
    893900      } 
    894       else if (input.startsWith("#")) {state = TABLE; event = IGNORE;} 
     901      else if (input.startsWith("#")) { state = TABLE; event = IGNORE; } 
    895902      // must check for freeform header first 
    896       else { 
    897         event = BARF; state = TABLE; 
    898       } 
    899     } else if (current == NODES) { 
     903      else { event = BARF; state = TABLE; } 
     904    } 
     905    else if (current == NODES) { 
    900906      if (input.equals("")) { 
    901907        state = NODES; event = IGNORE; 
    902908      } 
    903909      else if (input.matches("# Freeform \\d+ nodes:") || 
    904           input.matches("# Polyline \\d+ nodes:")) { 
     910          input.matches("# Polyline \\d+ nodes:")) 
     911      { 
    905912        state = NODES; event = INIT; 
    906913      } 
     
    922929  /** Displays an alarm box */ 
    923930  private static void displayErrorMsg(JComponent owner, int line, String msg) { 
    924     JOptionPane.showMessageDialog(owner, "Invalid overlay file: " 
    925       + msg + "\n" + "Error in line " + line , 
     931    JOptionPane.showMessageDialog(owner, "Invalid overlay file: " + 
     932        msg + "\n" + "Error in line " + line , 
    926933      "Cannot load overlays", JOptionPane.ERROR_MESSAGE); 
    927934  } 
  • trunk/loci/visbio/overlays/OverlayLine.java

    r2823 r2912  
    3535  // -- Static Fields -- 
    3636 
    37   /** The names of the statistics this object reports */ 
     37  /** The names of the statistics this object reports. */ 
    3838  protected static final String COORDS = "Coordinates"; 
    3939  protected static final String LENGTH = "Length"; 
     
    5858  // -- Static methods -- 
    5959 
    60   /** Returns the names of the statistics this object reports */ 
    61   public static String[] getStatTypes() {return STAT_TYPES;} 
     60  /** Returns the names of the statistics this object reports. */ 
     61  public static String[] getStatTypes() { return STAT_TYPES; } 
    6262 
    6363  // -- OverlayObject API methods -- 
     
    107107  } 
    108108 
    109   /** Returns a specific statistic of this object */ 
     109  /** Returns a specific statistic of this object. */ 
    110110  public String getStat(String name) { 
    111111    if (name.equals(COORDS)) { 
  • trunk/loci/visbio/overlays/OverlayMarker.java

    r2910 r2912  
    3434  // -- Static Fields -- 
    3535 
    36   /** The names of the statistics this object reports */ 
     36  /** The names of the statistics this object reports. */ 
    3737  protected static final String COORDS = "Coordinates"; 
    3838  protected static final String[] STAT_TYPES =  {COORDS}; 
    3939 
    40   /** The default width of the marker */ 
    41   protected float width;  
     40  /** The default width of the marker. */ 
     41  protected float width; 
    4242 
    4343  // -- Constructors -- 
     
    5151    x1 = x; 
    5252    y1 = y; 
    53     width = getDefaultWidth();  
     53    width = getDefaultWidth(); 
    5454  } 
    5555 
    5656  // -- Static methods -- 
    5757 
    58   /** Returns the names of the statistics this object reports */ 
    59   public static String[] getStatTypes() {return STAT_TYPES;} 
     58  /** Returns the names of the statistics this object reports. */ 
     59  public static String[] getStatTypes() { return STAT_TYPES; } 
    6060 
    6161  // -- OverlayObject API methods -- 
     
    106106  } 
    107107 
    108   /** Returns a specific statistic of this object*/ 
     108  /** Returns a specific statistic of this object. */ 
    109109  public String getStat(String name) { 
    110110    if (name.equals(COORDS)) { 
     
    131131 
    132132  // -- Overlay Marker API methods -- 
    133   
     133 
    134134  /** Returns the defualt width of this marker. */ 
    135135  protected float getDefaultWidth() { 
     
    140140  protected float getWidth() { return width; } 
    141141 
    142  
    143142  // -- Object API methods -- 
    144143 
  • trunk/loci/visbio/overlays/OverlayNodedObject.java

    r2910 r2912  
    3939  // -- Static Fields -- 
    4040 
    41   /** The names of the statistics this object reports */ 
     41  /** The names of the statistics this object reports. */ 
    4242  protected static final String BOUNDS = "Bounds"; 
    4343  protected static final String NODES = "Number of Nodes"; 
     
    7777  } 
    7878 
    79   /** Alpha value for highlighting */ 
     79  /** Alpha value for highlighting. */ 
    8080  protected static final float HLT_ALPHA = 0.5f; 
    8181 
    82   /** Radius in pixels of circle indicating a node is selected */ 
     82  /** Radius in pixels of circle indicating a node is selected. */ 
    8383  protected static final float RADIUS = 3.0f; 
    8484 
    8585  // -- Fields -- 
    8686 
    87   /** Synchronization object for nodes array */ 
     87  /** Synchronization object for nodes array. */ 
    8888  protected Object nodesSync = new Object(); 
    8989 
    90   /** Node array and associated tracking variables */ 
     90  /** Node array and associated tracking variables. */ 
    9191  protected float[][] nodes; 
    9292 
    93   /** Number of real nodes in the node array */ 
     93  /** Number of real nodes in the node array. */ 
    9494  protected int numNodes; 
    9595 
    96   /** Total number of nodes (real + buffer) nodes in the node array */ 
     96  /** Total number of nodes (real + buffer) nodes in the node array. */ 
    9797  protected int maxNodes; 
    9898 
    99   /** Length of curve of a noded object */ 
     99  /** Length of curve of a noded object. */ 
    100100  protected double curveLength; 
    101101 
    102   /** Whether there is a higlighted node */ 
     102  /** Whether there is a higlighted node. */ 
    103103  protected boolean highlightNode; 
    104104 
    105   /** Index of the highlighted node */ 
     105  /** Index of the highlighted node. */ 
    106106  protected int highlightIndex; 
    107107 
     
    150150  // -- Static methods -- 
    151151 
    152   /** Returns the names of the statistics this object reports */ 
     152  /** Returns the names of the statistics this object reports. */ 
    153153  public static String[] getStatTypes() { return STAT_TYPES; } 
    154154 
     
    231231 
    232232  /** Compute the shortest distance from this object to the given point. */ 
    233   public double getDistance (double x, double y) { 
     233  public double getDistance(double x, double y) { 
    234234    synchronized (nodesSync) { 
    235235      double[] distSegWt = MathUtil.getDistSegWt(nodes, (float) x, (float) y); 
     
    238238  } 
    239239 
    240   /** Returns a specific statistic of this object */ 
     240  /** Returns a specific statistic of this object. */ 
    241241  public String getStat(String name) { 
    242242    if (name.equals(BOUNDS)) { 
     
    268268  public boolean canBeFilled() { return true; } 
    269269 
    270   /** True iff this overlay can be resized using X1, X2, Y1, Y2 entry boxes */ 
     270  /** True iff this overlay can be resized using X1, X2, Y1, Y2 entry boxes. */ 
    271271  public boolean areBoundsEditable() { return false; } 
    272272  // currently, only non-noded objects can be resized this way. 
     
    290290    synchronized (nodesSync) { 
    291291      for (int i=0; i<numNodes; i++) { 
    292         float[] c = {nodes[0][i], nodes[1][i]};  
    293         double dist = MathUtil.getDistance(c, p);  
     292        float[] c = {nodes[0][i], nodes[1][i]}; 
     293        double dist = MathUtil.getDistance(c, p); 
    294294        if (dist < minDist) { 
    295295          minIndex = i; 
     
    321321  } 
    322322 
    323   /** Turn off node highlighting */ 
     323  /** Turn off node highlighting. */ 
    324324  public void turnOffHighlighting() { 
    325325    highlightNode = false; 
     
    327327  } 
    328328 
    329   /** Returns coordinates of node at given index in the node array */ 
    330   public float[] getNodeCoords (int index) { 
     329  /** Returns coordinates of node at given index in the node array. */ 
     330  public float[] getNodeCoords(int index) { 
    331331    float[] retvals = new float[2]; 
    332332    synchronized(nodesSync) { 
     
    334334        retvals[0] = nodes[0][index]; 
    335335        retvals[1] = nodes[1][index]; 
    336       } else { 
     336      } 
     337      else { 
    337338        retvals[0] = -1f; 
    338339        retvals[1] = -1f; 
     
    342343  } 
    343344 
    344   /** Returns a copy of the node array */ 
     345  /** Returns a copy of the node array. */ 
    345346  public float[][] getNodes() { 
    346347    synchronized(nodesSync) { 
     
    397398  } 
    398399 
    399   /**  
     400  /** 
    400401   * Updates the coordinates of the bounding box of a noded object by 
    401    * checking the entire node array.  
     402   * checking the entire node array. 
    402403   */ 
    403404  public void updateBoundingBox() { 
     
    446447    synchronized (nodesSync) { 
    447448      for (int i=0; i<numNodes-1; i++) { 
    448         double[] a = {(double) nodes[0][i], (double)nodes[1][i]}; 
     449        double[] a = {(double) nodes[0][i], (double) nodes[1][i]}; 
    449450        double[] b = {(double) nodes[0][i+1], (double) nodes[1][i+1]}; 
    450451        length += MathUtil.getDistance(a, b); 
     
    457458  // note: call updateBoundingBox() after a series of changes to the node array 
    458459 
    459   /** Sets coordinates of an existing node */ 
     460  /** Sets coordinates of an existing node. */ 
    460461  public void setNodeCoords(int ndx, float x, float y) { 
    461462    // Outline of this method: 
     
    475476        sameAsNext = true; 
    476477    } 
    477      
     478 
    478479    if (sameAsPrev || sameAsNext) { 
    479480      if (sameAsPrev && sameAsNext) { 
     
    511512    synchronized (nodesSync) { 
    512513      if (numNodes > 0 && (x == nodes[0][numNodes-1] && y == 
    513             nodes[1][numNodes-1])) { 
     514            nodes[1][numNodes-1])) 
     515      { 
    514516        // same as last node, do nothing 
    515517      } 
     
    539541      if (index >= 0 && index < numNodes) { 
    540542        // if array is full, make some more room. 
    541         if (numNodes >= maxNodes) {  
     543        if (numNodes >= maxNodes) { 
    542544          // numNodes should never exceed maxNodes but I threw the > in anyway. 
    543545          maxNodes *= 2; 
     
    547549        if (colocationalOK) { 
    548550          insert(index, x, y); 
    549         }  
     551        } 
    550552        else { 
    551553          boolean differentFromNext = false; 
     
    557559          } 
    558560          if (index > 0) { 
    559             differentFromPrev = MathUtil.areDifferent(getNodeCoords(index-1), c); 
     561            differentFromPrev = MathUtil.areDifferent( 
     562                getNodeCoords(index-1), c); 
    560563            notFirst = true; 
    561564          } 
     
    567570          */ 
    568571          if ((!notFirst && differentFromNext) || 
    569               (notFirst && differentFromPrev && differentFromNext)) { 
     572              (notFirst && differentFromPrev && differentFromNext)) 
     573          { 
    570574            insert(index, x, y); 
    571575 
     
    593597  } 
    594598 
    595   /** Deletes a range of nodes from the node array */ 
    596   public void deleteBetween (int i1, int i2) { 
     599  /** Deletes a range of nodes from the node array. */ 
     600  public void deleteBetween(int i1, int i2) { 
    597601    // assumes i1 < i2, both in bounds (less than numNodes) 
    598602    // checks whether i1 + 1 < i2, i.e., is there a non-zero 
    599603    // number of nodes to delete 
    600604    synchronized(nodesSync) { 
    601       if (0 <= i1 && i2 < numNodes && i1 + 1 < i2 ) { 
     605      if (0 <= i1 && i2 < numNodes && i1 + 1 < i2) { 
    602606        int ii2 = i2; 
    603607        // if adjacent-nodes-to-be are colococational, 
    604608        // delete one of them 
    605         if (MathUtil.areSame(getNodeCoords(i1), getNodeCoords(i2)))  
     609        if (MathUtil.areSame(getNodeCoords(i1), getNodeCoords(i2))) 
    606610          ii2 += 1; 
    607611        int victims = ii2 - i1 - 1; 
     
    614618        maxNodes -= victims; 
    615619        nodes = newNodes; 
    616       } else { 
     620      } 
     621      else { 
    617622        //System.out.println("deleteBetween(int, int) out of bounds error"); 
    618623      } 
     
    620625  } 
    621626 
    622   /** Deletes a node from the node array */ 
     627  /** Deletes a node from the node array. */ 
    623628  public void deleteNode(int index) { 
    624629    synchronized (nodesSync) { 
     
    626631        // This method includes built-in truncation: it doesn't bother to 
    627632        // copy the extra nodes in the node array. 
    628          
     633 
    629634        // Check if this delete operation will result in two colocational nodes 
    630         // becoming adjacent in the node array.  If so, also delete one of  
     635        // becoming adjacent in the node array.  If so, also delete one of 
    631636        // these nodes. 
    632637        int offset; 
    633         if (index > 0 && index < numNodes - 1 &&  
    634             MathUtil.areSame(getNodeCoords(index-1), getNodeCoords(index+1)))  
     638        if (index > 0 && index < numNodes - 1 && 
     639            MathUtil.areSame(getNodeCoords(index-1), getNodeCoords(index+1))) 
    635640          offset = 1; 
    636641        else offset = 0; 
    637642        float[][] newNodes =  new float[2][numNodes-1-offset]; 
    638643        System.arraycopy(nodes[0], 0, newNodes[0], 0, index-offset); 
    639         System.arraycopy(nodes[0], index+1, newNodes[0], index-offset, numNodes-index-1); 
     644        System.arraycopy(nodes[0], index+1, newNodes[0], index-offset, 
     645            numNodes-index-1); 
    640646        System.arraycopy(nodes[1], 0, newNodes[1], 0, index-offset); 
    641         System.arraycopy(nodes[1], index+1, newNodes[1], index-offset, numNodes-index-1); 
     647        System.arraycopy(nodes[1], index+1, newNodes[1], index-offset, 
     648            numNodes-index-1); 
    642649        numNodes -= 1 + offset; 
    643650        maxNodes = numNodes; 
     
    646653    } 
    647654  } 
    648    
     655 
    649656  // NOTE: Right now this method returns Freeforms only, though it could be used 
    650   // on Polylines too.  
    651   /** Deletes a node from the freeform object, creating two new freeforms  
    652    *  if the node deleted is an interior node.  
     657  // on Polylines too. 
     658  /** Deletes a node from the freeform object, creating two new freeforms 
     659   *  if the node deleted is an interior node. 
    653660   *  Returns resulting new freeforms if any. */ 
    654661  public OverlayFreeform[] removeNode(int index) { 
    655     OverlayFreeform[] children = {null, null};  
     662    OverlayFreeform[] children = {null, null}; 
    656663    if (index == 0 || index == numNodes - 1) { 
    657664      deleteNode(index); 
     
    663670  } 
    664671 
    665   /**  
     672  /** 
    666673   * Creates a new freeform by connecting the tail of this freeform to the 
    667674   * head of the freeform supplied. 
     
    671678    float[][] f1Nodes = this.getNodes(); 
    672679    float[][] f2Nodes = f2.getNodes(); 
    673     int len1 = f1Nodes[0].length;  
     680    int len1 = f1Nodes[0].length; 
    674681    int len2 = f2Nodes[0].length; 
    675682 
     
    680687    // this method won't copy the last node of f1 into the node array used to 
    681688    // construct f3. 
    682     int offset;  
    683     if (MathUtil.areSame(f1End, f2Beg)) offset = 1;  
     689    int offset; 
     690    if (MathUtil.areSame(f1End, f2Beg)) offset = 1; 
    684691    else offset = 0; 
    685692 
    686693    float[][] newNodes = new float[2][len1 + len2 - offset]; 
    687694    for (int i=0; i<2; i++) { 
    688       System.arraycopy(f1Nodes[i], 0, newNodes[i], 0, len1-offset);  
     695      System.arraycopy(f1Nodes[i], 0, newNodes[i], 0, len1-offset); 
    689696      System.arraycopy(f2Nodes[i], 0, newNodes[i], len1-offset, len2); 
    690697    } 
    691698 
    692     OverlayFreeform f3 = new OverlayFreeform (overlay, newNodes); 
     699    OverlayFreeform f3 = new OverlayFreeform(overlay, newNodes); 
    693700    return f3; 
    694701  } 
    695702 
    696   /** Reverses the node array (and therefore its internal orientation) */ 
     703  /** Reverses the node array (and therefore its internal orientation). */ 
    697704  public void reverseNodes() { 
    698705    truncateNodeArray(); 
     
    714721  } 
    715722 
    716   /** Deletes buffer nodes from the tail of the node array */ 
     723  /** Deletes buffer nodes from the tail of the node array. */ 
    717724  public void truncateNodeArray() { 
    718      resizeNodeArray(numNodes); 
     725    resizeNodeArray(numNodes); 
    719726  } 
    720727 
     
    741748 
    742749  // -- Helper methods -- 
    743    
     750 
    744751  // NOTE: Right now this method returns Freeforms only, though it could be used 
    745   // on Polylines too.  
    746   /**  
    747    * Slices a noded object in two.  
     752  // on Polylines too. 
     753  /** 
     754   * Slices a noded object in two. 
    748755   * @param seg the index of the segment on which to slice 
    749756   * @param weight the relative distance along the segment to slice 
    750    * The parameters seg and weight indicate a 'cut point' on the freeform.  
     757   * The parameters seg and weight indicate a 'cut point' on the freeform. 
    751758   * If weight is strictly between 0 and 1, the cut point is actually between 
    752    * two nodes, and all nodes of the original object are transferred to  
    753    * the child objects.  
     759   * two nodes, and all nodes of the original object are transferred to 
     760   * the child objects. 
    754761   */ 
    755762  // TODO -- combine this with 'split' method in polyline tool. 
    756   private OverlayFreeform[] slice(int seg, double weight) 
    757   { 
     763  private OverlayFreeform[] slice(int seg, double weight) { 
    758764    // create two new freeforms from the remainder of this freeform 
    759765    OverlayFreeform f1 = null, f2 = null; 
     
    762768 
    763769    synchronized (nodesSync) { 
    764       // compute indices into the node array of this freeform  
     770      // compute indices into the node array of this freeform 
    765771      int f1Start, f2Start, f1Stop, f2Stop; 
    766772      f1Start = 0; 
     
    814820  } 
    815821 
    816   // -- Helper Methods for Debugging --  
     822  // -- Helper Methods for Debugging -- 
    817823 
    818824  /** Prints node array of current freeform; for debugging */ 
    819   private void printNodes(float[][] nodes) { 
    820     System.out.println("Printing nodes..."); 
    821     synchronized (nodesSync) { 
    822       for (int i = 0; i < nodes[0].length; i++){ 
    823         System.out.println(i+":("+nodes[0][i]+","+nodes[1][i]+")"); 
     825  private void printNodes(float[][] n) { 
     826    System.out.println("Printing n..."); 
     827    synchronized (nodesSync) { 
     828      for (int i = 0; i < n[0].length; i++){ 
     829        System.out.println(i+":("+n[0][i]+","+n[1][i]+")"); 
    824830      } 
    825831    } 
     
    831837  } 
    832838 
    833   /** Prints current thread plus method name if provided */ 
     839  /** Prints current thread plus method name if provided. */ 
    834840  public static void printThread(String methodName) { 
    835841    System.out.println(methodName + ": currentThread()= " + 
  • trunk/loci/visbio/overlays/OverlayNumericStrategy.java

    r2886 r2912  
    2424package loci.visbio.overlays; 
    2525 
    26 public class OverlayNumericStrategy { 
     26/** Provides threshholds and other constants to overlays classes. */ 
     27public final class OverlayNumericStrategy { 
    2728 
    2829  // -- Fields -- 
    29    
     30 
    3031  /** 
    3132   * When drawing or editing, how far mouse 
     
    3637  /** 
    3738   * How close a mouseDrag event must be to a node 
    38    * in order to erase it 
     39   * in order to erase it. 
    3940   */ 
    4041  protected static final double ERASE_THRESH = 10.0; 
     
    4950  protected static final double RECONNECT_THRESH = 1.0; 
    5051 
    51   /** How close mouse must be to end node to resume drawing */ 
     52  /** How close mouse must be to end node to resume drawing. */ 
    5253  protected static final double RESUME_THRESH = 10.0; 
    5354 
    54   /** Smoothing factor for "single exponential smoothing" */ 
     55  /** Smoothing factor for "single exponential smoothing". */ 
    5556  protected static final float SMOOTHING_FACTOR = 0.35f; 
    5657 
     
    6061 
    6162  // -- Constructor -- 
    62    
     63 
    6364  /** Private constructor--ensure this object is not instantiated. */ 
    6465  private OverlayNumericStrategy() {} 
     
    8384  /** Returns the single exponential smoothing factor. */ 
    8485  public static double getSmoothingFactor() { return SMOOTHING_FACTOR; } 
    85    
     86 
    8687  /** Returns the polyline threshold. */ 
    8788  public static double getPolylineThreshold() { return POLYLINE_THRESH; } 
  • trunk/loci/visbio/overlays/OverlayObject.java

    r2911 r2912  
    103103  public abstract double getDistance(double x, double y); 
    104104 
    105   /** Gets a specific overlay statistic */ 
     105  /** Gets a specific overlay statistic. */ 
    106106  public abstract String getStat(String name); 
    107107 
     
    123123  public boolean canBeFilled() { return false; } 
    124124 
    125   /** True iff this overlay can be resized using X1, X2, Y1, Y2 entry boxes */ 
     125  /** True iff this overlay can be resized using X1, X2, Y1, Y2 entry boxes. */ 
    126126  public boolean areBoundsEditable() { return true; } 
    127127  // currently, only non-noded objects can be resized this way. 
     
    203203  /** Gets whether overlay is solid. */ 
    204204  public boolean isFilled() { return filled; } 
    205    
     205 
    206206  /** Gets whether overlay is scalable. */ 
    207207  public boolean isScalable() { return false; } 
  • trunk/loci/visbio/overlays/OverlayOval.java

    r2823 r2912  
    3434  // -- Static Fields -- 
    3535 
    36   /** The names of the statistics this object reports */ 
     36  /** The names of the statistics this object reports. */ 
    3737  public static final String COORDS = "Coordinates"; 
    3838  public static final String CTR = "Center"; 
     
    9696  // -- Static methods -- 
    9797 
    98   /** Returns the names of the statistics this object reports */ 
     98  /** Returns the names of the statistics this object reports. */ 
    9999  public static String[] getStatTypes() { return STAT_TYPES; } 
    100100 
     
    182182  } 
    183183 
    184   /** Returns a specific statistic of this object */ 
     184  /** Returns a specific statistic of this object. */ 
    185185  public String getStat(String name) { 
    186186    float xx = x2 - x1; 
  • trunk/loci/visbio/overlays/OverlayPolyline.java

    r2725 r2912  
    4444  } 
    4545 
    46   /** Constructs a freeform from an array of nodes */ 
     46  /** Constructs a freeform from an array of nodes. */ 
    4747  public OverlayPolyline(OverlayTransform overlay, float[][] nodes) { 
    4848    super(overlay, nodes); 
  • trunk/loci/visbio/overlays/OverlayText.java

    r2910 r2912  
    3333  // -- Static Fields -- 
    3434 
    35   /** The names of the statistics this object reports */ 
     35  /** The names of the statistics this object reports. */ 
    3636  protected static final String COORDS = "Coordinates"; 
    3737  protected static final String[] STAT_TYPES = {COORDS}; 
     
    5858  // -- Static methods -- 
    5959 
    60   /** Returns the names of the statistics this object reports */ 
    61   public static String[] getStatTypes() {return STAT_TYPES;} 
     60  /** Returns the names of the statistics this object reports. */ 
     61  public static String[] getStatTypes() { return STAT_TYPES; } 
    6262 
    6363  // -- OverlayText API methods -- 
     
    122122  } 
    123123 
    124   /** Returns a specific statistic of this object */ 
     124  /** Returns a specific statistic of this object. */ 
    125125  public String getStat(String name) { 
    126126    if (name.equals(COORDS)) { 
  • trunk/loci/visbio/overlays/OverlayTransform.java

    r2904 r2912  
    118118  protected int[] clipboardPos = null; 
    119119 
    120   /** Transient Select Box, if active */ 
     120  /** Transient Select Box, if active. */ 
    121121  protected TransientSelectBox selectBox; 
    122122 
    123   /** Type of last tool used */ 
     123  /** Type of last tool used. */ 
    124124  protected String lastToolType; 
    125125 
    126   /** Whether last tool has changed */ 
     126  /** Whether last tool has changed. */ 
    127127  protected boolean toolChanged; 
    128128 
     
    183183 
    184184  /** Adds a transient selection box. */ 
    185   public void addTSB (TransientSelectBox tsb) { selectBox = tsb; } 
     185  public void addTSB(TransientSelectBox tsb) { selectBox = tsb; } 
    186186 
    187187  /** Removes transient selection box. */ 
    188   public void removeTSB () { selectBox = null; } 
     188  public void removeTSB() { selectBox = null; } 
    189189 
    190190  /** Removes selected overlay objects at the given dimensional position. */ 
     
    428428  /** Exports the overlays as .xls to the given output file.*/ 
    429429  public HSSFWorkbook exportOverlays() { 
    430     return OverlayIO.exportOverlays (this); 
     430    return OverlayIO.exportOverlays(this); 
    431431  } 
    432432 
     
    548548 
    549549    // The current display 
    550     DisplayImpl display = link.getHandler().getWindow().getDisplay();  
     550    DisplayImpl display = link.getHandler().getWindow().getDisplay(); 
    551551 
    552552    if (dim != 2) { 
     
    588588              // (currently applies only to OverlayMarkers) 
    589589              if (obj.isScalable()) 
    590                 obj.rescale(OverlayUtil.getMultiplier(display));  
     590                obj.rescale(OverlayUtil.getMultiplier(display)); 
    591591              if (obj.hasText()) continue; 
    592592              rgbField.setSample(c++, obj.getData(), false); 
     
    626626        // retrieve select box data 
    627627        if (selectBox != null) { 
    628             selectData = selectBox.getData(); 
     628          selectData = selectBox.getData(); 
    629629        } 
    630630 
     
    898898 
    899899  // -- Helper methods -- 
    900    
     900 
    901901  /** Configures the given overlay to match the current settings. */ 
    902902  protected void configureOverlay(OverlayObject obj) { 
  • trunk/loci/visbio/overlays/OverlayUtil.java

    r2909 r2912  
    2828import java.util.Arrays; 
    2929import java.util.Vector; 
     30import loci.visbio.util.MathUtil; 
    3031import loci.visbio.view.TransformLink; 
    31 import loci.visbio.util.MathUtil; 
    3232import visad.*; 
    3333import visad.util.CursorUtil; 
    3434 
    35 /** Utility methods for Overlays */ 
     35/** Utility methods for Overlays. */ 
    3636public final class OverlayUtil { 
    3737 
    3838  // -- Constants -- 
    3939 
    40   /** Width of the selection layer beyond the object's boundaries */ 
     40  /** Width of the selection layer beyond the object's boundaries. */ 
    4141  protected static final float GLOW_WIDTH = 5.0f; // in pixels 
    4242 
    43   /** Alpha of the selection layer */ 
     43  /** Alpha of the selection layer. */ 
    4444  protected static final float GLOW_ALPHA = 0.15f; 
    4545 
    46   /** Color of the selection layer */ 
     46  /** Color of the selection layer. */ 
    4747  protected static final Color GLOW_COLOR = Color.yellow; 
    4848 
    49   /** Color of the highlight layer for noded objects */ 
     49  /** Color of the highlight layer for noded objects. */ 
    5050  protected static final Color HLT_COLOR = Color.green; 
    5151 
    52   /** Alpha of the highlight layer for noded object */ 
     52  /** Alpha of the highlight layer for noded object. */ 
    5353  protected static final float HLT_ALPHA = 0.5f; 
    5454 
    55   /** Color of the outline layer */ 
     55  /** Color of the outline layer. */ 
    5656  protected static final Color OUTLINE_COLOR = Color.cyan; 
    5757 
     
    8686  } 
    8787 
    88   /** List of all OverlayObject subclasses */ 
     88  /** List of all OverlayObject subclasses. */ 
    8989  public static final String[] OVERLAY_TYPES = 
    90     {"Line", "Freeform", "Marker", "Text", 
     90  {"Line", "Freeform", "Marker", "Text", 
    9191    "Oval", "Box", "Arrow", "Polyline"}; 
    9292 
     
    9696  // -- Statistics Utility Methods -- 
    9797 
    98   /** Get list of all OverlayObject subclasses */ 
     98  /** Get list of all OverlayObject subclasses. */ 
    9999  public static String[] getOverlayTypes() { return OVERLAY_TYPES; } 
    100100 
    101101  /** 
    102    * Returns statistic names for a particular class 
     102   * Returns statistic names for a particular class. 
    103103   */ 
    104104  protected static String[] getStatTypes(String overlayType) { 
    105105    String[] statTypes = null; 
    106106    if (overlayType.equals("Arrow")) statTypes = 
    107       OverlayArrow.getStatTypes(); 
     107        OverlayArrow.getStatTypes(); 
    108108    else if (overlayType.equals("Box")) statTypes = 
    109       OverlayBox.getStatTypes(); 
     109        OverlayBox.getStatTypes(); 
    110110    else if (overlayType.equals("Freeform")) statTypes = 
    111       OverlayFreeform.getStatTypes(); 
     111        OverlayFreeform.getStatTypes(); 
    112112    else if (overlayType.equals("Line")) statTypes = 
    113       OverlayLine.getStatTypes(); 
     113        OverlayLine.getStatTypes(); 
    114114    else if (overlayType.equals("Marker")) statTypes = 
    115       OverlayMarker.getStatTypes(); 
     115        OverlayMarker.getStatTypes(); 
    116116    else if (overlayType.equals("Oval")) statTypes = 
    117       OverlayOval.getStatTypes(); 
     117        OverlayOval.getStatTypes(); 
    118118    else if (overlayType.equals("Polyline"))statTypes = 
    119       OverlayPolyline.getStatTypes(); 
     119        OverlayPolyline.getStatTypes(); 
    120120    else if (overlayType.equals("Text")) statTypes = 
    121       OverlayText.getStatTypes(); 
     121        OverlayText.getStatTypes(); 
    122122    return statTypes; 
    123123  } 
     
    125125  // -- Selection Layer Utility Methods -- 
    126126 
    127   /** Computes a type-specific selection layer for the given OverlayObject */ 
     127  /** Computes a type-specific selection layer for the given OverlayObject. */ 
    128128  public static DataImpl getSelectionLayer(OverlayObject obj, 
    129       TransformLink link, boolean outline) { 
     129      TransformLink link, boolean outline) 
     130  { 
    130131    DataImpl layer = null; 
    131132    if (!obj.hasData()) layer = null; 
     
    145146  } 
    146147 
    147   /** Computes selection layer for OverlayArrow objects */ 
     148  /** Computes selection layer for OverlayArrow objects. */ 
    148149  public static DataImpl getArrowLayer(OverlayObject obj, TransformLink link) { 
    149150    OverlayTransform overlay = (OverlayTransform) link.getTransform(); 
     
    226227  } 
    227228 
    228   /** Computes selection layer for OverlayBox objects */ 
     229  /** Computes selection layer for OverlayBox objects. */ 
    229230  public static DataImpl getBoxLayer(OverlayObject obj, TransformLink link) { 
    230231    OverlayTransform overlay = (OverlayTransform) link.getTransform(); 
     
    291292  } 
    292293 
    293   /** Returns a selection layer for OverlayLine objects */ 
     294  /** Returns a selection layer for OverlayLine objects. */ 
    294295  public static DataImpl getLineLayer(OverlayObject obj, TransformLink link) { 
    295296    OverlayTransform overlay = (OverlayTransform) link.getTransform(); 
     
    301302    float y1 = obj.getY(); 
    302303    float y2 = obj.getY2(); 
    303  
    304304 
    305305    float delta = GLOW_WIDTH * getMultiplier(link); 
     
    325325                            {c1[1], c2[1], c3[1], c4[1]}}; 
    326326 
    327  
    328327    // construct range samples; 
    329328    Color col = GLOW_COLOR; 
     
    354353  } 
    355354 
    356   /** Returns a selection layer for OverlayMarker objects */ 
     355  /** Returns a selection layer for OverlayMarker objects. */ 
    357356  public static DataImpl getMarkerLayer(OverlayObject obj, TransformLink link) { 
    358357    OverlayTransform overlay = (OverlayTransform) link.getTransform(); 
     
    402401      }; 
    403402 
    404       // vertical part  
     403      // vertical part 
    405404      float[][] setSamples2 = { 
    406405        {x1 - delta, x1 + delta, x1 - delta, x1 + delta}, 
     
    430429      /* 
    431430      float dx = 0.0001; 
    432       // here's the code for creating a cross-shaped Gridded2DSet,  
     431      // here's the code for creating a cross-shaped Gridded2DSet, 
    433432      // which doesn't quite work 
    434433      setSamples = new float[][]{ 
     
    476475    FlatField field = null; 
    477476    try { 
    478       FunctionType fieldType = new FunctionType (domain, range); 
     477      FunctionType fieldType = new FunctionType(domain, range); 
    479478      field = new FlatField(fieldType, domainSet); 
    480479      field.setSamples(rangeSamples); 
     
    485484  } 
    486485 
    487   /** Computes selection layer for OverlayNodedObject objects */ 
     486  /** Computes selection layer for OverlayNodedObject objects. */ 
    488487  public static DataImpl getNodedLayer(OverlayObject obj, TransformLink link) { 
    489488    OverlayTransform overlay = (OverlayTransform) link.getTransform(); 
     
    514513    // Build nodes sets 
    515514    // ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 
    516      
     515 
    517516    int samples = 0; 
    518517 
     
    592591    UnionSet fieldSet = null; 
    593592    try { 
    594       fieldSet = new UnionSet (domain, trueSets); 
     593      fieldSet = new UnionSet(domain, trueSets); 
    595594      FunctionType fieldType = new FunctionType(domain, range); 
    596595      field = new FlatField(fieldType, fieldSet); 
     
    602601    return field; 
    603602  } 
    604   /** Computes a selection layer for OverlayOval objects */ 
     603 
     604  /** Computes a selection layer for OverlayOval objects. */ 
    605605  public static DataImpl getOvalLayer(OverlayObject obj, TransformLink link) { 
    606606    OverlayTransform overlay = (OverlayTransform) link.getTransform(); 
     
    665665  } 
    666666 
    667   /** Computes a selection layer for OverlayText objects */ 
     667  /** Computes a selection layer for OverlayText objects. */ 
    668668  public static DataImpl getTextLayer(OverlayObject obj, TransformLink link) { 
    669669    OverlayTransform overlay = (OverlayTransform) link.getTransform(); 
     
    703703  } 
    704704 
    705   /** Computes a standard outline layer for an OverlayObject */ 
     705  /** Computes a standard outline layer for an OverlayObject. */ 
    706706  public static DataImpl getOutlineLayer(OverlayObject obj, TransformLink link) 
    707707  { 
     
    769769    // This method may be a bit naive, obtaining the multiplier from 
    770770    // only one measurement. 
    771     int[] p1 = {0,0}; 
     771    int[] p1 = {0, 0}; 
    772772    int[] p2 = {0, 1000}; 
    773773    double[] d1 = CursorUtil.pixelToDomain(display, p1[0], p1[1]); 
     
    787787  // OverlayObject.computeGridParameters() 
    788788  // method from OverlayBox. 
    789   /** Computes corners of an OverlayObject's outline */ 
     789  /** Computes corners of an OverlayObject's outline. */ 
    790790  private static float[][] computeOutline(OverlayObject obj, 
    791      TransformLink link) { 
     791     TransformLink link) 
     792  { 
    792793    DisplayImpl display = link.getHandler().getWindow().getDisplay(); 
    793794    float x1 = obj.getX(); 
     
    809810  } 
    810811 
    811   /** Computes outline of a text object  */ 
     812  /** Computes outline of a text object.  */ 
    812813  private static float[][] computeTextOutline(OverlayObject obj, 
    813       OverlayTransform overlay) { 
     814      OverlayTransform overlay) 
     815  { 
    814816    if (obj instanceof OverlayText) ((OverlayText) obj).computeTextBounds(); 
    815817    float x1 = obj.getX(); 
     
    853855  } 
    854856 
    855   /** Converts an array of pixels as floats to domain */ 
     857  /** Converts an array of pixels as floats to domain. */ 
    856858  private static float[][] pixelToDomain(TransformLink link, 
    857       float[][] pixelSamples) { 
     859      float[][] pixelSamples) 
     860  { 
    858861    DisplayImpl display = link.getHandler().getWindow().getDisplay(); 
    859862    float[][] domainSamples = new 
     
    869872  } 
    870873 
    871   /** Connects a pair of VisAD-style 2D arrays of points */ 
     874  /** Connects a pair of VisAD-style 2D arrays of points. */ 
    872875  public static float[][] adjoin(float[][] a, float[][] b) { 
    873876    int alen = a[0].length; 
     
    875878    float[][] result = new float[a.length][alen + blen]; 
    876879    for (int j=0; j<2; j++) { 
    877         System.arraycopy(a[j], 0, result[j], 0, alen); 
    878         System.arraycopy(b[j], 0, result[j], alen, blen); 
     880      System.arraycopy(a[j], 0, result[j], 0, alen); 
     881      System.arraycopy(b[j], 0, result[j], alen, blen); 
    879882    } 
    880883    return result; 
    881884  } 
    882885 
    883   /** Given a set of nodes, creates a UnionSet of Gridded2DSets to  
     886  /** Given a set of nodes, creates a UnionSet of Gridded2DSets to 
    884887   *  highlight the nodes. */ 
    885888  public static Vector buildNodesSets(RealTupleType domain, float[][] nodes, 
    886       float width) { 
     889      float width) 
     890  { 
    887891    int len = nodes[0].length; 
    888892 
     
    890894    // of the curve and another to the 'left' (supposing the curve is oriented 
    891895    // in order of increasing node indices, i.e., the first node is nodes[][0], 
    892     // the last is nodes[][nodes.length-1]).   
     896    // the last is nodes[][nodes.length-1]). 
    893897    float[][] right = new float[2][len]; // store the gridpts 
    894     float[][] left = new float[2][len];  
     898    float[][] left = new float[2][len]; 
    895899 
    896900    if (len <=1) return null; 
    897901 
    898     // The senses of left and right remain the same except when the curve  
    899     // doubles back on itself, i.e., when two consecutive segments form an  
     902    // The senses of left and right remain the same except when the curve 
     903    // doubles back on itself, i.e., when two consecutive segments form an 
    900904    // angle of 180 degrees.  Then the flag 'orientationChanged' switches. 
    901905    boolean orientationChanged = false; // if this is true, right and left 
    902906    // must be switched 
    903      
    904907 
    905908    // This loop computes the points to use in the Gridded2DSets.  The sets 
     
    910913      // Each iteration of this loop computes a new pair of points 
    911914      // rigthPt and leftPt.  The points are computed differently 
    912       // depending on whether the index i points to  
     915      // depending on whether the index i points to 
    913916      // 1) the first node 
    914917      // 2) the last node 
     
    916919      float[] rightPt = new float[2]; 
    917920      float[] leftPt = new float[2]; 
    918        
     921 
    919922      // System.out.println("index = " + i); 
    920       if (i==0) {  
     923      if (i==0) { 
    921924        // Case 1: the first node 
    922925        // Just compute points a distance 'width' from the first node, 
    923926        // in the direction perpendicular to the first segment 
    924         
    925         float[] p1 = new float[] {nodes[0][0], nodes[1][0]}; // first node  
     927 
     928        float[] p1 = new float[] {nodes[0][0], nodes[1][0]}; // first node 
    926929        float[] p2 = new float[] {nodes[0][1], nodes[1][1]}; // second node 
    927930        // get a perpendicular vector to the right of p2-p1 
    928931        float[] vPerp = MathUtil.getRightPerpendicularVector2D(p2, p1); 
    929         rightPt = MathUtil.add(p1, MathUtil.scalarMultiply(vPerp, width));  
     932        rightPt = MathUtil.add(p1, MathUtil.scalarMultiply(vPerp, width)); 
    930933        leftPt = MathUtil.add(p1, MathUtil.scalarMultiply(vPerp, -1f * width)); 
    931934        // System.out.print("First node: "); 
     
    936939        // System.out.print("left pt: "); print(leftPt); 
    937940      } 
    938       else if (i == len - 1) {  
     941      else if (i == len - 1) { 
    939942        // Case 2: the last node 
    940943        // Just compute points a distance 'width' from the last node, 
    941944        // in the direction perpendicular to the last segment 
    942          
     945 
    943946        float[] p1 = new float[] {nodes[0][i-1], nodes[1][i-1]}; // penultimate 
    944947        // node 
    945         float[] p2 = new float[] {nodes[0][i], nodes[1][i]}; // last node  
     948        float[] p2 = new float[] {nodes[0][i], nodes[1][i]}; // last node 
    946949 
    947950        // Test if the last segment doubles back on the second to last segment 
     
    959962        float[] vPerp; 
    960963        if (anti) vPerp = 
    961           MathUtil.getRightPerpendicularVector2D(p1, p2); 
    962         // p1 and p2 above have been switched above to obtain a reflection  
     964            MathUtil.getRightPerpendicularVector2D(p1, p2); 
     965        // p1 and p2 above have been switched above to obtain a reflection 
    963966        else vPerp = MathUtil.getRightPerpendicularVector2D(p2, p1); 
    964967 
     
    966969        // add a multiple of this vector to the point p2, the last node in 
    967970        // the curve 
    968         float[] a = MathUtil.add(p2, MathUtil.scalarMultiply(vPerp, width));  
    969         float[] b = MathUtil.add(p2, MathUtil.scalarMultiply(vPerp, -1f * width)); 
     971        float[] a = MathUtil.add(p2, MathUtil.scalarMultiply(vPerp, width)); 
     972        float[] b = MathUtil.add(p2, MathUtil.scalarMultiply(vPerp, -1f * 
     973              width)); 
     974 
    970975        rightPt = orientationChanged ? b : a; 
    971976        leftPt = orientationChanged ? a : b; 
     
    979984        // System.out.println("orientation changed = "  + orientationChanged); 
    980985      } 
    981       else {  
     986      else { 
    982987        // Case 3: all interior nodes 
    983988        // Compute points a perpendicular distance 'width' away from the curve 
    984         // as in cases 1 and 2.  This time, however, the points lie on the  
     989        // as in cases 1 and 2.  This time, however, the points lie on the 
    985990        // the line bisecting the angle formed by adjacent segments. 
    986991 
     
    988993        float[] p2 = {nodes[0][i], nodes[1][i]}; 
    989994        float[] p3 = {nodes[0][i+1], nodes[1][i+1]}; 
    990          
     995 
    991996        // System.out.print("\nNode index " + i + ":"); 
    992997        // System.out.print("p1: "); print(p1); 
     
    10001005        if (MathUtil.areOpposite(v1, v2)) { 
    10011006          // vectors are antiparallel. just use v1 to calculate right and left 
    1002           float[] vPerp = MathUtil.getRightPerpendicularVector2D(p2, p1);  
    1003           float[] a = MathUtil.add(p2, MathUtil.scalarMultiply(vPerp, width));  
    1004           float[] b = MathUtil.add(p2, MathUtil.scalarMultiply(vPerp, -1f * width)); 
     1007          float[] vPerp = MathUtil.getRightPerpendicularVector2D(p2, p1); 
     1008          float[] a = MathUtil.add(p2, MathUtil.scalarMultiply(vPerp, width)); 
     1009          float[] b = MathUtil.add(p2, MathUtil.scalarMultiply(vPerp, -1f * 
     1010                width)); 
     1011 
    10051012          rightPt = orientationChanged ? b : a; 
    10061013          leftPt = orientationChanged ? a : b; 
     
    10131020          float[] bisectorReflected = MathUtil.scalarMultiply(bisector, -1f); 
    10141021 
    1015           // compute angle between the p2-p1 and bisector  
     1022          // compute angle between the p2-p1 and bisector 
    10161023          float sin = Math.abs(MathUtil.cross2D(bisector, 
    10171024                MathUtil.unit(MathUtil.vector(p2, p1)))); 
    10181025          if (sin < 0.1f) sin = 0.1f; // keep a lower bound on this value to 
    10191026          // prevent 1/sin from becoming too large 
    1020            
     1027 
    10211028          // compute offset distance from curve 
    10221029          float offset = width / sin; 
     
    10461053      left[1][i] = leftPt[1]; 
    10471054    } // end for 
    1048      
     1055 
    10491056    // assemble an array of gridded sets representing the highlighting 
    10501057    return makeGridded2DSets(domain, nodes, right, left, width); 
    1051   }  
     1058  } 
    10521059 
    10531060  /** Makes valid Gridded2DSets from the arrays supplied. 
     
    10561063   *  node indices increase from left to right across the screen) 
    10571064   *  @param left The points on the left side of the noded object (again 
    1058    *  supposing node indices increase from left to right across the screen) 
    1059    */    
     1065   *  supposing node indices increase from left to right across the screen). 
     1066   */ 
    10601067  public static Vector makeGridded2DSets(RealTupleType domain, 
    1061       float nodes[][], float[][] right, float[][] left, float width) { 
    1062  
    1063     // Note:  
     1068      float[][] nodes, float[][] right, float[][] left, float width) 
     1069  { 
     1070 
     1071    // Note: 
    10641072    // This method should probably determine whether Gridded2DSets will 
    10651073    // be invalid itself, but instead it relies on VisAD's Gridded2DSet 
     
    10721080      // This loop constructs Gridded2D sets, one for each segment of a noded 
    10731081      // object (implied here by the arrays right and left). 
    1074       // For each segment (between indices 'i' and 'i+1'),  
     1082      // For each segment (between indices 'i' and 'i+1'), 
    10751083      // try to construct a trapezoidal set: 
    10761084      float[][] setSamples = { 
     
    10801088 
    10811089      try { 
    1082         Gridded2DSet set = new Gridded2DSet(domain, setSamples, 2, 2, null,  
     1090        Gridded2DSet set = new Gridded2DSet(domain, setSamples, 2, 2, null, 
    10831091            null, null, false); 
    10841092        sets.add(set); 
    10851093      } 
    10861094      catch (VisADException ex) { 
    1087         // If samples form an invalid set, the grid is most likely  
    1088         // bow-tie shaped.   
     1095        // If samples form an invalid set, the grid is most likely 
     1096        // bow-tie shaped. 
    10891097        // "Uncross" the box just by switching the order of the two 
    10901098        // left points. 
     
    10961104        }; 
    10971105 
    1098         try {  
    1099           Gridded2DSet set = new Gridded2DSet(domain, setSamples, 2, 2, null,  
     1106        try { 
     1107          Gridded2DSet set = new Gridded2DSet(domain, setSamples, 2, 2, null, 
    11001108            null, null, false); 
    11011109          sets.add(set); 
     
    11131121          float[] vPerp = MathUtil.getRightPerpendicularVector2D(p2, p1); 
    11141122          float[] vPerpReflected = MathUtil.scalarMultiply(vPerp, -1f); 
    1115           float[] s1 = MathUtil.add(p1, vPerp);  
    1116           float[] s2 = MathUtil.add(p2, vPerp);  
     1123          float[] s1 = MathUtil.add(p1, vPerp); 
     1124          float[] s2 = MathUtil.add(p2, vPerp); 
    11171125          float[] s3 = MathUtil.add(p1, vPerpReflected); 
    11181126          float[] s4 = MathUtil.add(p2, vPerpReflected); 
     
    11241132 
    11251133          try { 
    1126             Gridded2DSet set = new Gridded2DSet(domain, setSamples, 2, 2, null,  
     1134            Gridded2DSet set = new Gridded2DSet(domain, setSamples, 2, 2, null, 
    11271135              null, null, false); 
    11281136            sets.add(set); 
    11291137          } 
    11301138          catch(VisADException ex3) { 
    1131             System.out.println("OverlayUtil: error making Gridded2DSets: " +  
     1139            System.out.println("OverlayUtil: error making Gridded2DSets: " + 
    11321140              "all three tries produced invalid sets (index " + i + ")."); 
    11331141            System.out.println("left points"); 
     
    11581166  } 
    11591167 
    1160   /**  
     1168  /** 
    11611169   * Casts and converts an array of floats in domain coordinates to doubles in 
    1162    * pixel coordinates.  
     1170   * pixel coordinates. 
    11631171   */ 
    1164   public static double[][] floatsToPixelDoubles(DisplayImpl d, float[][] nodes) { 
     1172  public static double[][] floatsToPixelDoubles(DisplayImpl d, float[][] 
     1173      nodes) 
     1174  { 
    11651175    double[][] nodesDbl = new double[nodes.length][nodes[0].length]; 
    11661176    for (int j=0; j<nodes[0].length; j++) { 
     
    11801190  } 
    11811191 
    1182   /** Prints a point. */  
     1192  /** Prints a point. */ 
    11831193  public static void print(float x, float y) { 
    11841194    System.out.println("[" + x + "," + y + "]"); 
     
    11871197  /** Prints a point. */ 
    11881198  public static void print(float[] p) { 
    1189     print(p[0], p[1]);  
     1199    print(p[0], p[1]); 
    11901200  } 
    11911201} 
  • trunk/loci/visbio/overlays/PointerTool.java

    r2725 r2912  
    3939  protected float grabX, grabY; 
    4040 
    41   /** Vector of "grabbed" objects */ 
     41  /** Vector of "grabbed" objects. */ 
    4242  protected Vector grabbed;  // the grabees 
    4343 
    44   /** The selection box which may be created by this tool */ 
     44  /** The selection box which may be created by this tool. */ 
    4545  protected TransientSelectBox select; 
    4646 
    47   /** Array of OverlayObjects at current dimensional position */ 
     47  /** Array of OverlayObjects at current dimensional position. */ 
    4848  protected OverlayObject[] objs; 
    4949 
     
    5454  protected float[][] bounds; 
    5555 
    56   /** Array of whether objects are selected at time of mouse press */ 
     56  /** Array of whether objects are selected at time of mouse press. */ 
    5757  protected boolean[] selected; 
    5858 
     
    131131          bound[2] = objs[i].getX2(); 
    132132          bound[3] = objs[i].getY2(); 
    133         } else { 
     133        } 
     134        else { 
    134135          bound[2] = bound[0]; 
    135136          bound[3] = bound[1]; 
     
    143144      // instantiate selection box 
    144145      select = new TransientSelectBox(overlay, display, px, py); 
    145       overlay.addTSB (select); 
     146      overlay.addTSB(select); 
    146147    } 
    147148 
     
    193194      grabY = dy; 
    194195      overlay.notifyListeners(new TransformEvent(overlay)); 
    195     } else if (select != null) { 
     196    } 
     197    else if (select != null) { 
    196198      // extend selection box 
    197199      select.setCorner(px, py); 
  • trunk/loci/visbio/overlays/PolylineTool.java

    r2909 r2912  
    160160  /** Instructs this tool to respond to a mouse drag. */ 
    161161  public void mouseDrag(DisplayEvent e, int px, int py, 
    162     float dx, float dy, int[] pos, int mods) { 
     162    float dx, float dy, int[] pos, int mods) 
     163  { 
    163164    // printMode("mouseDrag"); 
    164165    DisplayImpl display = (DisplayImpl) e.getDisplay(); 
     
    202203  /** Instructs this tool to respond to a mouse release. */ 
    203204  public void mouseUp(DisplayEvent e, int px, int py, 
    204       float dx, float dy, int[] pos, int mods) { 
     205      float dx, float dy, int[] pos, int mods) 
     206  { 
    205207    // printMode("mouseUp"); 
    206208    DisplayImpl display = (DisplayImpl) e.getDisplay(); 
     
    243245  /** Instructs this tool to respond to a mouse movement. */ 
    244246  public void mouseMoved(DisplayEvent e, int px, int py, 
    245       float dx, float dy, int[] pos, int mods) { 
     247      float dx, float dy, int[] pos, int mods) 
     248  { 
    246249    DisplayImpl display = (DisplayImpl) e.getDisplay(); 
    247250    // printMode("mouseMoved"); 
     
    289292          getDistanceToNode(line.getNumNodes() - 2, px, py, display); 
    290293 
    291  
    292294        // if near ndx, highlight selected node differently 
    293295        int flag = -1; 
     
    368370 
    369371  /** Adjusts last node and curve length */ 
    370   private void adjustLastNode (OverlayPolyline line, float dx, float dy) { 
    371     int numNodes = line.getNumNodes(); 
     372  private void adjustLastNode(OverlayPolyline pln, float dx, float dy) { 
     373    int numNodes = pln.getNumNodes(); 
    372374    boolean adjust = false; 
    373375    if (numNodes > 1) { 
    374376      float[] d = {dx, dy}; 
    375       float[] p = line.getNodeCoords(line.getNumNodes()-2); 
     377      float[] p = pln.getNodeCoords(line.getNumNodes()-2); 
    376378      if (MathUtil.areDifferent(d, p)) adjust = true; 
    377379    } 
     
    380382    } 
    381383    if (adjust) { 
    382       double lastSegLength = line.getLastSegmentLength(); 
    383       line.setLastNode(dx, dy); 
    384       double newLastSegLength = line.getLastSegmentLength(); 
     384      double lastSegLength = pln.getLastSegmentLength(); 
     385      pln.setLastNode(dx, dy); 
     386      double newLastSegLength = pln.getLastSegmentLength(); 
    385387      double delta = newLastSegLength - lastSegLength; 
    386       line.setCurveLength(line.getCurveLength() + delta); 
    387     } 
    388   } 
    389  
    390   // TODO -- replace this method with the similar one for freeforms, 
     388      pln.setCurveLength(line.getCurveLength() + delta); 
     389    } 
     390  } 
     391 
     392  // TODO -- combine this method with the similar one for freeforms, 
    391393  // currently located in OverlayNodedObject.java 
    392394  // Determine some way of combining the two. 
    393395  /** Splits an overlay polyline in two */ 
    394   private void split (OverlayPolyline line, int selectedNode) { 
     396  private void split(OverlayPolyline line, int index) { 
    395397    float[][] nodes = line.getNodes(); 
    396398    OverlayPolyline l1, l2; 
     
    398400    int numNodes = line.getNumNodes(); 
    399401 
    400     int numNodes1 = selectedNode; 
    401     int numNodes2 = numNodes - selectedNode - 1; 
    402     // selectedNode is an index into the node array; 
     402    int numNodes1 = index; 
     403    int numNodes2 = numNodes - index - 1; 
     404    // index is an index into the node array; 
    403405    float[][] n1 = new float[2][numNodes1]; 
    404406    float[][] n2 = new float[2][numNodes2]; 
    405407 
    406408    // if a non-trivial polyline remains 'left' of deleted node 
    407     if (selectedNode > 1) { 
     409    if (index > 1) { 
    408410      for (int i=0; i<2; i++) 
    409411        System.arraycopy(nodes[i], 0, n1[i], 0, numNodes1); 
     
    416418 
    417419    // if a non-trivial polyline remains 'right' of deleted node 
    418     if (selectedNode < numNodes - 2) { 
     420    if (index < numNodes - 2) { 
    419421      for (int i=0; i<2; i++) { 
    420422        System.arraycopy(nodes[i], numNodes1 + 1, n2[i], 0, 
     
    428430  } 
    429431 
    430   /**  
     432  /** 
    431433   * Gets distance to the node specified in pixel coordinates, handling 
    432    * awkward casts.  
    433    */  
     434   * awkward casts. 
     435   */ 
    434436  private double getDistanceToNode(int ndx, int px, int py, 
    435     DisplayImpl display) { 
     437    DisplayImpl display) 
     438  { 
    436439    double[] dPxlDbl = {(double) px, (double) py}; 
    437440    float[] nDom = line.getNodeCoords(ndx); 
     
    439442    int[] nPxl = CursorUtil.domainToPixel(display, nDomDbl); 
    440443    double[] nPxlDbl = {(double) nPxl[0], (double) nPxl[1]}; 
    441     double dist = MathUtil.getDistance (nPxlDbl, dPxlDbl); 
     444    double dist = MathUtil.getDistance(nPxlDbl, dPxlDbl); 
    442445    return dist; 
    443446  } 
     
    484487  // method with the same name? 
    485488  private int[] getNearestNode(DisplayImpl display, 
    486       OverlayObject[] objects, int px, int py, double threshold) { 
     489      OverlayObject[] objects, int px, int py, double threshold) 
     490  { 
    487491    Vector polylines = new Vector(); 
    488492    Vector indices = new Vector(); 
     
    506510        int[] cPxl = CursorUtil.domainToPixel(display, cDbl); 
    507511        double[] cPxlDbl = {(double) cPxl[0], (double) cPxl[1]}; 
    508         double dist = MathUtil.getDistance (cPxlDbl, p); 
     512        double dist = MathUtil.getDistance(cPxlDbl, p); 
    509513        if (dist < minDist && dist < threshold) { 
    510514          minDist = dist; 
     
    537541  } 
    538542 
    539   /** Prints a message for debugging */ 
     543  /** Prints a message for debugging. */ 
    540544  public void print(String methodName, String message) { 
    541545    boolean toggle = true; 
     
    547551  } 
    548552 
    549   /** Prints current mode and mouse event type: helpful for debugging */ 
     553  /** Prints current mode and mouse event type: helpful for debugging. */ 
    550554  private void printMode(String method) { 
    551555    String m; 
  • trunk/loci/visbio/overlays/StatsOptionsPane.java

    r2823 r2912  
    3636import loci.visbio.state.OptionManager; 
    3737 
    38 /** A tabbed pane full of checkboxes */ 
     38/** A tabbed pane full of checkboxes. */ 
    3939public class StatsOptionsPane extends JPanel implements ActionListener { 
    4040 
    4141  // -- Constants -- 
    4242 
    43   /** Action command for 'Toggle Current Tab' button */ 
     43  /** Action command for 'Toggle Current Tab' button. */ 
    4444  private static final String CURRENT = "current"; 
    4545 
    46   /** Action command for 'Toggle All Tabs' button */ 
     46  /** Action command for 'Toggle All Tabs' button. */ 
    4747  private static final String ALL = "all"; 
    4848 
    4949  // -- Fields -- 
    5050 
    51   /** All of the check boxes contained in all tabs */ 
     51  /** All of the check boxes contained in all tabs. */ 
    5252  protected JCheckBox[][] checkBoxes; 
    5353 
    54   /** The tabbed pane contained in this object */ 
     54  /** The tabbed pane contained in this object. */ 
    5555  protected JTabbedPane tabs; 
    5656 
    5757  // -- Constructor -- 
    5858 
    59   /** Creates an StatsOptionsPane object */ 
     59  /** Creates an StatsOptionsPane object. */ 
    6060  public StatsOptionsPane() { 
    6161    tabs = makeTabs(); 
     
    6868  // -- StatsOptionsPane API methods -- 
    6969 
    70   /** Saves current pane selections to OptionManager */ 
     70  /** Saves current pane selections to OptionManager. */ 
    7171  public void saveSettings() { 
    7272    OptionManager om = (OptionManager) 
     
    7676 
    7777    for (int type=0; type<overlayTypes.length; type++) { 
    78       String statTypes[] = OverlayUtil.getStatTypes(overlayTypes[type]); 
     78      String[] statTypes = OverlayUtil.getStatTypes(overlayTypes[type]); 
    7979      for (int i=0; i<statTypes.length; i++) { 
    8080        String name = overlayTypes[type] + "." + statTypes[i]; 
     
    8787  } 
    8888 
    89   /** Loads current pane selections from OptionManager */ 
     89  /** Loads current pane selections from OptionManager. */ 
    9090  public void loadSettings() { 
    9191    OptionManager om = (OptionManager) 
     
    9494 
    9595    for (int type=0; type<overlayTypes.length; type++) { 
    96       String statTypes[] = OverlayUtil.getStatTypes(overlayTypes[type]); 
     96      String[] statTypes = OverlayUtil.getStatTypes(overlayTypes[type]); 
    9797      for (int i=0; i<statTypes.length; i++) { 
    9898        String name = overlayTypes[type] + "." + statTypes[i]; 
     
    106106  // -- ActionListener interface methods -- 
    107107 
    108   /** Change selection state of check boxes depending on button pressed */ 
    109   public void actionPerformed (ActionEvent e) { 
     108  /** Change selection state of check boxes depending on button pressed. */ 
     109  public void actionPerformed(ActionEvent e) { 
    110110    if (ALL.equals(e.getActionCommand())) toggleAllTabs(); 
    111111    else if (CURRENT.equals(e.getActionCommand())) toggleCurrentTab(); 
     
    114114  // -- Helper Methods -- 
    115115 
    116   /** Makes the tabs of this ExportOptionsPane object */ 
     116  /** Makes the tabs of this ExportOptionsPane object. */ 
    117117  private JTabbedPane makeTabs() { 
    118118    OptionManager om = (OptionManager) 
     
    124124    // populate checkbox array 
    125125    for (int type=0; type<overlayTypes.length; type++) { 
    126       String statTypes[] = OverlayUtil.getStatTypes(overlayTypes[type]); 
     126      String[] statTypes = OverlayUtil.getStatTypes(overlayTypes[type]); 
    127127      checkBoxes[type] = new JCheckBox[statTypes.length]; 
    128128      for (int i=0; i<statTypes.length; i++) { 
     
    164164  } 
    165165 
    166   /** Makes a button bar with 2 buttons to toggle options */ 
     166  /** Makes a button bar with 2 buttons to toggle options. */ 
    167167  private JPanel makeButtons() { 
    168168    JButton toggleCurrent = new JButton("Toggle Current Tab"); 
     
    184184  } 
    185185 
    186   private JPanel makePane(JTabbedPane tabs, JPanel buttons) { 
    187     FormLayout fl = new FormLayout( "3dlu, pref, 3dlu", 
     186  private JPanel makePane(JTabbedPane jtp, JPanel buttons) { 
     187    FormLayout fl = new FormLayout("3dlu, pref, 3dlu", 
    188188        "pref, 3dlu, pref, 3dlu, pref"); 
    189189    PanelBuilder builder = new PanelBuilder(fl); 
     
    191191 
    192192    builder.addLabel("Select statistics to save/export:", cc.xy(2, 1)); 
    193     builder.add(tabs, cc.xy(2, 3)); 
     193    builder.add(jtp, cc.xy(2, 3)); 
    194194    builder.add(buttons, cc.xy(2, 5)); 
    195195    JPanel panel = builder.getPanel(); 
  • trunk/loci/visbio/overlays/TransientSelectBox.java

    r2725 r2912  
    7575  // -- TransientSelectBox API Methods -- 
    7676 
    77   /** Sets coordinates of draggable box corner */ 
    78   public void setCorner (int x, int y) { 
     77  /** Sets coordinates of draggable box corner. */ 
     78  public void setCorner(int x, int y) { 
    7979    x2 = x; 
    8080    y2 = y; 
    8181  } 
    8282 
    83   /** Returns the display on which this TSB exists */ 
     83  /** Returns the display on which this TSB exists. */ 
    8484  public DisplayImpl getActiveDisplay() { return display; } 
    8585 
     
    134134          outlineSamples[0].length, null, null, null, false); 
    135135    } 
    136     catch (SetException set ) { set.printStackTrace(); } 
     136    catch (SetException set) { set.printStackTrace(); } 
    137137    catch (VisADException exc) { exc.printStackTrace(); } 
    138138 
     
    168168      // go Mallards 
    169169      wholeTeam = new DataImpl[] {inField, outField}; 
    170       ret = new Tuple (wholeTeam, false); 
     170      ret = new Tuple(wholeTeam, false); 
    171171    } 
    172172    catch (VisADException exc) { exc.printStackTrace(); } 
     
    177177  /** 
    178178   * Gets domain coordinates of box corners 
    179    * Corners are returned as a double[4][2] 
     179   * Corners are returned as a double[4][2]. 
    180180   */ 
    181181  public double[][] getCornersDomain() { 
     
    192192    double[] p3 = CursorUtil.pixelToDomain(getActiveDisplay(), x1, y2); 
    193193 
    194     double[][] ret = {  {p0[0], p0[1]}, 
    195                         {p1[0], p1[1]}, 
    196                         {p2[0], p2[1]}, 
    197                         {p3[0], p3[1]}}; 
     194    double[][] ret = {{p0[0], p0[1]}, 
     195                      {p1[0], p1[1]}, 
     196                      {p2[0], p2[1]}, 
     197                      {p3[0], p3[1]}}; 
    198198 
    199199    return ret; 
  • trunk/loci/visbio/util/MathUtil.java

    r2908 r2912  
    380380  } 
    381381 
    382   /**  
     382  /** 
    383383   * Test whether two vectors are coordinate-wise opposite. 
    384    * @param u1 a unit vector 
    385    * @param u2 another unit vector  
    386    */  
     384   */ 
    387385  public static boolean areOpposite(float[] v1, float[] v2) { 
    388386   /*    if (v1.length != v2.length) return false; 
     
    401399  /** Tests whether two arrays of floats are identical. */ 
    402400  public static boolean areSame(float[] a, float[] b) { 
    403     boolean same = true;  
    404     if (a.length == b.length) {  
     401    boolean same = true; 
     402    if (a.length == b.length) { 
    405403      for (int i=0; i<a.length; i++){ 
    406404        if (a[i] != b[i]) { 
     
    418416    return !areSame(a, b); 
    419417  } 
    420  
    421418 
    422419  // -- Computational Geometry Methods -- 
     
    461458  } 
    462459 
    463   /**  
    464    * Gets a unit vector which bisects (p1 - p2) and (p3 - p2).  
     460  /** 
     461   * Gets a unit vector which bisects (p1 - p2) and (p3 - p2). 
    465462   * This vector points to the 'right' side of the line defined by p1->p2->p3. 
    466    */  
     463   */ 
    467464  public static float[] getRightBisectorVector2D(float[] p1, float[] p2, 
    468465      float[] p3) 
    469466  { 
    470467    // System.out.println("entering getBisectorVector2D ..."); //TEMP 
    471      
     468 
    472469    // Always retrieves the bisector vector on the right (as opposed to left) 
    473470    // side of the angle made by the two vectors. 
  • trunk/loci/visbio/util/Segment2D.java

    r2908 r2912  
    2828/** A 2D line segment. */ 
    2929public class Segment2D { 
    30    
     30 
    3131  /** Endpoints. */ 
    3232  protected Float a, b; 
     
    4545  public boolean intersects(Segment2D y) { 
    4646    // first check bounding box, then straddle 
    47     if (this.boundingBoxOverlapsBoundingBoxOf(y) &&  
    48         this.straddles(y) && y.straddles(this)) return true; 
    49     else return false; 
    50  } 
     47    return (this.boundingBoxOverlapsBoundingBoxOf(y) && 
     48        this.straddles(y) && y.straddles(this)); 
     49  } 
    5150 
    5251  /** Whether another segment meets the bounding box of this segment. 
     
    6059    float[] yb = {(float) y.getPtB().getX(), (float) y.getPtB().getY()}; 
    6160 
    62     // inside is not strict--a point on the boundary is considered inside  
     61    // inside is not strict--a point on the boundary is considered inside 
    6362    boolean meets = false; 
    6463    if ((MathUtil.inside(xa, ya, yb) || MathUtil.inside(xb, ya, yb)) || 
     
    6867  } 
    6968 
    70   /** Whether another segment crosses the line defined by this segment */ 
     69  /** Whether another segment crosses the line defined by this segment. */ 
    7170  public boolean straddles(Segment2D y) { 
    7271    // collect all parameters 
     
    8483 
    8584    // return true if cross products have opposite signs 
    86     if ((cross1 < 0 && cross2 > 0) || 
     85    return ((cross1 < 0 && cross2 > 0) || 
    8786        (cross1 > 0 && cross2 < 0) || 
    88         cross1 == 0 || cross2 == 0) return true; 
    89     else return false; 
     87        cross1 == 0 || cross2 == 0); 
    9088  } 
    9189 
  • trunk/loci/visbio/util/test/MathUtilTest.java

    r2908 r2912  
    3131 
    3232  // -- Constants -- 
    33    
     33 
    3434  public static final float DELTA = 0f; 
    3535 
     
    4646  } 
    4747 
    48   // -- Vector Math Tests --  
     48  // -- Vector Math Tests -- 
    4949 
    5050  /** Tests MathUtil.mag(). */ 
     
    8585    //---------------------------------------------------------------------- 
    8686    float[] v1 = {0f, 10f}; 
    87     float mag1 = (float) Math.sqrt(v1[0] * v1[0] + v1[1] * v1[1]);  
    88     float[] v1hatExpected = {v1[0] / mag1, v1[1] / mag1};; 
     87    float mag1 = (float) Math.sqrt(v1[0] * v1[0] + v1[1] * v1[1]); 
     88    float[] v1hatExpected = {v1[0] / mag1, v1[1] / mag1}; 
    8989    float[] v1hat = MathUtil.unit(v1); 
    9090    for (int i=0; i<v1.length; i++) { 
     
    136136  } 
    137137 
    138   /** Tests the MathUtil.vector() */ 
     138  /** Tests the MathUtil.vector() method. */ 
    139139  public void testVector() { 
    140140    float[] p1 = {3f, 4f, 0f}; 
     
    143143 
    144144    float[] v1 = MathUtil.vector(p1, p2); 
    145      
     145 
    146146    assertEquals(v1.length, v1Expected.length); 
    147147    for (int i=0; i<v1.length; i++) { 
     
    150150  } 
    151151 
    152   /** Tests the MathUtil.add() method */ 
     152  /** Tests the MathUtil.add() method. */ 
    153153  public void testAdd() { 
    154154    float[] v1 = {0f, -1f, 2f}; 
     
    168168  } 
    169169 
    170   /** Tests MathUtil.scalarMultiply() */ 
     170  /** Tests MathUtil.scalarMultiply(). */ 
    171171  public void testScalarMultiply() { 
    172172    float[] v = new float[100]; 
     
    193193    float[] v2 = MathUtil.scalarMultiply(v1, -1f); 
    194194    float[] v3 = {v2[0]}; 
    195      
     195 
    196196    assertEquals(true, MathUtil.areSame(v1, v1)); 
    197197    assertEquals(false, MathUtil.areSame(v1, v2)); 
     
    199199    assertEquals(false, MathUtil.areDifferent(v1, v1)); 
    200200    assertEquals(true, MathUtil.areOpposite(v1, v2)); 
    201     assertEquals(false, MathUtil.areOpposite(v1, v3));  
     201    assertEquals(false, MathUtil.areOpposite(v1, v3)); 
    202202  } 
    203203 
    204204  // -- Computational Geometry Tests -- 
    205205 
    206   /** Tests the MathUtil.inside() method */ 
     206  /** Tests the MathUtil.inside() method. */ 
    207207  public void testInside() { 
    208208    float[] a = {1f, 2f}; 
     
    211211    float[] c = {1f, -1f}; 
    212212 
    213     assertEquals("a should be between b1 and b2", true,  
     213    assertEquals("a should be between b1 and b2", true, 
    214214        MathUtil.inside(a, b1, b2)); 
    215215 
    216     assertEquals("a should be inside b2 and b1", true,  
     216    assertEquals("a should be inside b2 and b1", true, 
    217217        MathUtil.inside(a, b2, b1)); 
    218 assertEquals("c should not be inside b1 and b2", false,  
     218 
     219    assertEquals("c should not be inside b1 and b2", false, 
    219220        MathUtil.inside(c, b1, b2)); 
    220221 
    221     assertEquals("c should not be inside b2 and b1", false,  
     222    assertEquals("c should not be inside b2 and b1", false, 
    222223        MathUtil.inside(c, b2, b1)); 
    223224 
    224     assertEquals("b1 should be inside b1 and b2", true,  
     225    assertEquals("b1 should be inside b1 and b2", true, 
    225226        MathUtil.inside(b1, b1, b2)); 
    226227  } 
    227  
    228228 
    229229  /** Tests the computePointOnSegment method. */ 
     
    235235    float[] p2 = MathUtil.computePtOnSegment(a, b, 1f); 
    236236    float[] p3 = MathUtil.computePtOnSegment(a, b, .5f); 
    237      
     237 
    238238    float[] p3e = {2.5f, 3f}; 
    239239 
     
    243243  } 
    244244 
    245   /** Tests the MathUtil.bisect() method */ 
    246   public void testBisect () { 
     245  /** Tests the MathUtil.bisect() method. */ 
     246  public void testBisect() { 
    247247    float[] p1 = {0f, 1f}; 
    248248    float[] p2 = {0f, 0f}; 
    249249    float[] p3 = {1f, 0f}; 
    250     
     250 
    251251    float[] p4Expected = MathUtil.unit(new float[]{-1f, -1f}); 
    252252    float[] p4 = MathUtil.getRightBisectorVector2D(p1, p2, p3); 
     
    258258  } 
    259259 
    260   /** Tests the MathUtil.bisect() method */ 
     260  /** Tests the MathUtil.bisect() method. */ 
    261261  public void testRightBisectFlatCase() { 
    262262    float[] p1 = {0f, 0f}; 
     
    270270    compareFloats(vExpected, v, DELTA); 
    271271 
    272     float[] p4 = {1f, .2000000f};  
     272    float[] p4 = {1f, .2000000f}; 
    273273    float[] p5 = {1f, .2000001f}; 
    274274    float[] p6 = {1f, .20000015f}; 
     
    302302  } 
    303303 
    304   /** Tests the orient2D method */ 
     304  /** Tests the orient2D method. */ 
    305305  public void testOrient() { 
    306306    float[] p1 = {0f, 0f}; 
     
    318318  } 
    319319 
    320   // -- Helper Methods --  
    321    
     320  // -- Helper Methods -- 
     321 
    322322  /** Compares two arrays of floats, item-wise. */ 
    323323  public void compareFloats(float[] expected, float[] actual, float delta) { 
  • trunk/loci/visbio/util/test/Segment2DTest.java

    r2908 r2912  
    2525 
    2626import junit.framework.TestCase; 
     27import loci.visbio.util.MathUtil; 
    2728import loci.visbio.util.Segment2D; 
    28 import loci.visbio.util.MathUtil; 
    2929 
    3030/** Unit tests for the Segment2D class. */ 
     
    9999        c.boundingBoxOverlapsBoundingBoxOf(a)); 
    100100 
    101     // disjoint segments whose boxes touch  
     101    // disjoint segments whose boxes touch 
    102102    assertEquals("c should overlap b", true, 
    103103        c.boundingBoxOverlapsBoundingBoxOf(b)); 
     
    127127  } 
    128128 
    129 } // @@@@@  
     129} // @@@@@ 
Note: See TracChangeset for help on using the changeset viewer.