use of org.scijava.swing.checkboxtree.CheckBoxNodeEditor in project mafscaling by vimsh.
the class VVTCalc method createTreePanel.
protected void createTreePanel() {
DefaultMutableTreeNode wotTreeRoot = new DefaultMutableTreeNode("Root");
DefaultTreeModel treeModel = new DefaultTreeModel(wotTreeRoot);
pullTree = new JTree(treeModel);
pullTree.setCellRenderer(new PullNodeRenderer());
pullTree.setCellEditor(new CheckBoxNodeEditor(pullTree));
pullTree.setEditable(true);
pullTree.setRootVisible(false);
pullTree.setOpaque(false);
pullTree.setBackground(null);
pullTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
pullTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
Object obj = ((DefaultMutableTreeNode) e.getPath().getLastPathComponent()).getUserObject();
if (obj instanceof CheckBoxNodeData) {
CheckBoxNodeData checkBoxNode = (CheckBoxNodeData) obj;
XYSeriesCollection dataset;
XYSeries series;
for (int i = 0; i < hiddenSeries.size(); ++i) {
dataset = (XYSeriesCollection) chartPanels[i].getChart().getXYPlot().getDataset(0);
if (checkBoxNode.isChecked()) {
series = hiddenSeries.get(i).get(checkBoxNode.getText());
if (series != null) {
dataset.addSeries(series);
hiddenSeries.get(i).remove(checkBoxNode.getText());
}
} else {
for (int j = 0; j < dataset.getSeriesCount(); ++j) {
series = dataset.getSeries(j);
if (series.getDescription().equals(checkBoxNode.getText())) {
hiddenSeries.get(i).put(checkBoxNode.getText(), series);
dataset.removeSeries(j);
}
}
}
}
}
}
});
}
use of org.scijava.swing.checkboxtree.CheckBoxNodeEditor in project mafscaling by vimsh.
the class LogView method createWotTreePanel.
protected void createWotTreePanel() {
wotTreeMenu = new JPopupMenu();
JMenuItem item = new JMenuItem("Select All");
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (wotSelectedNode != null)
setWotNodesChecked(true);
}
});
wotTreeMenu.add(item);
item = new JMenuItem("Clear All");
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (wotSelectedNode != null)
setWotNodesChecked(false);
}
});
wotTreeMenu.add(item);
DefaultMutableTreeNode wotTreeRoot = new DefaultMutableTreeNode("Root");
DefaultTreeModel treeModel = new DefaultTreeModel(wotTreeRoot);
wotTree = new JTree(treeModel);
wotTree.setCellRenderer(new FileNodeRenderer());
wotTree.setCellEditor(new CheckBoxNodeEditor(wotTree));
wotTree.setEditable(true);
wotTree.setRootVisible(false);
wotTree.setOpaque(false);
wotTree.setBackground(null);
wotTree.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (event.getButton() == MouseEvent.BUTTON3) {
TreePath pathForLocation = wotTree.getPathForLocation(event.getPoint().x, event.getPoint().y);
if (pathForLocation != null) {
wotTree.setComponentPopupMenu(wotTreeMenu);
wotSelectedNode = (DefaultMutableTreeNode) pathForLocation.getLastPathComponent();
} else {
wotTree.setComponentPopupMenu(null);
wotSelectedNode = null;
}
}
super.mousePressed(event);
}
});
wotTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
}
Aggregations