Index: javax/imageio/ImageWriteParam.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/imageio/ImageWriteParam.java,v retrieving revision 1.1 diff -u -r1.1 ImageWriteParam.java --- javax/imageio/ImageWriteParam.java 4 Oct 2004 07:22:51 -0000 1.1 +++ javax/imageio/ImageWriteParam.java 4 Oct 2004 13:24:45 -0000 @@ -38,8 +38,361 @@ package javax.imageio; +import java.awt.Dimension; +import java.util.Locale; + public class ImageWriteParam extends IIOParam { - // FIXME: Incomplete. This class is merely present in order to allow - // compilation of the javax.imageio package. + public static final int MODE_DISABLED = 0; + public static final int MODE_DEFAULT = 1; + public static final int MODE_EXPLICIT = 2; + public static final int MODE_COPY_FROM_METADATA = 3; + + protected boolean canOffsetTiles; + protected boolean canWriteCompressed; + protected boolean canWriteProgressive; + protected boolean canWriteTiles; + protected int compressionMode = MODE_COPY_FROM_METADATA; + protected float compressionQuality; + protected String compressionType; + protected String[] compressionTypes; + protected Locale locale; + protected Dimension[] preferredTileSizes; + protected int progressiveMode = MODE_COPY_FROM_METADATA; + protected int tileGridXOffset; + protected int tileGridYOffset; + protected int tileHeight; + protected int tileWidth; + protected int tilingMode; + protected boolean tilingSet; + + /** + * Creates an empty ImageWriteParam object. + * The subclass is responsible to initialize all fields. + */ + protected ImageWriteParam() + { + // Do nothing here. + } + + /** + * Creates an ImageWriteParam object with the given locale. + * + * @param locale the locale to use for user visible strings + */ + public ImageWriteParam(Locale locale) + { + this.locale = locale; + } + + public float getBitRate(float quality) + { + checkNotExplicitCompression(); + checkCompressionTypesSet(); + + return -1.0f; + } + + private void checkSupportsCompression() + { + if (! canWriteCompressed()) + throw new UnsupportedOperationException("compression not supported"); + } + + private void checkNotExplicitCompression() + { + if (getCompressionMode() != MODE_EXPLICIT) + throw new IllegalStateException("compression mode is not MODE_EXPLICIT"); + } + + private void checkCompressionTypesSet() + { + if (getCompressionType() == null + && getCompressionTypes() != null) + throw new IllegalStateException("no compression type set"); + } + + private void checkSupportsProgressiveEncoding() + { + if (! canWriteProgressive()) + throw new UnsupportedOperationException + ("progressive output not supported"); + } + + private void checkSupportsTiling() + { + if (! canWriteTiles()) + throw new UnsupportedOperationException("tiling not supported"); + } + + private void checkNotExplicitTiling() + { + if (getTilingMode() != MODE_EXPLICIT) + throw new IllegalStateException("tiling mode not MODE_EXPLICIT"); + } + + private void checkTilingInitialized() + { + if (! tilingSet) + throw new IllegalStateException("tiling parameters not set"); + } + + private void checkMode(int mode) + { + if (mode < MODE_DISABLED || mode > MODE_COPY_FROM_METADATA) + throw new IllegalArgumentException("mode not supported"); + } + + public boolean canOffsetTiles() + { + return canOffsetTiles; + } + + public boolean canWriteCompressed() + { + return canWriteCompressed; + } + + public boolean canWriteProgressive() + { + return canWriteProgressive; + } + + public boolean canWriteTiles() + { + return canWriteTiles; + } + + public int getCompressionMode() + { + checkSupportsCompression(); + + return compressionMode; + } + + public float getCompressionQuality() + { + checkNotExplicitCompression(); + checkCompressionTypesSet(); + + return compressionQuality; + } + + public String[] getCompressionQualityDescriptions() + { + checkNotExplicitCompression(); + checkCompressionTypesSet();; + + return null; + } + + public float[] getCompressionQualityValues() + { + checkNotExplicitCompression(); + checkCompressionTypesSet();; + + return null; + } + + public String getCompressionType() + { + checkNotExplicitCompression(); + + return compressionType; + } + + public String[] getCompressionTypes() + { + checkSupportsCompression(); + + return compressionTypes != null ? (String[]) compressionTypes.clone() : null; + } + + public Locale getLocale() + { + return locale; + } + + public String getLocalizedCompressionTypeName() + { + checkNotExplicitCompression(); + checkCompressionTypesSet(); + + return getCompressionType(); + } + + public Dimension[] getPreferredTileSizes() + { + checkSupportsTiling(); + + return preferredTileSizes; + } + + public int getProgressiveMode() + { + checkSupportsProgressiveEncoding(); + + return progressiveMode; + } + + public int getTileGridXOffset() + { + checkNotExplicitTiling(); + checkTilingInitialized(); + + return tileGridXOffset; + } + + public int getTileGridYOffset() + { + checkNotExplicitTiling(); + checkTilingInitialized(); + + return tileGridYOffset; + } + + public int getTileHeight() + { + checkNotExplicitTiling(); + checkTilingInitialized(); + + return tileHeight; + } + + public int getTileWidth() + { + checkNotExplicitTiling(); + checkTilingInitialized(); + + return tileWidth; + } + + public int getTilingMode() + { + checkSupportsTiling(); + + return tilingMode; + } + + public boolean isCompressionLossless() + { + checkNotExplicitCompression(); + checkCompressionTypesSet(); + + return true; + } + + public void setCompressionMode(int mode) + { + checkSupportsCompression(); + checkMode(mode); + + compressionMode = mode; + + if (mode == MODE_EXPLICIT) + unsetCompression(); + } + + public void setCompressionQuality(float quality) + { + checkNotExplicitCompression(); + checkCompressionTypesSet(); + + if (quality < 0.0f || quality > 1.0f) + throw new IllegalArgumentException("quality out of range"); + + compressionQuality = quality; + } + + public void setCompressionType(String compressionType) + { + checkNotExplicitCompression(); + + String[] types = getCompressionTypes(); + + if (types == null) + throw new UnsupportedOperationException("no settable compression types"); + + if (compressionType == null) + this.compressionType = null; + + for (int i = types.length - 1; i >= 0; --i) + if (types[i].equals(compressionType)) + { + this.compressionType = compressionType; + return; + } + + throw new IllegalArgumentException("unknown compression type"); + } + + public void setProgressiveMode(int mode) + { + checkSupportsProgressiveEncoding(); + checkMode(mode); + + progressiveMode = mode; + } + + public void setTiling(int tileWidth, int tileHeight, + int tileGridXOffset, int tileGridYOffset) + { + checkNotExplicitTiling(); + + if (! canOffsetTiles + && tileGridXOffset != 0 + && tileGridYOffset != 0) + throw new UnsupportedOperationException("tile offsets not supported"); + + if (tileWidth < 0 || tileHeight < 0) + throw new IllegalArgumentException("negative tile dimension"); + + if (preferredTileSizes != null) + { + boolean found = false; + + for (int i = 0; i < preferredTileSizes.length; i += 2) + { + if (tileWidth >= preferredTileSizes[i].width + && tileWidth <= preferredTileSizes[i + 1].width + && tileHeight >= preferredTileSizes[i].height + && tileHeight <= preferredTileSizes[i + 1].height) + found = true; + } + + if (! found) + throw new IllegalArgumentException("illegal tile size"); + } + + this.tilingSet = true; + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.tileGridXOffset = tileGridXOffset; + this.tileGridYOffset = tileGridYOffset; + } + + public void setTilingMode(int mode) + { + checkSupportsTiling(); + checkMode(mode); + tilingMode = mode; + } + + public void unsetCompression() + { + checkNotExplicitCompression(); + + compressionType = null; + compressionQuality = 1.0F; + } + + public void unsetTiling() + { + checkNotExplicitTiling(); + + tileWidth = 0; + tileHeight = 0; + tileGridXOffset = 0; + tileGridYOffset = 0; + } } Index: javax/imageio/metadata/IIOMetadataFormat.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/imageio/metadata/IIOMetadataFormat.java,v retrieving revision 1.1 diff -u -r1.1 IIOMetadataFormat.java --- javax/imageio/metadata/IIOMetadataFormat.java 4 Oct 2004 08:15:27 -0000 1.1 +++ javax/imageio/metadata/IIOMetadataFormat.java 4 Oct 2004 13:24:45 -0000 @@ -38,6 +38,9 @@ package javax.imageio.metadata; +import java.util.Locale; +import javax.imageio.ImageTypeSpecifier; + /** * @author Michael Koch (address@hidden) */ @@ -65,4 +68,56 @@ int VALUE_RANGE_MIN_INCLUSIVE = 6; int VALUE_RANGE_MIN_INCLUSIVE_MASK = 4; int VALUE_RANGE_MIN_MAX_INCLUSIVE = 14; + + boolean canNodeAppear (String elementName, ImageTypeSpecifier imageType); + + int getAttributeDataType (String elementName, String attrName); + + String getAttributeDefaultValue (String elementName, String attrName); + + String getAttributeDescription (String elementName, String attrName, Locale locale); + + String[] getAttributeEnumerations (String elementName, String attrName); + + int getAttributeListMaxLength (String elementName, String attrName); + + int getAttributeListMinLength (String elementName, String attrName); + + String getAttributeMaxValue (String elementName, String attrName); + + String getAttributeMinValue (String elementName, String attrName); + + String[] getAttributeNames (String elementName); + + int getAttributeValueType (String elementName, String attrName); + + String[] getChildNames (String elementName); + + int getChildPolicy (String elementName); + + String getElementDescription (String elementName, Locale locale); + + int getElementMaxChildren (String elementName); + + int getElementMinChildren (String elementName); + + int getObjectArrayMaxLength (String elementName); + + int getObjectArrayMinLength (String elementName); + + Class getObjectClass (String elementName); + + Object getObjectDefaultValue (String elementName); + + Object[] getObjectEnumerations (String elementName); + + Comparable getObjectMaxValue (String elementName); + + Comparable getObjectMinValue (String elementName); + + int getObjectValueType (String elementName); + + String getRootName(); + + boolean isAttributeRequired (String elementName, String attrName); }