Example usage for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode

List of usage examples for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode.

Prototype

public DefaultMutableTreeNode(Object userObject) 

Source Link

Document

Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.

Usage

From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java

private DefaultMutableTreeNode getDiseaseSubNode(String nodeId, ClassSchemeItem csi,
        TreeFunctions treeFunctions, String nodeName) throws Exception {
    int firstSpace = nodeName.indexOf(" ");

    String nodeType = nodeName.substring(0, firstSpace).toUpperCase();
    return new DefaultMutableTreeNode(new WebNode(nodeId, nodeName,
            "javascript:" + treeFunctions.getJsFunctionName() + "('P_PARAM_TYPE=" + nodeType + "&P_IDSEQ="
                    + csi.getCsiIdseq() + "&P_CONTE_IDSEQ=" + csi.getCsConteIdseq() + "&P_CS_CSI_IDSEQ="
                    + csi.getCsCsiIdseq() + "&diseaseName=" + URLEncoder.encode(csi.getClassSchemeItemName())
                    + "&csName=" + URLEncoder.encode(csi.getClassSchemeLongName())
                    + treeFunctions.getExtraURLParameters() + "')",
            nodeName));//from w w  w . j  av a 2s .  com
}

From source file:edu.ucla.stat.SOCR.chart.ChartTree.java

private MutableTreeNode createMarkersNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Markers");
    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CategoryMarkerDemo1", "CategoryMarkerDemo1"));
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.CategoryMarkerDemo2", "CategoryMarkerDemo2"));
    DefaultMutableTreeNode n3 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.MarkerDemo1", "MarkerDemo1"));
    DefaultMutableTreeNode n4 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.MarkerDemo2", "MarkerDemo2"));
    root.add(n1);/*from  w  w w . j  a  va 2 s .  c  o m*/
    root.add(n2);
    root.add(n3);
    root.add(n4);
    return root;
}

From source file:edu.ucla.stat.SOCR.chart.ChartTree.java

private MutableTreeNode createOrientationNode() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Plot Orientation");

    DefaultMutableTreeNode n1 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.PlotOrientationDemo1", "PlotOrientationDemo1"));
    DefaultMutableTreeNode n2 = new DefaultMutableTreeNode(
            new DemoDescription("edu.ucla.stat.SOCR.chart.demo.PlotOrientationDemo2", "PlotOrientationDemo2"));

    root.add(n1);//from w  w  w.j  a va 2 s . c  om
    root.add(n2);

    return root;
}

From source file:org.jfree.chart.demo.SuperDemo.java

