Revision 103 org.gvsig.gazetteer/trunk/org.gvsig.gazetteer/org.gvsig.gazetteer.lib/src/main/java/org/gvsig/gazetteer/ui/showresults/ShowResultsDialogPanel.java

View differences:

ShowResultsDialogPanel.java
47 47
import javax.swing.JDialog;
48 48
import javax.swing.JPanel;
49 49

  
50
import org.gvsig.fmap.geom.primitive.Point;
50 51
import org.gvsig.gazetteer.GazetteerClient;
51 52
import org.gvsig.gazetteer.querys.Feature;
52 53
import org.gvsig.gazetteer.querys.GazetteerQuery;
53 54

  
54 55

  
55 56
/**
56
 * 
57
 * 
58
 * 
57
 *
58
 *
59
 *
59 60
 * @author Jorge Piera Llodra (piera_jor@gva.es)
60 61
 */
61 62
public class ShowResultsDialogPanel extends JPanel implements ActionListener {
......
72 73
	protected GazetteerQuery query = null;
73 74

  
74 75
	/**
75
	 * @param client 
76
	 * @param features 
77
	 * @param recordsByPage 
78
	 * @param translator 
76
	 * @param client
77
	 * @param features
78
	 * @param recordsByPage
79
	 * @param translator
79 80
	 */
80
	public ShowResultsDialogPanel(GazetteerClient client, Feature[] features, int recordsByPage, GazetteerQuery query) {        
81
	public ShowResultsDialogPanel(GazetteerClient client, Feature[] features, int recordsByPage, GazetteerQuery query) {
81 82
		this.client = client;
82 83
		this.currentPage = 1;
83 84
		this.recordsByPage = recordsByPage;
84 85
		this.query = query;
85
		initialize(client,features,recordsByPage);     
86
	} 
86
		initialize(client,features,recordsByPage);
87
	}
87 88

  
88 89
	/**
89
	 * 
90
	 * 
91
	 * 
92
	 * @param client 
93
	 * @param features 
94
	 * @param recordsByPage 
90
	 *
91
	 *
92
	 *
93
	 * @param client
94
	 * @param features
95
	 * @param recordsByPage
95 96
	 */
96
	public void initialize(GazetteerClient client, Feature[] features, int recordsByPage) {        
97
	public void initialize(GazetteerClient client, Feature[] features, int recordsByPage) {
97 98
		this.featuresLength = features.length;
98 99
		this.currentPage = 1;
99 100
		this.recordsByPage = recordsByPage;
......
101 102
		setDefaultButtonListeners();
102 103

  
103 104
		add(ppalPanel);
104
	} 
105
	}
105 106

  
106 107
	/**
107
	 * 
108
	 * 
108
	 *
109
	 *
109 110
	 */
110
	private void setDefaultButtonListeners() {        
111
	private void setDefaultButtonListeners() {
111 112
		nextButton = ppalPanel.getNextButton();
112 113
		lastButton = ppalPanel.getLastButton();
113 114
		mapButton = ppalPanel.getMapButton();
......
117 118
		lastButton.addActionListener(this);
118 119
		mapButton.addActionListener(this);
119 120
		closeButton.addActionListener(this);
120
	} 
121
	}
121 122

  
122 123
	/**
123
	 * 
124
	 * 
125
	 * 
126
	 * @param e 
124
	 *
125
	 *
126
	 *
127
	 * @param e
127 128
	 */
128
	public void actionPerformed(ActionEvent e) {        
129
	public void actionPerformed(ActionEvent e) {
129 130
		if (e.getActionCommand().equals("next")) {
130 131
			nextButtonActionPerformed();
131
		} 
132
		}
132 133
		if (e.getActionCommand().equals("last")) {
133 134
			lastButtonActionPerformed();
134
		} 
135
		}
135 136
		if (e.getActionCommand().equals("localize")) {
136 137
			loadButtonActionPerformed();
137
		} 
138
		}
138 139
		if (e.getActionCommand().equals("close")) {
139 140
			closeButtonActionPerformed();
140 141
		}
141 142

  
142
	} 
143
	}
143 144

  
144 145
	/**
145
	 * 
146
	 * 
147
	 * 
148
	 * @return 
146
	 *
147
	 *
148
	 *
149
	 * @return
149 150
	 */
150
	private int getNumPages() {        
151
	private int getNumPages() {
151 152
		if ((featuresLength % recordsByPage) == 0)
152 153
			return featuresLength/recordsByPage;
153 154
		return (featuresLength/recordsByPage) + 1;
154
	} 
155
	}
155 156

  
156 157
	/**
157
	 * 
158
	 * 
158
	 *
159
	 *
159 160
	 */
160
	public void nextButtonActionPerformed() {        
161
	public void nextButtonActionPerformed() {
161 162
		this.currentPage = this.currentPage + 1;
162 163

  
163 164
		if (this.currentPage == getNumPages()) {
......
169 170
		ppalPanel.actualizaLabel(currentPage,recordsByPage);
170 171

  
171 172

  
172
	} 
173
	}
173 174

  
174 175
	/**
175
	 * 
176
	 * 
176
	 *
177
	 *
177 178
	 */
178
	public void lastButtonActionPerformed() {        
179
	public void lastButtonActionPerformed() {
179 180
		this.currentPage = this.currentPage - 1;
180 181
		if (this.currentPage == 1) {
181 182
			lastButton.setEnabled(false);
......
187 188
		ppalPanel.actualizaLabel(currentPage,recordsByPage);
188 189

  
189 190

  
190
	} 
191
	}
191 192

  
192 193
	/**
193
	 * 
194
	 * 
194
	 *
195
	 *
195 196
	 */
196
	public void loadButtonActionPerformed() {        
197
	public void loadButtonActionPerformed() {
197 198
		Feature feature = ppalPanel.getFeature();
198 199

  
199 200
		if (feature != null){
200 201
			System.out.println("ID: " + feature.getId());
201 202
			System.out.println("NAME: " + feature.getName());
202 203
			System.out.println("DESCRIPTION: " + feature.getDescription());
203
			System.out.println("COORDINATES: X=" + feature.getCoordinates().getX() + " Y=" + feature.getCoordinates().getY());
204
			Point point = feature.getCoordinates();
205
            if (point != null) {
206
                System.out.println(
207
                    "COORDINATES: X=" + point.getX() + " Y=" + point.getY());
208
            }
204 209
		}
205
	} 
210
	}
206 211

  
207 212
	/**
208
	 * 
209
	 * 
213
	 *
214
	 *
210 215
	 */
211
	public void closeButtonActionPerformed() {        
216
	public void closeButtonActionPerformed() {
212 217
		parent.setVisible(false);
213
	} 
218
	}
214 219

  
215 220
	/**
216
	 * 
217
	 * 
218
	 * 
221
	 *
222
	 *
223
	 *
219 224
	 * @param parent The parent to set.
220 225
	 */
221
	public void setParent(JDialog parent) {        
226
	public void setParent(JDialog parent) {
222 227
		this.parent = parent;
223
	} 
228
	}
224 229
}

Also available in: Unified diff