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
Highlighted
Frequent Contributor
Posts: 90
Registered: ‎10-13-2015
Accepted Solution

How to set tooltip for the feature in Java and how to keep the temporary feature in GMSC

Hi all,

 

I have a piece of code where I create the new feature (legend entry) in GMSC in Java, everything works fine, I am able to set customValues, but I can't find a way, how to set the tooltip for that feature. I would expect something like storage.getFeature().setTooltip(String), but I can't find it.

 

try {
	
	Storage storage = getStorage(layerName);
	storage.getFeature().setVisible(true);            	
	
	while (iterator.hasNext()) {
		feature = iterator.next();

 

	private Storage getStorage(String name) throws StorageException
	{
		if (storage != null) 
		{
			if ( storage.getMetadata().getName() == name+".shp")
			return storage;	
			else {
				return storage = context.createTemporaryDataStorage(name+".shp", sStyleId);
			}	
		}
		
		else {		
			return storage = context.createTemporaryDataStorage(name+".shp", sStyleId);
		}		
	}

Another question is, how to keep the feature like that in the client in case the client is reload or close. I would like to achieve the same behavior like Redline or Measure features.

 

Thank you!

 

Regards,

Jakub

Staff
Posts: 72
Registered: ‎10-09-2015

Re: How to set tooltip for the feature in Java and how to keep the temporary feature in GMSC

Hi Jakub,

 

The tooltip is part of the GPrimitive itself. To be more precise the GAction is storing the tooltip information. As these parameters are immutable you do need to define it at creation time or by creating a copy of the geometry and update the storage.

 

new GPoint(new GAction("id", "My tooltip text"), style, coordinate);

 

There is currently no option to store your temporary storage like it is for Redlining or Dimensioning.

 

Regards,

Markus

Markus Holler
Product Line Director
Hexagon Geospatial
Frequent Contributor
Posts: 90
Registered: ‎10-13-2015

Re: How to set tooltip for the feature in Java and how to keep the temporary feature in GMSC

Oh, cool. It's easier than I expected Smiley Happy Thank you!

 

String tooltip = "";
String attrValueTooltip;
for (int l = 1; l < feature.getAttributeCount(); l++) {
	if (feature.getAttribute(l) == null) 
	{
		attrValueTooltip = "NULL";
	} 
	else 
	{
		attrValueTooltip = feature.getAttribute(l).toString();
	}
	
	tooltip = tooltip + "<b>"+featureSchema.getType(l).getName().getLocalPart()+":</b>"+attrValueTooltip+"<br />";
}			

GPolygonSet poly = new GPolygonSet(new GAction(UUID.randomUUID(),tooltip),
		GFeatureTypeStyleManager.getInstance().getStyle(sStyleId), coordinatesList, holePositions);

Is there a way how to achieve the same behavior like redline and measure feature - I mean keep the feature alive after the closing or reloading of the client? (e.g another type of storage, etc.) or it is actually "mission impossible"?

 

Staff
Posts: 72
Registered: ‎10-09-2015

Re: How to set tooltip for the feature in Java and how to keep the temporary feature in GMSC

No, it's a mission impossible like I wrote it in my first post.

Markus Holler
Product Line Director
Hexagon Geospatial
Frequent Contributor
Posts: 115
Registered: ‎04-05-2016

Re: How to set tooltip for the feature in Java and how to keep the temporary feature in GMSC

Hi Markus,

 

is it still not possible to store any features that I have generated programatically in the client's local cache?

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