private MutableTreeNode createAreaChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Area Charts");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("AreaChartDemo1", "AreaChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("StackedXYAreaChartDemo1", "StackedXYAreaChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(
            new DemoDescription("StackedXYAreaChartDemo2", "StackedXYAreaChartDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode(
            new DemoDescription("XYAreaChartDemo1", "XYAreaChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode5 = new DefaultMutableTreeNode(
            new DemoDescription("XYAreaChartDemo2", "XYAreaChartDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode6 = new DefaultMutableTreeNode(
            new DemoDescription("XYStepAreaRendererDemo1", "XYStepAreaRendererDemo1.java"));
    defaultmutabletreenode.add(defaultmutabletreenode1);
    defaultmutabletreenode.add(defaultmutabletreenode2);
    defaultmutabletreenode.add(defaultmutabletreenode3);
    defaultmutabletreenode.add(defaultmutabletreenode4);
    defaultmutabletreenode.add(defaultmutabletreenode5);
    defaultmutabletreenode.add(defaultmutabletreenode6);
    return defaultmutabletreenode;
}

From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java

private void loadChromosomeTreeLevel(final DefaultMutableTreeNode parent, final List<ParameterInfo> infos,
        final List<Parameter> parameters, final List<SubmodelParameter> submodelParameters,
        final List<eu.crisis_economics.abm.dashboard.generated.Gene> genes) throws ModelInformationException {

    for (final eu.crisis_economics.abm.dashboard.generated.Gene gene : genes) {
        final ParameterInfo info = findParameterInfo(infos, gene.getName());
        if (info == null)
            throw new ModelInformationException("Unrecognized parameter: " + gene.getName() + ".");

        //initializeParent(info,parent);
        final ParameterOrGene userObj = initializeUserObjectFromGene(gene, info);
        final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(userObj);
        getChromosomeTree().insertNodeInto(newNode, parent, parent.getChildCount());

    }// w w w. jav a2  s.  c  om

    for (final SubmodelParameter parameter : submodelParameters) {
        final ParameterInfo info = findParameterInfo(infos, parameter.getName());
        if (info == null)
            throw new ModelInformationException("Unrecognized parameter: " + parameter.getName() + ".");

        //initializeParent(info,parent);
        final SubmodelInfo submodelInfo = (SubmodelInfo) info;
        final String strType = parameter.getType();
        try {
            final Class<?> clazz = Class.forName(strType, true, currentModelHandler.getCustomClassLoader());
            if (submodelInfo.getActualType() == null
                    || !strType.equals(submodelInfo.getActualType().getName())) {
                submodelInfo.setActualType(clazz, null);
            }

            final ParameterOrGene userObj = new ParameterOrGene(info);
            final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(userObj);
            getChromosomeTree().insertNodeInto(newNode, parent, parent.getChildCount());

            final List<ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?>> batchSubparameters = ParameterTreeUtils
                    .fetchSubparameters(currentModelHandler, submodelInfo);
            final List<ParameterInfo> subparameters = new ArrayList<ParameterInfo>(batchSubparameters.size());
            for (final ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?> parameterInfo : batchSubparameters)
                subparameters.add(InfoConverter.parameterInfo2ParameterInfo(parameterInfo));

            loadChromosomeTreeLevel(newNode, subparameters, parameter.getParameterList(),
                    parameter.getSubmodelParameterList(), parameter.getGeneList());
        } catch (final ClassNotFoundException e) {
            throw new ModelInformationException(
                    "Invalid actual type " + strType + " for submodel parameter: " + submodelInfo.getName(), e);
        }
    }

    for (final Parameter parameter : parameters) {
        final ParameterInfo info = findParameterInfo(infos, parameter.getName());
        if (info == null)
            throw new ModelInformationException("Unrecognized parameter: " + parameter.getName() + ".");

        //initializeParent(info,parent);
        info.setDefinitionType(ParameterInfo.CONST_DEF);
        String parameterValue = ParameterUtil.getParameterValue(parameter);
        Object value;
        if (info.getType().equals("File") && parameterValue == null) {
            value = new File("");
        } else {
            value = ParameterInfo.getValue(parameterValue, info.getJavaType());
        }
        info.setValue(value);

        final ParameterOrGene userObj = new ParameterOrGene(info);
        final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(userObj);
        getChromosomeTree().insertNodeInto(newNode, parent, parent.getChildCount());
    }

}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java

private DefaultMutableTreeNode getFormNode(String nodeId, Form form, TreeFunctions treeFunctions,
        boolean showContextName) throws Exception {
    String formIdseq = form.getFormIdseq();

    String displayName = form.getLongName();
    String preferred_definition = form.getPreferredDefinition();
    String currContextId = form.getConteIdseq();
    String contextName = "";
    String formLongName = "";

    if (form.getLongName() != null)
        formLongName = URLEncoder.encode(form.getLongName());

    if (form.getContext() != null)
        contextName = form.getContext().getName();

    if (contextName != null)
        contextName = URLEncoder.encode(contextName);

    if (showContextName)
        displayName = displayName + " (" + contextName + ")";

    String protocolId = "";

    //TODO - tree for multiple form/protocols
    //if (form.getProtoIdseq() != null)
    // protocolId = form.getProtoIdseq();

    DefaultMutableTreeNode formNode = new DefaultMutableTreeNode(new WebNode(nodeId, displayName,
            "javascript:" + treeFunctions.getFormJsFunctionName() + "('P_PARAM_TYPE=CRF&P_IDSEQ=" + formIdseq
                    + "&P_CONTE_IDSEQ=" + currContextId + "&P_PROTO_IDSEQ=" + protocolId
                    //        + "&templateName=" + formLongName
                    //        + "&contextName=" + contextName
                    + treeFunctions.getExtraURLParameters() + "')",
            preferred_definition));/*from   w  w w.  ja va2s. c  o  m*/
    return formNode;
}

From source file:com.pironet.tda.SunJDKParser.java

/**
 * dump the monitor information/*from ww  w . ja v a 2  s . c  om*/
 */
private int[] dumpMonitors(DefaultMutableTreeNode catMonitors, DefaultMutableTreeNode catMonitorsLocks,
        MonitorMap mmap) {
    Iterator iter = mmap.iterOfKeys();
    int monitorsWithoutLocksCount = 0;
    int overallThreadsWaiting = 0;
    while (iter.hasNext()) {
        String monitor = (String) iter.next();
        Map<String, String>[] threads = mmap.getFromMonitorMap(monitor);
        ThreadInfo mi = new ThreadInfo(monitor, null, "", 0, null);
        DefaultMutableTreeNode monitorNode = new DefaultMutableTreeNode(mi);

        // first the locks
        Iterator<String> iterLocks = threads[MonitorMap.LOCK_THREAD_POS].keySet().iterator();
        int locks = 0;
        int sleeps = 0;
        while (iterLocks.hasNext()) {
            String thread = iterLocks.next();
            String stackTrace = threads[MonitorMap.LOCK_THREAD_POS].get(thread);
            if (threads[MonitorMap.SLEEP_THREAD_POS].containsKey(thread)) {
                createNode(monitorNode, "locks and sleeps on monitor: " + thread, null, stackTrace, 0);
                sleeps++;
            } else if (threads[MonitorMap.WAIT_THREAD_POS].containsKey(thread)) {
                createNode(monitorNode, "locks and waits on monitor: " + thread, null, stackTrace, 0);
                sleeps++;
            } else {
                createNode(monitorNode, "locked by " + thread, null, stackTrace, 0);
            }
            locks++;
        }

        Iterator iterWaits = threads[MonitorMap.WAIT_THREAD_POS].keySet().iterator();
        int waits = 0;
        while (iterWaits.hasNext()) {
            String thread = (String) iterWaits.next();
            if (!threads[MonitorMap.LOCK_THREAD_POS].containsKey(thread)) {
                createNode(monitorNode, "waits on monitor: " + thread, null,
                        threads[MonitorMap.WAIT_THREAD_POS].get(thread), 0);
                waits++;
            }
        }

        mi.setContent(ThreadDumpInfo.getMonitorInfo(locks, waits, sleeps));
        mi.setName(mi.getName() + ":    " + (sleeps) + " Thread(s) sleeping, " + (waits)
                + " Thread(s) waiting, " + (locks) + " Thread(s) locking");
        if (ThreadDumpInfo.areALotOfWaiting(waits)) {
            mi.setALotOfWaiting(true);
        }
        mi.setChildCount(monitorNode.getChildCount());

        ((Category) catMonitors.getUserObject()).addToCatNodes(monitorNode);
        if (locks == 0) {
            monitorsWithoutLocksCount++;
            overallThreadsWaiting += waits;
            ((Category) catMonitorsLocks.getUserObject()).addToCatNodes(monitorNode);
        }
    }
    return new int[] { monitorsWithoutLocksCount, overallThreadsWaiting };
}

From source file:gov.nih.nci.ncicb.cadsr.contexttree.service.impl.CDEBrowserTreeServiceImpl.java

private DefaultMutableTreeNode getTemplateNode(String nodeId, Form template, TreeFunctions treeFunctions)
        throws Exception {
    String templateIdseq = template.getFormIdseq();

    String longName = template.getLongName();
    String preferred_definition = template.getPreferredDefinition();
    String contextName = template.getContext().getName();
    String currContextId = template.getContext().getConteIdseq();
    DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(new WebNode(nodeId, longName,
            "javascript:" + treeFunctions.getFormJsFunctionName() + "('P_PARAM_TYPE=TEMPLATE&P_IDSEQ="
                    + templateIdseq + "&P_CONTE_IDSEQ=" + currContextId //context idseq
                    + "&templateName=" + URLEncoder.encode(longName) //longname
                    + "&contextName=" + URLEncoder.encode(contextName) + // context name
                    treeFunctions.getExtraURLParameters() + "')",
            preferred_definition)); //preffered definition
    return tmpNode;
}

From source file:dataviewer.DataViewer.java

private void fill_tree() {
    txt_count.setText("");

    DefaultTreeModel tm = (DefaultTreeModel) tr_files.getModel();
    DefaultMutableTreeNode top;/*from  ww  w. ja  v  a 2s. co  m*/
    cur_path = new File(cur_path).getAbsolutePath();
    if (cur_path.charAt(cur_path.length() - 1) == '.') {
        cur_path = cur_path.substring(0, cur_path.length() - 1);
    }
    if (cur_path.charAt(cur_path.length() - 1) == File.separatorChar) {
        cur_path = cur_path.substring(0, cur_path.length() - 1);
    }
    if (tm != null) {
        top = (DefaultMutableTreeNode) tm.getRoot();
        top.removeAllChildren();
        top.setUserObject(cur_path);
    } else {
        top = new DefaultMutableTreeNode(cur_path);
    }

    // get all children nodes and remove them
    // rename the user object
    ArrayList<String> files = this.getAllFileNames(cur_path);
    Collections.sort(files);

    int j = 1;
    int selected_index = -1;
    for (String f : files) {
        String ex = this.getExtension(f);
        boolean is_folder = (new File(cur_path + File.separator + f)).isDirectory();
        if (is_folder || ex.equals(".txt") || ex.equals(".dat") || ex.equals(".csv") || ex.equals(".tsv")) {
            DefaultMutableTreeNode node = new DefaultMutableTreeNode(f);
            top.add(node);
            if (f.equals(selected_file)) {
                selected_index = j;
            }
            j++;
        }
    }

    //DefaultTreeModel treeModel = new DefaultTreeModel(top);
    //tr_files.setModel(treeModel);
    if (tm == null) {
        tr_files.setModel(new DefaultTreeModel(top));
    } else {
        try {
            tm.reload();
        } catch (Exception e) {
            tm.reload();
        }
    }

    if (selected_index > -1) {
        tr_files.setSelectionRow(selected_index);
    }

    tr_files.grabFocus();
}

From source file:org.jfree.chart.demo.SuperDemo.java

private MutableTreeNode createStatisticalChartsNode() {
    DefaultMutableTreeNode defaultmutabletreenode = new DefaultMutableTreeNode("Statistical Charts");
    DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(
            new DemoDescription("BoxAndWhiskerChartDemo1", "BoxAndWhiskerChartDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode(
            new DemoDescription("HistogramDemo1", "HistogramDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(
            new DemoDescription("NormalDistributionDemo1", "NormalDistributionDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode4 = new DefaultMutableTreeNode(
            new DemoDescription("RegressionDemo1", "RegressionDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode5 = new DefaultMutableTreeNode(
            new DemoDescription("ScatterPlotDemo1", "ScatterPlotDemo1.java"));
    DefaultMutableTreeNode defaultmutabletreenode6 = new DefaultMutableTreeNode(
            new DemoDescription("ScatterPlotDemo2", "ScatterPlotDemo2.java"));
    DefaultMutableTreeNode defaultmutabletreenode7 = new DefaultMutableTreeNode(
            new DemoDescription("ScatterPlotDemo3", "ScatterPlotDemo3.java"));
    DefaultMutableTreeNode defaultmutabletreenode8 = new DefaultMutableTreeNode(
            new DemoDescription("ScatterPlotDemo4", "ScatterPlotDemo4.java"));
    DefaultMutableTreeNode defaultmutabletreenode9 = new DefaultMutableTreeNode(
            new DemoDescription("XYErrorRendererDemo1", "XYErrorRendererDemo1.java"));
    defaultmutabletreenode.add(defaultmutabletreenode1);
    defaultmutabletreenode.add(defaultmutabletreenode2);
    defaultmutabletreenode.add(defaultmutabletreenode3);
    defaultmutabletreenode.add(defaultmutabletreenode4);
    defaultmutabletreenode.add(defaultmutabletreenode5);
    defaultmutabletreenode.add(defaultmutabletreenode6);
    defaultmutabletreenode.add(defaultmutabletreenode7);
    defaultmutabletreenode.add(defaultmutabletreenode8);
    defaultmutabletreenode.add(defaultmutabletreenode9);
    return defaultmutabletreenode;
}