Symbol Editor: relative path for an icon parameter

Article ID: 2401
Last updated: 29 May, 2018
Article ID: 2401
Last updated: 29 May, 2018
Revision: 3
Views: 543
Posted: 23 Mar, 2012
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How do you set relative path for an icon parameter in Symbol Editor?

Answer

You can specify the icon with relative path using the following CSS rule:

node {

class : "ilog.views.sdm.graphic.IlvSDMCompositeNode" ; ;

...

children[1] : "@+Icon";

}

#Icon {

class : "ilog.views.graphic.IlvIcon" ;

imageLocation : "url(data/icons/info.gif)" ;

...

}

The icon location in this case is interpreted relative to the location of the CSS file.

You can also specify;

#Icon {

class : "ilog.views.graphic.IlvIcon" ;

imageLocation : "file:data/icons/info.gif" ;

...

}

In this case, the icon location is interpreted relative to the location where the program starts, not relative to the location of the CSS file.

In the Symbol Editor, when you are at the icon imageLocation, you can either enter an URL or a CSS expression. Entering "url(...)" in the imageLocation field is not allow because it is not a valid URL syntax and url(...) is not a CSS function.

There are two ways to specify the relative path for an icon in Symbol Editor:

  1. Specific location relative to the location where the program starts:

node {

class : "ilog.views.sdm.graphic.IlvSDMCompositeNode" ;

...

children[1] : "@+Icon";

}

#Icon {

class : "ilog.views.graphic.IlvIcon" ;

imageLocation : "@iconUrl" ;

...

}

where iconUrl is a parameter with value "jar:file:nasapalette.jar!/ilog/views/palettes/newpalette/icon/info.gif"

        2. Define a CSS function to accept the parameter as String or URL.

In the attached sample, you will find implementation of a CSS function (named url) that combines a base URL with a second part, which can either be a String or a relative URL. With this CSS function, you can specify the icon imageLocation as url(styleSheetURL(), @iconUrl) where iconUrl parameter is of type URL.

Since the URL customizer does not accept invalid URLs such as ../resources/icon.gif, this new CSS function will accept URL with the following syntax:

URL with protocol is file and the path starts with the keywork relative will be consider as relative URL.

  • Relative URL as file:relative/../resources/icon.gif will allow you to access the icon in the same jar file.
  • Absolute URL. Any URL that does not contain the file protocol or does not start with relative/ will be considered as an absolute URL.

The samplepalette.jar in the attached sample contains a symbol with two icons: the icon on the left has a fixed image while the icon on the right can be set with the symbol parameter.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2401
Last updated: 29 May, 2018
Revision: 3
Views: 543
Posted: 23 Mar, 2012 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Attached files

Also listed in


Others in this category