- All Known Implementing Classes:
OSGImageProvider
,OSGPostscriptProvider
public interface OSGProvider
Service provider interface for OutputStreamGraphics.
The names of the classes implementing this interface
and appearing in a jar file should be placed in a file named
META-INF/services/org.bzdev.gio.spi.OSGProviderand that file should be included in the jar file. For a modular jar file, the module-info.jar file's module declaration should contain
where "uses org.bzdev.graphs.spi.SymbolProvider; provides org.bzdev.graphs.spi.SymbolProvider with ...;
...
" is a comma-separated list of the
fully-qualified class names of the SymbolProvider providers that
the JAR file contains.
The image types that a provider supports will generally consist of a list of standard names, followed by ones that indicate this particular package. For example, a provider for SVG (Scalable Vector Graphics) images might use the types "svg", "SVG", and "svg-NAME" where NAME refers to a specif implementation. An example is "svg-batik" for the Apache Batik SVG implementation. A useful convention is to use a '-' in a name only to separate a generic name for an image type from a name referring to a particular implementation.
If two providers use the same image-type names, duplicates will be
ignored. Providers are loaded by the class
ServiceLoader
and the documentation for this class
describes how service providers are used.
-
Method Summary
Modifier and TypeMethodDescriptiongetMediaType
(String imageType) Get the media type (MIME type) for an image type supported by this provider.Class<? extends OutputStreamGraphics>
Get the subclass of OutputStreamGraphics for a provider.String[]
getSuffixes
(String imageType) Get the file-name suffixes for an image type supported by this provider.String[]
getTypes()
Get the image types this OSGProvider supports.
-
Method Details
-
getTypes
String[] getTypes()Get the image types this OSGProvider supports. The image type is name for the image format such as "ps", or "jpeg", not a media type (MIME type), and is intended for use within a java application, not elsewhere.- Returns:
- the image types this OSGProvider supports
-
getMediaType
Get the media type (MIME type) for an image type supported by this provider.- Parameters:
imageType
- the name of a format for an image- Returns:
- the media type; null if the image type is not supported by this provider.
-
getSuffixes
Get the file-name suffixes for an image type supported by this provider. Suffixes are the same as file-name extensions.- Parameters:
imageType
- the name of a format for an image- Returns:
- a list of file name suffixes; null if this provider does not support an image type.
-
getOsgClass
Class<? extends OutputStreamGraphics> getOsgClass()Get the subclass of OutputStreamGraphics for a provider. The subclass of OutputStreamGraphics returned must include a public constructor with five arguments:- the output stream (java.io.OutputStream).
- the image width (int) in user-space coordinates.
- the image height (int) in user-space coordinates.
- the image type (String).
- the preferAlpha flag (boolean). When
true
, an alpha channel is requested; otherwise the value is false. Whether or not an alpha channel can be used depends on the image type - some image formats do not support alpha channels.
- public static Integer getDefaultWidth(ImageOrientation)
- public static Integer getDefaultHeight(ImageOrientation)
- Returns:
- the subclass of OutputStreamGraphics for this provider
-