svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / MapOverview.java @ 944
History | View | Annotate | Download (3.61 KB)
1 |
/*
|
---|---|
2 |
* Created on 21-jun-2004
|
3 |
*
|
4 |
* TODO To change the template for this generated file go to
|
5 |
* Window - Preferences - Java - Code Generation - Code and Comments
|
6 |
*/
|
7 |
package com.iver.cit.gvsig.gui; |
8 |
|
9 |
import com.iver.andami.PluginServices; |
10 |
|
11 |
import com.iver.cit.gvsig.ProjectExtension; |
12 |
import com.iver.cit.gvsig.fmap.ExtentEvent; |
13 |
import com.iver.cit.gvsig.fmap.ExtentListener; |
14 |
import com.iver.cit.gvsig.fmap.FMap; |
15 |
import com.iver.cit.gvsig.fmap.NewMapControl; |
16 |
import com.iver.cit.gvsig.fmap.ViewPort; |
17 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointMapTool; |
18 |
import com.iver.cit.gvsig.gui.toolListeners.MapOverviewListener; |
19 |
import com.iver.cit.gvsig.project.castor.ProjectView; |
20 |
|
21 |
import com.iver.utiles.XMLEntity; |
22 |
|
23 |
import java.awt.Color; |
24 |
import java.awt.Graphics; |
25 |
import java.awt.Graphics2D; |
26 |
import java.awt.geom.AffineTransform; |
27 |
import java.awt.geom.Line2D; |
28 |
import java.awt.geom.Point2D; |
29 |
|
30 |
import java.util.ArrayList; |
31 |
|
32 |
|
33 |
/**
|
34 |
* DOCUMENT ME!
|
35 |
*
|
36 |
* @author FJP TODO To change the template for this generated type comment go
|
37 |
* to Window - Preferences - Java - Code Generation - Code and
|
38 |
* Comments
|
39 |
*/
|
40 |
public class MapOverview extends NewMapControl implements ExtentListener { |
41 |
private NewMapControl m_MapAssoc;
|
42 |
|
43 |
/**
|
44 |
* Crea un nuevo MapOverview.
|
45 |
*
|
46 |
* @param mapAssoc DOCUMENT ME!
|
47 |
*/
|
48 |
public MapOverview(NewMapControl mapAssoc) {
|
49 |
super();
|
50 |
m_MapAssoc = mapAssoc; |
51 |
|
52 |
// setModel((FMap) m_MapAssoc.getMapContext().clone()); // Lo inicializamos con
|
53 |
// los mismos temas que tenga el grande.
|
54 |
addMapTool("zoomtopoint", new PointMapTool()); |
55 |
|
56 |
MapOverviewListener movl = new MapOverviewListener(this); |
57 |
setCursor(movl.getCursor()); |
58 |
addTool("zoomtopoint", "zoomtopoint", movl); |
59 |
|
60 |
setTool("zoomtopoint");
|
61 |
} |
62 |
|
63 |
/**
|
64 |
* DOCUMENT ME!
|
65 |
*
|
66 |
* @return DOCUMENT ME!
|
67 |
*/
|
68 |
public FMap getAssociatedMapContext() {
|
69 |
return m_MapAssoc.getMapContext();
|
70 |
} |
71 |
|
72 |
/* (non-Javadoc)
|
73 |
* @see com.iver.cit.opensig.gui.IMapExtentListener#extentChanged(java.awt.geom.Rectangle2D)
|
74 |
*/
|
75 |
public void extentChanged(ExtentEvent evExtent) { |
76 |
// Nos llega el nuevo extent del FMap asociado, as? que dibujamos nuestro
|
77 |
// rect?ngulo para mostrar la zona de dibujo del otro mapa.
|
78 |
repaint(); |
79 |
} |
80 |
|
81 |
/* (non-Javadoc)
|
82 |
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
|
83 |
*/
|
84 |
protected void paintComponent(Graphics g) { |
85 |
super.paintComponent(g);
|
86 |
|
87 |
if ((m_MapAssoc.getMapContext().getViewPort().getExtent() != null) && |
88 |
(getMapContext().getViewPort().getExtent() != null)) {
|
89 |
ViewPort vp = getMapContext().getViewPort(); |
90 |
ViewPort vpOrig = m_MapAssoc.getMapContext().getViewPort(); |
91 |
Graphics2D g2 = (Graphics2D) g; |
92 |
g2.setColor(Color.black);
|
93 |
g2.setXORMode(Color.white);
|
94 |
|
95 |
// Dibujamos el extent del mapa asociado.
|
96 |
g2.setTransform(vp.getAffineTransform()); |
97 |
g2.fill(vpOrig.getExtent()); |
98 |
|
99 |
// dibujamos las l?neas vertical y horizontal
|
100 |
Point2D pRightUp = vp.toMapPoint(getWidth(), 0); |
101 |
Line2D.Double linVert = new Line2D.Double(vpOrig.getExtent() |
102 |
.getCenterX(), |
103 |
vp.getExtent().getMinY(), vpOrig.getExtent().getCenterX(), |
104 |
pRightUp.getY()); |
105 |
Line2D.Double linHoriz = new Line2D.Double(vp.getExtent().getMinX(), |
106 |
vpOrig.getExtent().getCenterY(), pRightUp.getX(), |
107 |
vpOrig.getExtent().getCenterY()); |
108 |
|
109 |
g2.draw(linVert); |
110 |
g2.draw(linHoriz); |
111 |
|
112 |
g2.setTransform(new AffineTransform()); |
113 |
|
114 |
// System.out.println("Dibujo el extent " + m_MapAssoc.getExtent().toString());
|
115 |
} |
116 |
} |
117 |
|
118 |
/**
|
119 |
* DOCUMENT ME!
|
120 |
*
|
121 |
* @param model DOCUMENT ME!
|
122 |
*/
|
123 |
public void setModel(FMap model) { |
124 |
this.setMapContext(model);
|
125 |
m_MapAssoc.getMapContext().getViewPort().addExtentListener(this);
|
126 |
getMapContext().getViewPort().addExtentListener(this);
|
127 |
} |
128 |
} |