Revision 2422 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/MapOverview.java
MapOverview.java | ||
---|---|---|
58 | 58 |
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener; |
59 | 59 |
|
60 | 60 |
import java.awt.Color; |
61 |
import java.awt.Cursor; |
|
61 | 62 |
import java.awt.Graphics; |
62 | 63 |
import java.awt.Graphics2D; |
63 | 64 |
import java.awt.geom.AffineTransform; |
... | ... | |
120 | 121 |
*/ |
121 | 122 |
public void refreshExtent() { |
122 | 123 |
try { |
124 |
if (this.getMapContext().getFullExtent()!=null){ |
|
123 | 125 |
this.getMapContext().getViewPort().setExtent(this.getMapContext().getFullExtent()); |
124 |
} catch (DriverException e1) { |
|
125 |
e1.printStackTrace(); |
|
126 |
} |
|
126 |
}else{ |
|
127 |
delModel(); |
|
128 |
} |
|
129 |
} catch (DriverException e1) { |
|
130 |
e1.printStackTrace(); |
|
131 |
} |
|
127 | 132 |
} |
128 | 133 |
|
129 | 134 |
/* (non-Javadoc) |
... | ... | |
131 | 136 |
*/ |
132 | 137 |
protected void paintComponent(Graphics g) { |
133 | 138 |
super.paintComponent(g); |
139 |
if ((m_MapAssoc.getMapContext().getViewPort().getExtent() != null) && |
|
140 |
(getMapContext().getViewPort().getExtent() != null)) { |
|
141 |
if (first) { |
|
142 |
first = false; |
|
143 |
repaint(); |
|
134 | 144 |
|
135 |
if ((m_MapAssoc.getMapContext().getViewPort().getExtent() != null) && |
|
136 |
(getMapContext().getViewPort().getExtent() != null)) { |
|
137 |
if (first) { |
|
138 |
first = false; |
|
139 |
repaint(); |
|
145 |
return; |
|
146 |
} else { |
|
147 |
first = true; |
|
148 |
} |
|
140 | 149 |
|
141 |
return; |
|
142 |
} else { |
|
143 |
first = true; |
|
144 |
} |
|
150 |
ViewPort vp = getMapContext().getViewPort(); |
|
151 |
ViewPort vpOrig = m_MapAssoc.getMapContext().getViewPort(); |
|
152 |
Graphics2D g2 = (Graphics2D) g; |
|
153 |
g2.setColor(Color.black); |
|
154 |
g2.setXORMode(Color.white); |
|
145 | 155 |
|
146 |
ViewPort vp = getMapContext().getViewPort(); |
|
147 |
ViewPort vpOrig = m_MapAssoc.getMapContext().getViewPort(); |
|
148 |
Graphics2D g2 = (Graphics2D) g; |
|
149 |
g2.setColor(Color.black); |
|
150 |
g2.setXORMode(Color.white); |
|
156 |
// Dibujamos el extent del mapa asociado. |
|
157 |
g2.setTransform(vp.getAffineTransform()); |
|
151 | 158 |
|
152 |
// Dibujamos el extent del mapa asociado. |
|
153 |
g2.setTransform(vp.getAffineTransform()); |
|
159 |
g2.fill(vpOrig.getAdjustedExtent()); |
|
160 |
// dibujamos las l?neas vertical y horizontal |
|
161 |
Point2D pRightUp = vp.toMapPoint(getWidth(), 0); |
|
162 |
Line2D.Double linVert = new Line2D.Double(vpOrig.getExtent() |
|
163 |
.getCenterX(), |
|
164 |
vp.getExtent().getMinY(), vpOrig.getExtent().getCenterX(), |
|
165 |
pRightUp.getY()); |
|
166 |
Line2D.Double linHoriz = new Line2D.Double(vp.getExtent().getMinX(), |
|
167 |
vpOrig.getExtent().getCenterY(), pRightUp.getX(), |
|
168 |
vpOrig.getExtent().getCenterY()); |
|
154 | 169 |
|
155 |
g2.fill(vpOrig.getAdjustedExtent()); |
|
156 |
// dibujamos las l?neas vertical y horizontal |
|
157 |
Point2D pRightUp = vp.toMapPoint(getWidth(), 0); |
|
158 |
Line2D.Double linVert = new Line2D.Double(vpOrig.getExtent() |
|
159 |
.getCenterX(), |
|
160 |
vp.getExtent().getMinY(), vpOrig.getExtent().getCenterX(), |
|
161 |
pRightUp.getY()); |
|
162 |
Line2D.Double linHoriz = new Line2D.Double(vp.getExtent().getMinX(), |
|
163 |
vpOrig.getExtent().getCenterY(), pRightUp.getX(), |
|
164 |
vpOrig.getExtent().getCenterY()); |
|
170 |
g2.draw(linVert); |
|
171 |
g2.draw(linHoriz); |
|
165 | 172 |
|
166 |
g2.draw(linVert); |
|
167 |
g2.draw(linHoriz); |
|
173 |
g2.setTransform(new AffineTransform()); |
|
168 | 174 |
|
169 |
g2.setTransform(new AffineTransform()); |
|
170 |
|
|
171 |
// System.out.println("Dibujo el extent " + m_MapAssoc.getExtent().toString()); |
|
172 |
} |
|
175 |
// System.out.println("Dibujo el extent " + m_MapAssoc.getExtent().toString()); |
|
176 |
} |
|
177 |
|
|
173 | 178 |
} |
174 | 179 |
|
175 | 180 |
/** |
... | ... | |
182 | 187 |
m_MapAssoc.getMapContext().getViewPort().addViewPortListener(this); |
183 | 188 |
getMapContext().getViewPort().addViewPortListener(this); |
184 | 189 |
} |
190 |
private void delModel(){ |
|
191 |
this.getMapContext().getViewPort().setExtent(null); |
|
192 |
m_MapAssoc.getMapContext().getViewPort().removeViewPortListener(this); |
|
193 |
getMapContext().getViewPort().removeViewPortListener(this); |
|
194 |
} |
|
185 | 195 |
|
186 | 196 |
/** |
187 | 197 |
* @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent) |
Also available in: Unified diff