Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] A question about the tool framework

One thing that we've been planning is to add code to the ViewportPainter class that watches the Map's blackboard and if features exist on the blackboard they will be drawn automatically. So what I'd like you to do is create a tool (like you said, a normal tool), that creates a feature (doesn't have to have any attributes, just a geometry) on the second click and adds the feature to the Map Blackboard and calls repaint().

Now there are two ways to handle the ViewportPainter.

1. The ViewportPainter can register itself as a listener on the Map's blackboard and keep track of the features that are added and removed 2. Each time it is called to repaint it can search the blackboard for features.

For each feature it can use the Drawing#drawFeature(...) method to draw the feature.

That'd be a great solution for uDig if you can develop on uDig itself. If you can't then you can use the DrawFeatureCommand to draw the feature on the ViewportPane. Zooming and panning is handled by the command.

If you elect to do the more complete change the you can look at the DrawFeatureCommand to see how to use the Drawing methods because they are poorly documented (blush).

Cheers,

Jesse

On 9-Mar-06, at 12:45 PM, Mark Presling wrote:

Hi All,

I need to create a tool for my RCP app that allows me to do the following:

1. Click on a point on a state highway. The system runs off and finds the closest exact point on the SH network to the click and returns
     the coords of that point (we have a whole subsystem doing
     linear<->spatial conversions for our linear network). A dot is
     rendered on the map at that point.
  2. Click on a second point on the same stretch of highway. The same
     thing happens as 1.
  3. After the second click, the system returns the geometry of that
     stretch of highway between the clicks.
  4. At this point I want to render a line on the map that represents
     that stretch of highway, effectively highlighting it.
  5. It does not have to do anything as fancy as the editing tools,
     it's really just a visual representation of what the user is
     selecting.

I have achieved this in testing using DrawShapeCommand's and it works well. However, I now need to deal with pan and zoom to reposition the rendered shapes.

At this point I figure that I should probably start using the editing tool framework as it already does this sort of thing with the PolygonTool.

So... my question is, how do I make a start with this. I have looked at the Polygon tool as an example, but it is pretty complex with all it's Behaviours and Activators. Is there an example tool that I can look at that has the capability to render points and lines on the map and move them in relation to pan/zoom actions?

Actually, I just found the examples for tool.coordinate and mapgraphic.coordinate. They seem to use a similar approach to what I have been doing with DrawShapeCommands, but they don't deal with pan/zoom either. How does this work? If the tool renders an Ellipse2D on the ViewPortGraphics and then you do a pan the Ellipse2D stays at the same point in image space. And then the CoordinateMapGraphic just renders some more shapes taken from the map blackboard. Am I missing something here? I had to actually reposition my dots manually with the use of a map listener. What does MapGraphic actually do?

Thanks. I hope my confusion hasn't rubbed off on my email!
Mark

--
This message has been scanned for viruses and dangerous
content by MailScanner, and is believed to be clean.

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



Back to the top