<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Hi.<br>
<br>
I suppose that you are loading this layer from a extension that is
installed in a gvSIG that is able to load the shape using the user
interface. Is it right?<br>
<br>
Regards,<br>
Jorge<br>
<br>
On 01/11/2011 10:20 PM, Claudio wrote:
<blockquote cite="mid:F3BAAB65-FC5A-4482-A717-5927AD83C97A@gmail.com"
type="cite">Dear list,
<div>I tried to load a simple layer (shape file) by code [1], but it
doesn't work...</div>
<div>someone can help me?</div>
<div>this is my extension code for the execute method:</div>
<div><br>
</div>
<div>......</div>
<div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><span
style="color: rgb(151, 19, 101);">public</span> <span
style="color: rgb(151, 19, 101);">void</span> execute(String
actionCommand) {</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(71, 144, 117);"><span
style="color: rgb(0, 0, 0);"><span class="Apple-tab-span"
style="white-space: pre;"> </span></span>// <span
style="color: rgb(144, 175, 200);">TODO</span> Auto-generated method
stub<span class="Apple-style-span" style="color: rgb(0, 0, 0);"><span
class="Apple-tab-span" style="white-space: pre;"> </span></span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><span
style="color: rgb(151, 19, 101);">try</span> {<span
class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><span
class="Apple-tab-span" style="white-space: pre;"></span>View v =
(View) PluginServices.getMDIManager().getActiveWindow();</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">MapControl
mapCtrl = v.getMapControl();</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">String
layerName = actionCommand;</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">VectorialFileDriver
driver = (VectorialFileDriver) LayerFactory.getDM().getDriver(<span
style="color: rgb(73, 45, 246);">"gvSIG shp driver"</span>);<span
class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">FLayer
prova = LayerFactory.createLayer(layerName, driver, <span
style="color: rgb(151, 19, 101);">new</span> File (<span
style="color: rgb(73, 45, 246);">"/Users/claudio/prova.shp"</span>), CRSFactory.getCRS(<span
style="color: rgb(73, 45, 246);">"EPSG:3003"</span>));</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">prova.setVisible(<span
style="color: rgb(151, 19, 101);">true</span>);</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">mapCtrl.getMapContext().getLayers().addLayer(prova);</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">}</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><span
style="color: rgb(151, 19, 101);">catch</span> (DriverLoadException e)
{</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(71, 144, 117);">//
<span style="color: rgb(144, 175, 200);">TODO</span> Auto-generated
catch block</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">e.printStackTrace();</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">} <span
class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><span
class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><br>
</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><span
class="Apple-style-span"
style="font-family: Helvetica; font-size: medium;">and this is the
eclipse console error message:</span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;"><br>
</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(20, 21, 141);"><span
style="color: rgb(0, 0, 0);">ERROR [AWT-EventQueue-1] (</span><span
style="text-decoration: underline;">BaseException.java:53</span><span
style="color: rgb(0, 0, 0);">) - </span><span
style="text-decoration: underline;">com.hardcode.driverManager.DriverLoadException</span><span
style="color: rgb(0, 0, 0);">: formatString is null.</span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);">null</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);"><span
class="Apple-tab-span" style="white-space: pre;"> </span>at
com.hardcode.driverManager.DriverManager.getDriver(<span
style="text-decoration: underline; color: rgb(20, 21, 141);">DriverManager.java:170</span>)</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);">........</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);"><br>
</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);"><br>
</div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);"><span
class="Apple-style-span"
style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium;">Thanks
a lot for every reply,</span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);"><span
class="Apple-style-span"
style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium;">Claudio</span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);"><span
class="Apple-style-span"
style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium;"><br>
</span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);"><span
class="Apple-style-span"
style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium;">[1] <a
moz-do-not-send="true"
href="http://www.gvsig.org/web/docdev/manual-para-desarrolladores-gvsig/librerias-internas/ejemplos-de-uso-de-fmap/anadir-una-capa-por-codigo">http://www.gvsig.org/web/docdev/manual-para-desarrolladores-gvsig/librerias-internas/ejemplos-de-uso-de-fmap/anadir-una-capa-por-codigo</a></span></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; color: rgb(255, 27, 25);"><br>
</div>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Gvsig_internacional mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Gvsig_internacional@listserv.gva.es">Gvsig_internacional@listserv.gva.es</a>
<a class="moz-txt-link-freetext" href="http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional">http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Jorge Piera Llodrá
gvSIG Development Team
PRODEVELOP
Plaza Don Juan de Villarrasa, 14 - 5
46001 Valencia
Tel: +34 963510612
Fax: +34 963510908
e-mail: <a class="moz-txt-link-abbreviated" href="mailto:jpiera@prodevelop.es">jpiera@prodevelop.es</a>
<a class="moz-txt-link-freetext" href="http://www.prodevelop.es">http://www.prodevelop.es</a>
<a class="moz-txt-link-freetext" href="http://www.gvsig.org">http://www.gvsig.org</a>
</pre>
</body>
</html>