001: /*
002: * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003: * Copyright (C) 2002-2005 NextApp, Inc.
004: *
005: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006: *
007: * The contents of this file are subject to the Mozilla Public License Version
008: * 1.1 (the "License"); you may not use this file except in compliance with
009: * the License. You may obtain a copy of the License at
010: * http://www.mozilla.org/MPL/
011: *
012: * Software distributed under the License is distributed on an "AS IS" basis,
013: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014: * for the specific language governing rights and limitations under the
015: * License.
016: *
017: * Alternatively, the contents of this file may be used under the terms of
018: * either the GNU General Public License Version 2 or later (the "GPL"), or
019: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020: * in which case the provisions of the GPL or the LGPL are applicable instead
021: * of those above. If you wish to allow use of your version of this file only
022: * under the terms of either the GPL or the LGPL, and not to allow others to
023: * use your version of this file under the terms of the MPL, indicate your
024: * decision by deleting the provisions above and replace them with the notice
025: * and other provisions required by the GPL or the LGPL. If you do not delete
026: * the provisions above, a recipient may use your version of this file under
027: * the terms of any one of the MPL, the GPL or the LGPL.
028: */
029:
030: package nextapp.echo2.testapp.interactive.testscreen;
031:
032: import nextapp.echo2.app.Border;
033: import nextapp.echo2.app.Color;
034: import nextapp.echo2.app.Column;
035: import nextapp.echo2.app.Extent;
036: import nextapp.echo2.app.Insets;
037: import nextapp.echo2.app.Label;
038: import nextapp.echo2.app.SplitPane;
039: import nextapp.echo2.app.Table;
040: import nextapp.echo2.app.event.ActionEvent;
041: import nextapp.echo2.app.event.ActionListener;
042: import nextapp.echo2.app.layout.SplitPaneLayoutData;
043: import nextapp.echo2.app.table.AbstractTableModel;
044: import nextapp.echo2.app.table.DefaultTableModel;
045: import nextapp.echo2.testapp.interactive.ButtonColumn;
046:
047: /**
048: * A test for evaluating the performance of <code>Tables</code>s.
049: */
050: public class TablePerformanceTest extends SplitPane {
051:
052: private Table testTable;
053:
054: private class MultiplicationTableModel extends AbstractTableModel {
055:
056: private int columnCount, rowCount;
057:
058: public MultiplicationTableModel(int columnCount, int rowCount) {
059: super ();
060: this .columnCount = columnCount;
061: this .rowCount = rowCount;
062: }
063:
064: /**
065: * @see nextapp.echo2.app.table.TableModel#getColumnCount()
066: */
067: public int getColumnCount() {
068: return columnCount;
069: }
070:
071: /**
072: * @see nextapp.echo2.app.table.TableModel#getRowCount()
073: */
074: public int getRowCount() {
075: return rowCount;
076: }
077:
078: /**
079: * @see nextapp.echo2.app.table.TableModel#getValueAt(int, int)
080: */
081: public Object getValueAt(int column, int row) {
082: return new Integer((column + 1) * (row + 1));
083: }
084: }
085:
086: public TablePerformanceTest() {
087: super (SplitPane.ORIENTATION_HORIZONTAL, new Extent(250,
088: Extent.PX));
089: setStyleName("DefaultResizable");
090:
091: Column groupContainerColumn = new Column();
092: groupContainerColumn.setCellSpacing(new Extent(5));
093: groupContainerColumn.setStyleName("TestControlsColumn");
094: add(groupContainerColumn);
095:
096: Column testColumn = new Column();
097: SplitPaneLayoutData splitPaneLayoutData = new SplitPaneLayoutData();
098: splitPaneLayoutData.setInsets(new Insets(10, 5));
099: testColumn.setLayoutData(splitPaneLayoutData);
100: add(testColumn);
101:
102: testTable = new Table();
103: testTable.setBorder(new Border(new Extent(1), Color.BLUE,
104: Border.STYLE_SOLID));
105: testColumn.add(testTable);
106:
107: ButtonColumn controlsColumn;
108:
109: controlsColumn = new ButtonColumn();
110: groupContainerColumn.add(controlsColumn);
111:
112: controlsColumn.add(new Label("TableModel"));
113:
114: controlsColumn.addButton("DefaultTableModel (Empty)",
115: new ActionListener() {
116: public void actionPerformed(ActionEvent e) {
117: testTable.setModel(new DefaultTableModel());
118: }
119: });
120:
121: controlsColumn.addButton("MultiplicationTableModel (12x12)",
122: new ActionListener() {
123: public void actionPerformed(ActionEvent e) {
124: testTable
125: .setModel(new MultiplicationTableModel(
126: 12, 12));
127: }
128: });
129:
130: controlsColumn.addButton("MultiplicationTableModel (12x25)",
131: new ActionListener() {
132: public void actionPerformed(ActionEvent e) {
133: testTable
134: .setModel(new MultiplicationTableModel(
135: 12, 25));
136: }
137: });
138:
139: controlsColumn.addButton("MultiplicationTableModel (12x50)",
140: new ActionListener() {
141: public void actionPerformed(ActionEvent e) {
142: testTable
143: .setModel(new MultiplicationTableModel(
144: 12, 50));
145: }
146: });
147:
148: controlsColumn.addButton("MultiplicationTableModel (12x100)",
149: new ActionListener() {
150: public void actionPerformed(ActionEvent e) {
151: testTable
152: .setModel(new MultiplicationTableModel(
153: 12, 100));
154: }
155: });
156:
157: controlsColumn.addButton("MultiplicationTableModel (25x12)",
158: new ActionListener() {
159: public void actionPerformed(ActionEvent e) {
160: testTable
161: .setModel(new MultiplicationTableModel(
162: 25, 12));
163: }
164: });
165:
166: controlsColumn.addButton("MultiplicationTableModel (25x25)",
167: new ActionListener() {
168: public void actionPerformed(ActionEvent e) {
169: testTable
170: .setModel(new MultiplicationTableModel(
171: 25, 25));
172: }
173: });
174:
175: controlsColumn.addButton("MultiplicationTableModel (25x50)",
176: new ActionListener() {
177: public void actionPerformed(ActionEvent e) {
178: testTable
179: .setModel(new MultiplicationTableModel(
180: 25, 50));
181: }
182: });
183:
184: controlsColumn.addButton("MultiplicationTableModel (25x100)",
185: new ActionListener() {
186: public void actionPerformed(ActionEvent e) {
187: testTable
188: .setModel(new MultiplicationTableModel(
189: 25, 100));
190: }
191: });
192:
193: controlsColumn.addButton("MultiplicationTableModel (8x1000)",
194: new ActionListener() {
195: public void actionPerformed(ActionEvent e) {
196: testTable
197: .setModel(new MultiplicationTableModel(
198: 8, 1000));
199: }
200: });
201:
202: controlsColumn.addButton("MultiplicationTableModel (8x2000)",
203: new ActionListener() {
204: public void actionPerformed(ActionEvent e) {
205: testTable
206: .setModel(new MultiplicationTableModel(
207: 8, 2000));
208: }
209: });
210:
211: controlsColumn.addButton("MultiplicationTableModel (8x5000)",
212: new ActionListener() {
213: public void actionPerformed(ActionEvent e) {
214: testTable
215: .setModel(new MultiplicationTableModel(
216: 8, 5000));
217: }
218: });
219:
220: controlsColumn = new ButtonColumn();
221: groupContainerColumn.add(controlsColumn);
222:
223: controlsColumn.add(new Label("Rollover/Selection"));
224:
225: controlsColumn.addButton("Enable Rollover Effects",
226: new ActionListener() {
227: public void actionPerformed(ActionEvent e) {
228: testTable.setRolloverBackground(Color.BLUE);
229: testTable.setRolloverForeground(Color.WHITE);
230: testTable.setRolloverEnabled(true);
231: }
232: });
233:
234: controlsColumn.addButton("Disable Rollover Effects",
235: new ActionListener() {
236: public void actionPerformed(ActionEvent e) {
237: testTable.setRolloverBackground(null);
238: testTable.setRolloverForeground(null);
239: testTable.setRolloverEnabled(false);
240: }
241: });
242:
243: controlsColumn.addButton("Enable Selection Effects",
244: new ActionListener() {
245: public void actionPerformed(ActionEvent e) {
246: testTable.setSelectionBackground(Color.GREEN);
247: testTable.setSelectionForeground(Color.BLUE);
248: testTable.setSelectionEnabled(true);
249: }
250: });
251:
252: controlsColumn.addButton("Disable Selection Effects",
253: new ActionListener() {
254: public void actionPerformed(ActionEvent e) {
255: testTable.setSelectionBackground(null);
256: testTable.setSelectionForeground(null);
257: testTable.setSelectionEnabled(false);
258: }
259: });
260: }
261: }
|