Example usage for weka.core Drawable graph

List of usage examples for weka.core Drawable graph

Introduction

In this page you can find the example usage for weka.core Drawable graph.

Prototype

String graph() throws Exception;

Source Link

Document

Returns a string that describes a graph representing the object.

Usage

From source file:de.fub.maps.project.detector.model.inference.impl.ShowGraphAction.java

License:Open Source License

@NbBundle.Messages({ "CLT_Tree_Visualization=Visualisation" })
@Override/*  ww w  . j a v a  2s  .c om*/
public void actionPerformed(ActionEvent e) {
    Classifier classifier = inferenceModel.getClassifier();
    if (classifier instanceof Drawable) {
        try {
            Drawable graph = (Drawable) classifier;
            JComponent panel = null;
            String graphDescriptor = null;

            switch (graph.graphType()) {
            case Drawable.BayesNet:
                graphDescriptor = graph.graph();

                if (graphDescriptor != null) {
                    LOG.log(Level.INFO, "\n{0}", graphDescriptor);
                    panel = createBayesGraph(graphDescriptor);
                }
                break;
            case Drawable.Newick:
                break;
            case Drawable.TREE:
                graphDescriptor = graph.graph();
                if (graphDescriptor != null) {
                    LOG.log(Level.INFO, "\n{0}", graphDescriptor);
                    panel = createTreeGraph(graphDescriptor);
                }
                break;
            default:
                break;
            }

            if (panel != null) {
                displayGraph(panel);
            }
        } catch (Exception ex) {
            NotifyDescriptor nd = new NotifyDescriptor.Message(MessageFormat
                    .format("{0}\nYou have to build the classifier before you can visualize.", ex.getMessage()),
                    NotifyDescriptor.Message.ERROR_MESSAGE);
            DialogDisplayer.getDefault().notify(nd);
        }
    }
}