source: src/main/java/weka/gui/explorer/VisualizePanel.java @ 14

Last change on this file since 14 was 4, checked in by gnappo, 14 years ago

Import di weka.

File size: 3.2 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 * VisualizePanel.java
19 * Copyright (C) 2007 University of Waikato, Hamilton, New Zealand
20 */
21
22package weka.gui.explorer;
23
24import weka.core.Instances;
25import weka.gui.explorer.Explorer.ExplorerPanel;
26import weka.gui.visualize.MatrixPanel;
27
28import java.awt.BorderLayout;
29
30/**
31 * A slightly extended MatrixPanel for better support in the Explorer.
32 *
33 * @author  fracpete (fracpete at waikato dot ac dot nz)
34 * @version $Revision: 1.15 $
35 * @see MatrixPanel
36 */
37public class VisualizePanel
38  extends MatrixPanel
39  implements ExplorerPanel {
40 
41  /** for serialization */
42  private static final long serialVersionUID = 6084015036853918846L;
43
44  /** the parent frame */
45  protected Explorer m_Explorer = null;
46
47  /**
48   * Sets the Explorer to use as parent frame (used for sending notifications
49   * about changes in the data)
50   *
51   * @param parent      the parent frame
52   */
53  public void setExplorer(Explorer parent) {
54    m_Explorer = parent;
55  }
56 
57  /**
58   * returns the parent Explorer frame
59   *
60   * @return            the parent
61   */
62  public Explorer getExplorer() {
63    return m_Explorer;
64  }
65 
66  /**
67   * Returns the title for the tab in the Explorer
68   *
69   * @return            the title of this tab
70   */
71  public String getTabTitle() {
72    return "Visualize";
73  }
74 
75  /**
76   * Returns the tooltip for the tab in the Explorer
77   *
78   * @return            the tooltip of this tab
79   */
80  public String getTabTitleToolTip() {
81    return "Explore the data";
82  }
83
84  /**
85   * Tests out the visualize panel from the command line.
86   *
87   * @param args may optionally contain the name of a dataset to load.
88   */
89  public static void main(String [] args) {
90
91    try {
92      final javax.swing.JFrame jf =
93        new javax.swing.JFrame("Weka Explorer: Visualize");
94      jf.getContentPane().setLayout(new BorderLayout());
95      final VisualizePanel sp = new VisualizePanel();
96      jf.getContentPane().add(sp, BorderLayout.CENTER);
97      jf.addWindowListener(new java.awt.event.WindowAdapter() {
98        public void windowClosing(java.awt.event.WindowEvent e) {
99          jf.dispose();
100          System.exit(0);
101        }
102      });
103      jf.pack();
104      jf.setSize(800, 600);
105      jf.setVisible(true);
106      if (args.length == 1) {
107        System.err.println("Loading instances from " + args[0]);
108        java.io.Reader r = new java.io.BufferedReader(
109                           new java.io.FileReader(args[0]));
110        Instances i = new Instances(r);
111        sp.setInstances(i);
112      }
113    } catch (Exception ex) {
114      ex.printStackTrace();
115      System.err.println(ex.getMessage());
116    }
117  }
118}
Note: See TracBrowser for help on using the repository browser.