Revision 41811
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControlManager.java | ||
---|---|---|
53 | 53 |
import java.util.Map; |
54 | 54 |
import java.util.prefs.Preferences; |
55 | 55 |
|
56 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
56 | 57 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
57 | 58 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent; |
58 | 59 |
import org.gvsig.fmap.mapcontrol.tools.snapping.snappers.ISnapper; |
... | ... | |
74 | 75 |
*/ |
75 | 76 |
public interface MapControlManager { |
76 | 77 |
|
77 |
public MapControl createJMapControlPanel() throws MapControlCreationException; |
|
78 |
|
|
79 |
public void addMapControlCreationListener(MapControlCreationListener listener);
|
|
78 |
public MapControl createJMapControlPanel(MapContext mapContext) throws MapControlCreationException;
|
|
79 |
|
|
80 |
public void addMapControlCreationListener(MapControlCreationListener listener); |
|
80 | 81 |
|
81 | 82 |
/** |
82 | 83 |
* Register a <code>MapControlDrawer</code> by name. |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControl.java | ||
---|---|---|
594 | 594 |
* </p> |
595 | 595 |
*/ |
596 | 596 |
public MapControl() { |
597 |
this(new MapContext(new ViewPort(MapContextLocator.getMapContextManager().getDefaultCRS()))); |
|
598 |
} |
|
599 |
|
|
600 |
public MapControl(MapContext theMapContext) { |
|
597 | 601 |
this.setName("MapControl"); |
598 | 602 |
Toolkit toolkit = Toolkit.getDefaultToolkit(); |
599 | 603 |
Image imageTransparentCursor = toolkit.createImage(new MemoryImageSource(16, 16, new int[16 * 16], 0,16)); |
... | ... | |
607 | 611 |
// Clase usada para cancelar el dibujado |
608 | 612 |
canceldraw = new CancelDraw(); |
609 | 613 |
|
610 |
/* |
|
611 |
* We are not accessing the user preferences here. |
|
612 |
* This is an early initialization and is supposed |
|
613 |
* to be reset afterwards from a higher level (plugin) |
|
614 |
*/ |
|
615 |
MapContextManager mcm = MapContextLocator.getMapContextManager(); |
|
616 |
vp = new ViewPort(mcm.getDefaultCRS()); |
|
614 |
vp = theMapContext.getViewPort(); |
|
617 | 615 |
|
618 |
setMapContext(new MapContext(vp));
|
|
616 |
setMapContext(theMapContext);
|
|
619 | 617 |
|
620 | 618 |
// eventos |
621 | 619 |
this.addComponentListener(this); |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlManager.java | ||
---|---|---|
37 | 37 |
import java.util.Set; |
38 | 38 |
import java.util.prefs.Preferences; |
39 | 39 |
|
40 |
import org.slf4j.Logger; |
|
41 |
import org.slf4j.LoggerFactory; |
|
42 |
|
|
40 | 43 |
import org.gvsig.fmap.geom.Geometry; |
44 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
41 | 45 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
42 | 46 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
43 | 47 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
... | ... | |
54 | 58 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
55 | 59 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
56 | 60 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
57 |
import org.slf4j.Logger; |
|
58 |
import org.slf4j.LoggerFactory; |
|
59 | 61 |
|
60 | 62 |
/** |
61 | 63 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
... | ... | |
330 | 332 |
return prefs; |
331 | 333 |
} |
332 | 334 |
|
333 |
public MapControl createJMapControlPanel() throws MapControlCreationException { |
|
334 |
MapControl mapControl = new MapControl(); |
|
335 |
public MapControl createJMapControlPanel(MapContext mapContext) throws MapControlCreationException {
|
|
336 |
MapControl mapControl = new MapControl(mapContext);
|
|
335 | 337 |
mapControl.setMapControlDrawer(this.createDefaultMapControlDrawer()); |
336 | 338 |
for( MapControlCreationListener listener : this.mapControlCreationListeners ) { |
337 | 339 |
if( listener!=null ) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/gui/DefaultViewPanel.java | ||
---|---|---|
124 | 124 |
protected ResponseAdapter consoleResponseAdapter = new ResponseAdapter(); |
125 | 125 |
protected boolean isShowConsole = false; |
126 | 126 |
private ViewPortListener viewPortListener; |
127 |
|
|
127 | 128 |
private static MapControlManager mapControlManager = MapControlLocator |
128 | 129 |
.getMapControlManager(); |
129 | 130 |
|
... | ... | |
144 | 145 |
|
145 | 146 |
public DefaultViewPanel(Document document) { |
146 | 147 |
this(); |
147 |
this.initialize(); |
|
148 |
this.initialize(((ViewDocument)document).getMapContext());
|
|
148 | 149 |
this.setDocument(document); |
149 | 150 |
} |
150 | 151 |
|
... | ... | |
154 | 155 |
* <code>setWindowData(WindowData)</code> method, the window will be |
155 | 156 |
* populated according to this properties. |
156 | 157 |
*/ |
157 |
protected void initialize() { |
|
158 |
protected void initialize(MapContext mapContext) {
|
|
158 | 159 |
super.initialize(); |
159 |
initComponents(); |
|
160 |
initComponents(mapContext);
|
|
160 | 161 |
hideConsole(); |
161 | 162 |
getConsolePanel().addResponseListener(consoleResponseAdapter); |
162 | 163 |
} |
... | ... | |
183 | 184 |
} |
184 | 185 |
|
185 | 186 |
// Se configura el mapControl |
186 |
m_MapControl.setMapContext(fmap); |
|
187 | 187 |
m_TOC.setMapContext(fmap); |
188 | 188 |
m_MapControl.getMapContext().getLayers().addLegendListener(m_TOC); |
189 | 189 |
|
... | ... | |
339 | 339 |
|
340 | 340 |
} |
341 | 341 |
|
342 |
protected void initComponents() { // GEN-BEGIN:initComponents |
|
342 |
protected void initComponents(MapContext mapContext) { // GEN-BEGIN:initComponents
|
|
343 | 343 |
// Remember to activate it |
344 | 344 |
try { |
345 |
m_MapControl = mapControlManager.createJMapControlPanel(); |
|
345 |
m_MapControl = mapControlManager.createJMapControlPanel(mapContext);
|
|
346 | 346 |
m_MapControl.setMapControlDrawer(mapControlManager |
347 | 347 |
.createDefaultMapControlDrawer()); |
348 | 348 |
} catch (MapControlCreationException e) { |
... | ... | |
604 | 604 |
} |
605 | 605 |
} |
606 | 606 |
} |
607 |
|
|
607 |
|
|
608 | 608 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/WizardPanel.java | ||
---|---|---|
133 | 133 |
// for compatibility purposes |
134 | 134 |
MapControl mc; |
135 | 135 |
try { |
136 |
mc = MapControlLocator.getMapControlManager().createJMapControlPanel(); |
|
136 |
mc = MapControlLocator.getMapControlManager().createJMapControlPanel(mapContext);
|
|
137 | 137 |
} catch (MapControlCreationException ex) { |
138 | 138 |
logger.warn("Can't create a MapControl.", ex); |
139 | 139 |
throw new RuntimeException(ex); |
140 | 140 |
} |
141 |
mc.setMapContext(mapContext); |
|
142 | 141 |
mapCtrl=mc; |
143 | 142 |
} |
144 | 143 |
return mapCtrl; |
Also available in: Unified diff