001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Rustem V. Rafikov
019: * @version $Revision: 1.3 $
020: */package javax.imageio.spi;
021:
022: import javax.imageio.stream.ImageInputStream;
023: import javax.imageio.ImageTypeSpecifier;
024: import javax.imageio.ImageWriter;
025:
026: import org.apache.harmony.luni.util.NotImplementedException;
027:
028: import java.awt.image.RenderedImage;
029: import java.io.IOException;
030:
031: public abstract class ImageWriterSpi extends ImageReaderWriterSpi {
032:
033: public static final Class[] STANDARD_OUTPUT_TYPE = new Class[] { ImageInputStream.class };
034:
035: protected Class[] outputTypes;
036: protected String[] readerSpiNames;
037:
038: protected ImageWriterSpi() throws NotImplementedException {
039: // TODO: implement
040: throw new NotImplementedException();
041: }
042:
043: public ImageWriterSpi(String vendorName, String version,
044: String[] names, String[] suffixes, String[] MIMETypes,
045: String pluginClassName, Class[] outputTypes,
046: String[] readerSpiNames,
047: boolean supportsStandardStreamMetadataFormat,
048: String nativeStreamMetadataFormatName,
049: String nativeStreamMetadataFormatClassName,
050: String[] extraStreamMetadataFormatNames,
051: String[] extraStreamMetadataFormatClassNames,
052: boolean supportsStandardImageMetadataFormat,
053: String nativeImageMetadataFormatName,
054: String nativeImageMetadataFormatClassName,
055: String[] extraImageMetadataFormatNames,
056: String[] extraImageMetadataFormatClassNames) {
057: super (vendorName, version, names, suffixes, MIMETypes,
058: pluginClassName, supportsStandardStreamMetadataFormat,
059: nativeStreamMetadataFormatName,
060: nativeStreamMetadataFormatClassName,
061: extraStreamMetadataFormatNames,
062: extraStreamMetadataFormatClassNames,
063: supportsStandardImageMetadataFormat,
064: nativeImageMetadataFormatName,
065: nativeImageMetadataFormatClassName,
066: extraImageMetadataFormatNames,
067: extraImageMetadataFormatClassNames);
068:
069: if (outputTypes == null || outputTypes.length == 0) {
070: throw new NullPointerException(
071: "output types array cannot be NULL or empty");
072: }
073:
074: this .outputTypes = outputTypes;
075: this .readerSpiNames = readerSpiNames;
076: }
077:
078: public boolean isFormatLossless() {
079: return true;
080: }
081:
082: public Class[] getOutputTypes() {
083: return outputTypes;
084: }
085:
086: public abstract boolean canEncodeImage(ImageTypeSpecifier type);
087:
088: public boolean canEncodeImage(RenderedImage im) {
089: return canEncodeImage(ImageTypeSpecifier
090: .createFromRenderedImage(im));
091: }
092:
093: public ImageWriter createWriterInstance() throws IOException {
094: return createWriterInstance(null);
095: }
096:
097: public abstract ImageWriter createWriterInstance(Object extension)
098: throws IOException;
099:
100: public boolean isOwnWriter(ImageWriter writer)
101: throws NotImplementedException {
102: // TODO: implement
103: throw new NotImplementedException();
104: }
105:
106: public String[] getImageReaderSpiNames() {
107: return readerSpiNames;
108: }
109: }
|