Oh I think I can explain.

You don't call the command; you add the command to the Map; and each time the 
map draws it will call your command (allowing the command to draw something on 
the screen).

When you are done with your visual feedback; you call command.setValid(false); 
and next time the map draws it will notice your command is no longer valid and 
stop using it.

-- 
Jody Garnett


On Saturday, 11 June 2011 at 12:52 AM, carlos henrique de souza junior wrote:

> 
> Good afternoon guys I was looking at the code of this page: 
> http://udig.refractions.net/confluence/display/DEV/Providing+Visual+Feedback+from+a+View
>  my doubts is when I call the command I have to draw MapGraphicContext pass 
> an object as I take this object on the map I'm working?
> 
> I'll paste the code down here
> 
> public void draw( MapGraphicContext context ) {
> 
>  //initialize the graphics handle
>  ViewportGraphics g = context.getGraphics();
>  g.setColor(Color.BLACK);
>  g.setStroke(ViewportGraphics.LINE_SOLID, 1);
> 
>  //get the map blackboard
>  IMap map = context.getLayer().getMap();
>  IBlackboard blackboard = map.getBlackboard();
> 
>  List<Coordinate> coordinates = (List<Coordinate>) blackboard.get("route");
> 
>  if (coordinates == null) {
>  return; //no coordinates to draw
>  }
> 
>  MathTransform data2world = CRS.findMathTransform( 
> DefaultGeographicCRS.WGS84, context.getCRS() );
> 
>  for (Coordinate coordinate : coordinates) {
>  Ellipse2D e = new Ellipse2D.Double(
>  coordinate.x-4,
>  coordinate.y-4,
>  10,10);
>  g.draw(e);
>  try {
>  Coordinate worldCoord = JTS.transform(coordinate, null, data2world );
>  Point point = context.worldToPixel(worldCoord);
>  g.drawOval( point.x-1, point.y-2, 3, 3);
>  } catch (TransformException e1) {
>  }
>  }
>  }
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel

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

Reply via email to