Revision 20100 branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/MapOverview.java

View differences:

MapOverview.java
76 76

  
77 77

  
78 78
/**
79
 * DOCUMENT ME!
79
 * <p>Lightweight <code>MapControl</code> that uses another <code>MapControl</code>'s <code>MapContext</code>, and updates
80
 *  any rectangular extent selected, to the associated <code>MapControl</code>.</p>
81
 *  
82
 * <p>Both <code>MapControl</code> instances work in the same projection. And, always, the not undefined <i>adjusted extent</i>
83
 *  of the associated one, will be enhanced as a red-bordered grey-filled rectangle in this one. Furthermore, draws a horizontal and vertical
84
 *  this component's width or height, black lines centered in that rectangle.</p>
80 85
 *
81
 * @author FJP TODO To change the template for this generated type comment go
82
 * 		   to Window - Preferences - Java - Code Generation - Code and
83
 * 		   Comments
86
 * @author FJP
84 87
 */
85 88
public class MapOverview extends MapControl implements ViewPortListener {
89
	/**
90
	 * <p>Associated <code>MapControl</code> instance that this component represents its overview.</p>
91
	 */
86 92
	private MapControl m_MapAssoc;
93
	
94
	/**
95
	 * <p>Determines that's the first time this component is going to be painted.</p>
96
	 */
87 97
	boolean first = true;
98

  
99
	/**
100
	 * <p>Tool listener used to apply a <i>zoom out</i> operation in this component graphical information.</p>
101
	 */
88 102
	private MapOverviewListener movl;
103
	
104
	/**
105
	 * <p>Tool listener used to allow user work with this component applying <i>pan</i> operations.</p>
106
	 */
89 107
	private MapOverviewPanListener movpl;
108
	
109
	/**
110
	 * <p>Tool listener used to apply a <i>zoom in</i> operation in this component graphical information.</p>
111
	 */
90 112
	private MapOverviewChangeZoomListener movczl;
113
	
114
	/**
115
	 * <p>Rectangular area selected in this component, that will be the extent of the associated <code>MapControl</code> instance.</p>
116
	 */
91 117
	private Rectangle2D extent;
118
	
119
	/**
120
	 * <p>Double buffer used to paint this component graphical information.</p>
121
	 */
92 122
	private BufferedImage image;
93 123

  
94 124
	/**
95
	 * Crea un nuevo MapOverview.
125
	 * <p>Creates a <code>MapOverview</code> instance associated to <code>mapAssoc</code>.</p>
96 126
	 *
97
	 * @param mapAssoc DOCUMENT ME!
127
	 * @param mapAssoc <code>MapControl</code> this component will be the overview
98 128
	 */
99 129
	public MapOverview(MapControl mapAssoc) {
100 130
		super();
......
123 153
	}
124 154

  
125 155
	/**
126
	 * DOCUMENT ME!
127
	 *
128
	 * @return DOCUMENT ME!
156
	 * @see MapControl#getMapContext()
129 157
	 */
130 158
	public MapContext getAssociatedMapContext() {
131 159
		return m_MapAssoc.getMapContext();
132 160
	}
161

  
162
	/**
163
	 * <p>Gets the <code>MapControl</code> instance that wrappers.</p>
164
	 * 
165
	 * @return the <code>MapControl</code> instance that wrappers
166
	 */
133 167
	public MapControl getAssociatedMapControl(){
134 168
		return m_MapAssoc;
135 169
	}
136 170

  
137
	/* (non-Javadoc)
138
	 * @see com.iver.cit.opensig.gui.IMapExtentListener#extentChanged(java.awt.geom.Rectangle2D)
171
	/*
172
	 * (non-Javadoc)
173
	 * @see com.iver.cit.gvsig.fmap.ViewPortListener#extentChanged(com.iver.cit.gvsig.fmap.ExtentEvent)
139 174
	 */
140 175
	public void extentChanged(ExtentEvent evExtent) {
141 176
		// Nos llega el nuevo extent del FMap asociado, as? que dibujamos nuestro
......
144 179
	}
145 180

  
146 181
	/**
147
	 * Recalcula el extent a aplicar de las capas que estan a?adidas.
182
	 * <p>If this had no extent, calls {@link #delModel() #delModel()}, otherwise recalculates this
183
	 *  component's view port extent as the union of all extents of all layers of this map.</p>
148 184
	 */
149 185
	public void refreshExtent() {
150 186
		try {
......
157 193
			e1.printStackTrace();
158 194
		}
159 195
	}
196
	
197
	/**
198
	 * <p>Repaints this component updating its <i>extent</i>.</p>
199
	 * 
200
	 * @param r the new extent
201
	 */
160 202
	public void refreshOverView(Rectangle2D r){
161 203
		extent=r;
162 204
		repaint();
163 205
	}
164

  
206
	
207
	/**
208
	 * <p>Repaints this component updating its <i>extent</i>.</p>
209
	 * 
210
	 * @param r the new extent
211
	 */
165 212
	protected void paintComponent(Graphics g) {
166 213
		super.paintComponent(g);
167 214
			if ((m_MapAssoc.getMapContext().getViewPort().getExtent() != null) &&
......
209 256
	}
210 257

  
211 258
	/**
212
	 * DOCUMENT ME!
259
	 * <p>Sets a <code>MapContext</code> to this component, configuring it to manage view port events produced
260
	 *  in the associated <code>MapControl</code> and this one's view port.</p>
261
	 * 
262
	 * <p>This <code>MapContext</code>'s projection will be the same as the associated <code>MapControl</code>'s one.</p>
263
	 * 
264
	 * <p>Setting the model includes the following steps:
265
	 *  <ul>
266
	 *   <li><b>1.-</b> set <code>model</code> as the <code>MapContext</code> of <code>this</code>.</li>
267
	 *   <li><b>2.-</b> set as <code>model</code> projection, the associated <code>MapControl<code>'s projection.</li>
268
	 *   <li><b>3.-</b> set <code>this</code> as <i>view port</i> listener of the associated <code>MapControl</code>'s <i>view port</i>.</li>
269
	 *   <li><b>4.-</b> set <code>this</code> as <i>view port</i> listener of this <code>MapContext</code>'s <i>view port</i></li>
270
	 *  </ul>
271
	 * </p>
213 272
	 *
214
	 * @param model DOCUMENT ME!
273
	 * @param model data to set 
215 274
	 */
216 275
	public void setModel(MapContext model) {
217 276
		this.setMapContext(model);
......
219 278
		m_MapAssoc.getMapContext().getViewPort().addViewPortListener(this);
220 279
		getMapContext().getViewPort().addViewPortListener(this);
221 280
	}
281
	
282
	/**
283
	 * <p>Removes this component as listener of the the associated <code>MapControl</code> and this one's view port. Besides,
284
     *  removes the extent.</p>
285
	 */
222 286
	private void delModel(){
223 287
		this.getMapContext().getViewPort().setExtent(null);
224 288
		m_MapAssoc.getMapContext().getViewPort().removeViewPortListener(this);
225 289
		getMapContext().getViewPort().removeViewPortListener(this);
226 290
	}
227 291

  
228
	/**
292
	/*
293
	 * (non-Javadoc)
229 294
	 * @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent)
230 295
	 */
231 296
	public void backColorChanged(ColorEvent e) {
232 297
	}
233 298

  
299
	/**
300
	 * @see ViewPortListener#projectionChanged(ProjectionEvent)
301
	 *
302
	 * @see MapControl#setProjection(IProjection)
303
	 */
234 304
	public void projectionChanged(ProjectionEvent e) {
235 305
		super.setProjection(e.getNewProjection());
236 306

  
237 307
	}
238 308

  
309
	/**
310
	 * <p>Unimplemented.</p>
311
	 * 
312
	 * <p>Can't change the projection, because must be the same as the one of the
313
	 *  associated <code>MapControl</code> instance.</p>
314
	 */
239 315
	public void setProjection(IProjection proj) {
240 316
		//No permitimos cambiar la proyeccion
241 317
		//ya que debe ser la misma que la del

Also available in: Unified diff