Moin Ede :) I want to do it in my plugin, not via scripting. I had no idea that scripting was possible though, thanks!
I did add context.getLayerViewPanel().repaint(); as last line now, nothing visually changed. I attached an image, not sure if it will work on this mailing list. Alternatively it is at http://i.imgur.com/tbPOGft.png Layer#fireAppearanceChanged says "This event will be ignored if LayerManager#isFiringEvents is false". I checked and context.getLayerManager().isFiringEvents() is true. To me the documentation of Layer#fireAppearanceChanged suggests it is all that is needed. Cheers, Hannes On Wed, 27 May 2015 20:06:29 +0000 jump-pilot-devel-requ...@lists.sourceforge.net wrote: > you probably do not need to actually hack a plugin for that. most > likely a bean script will suffice. check out > http://ojwiki.soldin.de/index.php?title=Scripting_with_BeanShell > > you are probably missing a repaint as in this example > > http://ojwiki.soldin.de/index.php?title=Beanshell:Changing_linewidth_of_selected_layers > > ..ede > > On 27.05.2015 14:59, Johannes Kr?ger wrote: > > Hi everyone, > > > > I am using Version 1.8.0, rev 4164. > > > > In the code of a plugin I am writing I defined a FeatureDataset > > with an attribute "number" with integer values from 0 to 2. I added > > that FD to a layer. Now I want to style the layer by that > > attribute. From various ancient mailing list threads and random > > guessing I ended up with this: > > > > layer.getBasicStyle().setEnabled(false); > > layer.addStyle(new ColorThemingStyle("number", > > CollectionUtil.createMap( > > new Object[]{ > > 0, new BasicStyle(Color.blue), > > 1, new BasicStyle(Color.orange), > > 2, new BasicStyle(Color.red)}), > > new BasicStyle(Color.green) //default > > ) > > ); > > layer.getStyle(ColorThemingStyle.class).setEnabled(true); > > layer.fireAppearanceChanged(); > > > > This should assign blue to features where the "number" is 0, orange > > to those with 1 etc. > > > > When I run this plugin within OpenJUMP, the features in the map are > > displayed in a grey color, not the colors I assigned. Once I open > > and directly "OK"-close the "Change Styles"-dialog of the layer, > > the style I defined in the code is used. So, what am I missing? > > > > I already tried appending this without success: > > context.getLayerManager().fireLayerChanged(layer, > > LayerEventType.APPEARANCE_CHANGED); > > > > Is this even the right approach? I got it mostly from > > http://lists.refractions.net/pipermail/jump-users/2004-August/001352.html > > > > If someone feels generous, I would also be highly interested in a > > basic example of using a ranged style. I got as far as knowing that > > I would need to use Range but have no idea how to do that or how to > > apply it. > > > > Thanks, Hannes > >
------------------------------------------------------------------------------
_______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel