ImageIOPanel.java
2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Service
* org.apache.felix.webconsole.ConfigurationPrinter
*/
package com.day.image.internal;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.webconsole.ConfigurationPrinter;
import javax.imageio.spi.IIORegistry;
import javax.imageio.spi.ImageReaderSpi;
import javax.imageio.spi.ImageReaderWriterSpi;
import javax.imageio.spi.ImageWriterSpi;
import java.io.PrintWriter;
import java.util.Iterator;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
@Component
@Service(value={ConfigurationPrinter.class})
public class ImageIOPanel
implements ConfigurationPrinter {
private static final String TITLE = "GFX ImageIO Formats";
public String getTitle() {
return "GFX ImageIO Formats";
}
public void printConfiguration(PrintWriter pw) {
pw.println("Image Reader Provider");
pw.println("---------------------");
this.printReaderWriterSpiTxt(pw, ImageReaderSpi.class);
pw.println();
pw.println("Image Writer Provider");
pw.println("---------------------");
this.printReaderWriterSpiTxt(pw, ImageWriterSpi.class);
}
private <T extends ImageReaderWriterSpi> void printReaderWriterSpiTxt(PrintWriter pw, Class<T> category) {
Iterator<T> spis = IIORegistry.getDefaultInstance().getServiceProviders(category, true);
while (spis.hasNext()) {
ImageReaderWriterSpi spi = (ImageReaderWriterSpi)spis.next();
pw.printf("%s (%s, %s): formats: [%s], MIME types: [%s]%n", spi.getDescription(null), spi.getVersion(), spi.getVendorName(), this.format(spi.getFormatNames()), this.format(spi.getMIMETypes()));
}
}
private String format(Object[] values) {
if (values == null || values.length == 0) {
return "";
}
StringBuilder buf = new StringBuilder();
String sep = "";
for (Object value : values) {
buf.append(sep);
buf.append(value);
sep = ", ";
}
return buf.toString();
}
}