-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTScoreTableModel.java
More file actions
83 lines (75 loc) · 2.46 KB
/
Copy pathTScoreTableModel.java
File metadata and controls
83 lines (75 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* File :TScoraeTableModel.java
* Project: Math Tools in Java
* Purpose: data management for displaying in table
* Author : Wachara R.
* First Released: Sat 17 May 2008
* Last Updated : Sat 14 June 2008
*/
package tscoreApp;
import tscore.TScore;
import javax.swing.table.*;
class TScoreTableModel extends AbstractTableModel {
String[ ] columnNames = { "RawScore", "Frequency", "Cum Freq", "Percentile", "T Score","Grade"};
Object[][] cell;
int rowCount;
double mean; // average value
double sd; // standard deviation.
double[ ] za; // area under normal curve
double[ ] tscore; // T Score
double[ ] classifiedData; // data which being classified
int [ ] freq; // frequency of data
int [ ] cf; // cumulated frequency
String [ ] gr; // grade level
int [ ] gc; // grade count
// Model constructor.
public TScoreTableModel () { }
public TScoreTableModel (double[] rawScore, int numData, int gradeOption) {
TScore ts = new TScore( rawScore, numData,gradeOption);
int numDataAtLast = ts.getnumDataAtLast();
rowCount = numDataAtLast;
classifiedData = new double[numDataAtLast];
classifiedData = ts.getManagedData();
freq = new int[numDataAtLast];
cf = new int[numDataAtLast];
za = new double[numDataAtLast];
tscore = new double[numDataAtLast];
gr = new String[numDataAtLast];
freq= ts.getFrequency();
cf = ts.getCumulativeFrequency();
za= ts.getPercentile();
tscore = ts.getTScore();
gr = ts.getGrade();
mean = ts.getMean();
sd=ts.getStandardDeviation();
gc = ts.getGradeCount();
cell = new Object[numDataAtLast][6];
for(int i= 0; i < numDataAtLast; i++) {
cell[i][0] = String.format("%.2f",classifiedData[i]);
cell[i][1] =String.format("%4d", freq[i]);
cell[i][2] = String.format("%4d",cf[i]);
cell[i][3] = String.format("%2.2f", za[i]*100);
cell[i][4] = String.format("%.2f",tscore[i]);
cell[i][5] = gr[i] ;
} // for i
}
// Retrieve the number of rows for the table to be prepared.
public int getRowCount() {
return rowCount;
}
// retrieve the column count.
public int getColumnCount() {
return columnNames.length;
}
// Retrieve each of the table values at the specified
// row and column.
public Object getValueAt(int row, int column) {
return cell[row][column];
}
// Retrieve the column names to be used in the table header.
public String getColumnName(int column) {
return columnNames[column];
}
public double getMean() { return mean; }
public double getSD() { return sd;}
public int [ ] getGradeCount() {return gc;}
}