Hello, 

I am not sure how to do it with mapgraphic, so I craated a temporary layer 
containing lines and add it to the map like this:
(Probably is not the best way...)

// CREATE FEATURE TYPE FOR TEMP LAYER ( LINES IN THIS CASE)

                        // build feature type builder
                        SimpleFeatureTypeBuilder featureTypeBuilder = new 
SimpleFeatureTypeBuilder();
                        featureTypeBuilder.setNamespaceURI("http://localhost/";);
                        featureTypeBuilder.setCRS(DefaultGeographicCRS.WGS84);
                        // add attributes in order
                        featureTypeBuilder.add("Location", LineString.class);
                        featureTypeBuilder.add("ID", Integer.class);
                        featureTypeBuilder.add("Name", String.class);
                        // build the type for the feature with attributes above
                        featureTypeBuilder.setName("name");
                        SimpleFeatureType myFeatureType = 
featureTypeBuilder.buildFeatureType();

// CREATE FEATURE
                                GeometryFactory geometryFactory = 
JTSFactoryFinder
                                        .getGeometryFactory(null);

                                // Obtain coordinates for the path 
                                Coordinate[] coords=MYgetCoordinates();
                                if (coords!=null){
                                        // Create line String with the path 
from the coords list
                                        SimpleFeatureBuilder 
featureBuilder=null;
                                        featureBuilder = new 
SimpleFeatureBuilder(myFeatureType);
                                        LineString line = 
geometryFactory.createLineString(coords);
                                        
                                        // Create Feature containing the line 
string , add the attributes in order
                                        featureBuilder.add(line);
                                        featureBuilder.add(1);
                                        featureBuilder.add("name");
                                        SimpleFeature feature = 
featureBuilder.buildFeature("name");
                                                                                
                        
                                        
                                        FeatureStore fs 
=newGeoresource.resolve(FeatureStore.class, null);
                                        FeatureCollection features = 
FeatureCollections.newCollection();
                                        features.add(feature);
                                        fs.removeFeatures(Filter.INCLUDE);
                                        fs.addFeatures(features);
                                        return newGeoresource;
                                }

// ADD FEATURE TO TEMP LAYER

// Create temp layer (add data to the linear layer)
                IGeoResource newGeoresource = 
catalog.createTemporaryResource(myFeatureType);
FeatureStore fs =newGeoresource.resolve(FeatureStore.class, null);
                                        FeatureCollection features = 
FeatureCollections.newCollection();
                                        features.add(feature);
                                        fs.addFeatures(features);
                Layer layer= layerFactory.createLayer(newGeoresource);

// ADD LAYER TO UDIG....




________________________________________
De: [email protected] 
[[email protected]] En nombre de carlos henrique de 
souza junior [[email protected]]
Enviado el: martes, 05 de julio de 2011 19:45
Para: [email protected]
Asunto: Re: [udig-devel] draw in map

excuse the delay but I had no time to test what you said

I do not know what the best way, actually I'm still learning and messing with 
uDig mapgraphic was the first way I found to draw on the map

I will test it said
but if you can send me how you would do good, because any way to do this would 
be good for me already

Thank you very much

2011/6/29 
<[email protected]<mailto:[email protected]>>


------------------------------

Message: 4
Date: Wed, 29 Jun 2011 09:35:58 +0200
From: Joaqu?n Rodriguez-Guerra Urcelay 
<[email protected]<mailto:[email protected]>>
Subject: Re: [udig-devel] draw in map
To: User-friendly Desktop Internet GIS
       
<[email protected]<mailto:[email protected]>>
Message-ID:
       
<[email protected]<mailto:[email protected]>>
Content-Type: text/plain; charset="iso-8859-1"

Hello,

You can find some more info in this link too:
http://udig-devel.19327.n5.nabble.com/Drawing-lines-on-a-layer-from-a-ViewPart-td25563.html

I am intereseted in drawing lines over the map (I want them to move together 
with the map), and so far I have done this by creating a temporary layer with 
these lines...
I wonder if doing this with a mapgraphic instead would be more optimus, what do 
you think?

I guess I would just have to implement the draw method in a new  a class 
implementing mapgraphic (similar to the one in 
http://udig.refractions.net/confluence/display/DEV/Providing+Visual+Feedback+from+a+View,
 or like the AnimationMapGraphic class in the tutorials plugin). And then add 
that mapgraphic to my map, but how?? I have read several posts where you say:

"A MapGraphic is a normal layer - just one that happens not to have any
data :-) You add it like a normal layer; I think the wiki has some
examples of sending an addLayer command? I don't have the code in front
of me right now so you will have to check."

Would it be as easy as running?

map.sendCommandASync(new AddLayerCommand((Layer) new AnimationMapGraphic()));

Thanks,

Joaqu?n
________________________________________
De: 
[email protected]<mailto:[email protected]>
 
[[email protected]<mailto:[email protected]>]
 En nombre de carlos henrique de souza junior 
[[email protected]<mailto:[email protected]>]
Enviado el: martes, 28 de junio de 2011 21:54
Para: [email protected]<mailto:[email protected]>
Asunto: Re: [udig-devel] draw in map

