I'm trying to write a uDIG plug-in that renders a custom file type *.foo and 
applies a default drawing style whenever a user opens a file with extension 
.foo.

The .foo files contain all sorts of feature types to be rendered in different 
styles. The user shall _not_ be burdened with editing an SLD file, I just want 
him to open a file and see water features in blue, parks in green, roads in 
grey etc.

I created an extension fooStyle for net.refractions.udig.project.style that 
implements the StyleContent interface. My method createDefaultStyle() checks if 
the IGeoResource is a FooGeoResource, and if so, it reads an SLD file as a 
resource relative to the current class and builds a Style object from it which 
will then be placed onto the StyleBlackboard by the caller.

Now the problem is how to ensure that the BasicFeatureRenderer selects my 
fooStyle instead of the standard sldStyle.

As far as I can see, the renderer simply takes the first Style object from the 
blackboard, and I can't figure out how to make sure that my fooStyle appears 
_before_ the sldStyle. It seems the order on the blackboard depends on the 
order of the extensions for the style extension point, which in turn depends on 
the OSGi bundle order of the corresponding plug-ins, and I don't see how I can 
influence the bundle sequence number.

In fact, I installed my plug-in in several different Eclipse instances, and my  
plug-in appears sometimes first and sometimes last in the list.

OSGi tells you not to rely on a given bundle activation order, as bundles may 
come and go at any time.

If my bundle gets activated first, everything is fine, since my style is the 
first on the blackboard. If my bundle gets activated last, I'm not sure what to 
do. As a workaround, I currently set my bundle id to 
net.refractions.udig.style.sld (only in the implementation class, not in the 
plugin.xml) so that my style overwrites the sldStyle on the blackboard.

Is there a more intelligent way of disabling the default style? Is there a way 
of defining a filetype-to-style mapping?

Best regards,

Harald 
 
*******************************************
innovative systems GmbH Navigation-Multimedia
Geschaeftsfuehrung: Dr. Peter Geiselhart - Kevin Brown - Edwin Summers - Regis 
Baudot 
Sitz der Gesellschaft: Hamburg - Registergericht: Hamburg HRB 59980 
 
*******************************************
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte 
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail 
irrtuemlich erhalten haben, informieren Sie bitte sofort den Absender und 
loeschen Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe 
dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error) please 
notify the sender immediately and delete this e-mail. Any unauthorized copying, 
disclosure or distribution of the contents in this e-mail is strictly forbidden.
*******************************************
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to