java.lang.Object
org.jtrim2.image.async.InputStreamImageLink
- All Implemented Interfaces:
AsyncDataLink<ImageResult>
Defines an
AsyncDataLink providing images read from an
InputStream. The InputStream is provided by a
InputStreamOpener. To load the image, the ImageIO library of
Java is used and therefore the meta data of the retrieved image is a
JavaIIOMetaData.
The InputStreamImageLink is able to retrieve partially retrieved
image and even the meta data without the image until the complete image is
available. This however carries a certain amount of overhead because the
partial image needs to be copied before being published. Therefore, users
of InputStreamImageLink has to specify how much overhead they can
tolerate, in order to display partially read images. The overhead is
specified as a percentage of the time of the whole image reading process.
Thread safety
The methods of this class are safe to be accessed by multiple threads concurrently.Synchronization transparency
The methods of this class are not synchronization transparent.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInputStreamImageLink(TaskExecutor executor, InputStreamOpener streamOpener, double allowedIntermediateRatio) Creates a newInputStreamImageLinkwhich reads the image read from the specifiedInputStreamOpeneron the givenTaskExecutor. -
Method Summary
Modifier and TypeMethodDescriptiongetData(CancellationToken cancelToken, AsyncDataListener<? super ImageResult> dataListener) toString()Returns the string representation of thisAsyncDataLinkin no particular format
-
Constructor Details
-
InputStreamImageLink
public InputStreamImageLink(TaskExecutor executor, InputStreamOpener streamOpener, double allowedIntermediateRatio) Creates a newInputStreamImageLinkwhich reads the image read from the specifiedInputStreamOpeneron the givenTaskExecutor.- Parameters:
executor- theTaskExecutoron which the image will be read from the input stream. This argument cannot benull.streamOpener- theInputStreamOpenerproviding the image to be loaded. This argument cannot benull.allowedIntermediateRatio- defines the approximate ratio (percentage divided by 100) of the overhead to be tolerated in order to provide intermediate images. Providing too high value for this argument might decrease performance considerably. That is, the overhead defined by this argument is likely to come true. For example: Specifying 0.5 for this argument will likely increase the time needed to read the complete image to twice the needed amount. This argument should be between0.0and1.0but the actual value of this argument is not verified. Specifying less than zero is equivalent to specifying zero, while specifying more than one, is equivalent to specifying one.- Throws:
NullPointerException- thrown if any of the arguments isnull
-
-
Method Details
-
getData
public AsyncDataController getData(CancellationToken cancelToken, AsyncDataListener<? super ImageResult> dataListener) Implementation note: This method will submit a task to retrieve the image to the executor specified at construction time.
- Specified by:
getDatain interfaceAsyncDataLink<ImageResult>
-
toString
Returns the string representation of thisAsyncDataLinkin no particular formatThis method is intended to be used for debugging only.
-