KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > testapp > interactive > testscreen > TablePerformanceTest


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.testapp.interactive.testscreen;
31
32 import nextapp.echo2.app.Border;
33 import nextapp.echo2.app.Color;
34 import nextapp.echo2.app.Column;
35 import nextapp.echo2.app.Extent;
36 import nextapp.echo2.app.Insets;
37 import nextapp.echo2.app.Label;
38 import nextapp.echo2.app.SplitPane;
39 import nextapp.echo2.app.Table;
40 import nextapp.echo2.app.event.ActionEvent;
41 import nextapp.echo2.app.event.ActionListener;
42 import nextapp.echo2.app.layout.SplitPaneLayoutData;
43 import nextapp.echo2.app.table.AbstractTableModel;
44 import nextapp.echo2.app.table.DefaultTableModel;
45 import nextapp.echo2.testapp.interactive.ButtonColumn;
46
47 /**
48  * A test for evaluating the performance of <code>Tables</code>s.
49  */

50 public class TablePerformanceTest extends SplitPane {
51     
52     private Table testTable;
53     
54     private class MultiplicationTableModel extends AbstractTableModel {
55         
56         private int columnCount, rowCount;
57         
58         public MultiplicationTableModel(int columnCount, int rowCount) {
59             super();
60             this.columnCount = columnCount;
61             this.rowCount = rowCount;
62         }
63
64         /**
65          * @see nextapp.echo2.app.table.TableModel#getColumnCount()
66          */

67         public int getColumnCount() {
68             return columnCount;
69         }
70         
71         /**
72          * @see nextapp.echo2.app.table.TableModel#getRowCount()
73          */

74         public int getRowCount() {
75             return rowCount;
76         }
77         
78         /**
79          * @see nextapp.echo2.app.table.TableModel#getValueAt(int, int)
80          */

81         public Object JavaDoc getValueAt(int column, int row) {
82             return new Integer JavaDoc((column + 1) * (row + 1));
83         }
84     }
85     
86     public TablePerformanceTest() {
87         super(SplitPane.ORIENTATION_HORIZONTAL, new Extent(250, Extent.PX));
88         setStyleName("DefaultResizable");
89         
90         Column groupContainerColumn = new Column();
91         groupContainerColumn.setCellSpacing(new Extent(5));
92         groupContainerColumn.setStyleName("TestControlsColumn");
93         add(groupContainerColumn);
94         
95         Column testColumn = new Column();
96         SplitPaneLayoutData splitPaneLayoutData = new SplitPaneLayoutData();
97         splitPaneLayoutData.setInsets(new Insets(10, 5));
98         testColumn.setLayoutData(splitPaneLayoutData);
99         add(testColumn);
100         
101         testTable = new Table();
102         testTable.setBorder(new Border(new Extent(1), Color.BLUE, Border.STYLE_SOLID));
103         testColumn.add(testTable);
104
105         ButtonColumn controlsColumn;
106         
107         controlsColumn = new ButtonColumn();
108         groupContainerColumn.add(controlsColumn);
109
110         controlsColumn.add(new Label("TableModel"));
111         
112         controlsColumn.addButton("DefaultTableModel (Empty)", new ActionListener() {
113             public void actionPerformed(ActionEvent e) {
114                 testTable.setModel(new DefaultTableModel());
115             }
116         });
117         
118         controlsColumn.addButton("MultiplicationTableModel (12x12)", new ActionListener() {
119             public void actionPerformed(ActionEvent e) {
120                 testTable.setModel(new MultiplicationTableModel(12, 12));
121             }
122         });
123         
124         controlsColumn.addButton("MultiplicationTableModel (12x25)", new ActionListener() {
125             public void actionPerformed(ActionEvent e) {
126                 testTable.setModel(new MultiplicationTableModel(12, 25));
127             }
128         });
129         
130         controlsColumn.addButton("MultiplicationTableModel (12x50)", new ActionListener() {
131             public void actionPerformed(ActionEvent e) {
132                 testTable.setModel(new MultiplicationTableModel(12, 50));
133             }
134         });
135         
136         controlsColumn.addButton("MultiplicationTableModel (12x100)", new ActionListener() {
137             public void actionPerformed(ActionEvent e) {
138                 testTable.setModel(new MultiplicationTableModel(12, 100));
139             }
140         });
141         
142         controlsColumn.addButton("MultiplicationTableModel (25x12)", new ActionListener() {
143             public void actionPerformed(ActionEvent e) {
144                 testTable.setModel(new MultiplicationTableModel(25, 12));
145             }
146         });
147         
148         controlsColumn.addButton("MultiplicationTableModel (25x25)", new ActionListener() {
149             public void actionPerformed(ActionEvent e) {
150                 testTable.setModel(new MultiplicationTableModel(25, 25));
151             }
152         });
153         
154         controlsColumn.addButton("MultiplicationTableModel (25x50)", new ActionListener() {
155             public void actionPerformed(ActionEvent e) {
156                 testTable.setModel(new MultiplicationTableModel(25, 50));
157             }
158         });
159         
160         controlsColumn.addButton("MultiplicationTableModel (25x100)", new ActionListener() {
161             public void actionPerformed(ActionEvent e) {
162                 testTable.setModel(new MultiplicationTableModel(25, 100));
163             }
164         });
165         
166         controlsColumn.addButton("MultiplicationTableModel (8x1000)", new ActionListener() {
167             public void actionPerformed(ActionEvent e) {
168                 testTable.setModel(new MultiplicationTableModel(8, 1000));
169             }
170         });
171         
172         controlsColumn.addButton("MultiplicationTableModel (8x2000)", new ActionListener() {
173             public void actionPerformed(ActionEvent e) {
174                 testTable.setModel(new MultiplicationTableModel(8, 2000));
175             }
176         });
177         
178         controlsColumn.addButton("MultiplicationTableModel (8x5000)", new ActionListener() {
179             public void actionPerformed(ActionEvent e) {
180                 testTable.setModel(new MultiplicationTableModel(8, 5000));
181             }
182         });
183         
184         controlsColumn = new ButtonColumn();
185         groupContainerColumn.add(controlsColumn);
186
187         controlsColumn.add(new Label("Rollover/Selection"));
188         
189         controlsColumn.addButton("Enable Rollover Effects", new ActionListener() {
190             public void actionPerformed(ActionEvent e) {
191                 testTable.setRolloverBackground(Color.BLUE);
192                 testTable.setRolloverForeground(Color.WHITE);
193                 testTable.setRolloverEnabled(true);
194             }
195         });
196         
197         controlsColumn.addButton("Disable Rollover Effects", new ActionListener() {
198             public void actionPerformed(ActionEvent e) {
199                 testTable.setRolloverBackground(null);
200                 testTable.setRolloverForeground(null);
201                 testTable.setRolloverEnabled(false);
202             }
203         });
204         
205         controlsColumn.addButton("Enable Selection Effects", new ActionListener() {
206             public void actionPerformed(ActionEvent e) {
207                 testTable.setSelectionBackground(Color.GREEN);
208                 testTable.setSelectionForeground(Color.BLUE);
209                 testTable.setSelectionEnabled(true);
210             }
211         });
212         
213         controlsColumn.addButton("Disable Selection Effects", new ActionListener() {
214             public void actionPerformed(ActionEvent e) {
215                 testTable.setSelectionBackground(null);
216                 testTable.setSelectionForeground(null);
217                 testTable.setSelectionEnabled(false);
218             }
219         });
220     }
221 }
222
Popular Tags