/******************************************************************* Copyright (c) 2001-2010 Apprisant Technologies Inc. All rights reserved. Apprisant Technologies permits non-exclusive royalty free use, copying and modification of this demo program source code for the purposes of evaluating the Apprisant Toolkit or building applications that use it. This software and documentation is provided "AS IS". APPRISANT TECHNOLOGIES DISCLAIMS ANY REPRESENTATIONS AND WARRANTIES, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTY OF MERCHANTABILITY AND FITNESS OF THIS PRODUCT FOR ANY PARTICULAR PURPOSE. APPRISANT TECHNOLOGIES SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY ANY PARTY, INCLUDING LOST PROFITS, ARISING FROM THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ITS DERIVATIONS. ********************************************************************/ package show; import javax.swing.*; import javax.swing.table.*; /* This class is the TableModel that holds the data for both the table and the diagram in the Show demo. All of the methods in this class are TableModel methods except startShowDemo which is used to trigger population of the table and diagram. */ public class ShowData extends AbstractTableModel { static String [] [] data = { { "N10", "NorthCorner Company" }, { "N11", "Peter Pan" }, { "N12", "Frozen Ice Co." }, { "N13", "Lucky 13" }, { "N14", "The Ice Cream Store" }, { "N15", "Milky Way" }, { "N16", "Northwestern Confections" }, { "N17", "Heidy & Howdy" }, { "N18", "Handy Man" }, { "N19", "Classic Creamery" }, { "N20", "Twenty Questions" }, { "W11", "Prairie Moon" }, { "W12", "Pea Pod Pearl" }, { "W13", "Chocolate Cream Soldier" }, { "W14", "West Hills" }, { "S10", "Southern Cactus" }, { "S11", "Fairy Floss" }, { "S12", "Candy Tufts" }, { "S13", "Bear's Den Fudge" }, { "S14", "Chocolate Teddy" }, { "S15", "Le Chocolaterie" }, { "E11", "The Kitchen Store" }, { "E12", "Pots & Pans" }, { "E13", "Dinnerware Etc." }, { "E14", "Brandywine" }, { "A10", "Silver Surprises" }, { "A11", "The Pottery Barn" }, { "A12", "Jungle Craft" }, { "A13", "Merry Mingling" }, { "A14", "The Middle Initial" }, { "A15", "Doorway Signs" }, { "A16", "Western Lighting" }, { "A17", "Oriental Imports" }, { "B10", "Ocean Plus" }, { "B11", "Surfer Tricks" }, { "B12", "Sports Galore" }, { "B13", "Lights Aglow" }, { "B14", "Hard Rock Landscaping" }, { "B15", "Greener Than Thou" }, { "B16", "Nine Lives Houseplants" }, { "B17", "Hanging Lanterns" }, { "M1", "Midnight Light Accessories" }, { "M2", "Forefront Household Products" }, { "C10", "The Little Mermaid" }, { "C11", "Country Cottage" }, { "C12", "Ribbons 'n' Things" }, { "C13", "Antiques from Antiquity" }, { "C14", "Here and Now" }, { "C15", "Furnishings from Yore" }, { "C16", "Smith's Antiques" }, { "C17", "Helen's Housewares" }, { "D10", "Dogs & Cats" }, { "D11", "The Fudge Factory" }, { "D12", "Jewelry and Gifts Galore" }, { "D13", "Games, games, games" }, { "D14", "Cotton Press" }, { "D15", "Rat's Nest Antiques" }, { "D16", "Curios" }, { "D17", "At Last The End" } }; // column names after columns are swapped static String[] columnNames = { "Company", "Booth"}; /* Static block to sort the data by name and interchange the columns. */ static { // sort the rows for (int row = 0; row < data.length; row++) { int smallest = row; for (int r = row + 1; r < data.length; r++) { if ((data[smallest][1]).compareTo(data[r][1]) > 0) { smallest = r; } } if (smallest > row) { String tmpBooth = data[row][0]; String tmpName = data[row][1]; data[row][0] = data[smallest][0]; data[row][1] = data[smallest][1]; data[smallest][0] = tmpBooth; data[smallest][1] = tmpName; } } // swap the columns for (int row = 0; row < data.length; row++) { String tmpBooth = data[row][0]; data[row][0] = data[row][1]; data[row][1] = tmpBooth; } } public ShowData() { super(); } public int getRowCount() { return data.length; } public int getColumnCount() { return data[0].length; } public Object getValueAt (int row, int col) { return data[row][col]; } public String getColumnName (int columnIndex) { return columnNames[columnIndex]; } public Class getColumnClass (int columnIndex) { return data[0][columnIndex].getClass(); } public boolean isCellEditable (int rowIndex, int columnIndex) { return false; } public void setValueAt (Object value, int rowIndex, int columnIndex) { } /* Fires events to populate the table and diagram. */ public void startShowDemo() { fireTableStructureChanged(); fireTableDataChanged(); } }