Image repository service
The image repository service is defined by the interface
IlpImageRepository. It is used to load all
JViews TGO images. This service will return the requested image if it is already in the repository. Otherwise, it will use the URL access service to locate the image. If the image cannot be found, a default image is returned.
The image repository serves two main purposes:
1. It matches an image and the file location of this image.
2. It provides memory management, that is, reuse of images that have already been loaded.
By keeping one reusable instance of an image in a repository, the image does not need to be loaded in memory multiple times.
The
IlpImageRepository interface provides five methods to manage the image repository:
getImage. Gets an image by location. The location is described in the form of a string presenting the relative path of the image. If the image is not already in the repository, it will be retrieved from the given location (as resolved by the URL access service).
getImageLocation. Gets the location string associated with an image in the repository. This method searches the repository for the specified image and returns the location of the image if it is found or
null otherwise.
getImageLocations. Gets a list of all the image locations currently in the repository.
getImageURL. Gets the location of an image in the repository as a URL. This method searches the repository for the specified image and returns the location of the image as a URL if it is found or
null otherwise.
How to use the image repository service through the API
The following code extract shows you how you can use this service in your application:
IlpContext context = IltSystem.GetDefaultContext();
IlpImageRepository repository = context.getImageRepository();
Image img = repository.getImage("ilog/tgo/check.png");
By default, the image repository service is implemented by the class
IltDefaultImageRepository.
How to customize the image repository service through the API
The following code extract shows you how you can customize the context to use your own image repository implementation:
context.addService(IlpImageRepository.class, myImageRepository);
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.