/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * VisualizePanel.java * Copyright (C) 2007 University of Waikato, Hamilton, New Zealand */ package weka.gui.explorer; import weka.core.Instances; import weka.gui.explorer.Explorer.ExplorerPanel; import weka.gui.visualize.MatrixPanel; import java.awt.BorderLayout; /** * A slightly extended MatrixPanel for better support in the Explorer. * * @author fracpete (fracpete at waikato dot ac dot nz) * @version $Revision: 1.15 $ * @see MatrixPanel */ public class VisualizePanel extends MatrixPanel implements ExplorerPanel { /** for serialization */ private static final long serialVersionUID = 6084015036853918846L; /** the parent frame */ protected Explorer m_Explorer = null; /** * Sets the Explorer to use as parent frame (used for sending notifications * about changes in the data) * * @param parent the parent frame */ public void setExplorer(Explorer parent) { m_Explorer = parent; } /** * returns the parent Explorer frame * * @return the parent */ public Explorer getExplorer() { return m_Explorer; } /** * Returns the title for the tab in the Explorer * * @return the title of this tab */ public String getTabTitle() { return "Visualize"; } /** * Returns the tooltip for the tab in the Explorer * * @return the tooltip of this tab */ public String getTabTitleToolTip() { return "Explore the data"; } /** * Tests out the visualize panel from the command line. * * @param args may optionally contain the name of a dataset to load. */ public static void main(String [] args) { try { final javax.swing.JFrame jf = new javax.swing.JFrame("Weka Explorer: Visualize"); jf.getContentPane().setLayout(new BorderLayout()); final VisualizePanel sp = new VisualizePanel(); jf.getContentPane().add(sp, BorderLayout.CENTER); jf.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { jf.dispose(); System.exit(0); } }); jf.pack(); jf.setSize(800, 600); jf.setVisible(true); if (args.length == 1) { System.err.println("Loading instances from " + args[0]); java.io.Reader r = new java.io.BufferedReader( new java.io.FileReader(args[0])); Instances i = new Instances(r); sp.setInstances(i); } } catch (Exception ex) { ex.printStackTrace(); System.err.println(ex.getMessage()); } } }