View Javadoc
1 /* ------------------------------------------------------------------- 2 GeoVISTA Center (Penn State, Dept. of Geography) 3 Java source file for the class ShapeFileToShape 4 Copyright (c), 2002, GeoVISTA Center 5 All Rights Reserved. 6 Original Author: Frank Hardisty 7 $Author: hardisty $ 8 $Id: ShapeFileToShape.java,v 1.4 2003/05/05 21:15:00 hardisty Exp $ 9 $Date: 2003/05/05 21:15:00 $ 10 Reference: Document no: 11 ___ ___ 12 ------------------------------------------------------------------- * 13 */ 14 15 16 package edu.psu.geovista.data.geog; 17 18 import javax.swing.*; 19 import javax.swing.event.*; 20 import java.awt.*; 21 import java.awt.event.*; 22 import java.awt.image.*; 23 import java.awt.geom.*; 24 import java.util.*; 25 import edu.psu.geovista.io.geog.*; 26 import edu.psu.geovista.ui.event.*; 27 28 29 /*** 30 * This class does nothing now and is slated for removal. 31 * All its functionality has been moved to ShapeFileDataReader 32 * 33 * This bean (used to) takes a shapefile and turns it into GeneralPath objects. 34 * Note that there is a loss of accuracy from double to float upon doing so. 35 */ 36 public class ShapeFileToShape implements ActionListener { 37 38 private transient DataSetForApps inputDataSetForApps; 39 private transient DataSetForApps outputDataSetForApps; 40 private transient EventListenerList listenerList; 41 42 43 44 public ShapeFileToShape() { 45 super(); 46 listenerList = new EventListenerList(); 47 } 48 49 50 51 52 public void setInputDataSetForApps(DataSetForApps inputDataSetForApps) { 53 if (inputDataSetForApps != null) { 54 this.inputDataSetForApps = inputDataSetForApps; 55 this.outputDataSetForApps = inputDataSetForApps; 56 this.fireActionPerformed("made shapes"); 57 this.fireDataSetChanged(this.outputDataSetForApps.getDataObjectOriginal()); 58 } 59 60 } 61 public DataSetForApps getInputDataSetForApps() { 62 return this.inputDataSetForApps; 63 } 64 65 public void setOutputDataSetForApps(DataSetForApps outputDataSetForApps) { 66 this.outputDataSetForApps = outputDataSetForApps; 67 } 68 public DataSetForApps getOutputDataSetForApps() { 69 return this.outputDataSetForApps; 70 } 71 public void setInputDataSet(Object[] inputDataSet) { 72 73 if (inputDataSet != null) { 74 this.inputDataSetForApps = new DataSetForApps(); 75 this.inputDataSetForApps.setDataObject(inputDataSet); 76 this.outputDataSetForApps = this.inputDataSetForApps; 77 78 this.fireActionPerformed("made shapes"); 79 this.fireDataSetChanged(this.outputDataSetForApps.getDataObjectOriginal()); 80 } 81 82 } 83 public Object[] getInputDataSet() { 84 return this.inputDataSetForApps.getDataObjectOriginal(); 85 } 86 87 public void setOutputDataSet(Object[] outputDataSet) { 88 //this.outputDataSet = outputDataSet; 89 } 90 public Object[] getOutputDataSet() { 91 return this.outputDataSetForApps.getDataObjectOriginal(); 92 } 93 94 95 public void setListenerList(EventListenerList listenerList) { 96 this.listenerList = listenerList; 97 } 98 public EventListenerList getListenerList() { 99 return this.listenerList; 100 } 101 102 public void actionPerformed (ActionEvent e) { 103 104 if (e.getSource() instanceof GeoData48States){ 105 GeoData48States data = (GeoData48States)e.getSource(); 106 this.setInputDataSet(data.getDataSet()); 107 } 108 } 109 110 /*** 111 * implements ActionListener 112 */ 113 public void addActionListener(ActionListener l) { 114 listenerList.add(ActionListener.class, l); 115 } 116 117 /*** 118 * removes an ActionListener from the button 119 */ 120 public void removeActionListener(ActionListener l) { 121 listenerList.remove(ActionListener.class, l); 122 } 123 124 /*** 125 * Notify all listeners that have registered interest for 126 * notification on this event type. The event instance 127 * is lazily created using the parameters passed into 128 * the fire method. 129 * @see EventListenerList 130 */ 131 protected void fireActionPerformed(String command) { 132 // Guaranteed to return a non-null array 133 Object[] listeners = listenerList.getListenerList(); 134 ActionEvent e = null; 135 // Process the listeners last to first, notifying 136 // those that are interested in this event 137 for (int i = listeners.length - 2; i >= 0; i -= 2) { 138 if (listeners[i] == ActionListener.class) { 139 // Lazily create the event: 140 if (e == null) { 141 e = new ActionEvent(this, 142 ActionEvent.ACTION_PERFORMED, 143 command); 144 } 145 ((ActionListener)listeners[i + 1]).actionPerformed(e); 146 } 147 } 148 } 149 /*** 150 * implements DataSetListener 151 */ 152 public void addDataSetListener(DataSetListener l) { 153 listenerList.add(DataSetListener.class, l); 154 } 155 156 /*** 157 * removes an DataSetListener from the button 158 */ 159 public void removeDataSetListener(DataSetListener l) { 160 listenerList.remove(DataSetListener.class, l); 161 } 162 163 /*** 164 * Notify all listeners that have registered interest for 165 * notification on this event type. The event instance 166 * is lazily created using the parameters passed into 167 * the fire method. 168 * @see EventListenerList 169 */ 170 protected void fireDataSetChanged(Object[] dataSet) { 171 //System.out.println("ShpToShp.fireDataSetChanged, Hi!!"); 172 // Guaranteed to return a non-null array 173 Object[] listeners = listenerList.getListenerList(); 174 DataSetEvent e = null; 175 // Process the listeners last to first, notifying 176 // those that are interested in this event 177 for (int i = listeners.length - 2; i >= 0; i -= 2) { 178 if (listeners[i] == DataSetListener.class) { 179 // Lazily create the event: 180 if (e == null) { 181 e = new DataSetEvent(this,dataSet); 182 183 } 184 ((DataSetListener)listeners[i + 1]).dataSetChanged(e); 185 } 186 } 187 } 188 }

This page was automatically generated by Maven