View Javadoc
1 /* ------------------------------------------------------------------- 2 GeoVISTA Center (Penn State, Dept. of Geography) 3 Java source file for the class GeoDataTestNulls 4 Copyright (c), 2002, GeoVISTA Center 5 All Rights Reserved. 6 Original Author: Frank Hardisty 7 $Author: hardisty $ 8 $Id: GeoDataTestNulls.java,v 1.1 2003/04/25 17:44:57 hardisty Exp $ 9 $Date: 2003/04/25 17:44:57 $ 10 Reference: Document no: 11 ___ ___ 12 ------------------------------------------------------------------- * 13 */ 14 15 16 package edu.psu.geovista.data.geog; 17 import java.awt.*; 18 import java.awt.event.*; 19 import javax.swing.event.*; 20 import edu.psu.geovista.io.geog.*; 21 import edu.psu.geovista.db.dbase.*; 22 import java.util.zip.*; 23 import edu.psu.geovista.io.csv.*; 24 25 import java.net.*; 26 import java.io.*; 27 28 /*** 29 * Reads shapefiles from included resources 30 * 31 * Object[0] = names of variables 32 * 0bject[1] = data (double[], int[], or String[]) 33 * 0bject[1] = data (double[], int[], or String[]) 34 * ... 35 * Object[n-1] = the shapefile data 36 * 37 * also see DBaseFile, ShapeFile 38 * 39 */ 40 public class GeoDataTestNulls { 41 42 public static final String COMMAND_DATA_SET_MADE = "dataMade"; 43 44 private transient DataSetForApps dataForApps; 45 private transient EventListenerList listenerList; 46 47 public GeoDataTestNulls() { 48 super(); 49 listenerList = new EventListenerList(); 50 this.dataForApps = this.makeDataSetForApps(); 51 this.fireActionPerformed(COMMAND_DATA_SET_MADE); 52 } 53 54 private DataSetForApps makeDataSetForApps(){ 55 Object[] shpData = null; 56 try { 57 58 Class cl = this.getClass(); 59 60 InputStream isCSV = cl.getResourceAsStream("resources/test_nulls.csv"); 61 GeogCSVReader csv = new GeogCSVReader(); 62 Object[] csvData = csv.readFile(isCSV); 63 64 shpData = new Object[csvData.length + 1]; 65 for (int i = 0; i < csvData.length; i++) { 66 shpData[i] = csvData[i]; 67 } 68 69 InputStream isSHP = cl.getResourceAsStream("resources/test_nulls.shp"); 70 shpData[csvData.length] = new ShapeFile(isSHP); 71 72 } catch (Exception ex) { 73 ex.printStackTrace(); 74 } 75 //this.fireActionPerformed(COMMAND_DATA_SET_MADE); 76 this.dataForApps = new DataSetForApps(); 77 dataForApps.setDataObject(shpData); 78 return dataForApps; 79 80 } 81 82 //private Object[] makeDataSet(String fileName){ 83 // this.makeDataSetForApps(fileName); 84 // return dataForApps.getDataObjectOriginal(); 85 //} 86 87 private String removeExtension(String fileName){ 88 String removed = fileName; 89 int index = fileName.lastIndexOf("."); 90 if (index > -1) { //if it was found 91 int len = fileName.length(); 92 removed = fileName.substring(0,index); 93 } 94 return removed; 95 } 96 97 public void setDataForApps (DataSetForApps dataForApps) { 98 this.dataForApps = dataForApps; 99 } 100 public DataSetForApps getDataForApps() { 101 return this.dataForApps; 102 } 103 104 public Object[] getDataSet() { 105 return this.dataForApps.getDataObjectOriginal(); 106 107 } 108 109 110 /*** 111 * implements ActionListener 112 */ 113 public void addActionListener(ActionListener l) { 114 listenerList.add(ActionListener.class, l); 115 this.fireActionPerformed(COMMAND_DATA_SET_MADE); 116 //System.out.println("GeoDataTestNulls.addActionListener, Hi!!"); 117 } 118 119 /*** 120 * removes an ActionListener from the button 121 */ 122 public void removeActionListener(ActionListener l) { 123 listenerList.remove(ActionListener.class, l); 124 } 125 126 /*** 127 * Notify all listeners that have registered interest for 128 * notification on this event type. The event instance 129 * is lazily created using the parameters passed into 130 * the fire method. 131 * @see EventListenerList 132 */ 133 protected void fireActionPerformed(String command) { 134 // Guaranteed to return a non-null array 135 Object[] listeners = listenerList.getListenerList(); 136 ActionEvent e = null; 137 // Process the listeners last to first, notifying 138 // those that are interested in this event 139 for (int i = listeners.length - 2; i >= 0; i -= 2) { 140 if (listeners[i] == ActionListener.class) { 141 // Lazily create the event: 142 if (e == null) { 143 e = new ActionEvent(this, 144 ActionEvent.ACTION_PERFORMED, 145 command); 146 } 147 ((ActionListener)listeners[i + 1]).actionPerformed(e); 148 } 149 } 150 } 151 public EventListenerList getListenerList() { 152 return listenerList; 153 } 154 public void setListenerList(EventListenerList listenerList) { 155 this.listenerList = listenerList; 156 } 157 158 }

This page was automatically generated by Maven