1 /* -------------------------------------------------------------------
2 GeoVISTA Center (Penn State, Dept. of Geography)
3 Java source file for the class ShapeAffineTransform
4 Copyright (c), 2002, GeoVISTA Center
5 All Rights Reserved.
6 Original Author: Frank Hardisty
7 $Author: hardisty $
8 $Id: ShapeAffineTransform.java,v 1.2 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
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.app.map.*;
27
28 /***
29 * put your documentation comment here
30 */
31 public class ShapeAffineTransform implements ShapeTransformer{
32
33 private Object[] inputDataSet;
34 private Object[] outputDataSet;
35 private Shape[] oldShapes;
36 private Shape[] newShapes;
37 private AffineTransform xForm;
38 private EventListenerList listenerList;
39
40 public ShapeAffineTransform() {
41 super();
42 xForm = new AffineTransform();
43 listenerList = new EventListenerList();
44 }
45
46 public Shape[] makeTransformedShapes (Shape[] shapes, AffineTransform xForm) {
47 Shape[] newShapes = new Shape[shapes.length];
48 for (int i = 0; i < shapes.length; i++) {
49 GeneralPath gp = (GeneralPath)shapes[i];
50 newShapes[i] = gp.createTransformedShape(xForm);
51 }
52 return newShapes;
53 }
54 //this.oldShapes = shapes;
55 //this.newShapes = this.transform(oldShapes);
56 //return this.transform(shapes);
57 //}
58 public Shape[] transform(Shape[] oldShapes){
59 Shape[] newShapes = new Shape[oldShapes.length];
60 //we have a problem here... the shapes created with this method
61 //are not independent of each other.
62 for (int i = 0; i < oldShapes.length; i++) {
63 //GeneralPath gp = (GeneralPath)oldShapes[i];
64 //GeneralPath gp2 = new GeneralPath();
65 //PathIterator pi = gp.getPathIterator(xForm);
66 //pi.currentSegment()
67 //gp2.append(gp,false);
68 //newShapes[i] = xForm.createTransformedShape(gp2);
69
70
71 newShapes[i] = xForm.createTransformedShape(oldShapes[i]);
72 //} else {
73 //newShapes[i] = xForm.createTransformedShape(oldShapes[i]);
74 //}
75 }
76 return newShapes;
77 }
78
79 public void setInputDataSet(Object[] inputDataSet) {
80 this.inputDataSet = inputDataSet;
81 }
82 public Object[] getInputDataSet() {
83 return this.inputDataSet;
84 }
85
86 public void setOutputDataSet(Object[] outputDataSet) {
87 this.outputDataSet = outputDataSet;
88 }
89 public Object[] getOutputDataSet() {
90 return this.outputDataSet;
91 }
92
93 public void setOldShapes(Shape[] oldShapes) {
94 this.oldShapes = oldShapes;
95
96 }
97 public Shape[] getOldShapes() {
98 return this.oldShapes;
99 }
100
101 public void setNewShapes(Shape[] newShapes) {
102 this.newShapes = newShapes;
103 }
104 public Shape[] getNewShapes() {
105 return this.newShapes;
106 }
107
108 public void setXForm(AffineTransform xForm) {
109 this.xForm = xForm;
110 }
111 public AffineTransform getXForm() {
112 return this.xForm;
113 }
114
115 public void setListenerList(EventListenerList listenerList) {
116 this.listenerList = listenerList;
117 }
118 public EventListenerList getListenerList() {
119 return this.listenerList;
120 }
121 /***
122 * implements ActionListener
123 */
124 public void addActionListener(ActionListener l) {
125 listenerList.add(ActionListener.class, l);
126 }
127
128 /***
129 * removes an ActionListener from the button
130 */
131 public void removeActionListener(ActionListener l) {
132 listenerList.remove(ActionListener.class, l);
133 }
134
135 /***
136 * Notify all listeners that have registered interest for
137 * notification on this event type. The event instance
138 * is lazily created using the parameters passed into
139 * the fire method.
140 * @see EventListenerList
141 */
142 protected void fireActionPerformed(String command) {
143 // Guaranteed to return a non-null array
144 Object[] listeners = listenerList.getListenerList();
145 ActionEvent e = null;
146 // Process the listeners last to first, notifying
147 // those that are interested in this event
148 for (int i = listeners.length - 2; i >= 0; i -= 2) {
149 if (listeners[i] == ActionListener.class) {
150 // Lazily create the event:
151 if (e == null) {
152 e = new ActionEvent(this,
153 ActionEvent.ACTION_PERFORMED,
154 command);
155 }
156 ((ActionListener)listeners[i + 1]).actionPerformed(e);
157 }
158 }
159 }
160
161 }
This page was automatically generated by Maven