Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Frequent Contributor
Posts: 90
Registered: ‎10-13-2015

Create the feature symbology in Java GMSC

[ Edited ]

Hi all,

 

I build the GMSC feature programatically in Java and I would like to let the user create the new symbology and assign this symbology to the feature, just size, color, opacity and type of line and the same for polygons. Is there a way how to create new symbology in Java?

 

Thanks for a help!

 

Regards,

Jakub

Technical Evangelist
Posts: 148
Registered: ‎10-20-2015

Re: Create the feature symbology in Java GMSC

Hi Jakub,

you want to create the FeatureTypeStyle xml? Am I right?

 

Regards,

Steve

 

 

Frequent Contributor
Posts: 90
Registered: ‎10-13-2015

Re: Create the feature symbology in Java GMSC

[ Edited ]

Hi Steve,

well, I am not sure, probably yes. I need to achieve the same behavior as if you prepare the style in administration and then you can use it throught UUID in Java like

 

GPolyline line = new GPolyline(new GAction(UUID.randomUUID()),
GFeatureTypeStyleManager.getInstance().getStyle(UUID.fromString("5680a000-f0a0-4299-987c-74da1334f7cc")), coordinatesList);

 But I don't know how to create it on the client side without having prepared configuration in the administration.

 

Thanks,

Jakub

 

Technical Evangelist
Posts: 148
Registered: ‎10-20-2015

Re: Create the feature symbology in Java GMSC

You can't add a style to GFeatureTypeStyleManager so that you cann call getStyle.

 

But you can create a IFeatureTypeStyle by using FeatureTypeStyleFactory.createFeatureTypeStyle(UUID, FeatureTypeStyleType, IResourceProvider)

 

Please keep in mind that the given UUID is only a property of the IFeatureTypeStyle. This method doesn't adds the style to your GFeatureTypeStyleManager. It only creates the necessary render class. 

 

The net.opengis.se.v_1_1_0.FeatureTypeStyle is the wrapper class for the xml, so you can set all settings.

 

 

 

 

 

 

Highlighted
Frequent Contributor
Posts: 90
Registered: ‎10-13-2015

Re: Create the feature symbology in Java GMSC

Hi Steve, 

 

thanks for your answer, I have moved a bit forward. I can set the style to the geometry, but I don't understand the relation between FeatureTypeStyleType and IFeatureTypeStyle.

 

FeatureTypeStyleType ft = new FeatureTypeStyleType();
IFeatureTypeStyle style = FeatureTypeStyleFactory.createAreaStyle(Color.BLUE, 1.0D, GSymbolizer.Uom.PIXEL, true, new Color(0, 0, 255, 125), true);		
IFeatureTypeStyle featureStyle = FeatureTypeStyleFactory.createFeatureTypeStyle(UUID.randomUUID(), ft, null);

I need to use FeatureTypeStyleType as the input of 

 

FeatureTypeStyleFactory.createFeatureTypeStyle(UUID.randomUUID(), ft, null)

 But I have absolutely no idea what should be in FeatureTypeStyleType ft and last parameter is IResourceProvider - I can obtain IResourceProvider as style.getResourceProvider(), but it is null

 

Now I can use style this way and this renders my polygons with the style above (blue color) 

 

 

GPolygonSet poly = new GPolygonSet(new GAction(UUID.randomUUID(),tooltip),
style, coordinatesList, holePositions);

 

 

But I (probably) need to pass the parameter UUID to createTemporaryDataStorage() method - because this changes the legend icon and this is my issue

 

 

return storage = context.createTemporaryDataStorage(name + ".shp", featureStyle.getUniqueId());

 

Situation looks like on the picture below - map style interpretation is ok, but the legend icon is not related to the map style. Probably because featureStyle has not correct values.

 

 

Thanks for a help!

 

Regards,

Jakub

 

Contributor
Posts: 68
Registered: ‎11-12-2015

Re: Create the feature symbology in Java GMSC

Hi all,

 

anything new regarding symbology in legend?

 

I did a little research and it seems that the legend icon is always generated from symbology saved in database. Is that correct? Or is there some way how to create a legend icon for temp layer created on client?

 

Thanks,

 

Tereza

Technical Evangelist
Posts: 148
Registered: ‎10-20-2015

Re: Create the feature symbology in Java GMSC

Hi Jakub,

you dont't need FeatureTypeStyleFactory.createFeatureTypeStyle if FeatureTypeStyleFactory.createAreaStyle provides all necessary settings for you.

 

IFeatureTypeStyle is our internal class which will be used by the renderer to style a geometry. FeatureTypeStyle is the XML-wrapper class which provides all possible style-settings.

 

Jakbu's comment:

Situation looks like on the picture below - map style interpretation is ok, but the legend icon is not related to the map style. Probably because featureStyle has not correct values.

 

Yes that's correct because the legend always uses the Style-Id which was provided by the context.createTemporaryDataStorage method and gets it from the GFeatureTypeStyleManager.

 

Therefore this must be the id of a style which is available at the database and assigned to the feature. I've re-read your first comment

 

Jakbu's comment:

I build the GMSC feature programatically in Java and I would like to let the user create the new symbology and assign this symbology to the feature, just size, color, opacity and type of line and the same for polygons

 

 

Maybe the following solution is the best for you which is the same as we do in case of the Redline-Styling.

  1. Define an area-style at your administrator which uses database values for the color, opacity etc. The style must be part of a symbology library which is already used in your project/legend.
  2. Create a geometry and get your style instance from the GFeatureTypeStyleManager by using it's id.
  3. Set the database values (CustomValues) so that the right color, opacity etc. will be used. The default values will be used if a database-value (CustomValue) is not present.

So please note that the legend icon only represents the default values. but that's the same as for our redline functionality.

 

Best Regards,

Steve

Frequent Contributor
Posts: 113
Registered: ‎04-05-2016

Re: Create the feature symbology in Java GMSC

Hi Steve,

 

I am working on a similar solution. In GMSC client there is a styling GUI that is used when adding new redlining features. Can I use this GUI to change the style of the features in my temporary storage?

 

Regards,

Sven

Frequent Contributor
Posts: 113
Registered: ‎04-05-2016

Re: Create the feature symbology in Java GMSC

Or as an alternative solution:

 

Can I somehow use the clientside style editor (in GMSC 2016) to set a custom styling for my temporary storage layer?

I can do it for the normal Redline-layer but the option (Edit user-defined style) is missing on my storage layer.

 

Is there a way to enable it? What are the requirements of my storage to enable it?

 

Thank you!

 

Regards,

Sven

 

Technical Evangelist
Posts: 148
Registered: ‎10-20-2015

Re: Create the feature symbology in Java GMSC

Hi Sven,

I need more information about your StorageMetadata. Please post the part of your code where you create the temporary storage layer. 

 

Best Regards,

Steve

 

 

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.