Hi guys
the knowledge that I have to come mapgraphic this link:
http://udig.refractions.net/confluence/display/DEV/Providing+Visual+Feedback+from+a+View

the problem is, the command asks for a draw in this class as a parameter 
MapGraphicContext

public void draw (MapGraphicContext context)

I've searched but not found how to get a MapGraphicContext to move to the draw

I've seen in some places qa idea is to join mapgraphic + tool
My plugin extends simpletool already, so as I join the mapgraphic?
gotta extend another class?


thanks for help guys


Send udig-devel mailing list submissions to
      
[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>

To subscribe or unsubscribe via the World Wide Web, visit
      http://lists.refractions.net/mailman/listinfo/udig-devel
or, via email, send a message with subject or body 'help' to
      
[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>

You can reach the person managing the list at
      
[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>

When replying, please edit your Subject line so it is more specific
than "Re: Contents of udig-devel digest..."


Today's Topics:

 1. Re: draw in map (carlos henrique de souza junior)


----------------------------------------------------------------------

Message: 1
Date: Mon, 27 Jun 2011 14:19:35 -0300
From: carlos henrique de souza junior 
<[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
Subject: Re: [udig-devel] draw in map
To: 
[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
Message-ID: 
<[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
Content-Type: text/plain; charset="iso-8859-1"

excuse the lack of knowledge but as I do that?
My difficulty is the code if you have a wonderful example
thanks




Date: Sun, 26 Jun 2011 20:25:26 +1000
From: Jody Garnett 
<[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
Subject: Re: [udig-devel] udig-devel Digest, Vol 92, Issue 34
To: User-friendly Desktop Internet GIS
     
<[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
Message-ID: 
<[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>
Content-Type: text/plain; charset="utf-8"

> Could you try out the "graph" plugin? It uses a relationship between a
tool and a map > graphic to show different routes when choosing the shortest
route...

> I see that the page you mention already describes this; it is just that
graph is a nicer > example.
--
Jody Garnett


On Sunday, 26 June 2011 at 12:14 PM, carlos henrique de souza junior wrote:

 >> I do not know or use the best mapgraphic not know how to "get" the
mapgraphic the map in order to draw him to call the function
> I saw how it works with this link
> (
http://udig.refractions.net/confluence/display/DEV/Providing+Visual+Feedback+from+a+View
)
> but not found anything talking about how to get the mapgraphic
> could help me with this please?
>
>
>  Date: Sun, 26 Jun 2011 09:46:27 +1000
>  From: Jody Garnett 
> <[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
>  
> (mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
)>
>  Subject: Re: [udig-devel] draw in map
>  To: User-friendly Desktop Internet GIS
> <[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
>  
> (mailto:[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
)>
>  Message-ID: 
> <[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
>  (mailto:
[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>)>
>  Content-Type: text/plain; charset="utf-8"
>
>  You may wish to use a "Mapgraphic" or decorator to display feedback on
the map that moves around with the map. The draw shape command is mostly
intended for visual feedback when using a tool. You can (if needed) update
the data that your draw shape command uses (your teste Line2D in this case)
so that the line is scaled as the map zoom changes. It is best to record
your positions as "coordinates" in this case; and use the viewport methods
to transform them into pixels as needed.
>
>  --
>  Jody Garnett
>
>
>  On Friday, 24 June 2011 at 1:41 AM, carlos henrique de souza junior
wrote:
>
> >
> > hello guys I'm trying to create a plugin to draw the map floor plan for
an irrigation system, but am having trouble with the fact of drawing lines
on the map because the drawings do not move together with the map.
> > For example if I give a map zoom increases the size but the design stays
the same size
> > this test is that when I give a click on the map it should draw a line
from the point you clicked:
> >
> >
> > Line2D teste = new Line2D.Double(new Double(e.x), new Double(e.y),e.x +
122, e.y + 15);
> >
> > DrawShapeCommand dF =
getContext().getDrawFactory().createDrawShapeCommand(teste,Color.BLUE);
> >
> > dF.setStroke(133333, 0);
> >
> > getContext().sendSyncCommand(dF);
> >
> >
> >
> > Anyone know why this desenhao not respond to command together with the
map?
> > _______________________________________________
> > User-friendly Desktop Internet GIS (uDig)
> > http://udig.refractions.net
> > http://lists.refractions.net/mailman/listinfo/udig-devel
>
>  -------------- next part --------------
>  An HTML attachment was scrubbed...
>  URL: <
http://lists.refractions.net/pipermail/udig-devel/attachments/20110626/7756914e/attachment-0001.html
>
>
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.refractions.net/pipermail/udig-devel/attachments/20110627/b9ebc478/attachment-0001.html>

------------------------------

_______________________________________________
udig-devel mailing list
[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>
http://lists.refractions.net/mailman/listinfo/udig-devel


End of udig-devel Digest, Vol 92, Issue 39
******************************************


______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.

______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.

______________________



------------------------------

_______________________________________________
udig-devel mailing list
[email protected]<mailto:[email protected]>
http://lists.refractions.net/mailman/listinfo/udig-devel


End of udig-devel Digest, Vol 92, Issue 46
******************************************


______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.

______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.

______________________

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to