Package weka.gui.visualize

Examples of weka.gui.visualize.VisualizePanel


   *
   * @param e a VisualizableErrorEvent
   */
  public synchronized void acceptDataSet(VisualizableErrorEvent e) {
    if (m_visPanel == null) {
      m_visPanel = new VisualizePanel();
    }
    if (m_masterPlot == null) {
      m_masterPlot = e.getDataSet();
    }
    try {
View Full Code Here


    setUpFinal();
  }

  protected void setUpFinal() {
    if (m_visPanel == null) {
      m_visPanel = new VisualizePanel();
    }
    add(m_visPanel, BorderLayout.CENTER);
  }
View Full Code Here

    }
  }

  protected void setUpFinal() {
    if (m_visPanel == null) {
      m_visPanel = new VisualizePanel();
    }
    add(m_visPanel, BorderLayout.CENTER);
  }
View Full Code Here

    if (request.compareTo("Show plot") == 0) {
      try {
  // popup visualize panel
  if (!m_framePoppedUp) {
    m_framePoppedUp = true;
    final VisualizePanel vis = new VisualizePanel();
    PlotData2D pd1 = new PlotData2D(m_visualizeDataSet);
    pd1.setPlotName(m_visualizeDataSet.relationName());
    try {
      vis.setMasterPlot(pd1);
    } catch (Exception ex) {
      System.err.println(Messages.getInstance().getString("DataVisualizer_PerformRequest_Error_Text"));
      ex.printStackTrace();
    }
    final JFrame jf = new JFrame(Messages.getInstance().getString("DataVisualizer_PerformRequest_Jf_JFrame_Text"));
View Full Code Here

   * @param e a ThresholdDataEvent
   */
  public synchronized void acceptDataSet(ThresholdDataEvent e) {
    if (!GraphicsEnvironment.isHeadless()) {
      if (m_visPanel == null) {
        m_visPanel = new VisualizePanel();
      }
      if (m_masterPlot == null) {
        m_masterPlot = e.getDataSet();
      }
      try {
View Full Code Here

   * @param e a VisualizableErrorEvent
   */
  public synchronized void acceptDataSet(VisualizableErrorEvent e) {
    if (!GraphicsEnvironment.isHeadless()) {
      if (m_visPanel == null) {
        m_visPanel = new VisualizePanel();
      }
      if (m_masterPlot == null) {
        m_masterPlot = e.getDataSet();
      }
      try {
View Full Code Here

        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(Messages.getInstance().getString("GUIChooser_LoadingInstancesFrom_Error_Text") + 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(Messages.getInstance().getString("GUIChooser_MasterPlot_Text"));
              panel.setMasterPlot(pd1);
            } else {
              pd1.setPlotName(Messages.getInstance().getString("GUIChooser_Plot_Text") + (j+1));
              pd1.m_useCustomColour = true;
              pd1.m_customColour = (j % 2 == 0) ? Color.red : Color.blue;
              panel.addPlot(pd1);
            }
          }
          catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(
                m_Self, Messages.getInstance().getString("GUIChooser_Plot_LoadingFile_Error_Text_Front") + files[j] + Messages.getInstance().getString("GUIChooser_Plot_LoadingFile_Error_Text_End") + ex.getMessage());
            return;
          }
        }

        // create frame
        final JFrame frame = new JFrame(Messages.getInstance().getString("GUIChooser_Plot_PlotName_Text") + filenames);
        frame.setIconImage(m_Icon);
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(panel, BorderLayout.CENTER);
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            m_Plots.remove(frame);
            frame.dispose();
            checkExit();
          }
        });
        frame.pack();
        frame.setSize(800, 600);
        frame.setVisible(true);
        m_Plots.add(frame);
      }
    });
   
    // Visualization/ROC
    JMenuItem jMenuItemVisualizationROC = new JMenuItem();
    m_jMenuVisualization.add(jMenuItemVisualizationROC);
    jMenuItemVisualizationROC.setText(Messages.getInstance().getString("GUIChooser_ROC_Text"));
    // jMenuItemVisualizationROC.setMnemonic('R');
    jMenuItemVisualizationROC.
      setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_MASK));
   
    jMenuItemVisualizationROC.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // 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 ex) {
          ex.printStackTrace();
          JOptionPane.showMessageDialog(
              m_Self, Messages.getInstance().getString("GUIChooser_ROC_LoadingFile_Error_Text_Front") + filename + Messages.getInstance().getString("GUIChooser_ROC_LoadingFile_Error_Text_End") + ex.getMessage());
          return;
        }
        result.setClassIndex(result.numAttributes() - 1);
        ThresholdVisualizePanel vmc = new ThresholdVisualizePanel();
        vmc.setROCString(Messages.getInstance().getString("GUIChooser_ROC_AreaUnderROC_Text_Front") +
            Utils.doubleToString(ThresholdCurve.getROCArea(result), 4) + Messages.getInstance().getString("GUIChooser_ROC_AreaUnderROC_Text_End"));
        vmc.setName(result.relationName());
        PlotData2D tempd = new PlotData2D(result);
        tempd.setPlotName(result.relationName());
        tempd.addInstanceNumberAttribute();
        try {
          vmc.addPlot(tempd);
        }
        catch (Exception ex) {
          ex.printStackTrace();
          JOptionPane.showMessageDialog(
              m_Self, Messages.getInstance().getString("GUIChooser_ROC_AddingPlot_Error_Text") + ex.getMessage());
          return;
        }

        final JFrame frame = new JFrame(Messages.getInstance().getString("GUIChooser_ROC_File_Text") + filename);
        frame.setIconImage(m_Icon);
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(vmc, BorderLayout.CENTER);
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            m_ROCs.remove(frame);
            frame.dispose();
            checkExit();
          }
        });
        frame.pack();
        frame.setSize(800, 600);
        frame.setVisible(true);
        m_ROCs.add(frame);
      }
    });
   
    // Visualization/TreeVisualizer
    JMenuItem jMenuItemVisualizationTree = new JMenuItem();
    m_jMenuVisualization.add(jMenuItemVisualizationTree);
    jMenuItemVisualizationTree.setText(Messages.getInstance().getString("GUIChooser_TreeVisualizer_Text"));
    // jMenuItemVisualizationTree.setMnemonic('T');
    jMenuItemVisualizationTree.
      setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK));
   
    jMenuItemVisualizationTree.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // 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 ex) {
          ex.printStackTrace();
          JOptionPane.showMessageDialog(
              m_Self, Messages.getInstance().getString("GUIChooser_TreeVisualizer_LoadingFile_Error_Text_Front") + filename + Messages.getInstance().getString("GUIChooser_TreeVisualizer_LoadingFile_Error_Text_End") + ex.getMessage());
          return;
        }

        // create frame
        final JFrame frame = new JFrame(Messages.getInstance().getString("GUIChooser_TreeVisualizer_File_Text") + filename);
        frame.setIconImage(m_Icon);
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(new TreeVisualizer(null, top, arrange), BorderLayout.CENTER);
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            m_TreeVisualizers.remove(frame);
            frame.dispose();
            checkExit();
          }
        });
        frame.pack();
        frame.setSize(800, 600);
        frame.setVisible(true);
        m_TreeVisualizers.add(frame);
      }
    });
   
    // Visualization/GraphVisualizer
    JMenuItem jMenuItemVisualizationGraph = new JMenuItem();
    m_jMenuVisualization.add(jMenuItemVisualizationGraph);
    jMenuItemVisualizationGraph.setText(Messages.getInstance().getString("GUIChooser_GraphVisualizer_Text"));
