PATH syntax for loading an image file into an IlvIcon instance

Article ID: 2391
Last updated: 29 May, 2018
Article ID: 2391
Last updated: 29 May, 2018
Revision: 3
Views: 427
Posted: 19 Jan, 2012
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

What is the PATH syntax for loading an image file into an IlvIcon instance?

Answer

When specifying the image to be used in an IlvIcon instance, the path you use to point to the image may be relative or absolute.

The code that loads the image tries first to resolve the image location as an absolute URL, then as a relative URL, using the URL of the IVL file as the base URL.

For example, let's assume the following directory structure:

C:

|--projects

|--jviews

|--images
|--image.jpg

In order to specify the absolute URL, you would use a string like the following:

"file:/C:/projects/jviews/images/image.jpg"

See also the attached graphics-absolute.ivl.

In order to specify the relative URL, you would follow the RFC2396 specification for relative URIs which do not begin with a scheme (file:). Therefore, you should use for relative URIs the exact directory and file name structure, as follows:

"images/image.jpg"

Note that the following will not work:

"images\image.jpg"

"/images/image.jpg"

See also the attached graphics-relative.ivl.


On a related note, you should generally not rely on the current working directory for loading your files. Assuming that the current directory is the working directory is not a safe assumption. For an application, the working directory is the directory from where you launched your application. For a servlet, it depends on the application server. For applets, you do not have the permissions to access files.

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

Also listed in


Others in this category