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.
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.
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.
19
* & Matthias Schubert (schubert@dbs.ifi.lmu.de)
20
* & Zhanna Melnikova-Albrecht (melnikov@cip.ifi.lmu.de)
21
* & Rainer Holzmann (holzmann@cip.ifi.lmu.de)
24
package weka.clusterers.forOPTICSAndDBScan.OPTICS_GUI;
26
import weka.clusterers.forOPTICSAndDBScan.DataObjects.DataObject;
27
import weka.core.FastVector;
28
import weka.core.Utils;
30
import javax.swing.table.AbstractTableModel;
34
* ResultVectorTableModel.java <br/>
35
* Authors: Rainer Holzmann, Zhanna Melnikova-Albrecht <br/>
36
* Date: Sep 12, 2004 <br/>
37
* Time: 9:23:31 PM <br/>
38
* $ Revision 1.4 $ <br/>
41
* @author Zhanna Melnikova-Albrecht (melnikov@cip.ifi.lmu.de)
42
* @author Rainer Holzmann (holzmann@cip.ifi.lmu.de)
43
* @version $Revision: 1.3 $
45
public class ResultVectorTableModel
46
extends AbstractTableModel {
48
/** for serialization */
49
private static final long serialVersionUID = -7732711470435549210L;
52
* Holds the ClusterOrder (dataObjects with their r_dist and c_dist) for the GUI
54
private FastVector resultVector;
56
// *****************************************************************************************************************
58
// *****************************************************************************************************************
61
* Constructs a default <code>DefaultTableModel</code>
62
* which is a table of zero columns and zero rows.
64
public ResultVectorTableModel(FastVector resultVector) {
65
this.resultVector = resultVector;
68
// *****************************************************************************************************************
70
// *****************************************************************************************************************
73
* Returns the number of rows of this model.
74
* The number of rows is the number of dataObjects stored in the resultVector
75
* @return the number of rows of this model
77
public int getRowCount() {
78
if (resultVector == null)
81
return resultVector.size();
85
* Returns the number of columns of this model.
86
* The number of columns is 4 (dataObject.key, dataobject, c_dist, r_dist)
87
* @return int The number of columns of this model
89
public int getColumnCount() {
90
if (resultVector == null)
97
* Returns the value for the JTable for a given position.
98
* @param row The row of the value
99
* @param column The column of the value
102
public Object getValueAt(int row, int column) {
103
DataObject dataObject = (DataObject) resultVector.elementAt(row);
107
return dataObject.getKey();
111
return ((dataObject.getCoreDistance() == DataObject.UNDEFINED) ?
113
Utils.doubleToString(dataObject.getCoreDistance(), 3, 5));
115
return ((dataObject.getReachabilityDistance() == DataObject.UNDEFINED) ?
117
Utils.doubleToString(dataObject.getReachabilityDistance(), 3, 5));
123
// *****************************************************************************************************************
125
// *****************************************************************************************************************