//   jMenuItemVisualizationGraph.setMnemonic('G');
    jMenuItemVisualizationGraph.
      setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, KeyEvent.CTRL_MASK));
   
    jMenuItemVisualizationGraph.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // 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 ex) {
          ex.printStackTrace();
          JOptionPane.showMessageDialog(
View Full Code Here

            Messages.getInstance().getString("ClustererPanel_StartClusterer_Run_JOptionPaneShowMessageDialog_Text_Second"),
            JOptionPane.ERROR_MESSAGE);
      m_Log.statusMessage(Messages.getInstance().getString("ClustererPanel_StartClusterer_Run_Log_StatusMessage_Nineth"));
    } finally {
      if (predData != null) {
        m_CurrentVis = new VisualizePanel();
        m_CurrentVis.setName(name+" ("+inst.relationName()+")");
        m_CurrentVis.setLog(m_Log);
        predData.setPlotName(name+" ("+inst.relationName()+")");
       
        try {
View Full Code Here

    FastVector o = null;
    if (selectedName != null) {
      o = (FastVector)m_History.getNamedObject(selectedName);
    }

    VisualizePanel temp_vp = null;
    String temp_grph = null;
    Clusterer temp_clusterer = null;
    Instances temp_trainHeader = null;
    int[] temp_ignoreAtts = null;
   
    if (o != null) {
      for (int i = 0; i < o.size(); i++) {
  Object temp = o.elementAt(i);
  if (temp instanceof Clusterer) {
    temp_clusterer = (Clusterer)temp;
  } else if (temp instanceof Instances) { // training header
    temp_trainHeader = (Instances)temp;
  } else if (temp instanceof int[]) { // ignored attributes
    temp_ignoreAtts = (int[])temp;
  } else if (temp instanceof VisualizePanel) { // normal errors
    temp_vp = (VisualizePanel)temp;
  } else if (temp instanceof String) { // graphable output
    temp_grph = (String)temp;
  }
      }
    }
     
    final VisualizePanel vp = temp_vp;
    final String grph = temp_grph;
    final Clusterer clusterer = temp_clusterer;
    final Instances trainHeader = temp_trainHeader;
    final int[] ignoreAtts = temp_ignoreAtts;
   
    JMenuItem saveModel = new JMenuItem(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_SaveModel_JMenuItem_Text"));
    if (clusterer != null) {
      saveModel.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      saveClusterer(selectedName, clusterer, trainHeader, ignoreAtts);
    }
  });
    } else {
      saveModel.setEnabled(false);
    }
    resultListMenu.add(saveModel);
   
    JMenuItem reEvaluate =
      new JMenuItem(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_ReEvaluate_JMenuItem_Text"));
    if (clusterer != null && m_TestInstances != null) {
      reEvaluate.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      reevaluateModel(selectedName, clusterer, trainHeader, ignoreAtts);
    }
  });
    } else {
      reEvaluate.setEnabled(false);
    }
    resultListMenu.add(reEvaluate);
   
    resultListMenu.addSeparator();
   
    JMenuItem visClusts = new JMenuItem(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_VisClusts_JMenuItem_Text"));
    if (vp != null) {
      visClusts.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        visualizeClusterAssignments(vp);
      }
    });
     
    } else {
      visClusts.setEnabled(false);
    }
    resultListMenu.add(visClusts);

    JMenuItem visTree = new JMenuItem(Messages.getInstance().getString("ClustererPanel_VisualizeClusterer_VisTree_JMenuItem_Text"));
    if (grph != null) {
      visTree.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      String title;
      if (vp != null) title = vp.getName();
      else title = selectedName;
      visualizeTree(grph, title);
    }
  });
    } else {
View Full Code Here

                                            JOptionPane.ERROR_MESSAGE);
              m_Log.statusMessage(Messages.getInstance().getString("ClustererPanel_ReEvaluateModel_Run_Log_StatusMessage_Text_Fourth"));

            } finally {
              if (predData != null) {
                m_CurrentVis = new VisualizePanel();
                m_CurrentVis.setName(name+" ("+userTest.relationName()+")");
                m_CurrentVis.setLog(m_Log);
                predData.setPlotName(name+" ("+userTest.relationName()+")");
 
                try {
View Full Code Here

TOP

Related Classes of weka.gui.visualize.VisualizePanel

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.