Indice de Foros
Foro Cartesia
Geomática y Topografía 
  Cartesia · Crea tu Blog · Cursos · Contacta · Publicidad   · Cartesia twitter ·
 Avanzada
 Indice  FAQFAQ  Registrarse EntrarEntrar 


[Kosmo] R: Resumen de Kosmo, Vol 24, Envío 37 (Extending the drawPolygon tool)   
Publicar nuevo tema   Responder al tema    Indice de Foros -> SIG y Cartografía
Tema Anterior :: Tema siguiente  
Autor Mensaje
sbcalvo



Registrado: 10 Abr 2007
Mensajes: 224

MensajePublicado: Lun 28 Abr 2008, 11:42    Asunto: [Kosmo] R: Resumen de Kosmo, Vol 24, Envío 37 (Extending the Responder citando

Good morning again, Giovanni.

You should add them to the DisegnaPoligonoExtension install method:

public void install( PlugInContext context ) throws Exception {

DelegatingTool delPolygonTool = (DelegatingTool) MyCursorTool.create(context.getWorkbenchContext());
drawPolygonTool = (MyCursorTool) delPolygonTool.getDelegate();
context.getWorkbenchFrame().getToolBar().addCursorTool(drawPolygonTool.getName(),
delPolygonTool, MyCursorTool.createEnableCheck(context.getWorkbenchContext(),drawPolygonTool));

}

Regards,

Giovanni Virdis escribió:
> I have created the following class:
>
> public class DisegnaPoligono extends DrawPolygonTool {
>
> /** Nome Plugin */
> public final static String NAME = "Nuovo Poligono";
>
> /** Icona Plugin */
> public final static Icon ICON = IconLoader.icon("DrawPolygon.gif");
>
> public String getName() {
> return NAME;
> }
>
> public Icon getIcon() {
> return ICON;
> }
>
> protected DisegnaPoligono(FeatureDrawingUtil featureDrawingUtil)
> {
> super(featureDrawingUtil);
> }
>
> public static CursorTool create( LayerNamePanelProxy layerNamePanelProxy )
> {
> FeatureDrawingUtil featureDrawingUtil = new FeatureDrawingUtil(layerNamePanelProxy);
> return featureDrawingUtil.prepare(new DisegnaPoligono(featureDrawingUtil), true);
> }
>
> protected void gestureFinished() throws Exception
> {
> reportNothingToUndoYet();
>
> String message =createEnableCheck(getWorkbench().getContext(),this).check(null);
>
> if(message != null)
> {
> getWorkbench().getFrame().warnUser(message);
> return;
> }
>
> if (!checkPolygon()) {
> return;
> }
>
> // Here an add edit transaction is created, you can get the drawed polygon with the method getPolygon()
> featureDrawingUtil.drawRing(getPolygon(),isRollingBackInvalidEdits(), this, getPanel());
>
> // If you want to open a custom dialog or something else, change the previous line and open your dialog
> // After that, if the dialog has finished correctly, add your feature to the editable layer.
> }
>
>
> }
>
> where I put the code lines that you have sended me
>
> " DelegatingTool delPolygonTool = (DelegatingTool)
> MyCursorTool.create(toolbox.getContext());
> drawPolygonTool = (MyCursorTool) delPolygonTool.getDelegate();
> context.getWorkbenchFrame().getToolBar().addCursorTool(drawPolygonTool.getName(),
> delPolygonTool,
>
> MyCursorTool.createEnableCheck(context.getWorkbenchContext(),drawPolygonTool));"
>
> to associate the button to the toolbar
>
>
>
>
> Message: 3
> Date: Mon, 28 Apr 2008 11:54:18 +0200
> From: Sergio Baños Calvo <sbc en saig.es>
> Subject: Re: [Kosmo] R: Resumen de Kosmo, Vol 24, Envío 31 (Extending
> the drawPolygon tool)
> To: Lista de Kosmo <kosmo en saig.es>
> Message-ID: <48159ECA.6030702 en saig.es>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Good morning Giovanni.
>
> I think there is a concept that should be clarified:
>
> PlugIns -> Menu items and toolbar buttons that executes an action
> Tools -> Activates a cursor with an associated funcionality
>
> In the example that you sent the two concepts are mixed in one. The
> functionality that you're trying to develop uses a cursor to draw the
> polygon, so a tool should be used. You should change your code and
> redefine only the methods getName() and getIcon() (to use the ones that
> you have indicated) and the gestureFinished() and create() methods:
>
> public static CursorTool create( LayerNamePanelProxy
> layerNamePanelProxy ) {
> FeatureDrawingUtil featureDrawingUtil = new
> FeatureDrawingUtil(layerNamePanelProxy);
>
> return featureDrawingUtil.prepare(new
> MyCursorTool(featureDrawingUtil), true);
> }
>
> protected void gestureFinished() throws Exception {
> reportNothingToUndoYet();
>
> String message =
> createEnableCheck(getWorkbench().getContext(),this).check(null);
>
> if(message != null)
> {
> getWorkbench().getFrame().warnUser(message);
> return;
> }
>
> if (!checkPolygon()) {
> return;
> }
>
> // Here an add edit transaction is created, you can get the
> drawed polygon with the method getPolygon()
> featureDrawingUtil.drawRing(getPolygon(),
> isRollingBackInvalidEdits(), this, getPanel());
>
> // If you want to open a custom dialog or something else, change
> the previous line and open your dialog
> // After that, if the dialog has finished correctly, add your
> feature to the editable layer.
> }
>
> Your class must only extend the DrawPolygonTool class and must no
> implement PlugIn.
>
> In order to add the tool to the main toolbar, use this:
>
> DelegatingTool delPolygonTool = (DelegatingTool)
> MyCursorTool.create(toolbox.getContext());
> drawPolygonTool = (MyCursorTool) delPolygonTool.getDelegate();
> context.getWorkbenchFrame().getToolBar().addCursorTool(drawPolygonTool.getName(),
> delPolygonTool,
>
> MyCursorTool.createEnableCheck(context.getWorkbenchContext(),drawPolygonTool));
>
> Hope this helps.
>
> Regards,
>
> _______________________________________________
> Kosmo mailing list
> Kosmo en saig.es
> http://lists.saig.es/mailman/listinfo/kosmo
>
>

--

Sergio Baños Calvo

Jefe de desarrollos
Sistemas Abiertos de Información Geográfica, S.L. (SAIG S.L.)
Tlfno. móvil: 685005960
Tlfno. fijo: (+34) 954788876

E-mail: sbc en saig.es

_______________________________________________
Kosmo mailing list
Kosmo en saig.es
http://lists.saig.es/mailman/listinfo/kosmo
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mostrar mensajes de anteriores:   

Temas similares
Tema Autor Foro Respuestas Ultimo Mensaje
No hay mensajes nuevos [Kosmo] R: Resumen de Kosmo, Vol 24, ... sbcalvo SIG y Cartografía 0 Lun 28 Abr 2008, 10:55 Ver último mensaje
sbcalvo
No hay mensajes nuevos [Kosmo] R: Resumen de Kosmo, Vol 25, ... sbcalvo SIG y Cartografía 0 Jue 08 May 2008, 07:55 Ver último mensaje
sbcalvo
No hay mensajes nuevos [Kosmo] Resumen de Kosmo, Vol 18, En... sbcalvo SIG y Cartografía 0 Mar 16 Oct 2007, 12:08 Ver último mensaje
sbcalvo
No hay mensajes nuevos [Kosmo] R: Resumen de Kosmo, Vol 25, ... sbcalvo SIG y Cartografía 0 Mar 06 May 2008, 13:21 Ver último mensaje
Invitado
No hay mensajes nuevos [Kosmo] R: Resumen de Kosmo, Vol 24, ... g.virdis SIG y Cartografía 0 Lun 28 Abr 2008, 11:36 Ver último mensaje
Invitado
No hay mensajes nuevos [Kosmo] Resumen de Kosmo, Vol 23, En... moxdata SIG y Cartografía 0 Sab 29 Mar 2008, 18:16 Ver último mensaje
moxdata
No hay mensajes nuevos [Kosmo] Resumen de Kosmo, Vol 16, En... alidesjunior SIG y Cartografía 0 Vie 24 Ago 2007, 16:41 Ver último mensaje
Invitado
No hay mensajes nuevos [Kosmo] R: Resumen de Kosmo, Vol 24, ... Invitado SIG y Cartografía 1 Mar 29 Abr 2008, 10:12 Ver último mensaje
sbcalvo

Publicar nuevo tema   Responder al tema    Indice de Foros -> SIG y Cartografía Todas las horas son CET (Europa)
Página 1 de 1

 
Cambiar a:  
Puede publicar nuevos temas en este foro
No puede responder a temas en este foro
No puede editar sus mensajes en este foro
No puede borrar sus mensajes en este foro
No puede votar en encuestas en este foro
No puede adjuntar archivos en este foro
No Puede descargar archivos de este foro


Powered by Cartesia ©