Package weka.gui.scripting

Examples of weka.gui.scripting.JythonPanel


      jMenuItemJythonConsole.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, KeyEvent.CTRL_MASK));
      jMenuItemJythonConsole.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    if (m_BayesNetGUIFrame == null) {
      jMenuItemJythonConsole.setEnabled(false);
      final JythonPanel jythonPanel = new JythonPanel();
      m_JythonConsoleFrame = new JFrame(jythonPanel.getPlainTitle());
      m_JythonConsoleFrame.setIconImage(m_Icon);
      m_JythonConsoleFrame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      m_JythonConsoleFrame.setJMenuBar(jythonPanel.getMenuBar());
      m_JythonConsoleFrame.getContentPane().add(jythonPanel, BorderLayout.CENTER);
      m_JythonConsoleFrame.addWindowListener(new WindowAdapter() {
        public void windowClosed(WindowEvent w) {
    m_JythonConsoleFrame = null;
    jMenuItemJythonConsole.setEnabled(true);
View Full Code Here


  jMenuItemToolsJythonConsole.setMnemonic('J');
  jMenuItemToolsJythonConsole.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
      String title = jMenuItemToolsJythonConsole.getText();
      if (!containsWindow(title)) {
        final JythonPanel panel = new JythonPanel();
        final Container frame = createFrame(
      m_Self, title, panel, new BorderLayout(),
      BorderLayout.CENTER, 800, 600, panel.getMenuBar(), false, true);

        // custom listener
        if (frame instanceof ChildFrameMDI) {
    ((ChildFrameMDI) frame).addInternalFrameListener(new InternalFrameAdapter() {
      public void internalFrameClosing(InternalFrameEvent e) {
        ((ChildFrameMDI) frame).dispose();
      }
    });
        }
        else if (frame instanceof ChildFrameSDI) {
    ((ChildFrameSDI) frame).addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        ((ChildFrameSDI) frame).dispose();
      }
    });
        }
      }
      else {
        showWindow(getWindow(title));
      }
    }
      });
      }

      // Tools/EnsembleLibrary
      /* currently disabled due to bugs... FracPete
      jMenuItemToolsEnsembleLibrary = new JMenuItem();
      jMenuTools.add(jMenuItemToolsEnsembleLibrary);
      jMenuItemToolsEnsembleLibrary.setText("EnsembleLibrary");
      jMenuItemToolsEnsembleLibrary.setMnemonic('E');
      jMenuItemToolsEnsembleLibrary.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    String title = jMenuItemToolsEnsembleLibrary.getText();
    if (!containsWindow(title)) {
      EnsembleLibrary value = new EnsembleLibrary();
      EnsembleLibraryEditor libraryEditor = new EnsembleLibraryEditor();
      libraryEditor.setValue(value);
      createFrame(
    m_Self, title, libraryEditor.getCustomEditor(), new BorderLayout(),
    BorderLayout.CENTER, 800, 600, null, true, true);
    }
    else {
      showWindow(getWindow(title));
    }
  }
      });
      */

      // Visualization
      jMenuVisualization = new JMenu();
      jMenuBar.add(jMenuVisualization);
      jMenuVisualization.setText("Visualization");
      jMenuVisualization.setMnemonic('V');

      // Visualization/Plot
      jMenuItemVisualizationPlot = new JMenuItem();
      jMenuVisualization.add(jMenuItemVisualizationPlot);
      jMenuItemVisualizationPlot.setText("Plot");
      jMenuItemVisualizationPlot.setMnemonic('P');
      jMenuItemVisualizationPlot.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    // choose file
    int retVal = m_FileChooserPlot.showOpenDialog(m_Self);
    if (retVal != JFileChooser.APPROVE_OPTION)
      return;

    // build plot
    VisualizePanel panel = new VisualizePanel();
    String filenames = "";
    File[] files = m_FileChooserPlot.getSelectedFiles();
    for (int j = 0; j < files.length; j++) {
      String filename = files[j].getAbsolutePath();
      if (j > 0)
        filenames += ", ";
      filenames += filename;
      System.err.println("Loading instances from " + filename);
      try {
        Reader r = new java.io.BufferedReader(new FileReader(filename));
        Instances i = new Instances(r);
        i.setClassIndex(i.numAttributes()-1);
        PlotData2D pd1 = new PlotData2D(i);

        if (j == 0) {
    pd1.setPlotName("Master plot");
    panel.setMasterPlot(pd1);
        } else {
    pd1.setPlotName("Plot "+(j+1));
    pd1.m_useCustomColour = true;
    pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
    panel.addPlot(pd1);
        }
      }
      catch (Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(
      m_Self, "Error loading file '" + files[j] + "':\n" + e.getMessage());
        return;
      }
    }

    // create frame
    createFrame(
        m_Self, jMenuItemVisualizationPlot.getText() + " - " + filenames,
        panel, new BorderLayout(),
        BorderLayout.CENTER, 800, 600, null, true, true);
  }
      });

      // Visualization/ROC
      // based on this Wiki article:
      // http://weka.sourceforge.net/wiki/index.php/Visualizing_ROC_curve
      jMenuItemVisualizationROC = new JMenuItem();
      jMenuVisualization.add(jMenuItemVisualizationROC);
      jMenuItemVisualizationROC.setText("ROC");
      jMenuItemVisualizationROC.setMnemonic('R');
      jMenuItemVisualizationROC.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    // choose file
    int retVal = m_FileChooserROC.showOpenDialog(m_Self);
    if (retVal != JFileChooser.APPROVE_OPTION)
      return;

    // create plot
    String filename  = m_FileChooserROC.getSelectedFile().getAbsolutePath();
    Instances result = null;
    try {
      result = new Instances(new BufferedReader(new FileReader(filename)));
    }
    catch (Exception e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(
    m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
      return;
    }
    result.setClassIndex(result.numAttributes() - 1);
    ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
    vmc.setROCString("(Area under ROC = " +
        Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + ")");
    vmc.setName(result.relationName());
    PlotData2D tempd = new PlotData2D(result);
    tempd.setPlotName(result.relationName());
    tempd.addInstanceNumberAttribute();
    try {
      vmc.addPlot(tempd);
    }
    catch (Exception e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(
    m_Self, "Error adding plot:\n" + e.getMessage());
      return;
    }

    createFrame(
        m_Self, jMenuItemVisualizationROC.getText() + " - " + filename,
        vmc, new BorderLayout(),
        BorderLayout.CENTER, 800, 600, null, true, true);
  }
      });

      // Visualization/TreeVisualizer
      jMenuItemVisualizationTreeVisualizer = new JMenuItem();
      jMenuVisualization.add(jMenuItemVisualizationTreeVisualizer);
      jMenuItemVisualizationTreeVisualizer.setText("TreeVisualizer");
      jMenuItemVisualizationTreeVisualizer.setMnemonic('T');
      jMenuItemVisualizationTreeVisualizer.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    // choose file
    int retVal = m_FileChooserTreeVisualizer.showOpenDialog(m_Self);
    if (retVal != JFileChooser.APPROVE_OPTION)
      return;

    // build tree
    String filename = m_FileChooserTreeVisualizer.getSelectedFile().getAbsolutePath();
    TreeBuild builder = new TreeBuild();
    Node top = null;
    NodePlace arrange = new PlaceNode2();
    try {
      top = builder.create(new FileReader(filename));
    }
    catch (Exception e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(
    m_Self, "Error loading file '" + filename + "':\n" + e.getMessage());
      return;
    }

    // create frame
    createFrame(
        m_Self, jMenuItemVisualizationTreeVisualizer.getText() + " - " + filename,
        new TreeVisualizer(null, top, arrange), new BorderLayout(),
        BorderLayout.CENTER, 800, 600, null, true, true);
  }
      });

      // Visualization/GraphVisualizer
      jMenuItemVisualizationGraphVisualizer = new JMenuItem();
      jMenuVisualization.add(jMenuItemVisualizationGraphVisualizer);
      jMenuItemVisualizationGraphVisualizer.setText("GraphVisualizer");
      jMenuItemVisualizationGraphVisualizer.setMnemonic('G');
      jMenuItemVisualizationGraphVisualizer.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent evt) {
    // choose file
    int retVal = m_FileChooserGraphVisualizer.showOpenDialog(m_Self);
    if (retVal != JFileChooser.APPROVE_OPTION)
      return;

    // build graph
    String filename = m_FileChooserGraphVisualizer.getSelectedFile().getAbsolutePath();
    GraphVisualizer panel = new GraphVisualizer();
    try{
      if (    filename.toLowerCase().endsWith(".xml")
    || filename.toLowerCase().endsWith(".bif") ) {
        panel.readBIF(new FileInputStream(filename));
      }
      else {
        panel.readDOT(new FileReader(filename));
      }
    }
    catch (Exception e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(
View Full Code Here

TOP

Related Classes of weka.gui.scripting.JythonPanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.