示例#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();
 }
示例#2
0
 public void mousePressed(MouseEvent e) {
   if (ctx != null) {
     // save the current selection set operator
     prevSetOp = ctx.getSetOperator(tm).getSetOperator();
     // set the selection set operator
     ctx.getSetOperator(tm).setFromInputEventMask(e.getModifiers());
   }
   start = e.getPoint();
   current = e.getPoint();
   selecting = true;
   repaint();
 }
示例#3
0
  /**
   * Constructs a ClutoTree diaplay which is initialized with tableModel as the data model, and the
   * given selection model.
   *
   * @param clutoSolution The clustering solution
   * @param tableContext The context which manages views and selections.
   * @param tableModel the data model for the parallel coordinate display
   */
  public ClutoTree(ClutoSolution clutoSolution, TableContext tableContext, TableModel tableModel) {
    ctx = tableContext;
    tm = tableModel;
    lsm = ctx.getRowSelectionModel(tm);

    // labelModel
    int ncol = tm.getColumnCount();
    for (int i = 0; i < ncol; i++) {
      labelModel.addElement(tm.getColumnName(i));
    }

    setLayout(new BorderLayout());
    btnP = new JToolBar();
    add(btnP, BorderLayout.NORTH);
    labelChoice.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              labelColumn = 0;
              String ln = (String) e.getItem();
              if (ln != null) {
                for (int c = 0; c < tm.getColumnCount(); c++) {
                  if (ln.equals(tm.getColumnName(c))) {
                    labelColumn = c;
                    break;
                  }
                }
              }
              graph.invalidate();
              validate();
              repaint();
            }
          }
        });
    btnP.add(labelChoice);

    graph = new SimpleGraph();
    graph.getGraphDisplay().setOpaque(true);
    graph.getGraphDisplay().setBackground(Color.white);
    graph.getGraphDisplay().setGridColor(new Color(220, 220, 220));
    graph.showGrid(false);
    graph.showAxis(BorderLayout.WEST, false);
    graph.showAxis(BorderLayout.EAST, true);
    graph.getAxisDisplay(BorderLayout.EAST).setZoomable(true);
    graph.getAxisDisplay(BorderLayout.EAST).setAxisLabeler(labeler);
    ((LinearAxis) graph.getYAxis()).setTickIncrement(-1.);
    graph.getAxisDisplay(BorderLayout.SOUTH).setZoomable(true);
    gs = new GraphSegments();
    gs.setColor(Color.blue);
    idxSelColor = new IndexSelectColor(Color.cyan, null, new DefaultListSelectionModel());
    gs.setIndexedColor(idxSelColor);
    graph.addGraphItem(gs);
    graph.getGraphDisplay().addMouseListener(ma);

    add(graph);
    if (lsm != null) {
      lsm.addListSelectionListener(selListener);
    }
    display(makeTree(clutoSolution));
  }