Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Antwort: Re: [udig-devel] question concerning interface MapGraphic

version: 1.1 RC8
 
tony roth
-----udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx schrieb: -----

An: User-friendly Desktop Internet GIS <udig-devel@xxxxxxxxxxxxxxxxxxxxx>
Von: Jesse Eichar <jeichar@xxxxxxxxxxxxxxx>
Gesendet von: udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx
Datum: 18.07.2007 08:31PM
Thema: Re: [udig-devel] question concerning interface MapGraphic

Sounds like a bug to me.  I thought we had recently fixed one like this.  What version of uDig are you using?

Jesse

On Jul 18, 2007, at 7:48 AM, tony.roth@xxxxxx wrote:

Hi.
since some of my users want a red cross in the center of the map (don't ask why...) I implemented the class attached below. It is realized like the ScalebarMapGraphic and published via the extension point "net.refractions.udig.mapgraphic.mapgraphic".
The application gets a reference to the layer like done in AbstractToggleMapGraphicAction using the MapGraphicService.
The user can toggle on/off the scalebar and the cross with a checkbox in a viewpart. Each has its own checkbox. If the state of the checkbox changes, the visibility of the layer is set to the appropriate state and the layer is refreshed:
crossLayer.setVisible(checkboxState);
crossLayer.refresh(null);
If only one of both layers is visible it works fine. But if both are active I get the following behaviour:
scalebarLayer visible, crossLayer not visible -> visible: works (I can see both)
scalebarLayer visible, crossLayer visible -> not visible: nothing happens (the cross is still visible)
if I deactivate the scalebar both disappear. if I activate the scalebar again both appear (which is wrong) and then (after a second) the cross disappears.
the same happens if both are activated and I remove the scalebar:
crossLayer visible, scalebarLayer visible  -> not visible: nothing happens (the scalebar is still visible)
if I deactivate the cross both disappear
In MapGraphic is the hint to check the clip area of the Viewportgraphics object to determine what area needs to be refreshed. I cannot find a passage in ScalebarMapGraphic  where this is done.
Can someone help me with this? 
thanks,
tony roth
package foo.bar;
import java.awt.Color;
import java.awt.geom.GeneralPath;
import net.refractions.udig.mapgraphic.MapGraphic;
import net.refractions.udig.mapgraphic.MapGraphicContext;
import net.refractions.udig.ui.graphics.ViewportGraphics;
/**
 * Decorator object
 *
 */
public class CenterCrossMapGraphic implements MapGraphic {
 public void draw(MapGraphicContext context) {
  
  int displayWidth = context.getRenderManagerInternal().getMapDisplay().getWidth();
  int displayHeight = context.getRenderManagerInternal().getMapDisplay().getHeight();
 
  ViewportGraphics graphics = context.getGraphics();
  GeneralPath path = new GeneralPath();
        path.moveTo(displayWidth/2, displayHeight/2-10);
        path.lineTo(displayWidth/2, displayHeight/2+10);
 
        path.moveTo(displayWidth/2-10, displayHeight/2);
        path.lineTo(displayWidth/2+10, displayHeight/2);
        Color halo = new Color(255,255,255,128);
        graphics.setColor(halo);
        graphics.setStroke(ViewportGraphics.LINE_SOLID, 3);
        graphics.draw(path);
       
        graphics.setColor(Color.RED);
        graphics.setStroke(ViewportGraphics.LINE_SOLID, 1);
        graphics.draw(path);
 }
}
_______________________________________________
User-friendly Desktop Internet GIS (uDig)

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


Back to the top