Example #1
0
 public void mouseReleased(MouseEvent e) {
   current = e.getPoint();
   // intersect with graph
   Rectangle selrect =
       new Rectangle(start.x, start.y, current.x - start.x, current.y - start.y);
   int[] gi = gs.getIndicesAt(selrect, graph.getXAxis(), graph.getYAxis());
   DefaultListSelectionModel rsm = new DefaultListSelectionModel();
   if (gi != null) {
     rsm.setValueIsAdjusting(true);
     for (int j = 0; j < gi.length; j++) {
       // find node and select segs for node and all descendents
       int nodeidx = gi[j] / 2;
       TreeNode tn = nodemap[nodeidx];
       selectTraverse(tn, rsm);
     }
     rsm.setValueIsAdjusting(false);
   }
   if (ctx != null) {
     // Merge this selection with the table selection list
     // using the current set selection operator
     ColumnMap cmap = ctx.getColumnMap(tm, 0);
     if (cmap != null) {
       cmap.selectValues(rsm);
     }
   }
   if (ctx != null) {
     // restore the original selection set operator
     ctx.getSetOperator(tm).setSetOperator(prevSetOp);
   }
   repaint();
 }
Example #2
0
 /**
  * Display the tree rooted at node tn in the graph as a dendogram.
  *
  * @param tn the root node of the tree to display
  */
 private void display(TreeNode tn) {
   double[] segs = dendogram(tn);
   double distance = 10.;
   if (tn instanceof Cluster) {
     distance = ((Cluster) tn).getSimilarity();
   } else {
     distance = ((DefaultMutableTreeNode) tn).getDepth();
   }
   gs.setData(segs, GraphDataModel.FORMAT_XY);
   graph.getXAxis().setMin(distance);
   graph.getXAxis().setMax(0.);
   graph.getYAxis().setMin(tm.getRowCount() - .5);
   graph.getYAxis().setMax(-.5);
   repaint();
 }