Пример #1
0
  /**
   * Generate a list of line segments that construct a dendogram of the tree rooted at node tn.
   *
   * @param tn the root of the tree
   * @return the segements comprising the dendogram
   */
  private double[] dendogram(TreeNode tn) {
    double distance = 0.;
    nodemap = new TreeNode[getNodeCount(tn)];
    int[] leafmap = new int[getLeafCount(tn)]; // record order of rows
    int[] nodeidx = new int[1];
    double[] segs = null;
    double[] childpos = new double[2];

    nodeidx[0] = 0;
    if (tn instanceof Cluster) {
      distance = ((Cluster) tn).getSimilarity();
    } else {
      distance = ((DefaultMutableTreeNode) tn).getDepth();
    }
    segs = new double[getNodeCount(tn) * 8];
    // start recursive depth first traversal
    traverse(tn, 0, distance, nodeidx, nodemap, leafmap, segs, childpos);
    // set map of row index to leafnode ordinal
    idxMap.setIndex(leafmap);
    return segs;
  }
Пример #2
0
 /**
  * Return a label for the given point on the graph axis
  *
  * @param value the value on the graph
  * @return the label for the given value
  */
 private String getLeafLabel(double value) {
   String label = Double.toString(value);
   try {
     int v = (int) value;
     int r = idxMap.getSrc(v);
     if (r < 0 || r >= tm.getRowCount()) {
       return "";
     }
     if (labelColumn >= 0 && labelColumn < tm.getColumnCount()) {
       Object o = tm.getValueAt(r, labelColumn);
       return o != null ? o.toString() : "";
     }
   } catch (Exception ex) {
     ExceptionHandler.popupException("" + ex);
   }
   try {
     label = Integer.toString((int) value);
   } catch (Exception ex) {
     ExceptionHandler.popupException("" + ex);
   }
   return label;
 }
Пример #3
0
 public int[] getLeafMap() {
   return idxMap.getIndex();
 }