use of javax.imageio.spi.ImageReaderWriterSpi in project jdk8u_jdk by JetBrains.
the class ImageIO method getReaderWriterInfo.
private static <S extends ImageReaderWriterSpi> String[] getReaderWriterInfo(Class<S> spiClass, SpiInfo spiInfo) {
// Ensure category is present
Iterator<S> iter;
try {
iter = theRegistry.getServiceProviders(spiClass, true);
} catch (IllegalArgumentException e) {
return new String[0];
}
HashSet<String> s = new HashSet<String>();
while (iter.hasNext()) {
ImageReaderWriterSpi spi = iter.next();
Collections.addAll(s, spiInfo.info(spi));
}
return s.toArray(new String[s.size()]);
}
use of javax.imageio.spi.ImageReaderWriterSpi in project imageio-ext by geosolutions-it.
the class TIFFImageReaderSpi method onRegistration.
@Override
public void onRegistration(ServiceRegistry registry, Class category) {
super.onRegistration(registry, category);
if (registered) {
return;
}
registered = true;
Iterator<ImageReaderWriterSpi> readers = ImageIOUtilities.getJDKImageReaderWriterSPI(registry, "TIFF", true).iterator();
while (readers.hasNext()) {
final ImageReaderSpi spi = (ImageReaderSpi) readers.next();
if (spi == this)
continue;
registry.deregisterServiceProvider(spi);
registry.setOrdering(category, this, spi);
}
}
use of javax.imageio.spi.ImageReaderWriterSpi in project imageio-ext by geosolutions-it.
the class JP2KKakaduImageReaderSpi method onRegistration.
/**
* Upon registration, this method ensures that this SPI is listed at the top
* of the ImageReaderSpi items, so that it will be invoked before the
* default ImageReaderSpi
*
* @param registry
* ServiceRegistry where this object has been registered.
* @param category
* a Class object indicating the registry category under
* which this object has been registered.
*/
@SuppressWarnings("unchecked")
public synchronized void onRegistration(ServiceRegistry registry, Class category) {
super.onRegistration(registry, category);
if (registered) {
return;
}
registered = true;
if (!KakaduUtilities.isKakaduAvailable()) {
final IIORegistry iioRegistry = (IIORegistry) registry;
final Class<ImageReaderSpi> spiClass = ImageReaderSpi.class;
final Iterator<ImageReaderSpi> iter = iioRegistry.getServiceProviders(spiClass, true);
while (iter.hasNext()) {
final ImageReaderSpi provider = (ImageReaderSpi) iter.next();
if (provider instanceof JP2KKakaduImageReaderSpi) {
registry.deregisterServiceProvider(provider);
}
}
return;
}
final List<ImageReaderWriterSpi> readers = KakaduUtilities.getJDKImageReaderWriterSPI(registry, "jpeg2000", true);
for (ImageReaderWriterSpi elem : readers) {
if (elem instanceof ImageReaderSpi) {
final ImageReaderSpi spi = (ImageReaderSpi) elem;
;
if (spi == this)
continue;
registry.deregisterServiceProvider(spi);
registry.setOrdering(category, this, spi);
}
}
}
use of javax.imageio.spi.ImageReaderWriterSpi in project imageio-ext by geosolutions-it.
the class GDALUtilities method getJDKImageReaderWriterSPI.
@SuppressWarnings("unchecked")
public static List getJDKImageReaderWriterSPI(ServiceRegistry registry, String formatName, boolean isReader) {
IIORegistry iioRegistry = (IIORegistry) registry;
Class spiClass;
if (isReader)
spiClass = ImageReaderSpi.class;
else
spiClass = ImageWriterSpi.class;
// useOrdering
Iterator iter = iioRegistry.getServiceProviders(spiClass, true);
String[] formatNames;
ImageReaderWriterSpi provider;
ArrayList list = new ArrayList();
while (iter.hasNext()) {
provider = (ImageReaderWriterSpi) iter.next();
// Get the formatNames supported by this Spi
formatNames = provider.getFormatNames();
final int length = formatNames.length;
for (int i = 0; i < length; i++) {
if (formatNames[i].equalsIgnoreCase(formatName)) {
// Must be a JDK provided ImageReader/ImageWriter
list.add(provider);
break;
}
}
}
return list;
}
use of javax.imageio.spi.ImageReaderWriterSpi in project imageio-ext by geosolutions-it.
the class TIFFImageWriterSpi method onRegistration.
public void onRegistration(ServiceRegistry registry, Class category) {
super.onRegistration(registry, category);
if (registered) {
return;
}
registered = true;
final Iterator<ImageReaderWriterSpi> writers = ImageIOUtilities.getJDKImageReaderWriterSPI(registry, "TIFF", true).iterator();
while (writers.hasNext()) {
final ImageWriterSpi spi = (ImageWriterSpi) writers.next();
if (spi == this)
continue;
registry.deregisterServiceProvider(spi);
registry.setOrdering(category, this, spi);
}
}
Aggregations