* * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception UnsupportedOperationException if there are no * settable compression types. * @exception IllegalArgumentException if * <code>compressionType</code> is non-<code>null</code> but is not * one of the values returned by <code>getCompressionTypes</code>. * * @see #getCompressionTypes * @see #getCompressionType * @see #unsetCompression */ public void setCompressionType(String compressionType) { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported"); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } String[] legalTypes = getCompressionTypes(); if (legalTypes == null) { throw new UnsupportedOperationException( "No settable compression types"); } if (compressionType != null) { boolean found = false; if (legalTypes != null) { for (int i = 0; i < legalTypes.length; i++) { if (compressionType.equals(legalTypes[i])) { found = true; break; } } } if (!found) { throw new IllegalArgumentException("Unknown compression type!"); } } this.compressionType = compressionType; } /** * Returns the currently set compression type, or * <code>null</code> if none has been set. The type is returned * as a <code>String</code> from among those returned by * <code>getCompressionTypes</code>. * If no compression type has been set, <code>null</code> is * returned. * * <p> The default implementation checks whether compression is * supported and the compression mode is * <code>MODE_EXPLICIT</code>. If so, it returns the value of the * <code>compressionType</code> instance variable. * * @return the current compression type as a <code>String</code>, * or <code>null</code> if no type is set. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * * @see #setCompressionType */ public String getCompressionType() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } return compressionType; } /** * Removes any previous compression type and quality settings. * * <p> The default implementation sets the instance variable * <code>compressionType</code> to <code>null</code>, and the * instance variable <code>compressionQuality</code> to * <code>1.0F</code>. * * @exception UnsupportedOperationException if the plug-in does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * * @see #setCompressionType * @see #setCompressionQuality */ public void unsetCompression() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported"); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } this.compressionType = null; this.compressionQuality = 1.0F; } /** * Returns a localized version of the name of the current * compression type, using the <code>Locale</code> returned by * <code>getLocale</code>. * * <p> The default implementation checks whether compression is * supported and the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>compressionType</code> is <code>non-null</code> the value * of <code>getCompressionType</code> is returned as a * convenience. * * @return a <code>String</code> containing a localized version of * the name of the current compression type. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if no compression type is set. */ public String getLocalizedCompressionTypeName() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if (getCompressionType() == null) { throw new IllegalStateException("No compression type set!"); } return getCompressionType(); } /** * Returns <code>true</code> if the current compression type * provides lossless compression. If a plug-in provides only * one mandatory compression type, then this method may be * called without calling <code>setCompressionType</code> first. * * <p> If there are multiple compression types but none has * been set, an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks whether compression is * supported and the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code> * <code>true</code> is returned as a convenience. * * @return <code>true</code> if the current compression type is * lossless. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. */ public boolean isCompressionLossless() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported"); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } return true; } /** * Sets the compression quality to a value between <code>0</code> * and <code>1</code>. Only a single compression quality setting * is supported by default; writers can provide extended versions * of <code>ImageWriteParam</code> that offer more control. For * lossy compression schemes, the compression quality should * control the tradeoff between file size and image quality (for * example, by choosing quantization tables when writing JPEG * images). For lossless schemes, the compression quality may be * used to control the tradeoff between file size and time taken * to perform the compression (for example, by optimizing row * filters and setting the ZLIB compression level when writing * PNG images). * * <p> A compression quality setting of 0.0 is most generically * interpreted as "high compression is important," while a setting of * 1.0 is most generically interpreted as "high image quality is * important." * * <p> If there are multiple compression types but none has been * set, an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported, and that the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> returns <code>null</code> or * <code>compressionType</code> is non-<code>null</code> it sets * the <code>compressionQuality</code> instance variable. * * @param quality a <code>float</code> between <code>0</code>and * <code>1</code> indicating the desired quality level. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * @exception IllegalArgumentException if <code>quality</code> is * not between <code>0</code>and <code>1</code>, inclusive. * * @see #getCompressionQuality */ public void setCompressionQuality(float quality) { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported"); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if (getCompressionTypes() != null && getCompressionType() == null) { throw new IllegalStateException("No compression type set!"); } if (quality < 0.0F || quality > 1.0F) { throw new IllegalArgumentException("Quality out-of-bounds!"); } this.compressionQuality = quality; } /** * Returns the current compression quality setting. * * <p> If there are multiple compression types but none has been * set, an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported and that the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code>, it * returns the value of the <code>compressionQuality</code> * instance variable. * * @return the current compression quality setting. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * * @see #setCompressionQuality */ public float getCompressionQuality() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } return compressionQuality; } /** * Returns a <code>float</code> indicating an estimate of the * number of bits of output data for each bit of input image data * at the given quality level. The value will typically lie * between <code>0</code> and <code>1</code>, with smaller values * indicating more compression. A special value of * <code>-1.0F</code> is used to indicate that no estimate is * available. * * <p> If there are multiple compression types but none has been set, * an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported and the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code>, and * <code>quality</code> is within bounds, it returns * <code>-1.0</code>. * * @param quality the quality setting whose bit rate is to be * queried. * * @return an estimate of the compressed bit rate, or * <code>-1.0F</code> if no estimate is available. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * @exception IllegalArgumentException if <code>quality</code> is * not between <code>0</code>and <code>1</code>, inclusive. */ public float getBitRate(float quality) { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } if (quality < 0.0F || quality > 1.0F) { throw new IllegalArgumentException("Quality out-of-bounds!"); } return -1.0F; } /** * Returns an array of <code>String</code>s that may be used along * with <code>getCompressionQualityValues</code> as part of a user * interface for setting or displaying the compression quality * level. The <code>String</code> with index <code>i</code> * provides a description of the range of quality levels between * <code>getCompressionQualityValues[i]</code> and * <code>getCompressionQualityValues[i + 1]</code>. Note that the * length of the array returned from * <code>getCompressionQualityValues</code> will always be one * greater than that returned from * <code>getCompressionQualityDescriptions</code>. * * <p> As an example, the strings "Good", "Better", and "Best" * could be associated with the ranges <code>[0, .33)</code>, * <code>[.33, .66)</code>, and <code>[.66, 1.0]</code>. In this * case, <code>getCompressionQualityDescriptions</code> would * return <code>{ "Good", "Better", "Best" }</code> and * <code>getCompressionQualityValues</code> would return * <code>{ 0.0F, .33F, .66F, 1.0F }</code>. * * <p> If no descriptions are available, <code>null</code> is * returned. If <code>null</code> is returned from * <code>getCompressionQualityValues</code>, this method must also * return <code>null</code>. * * <p> The descriptions should be localized for the * <code>Locale</code> returned by <code>getLocale</code>, if it * is non-<code>null</code>. * * <p> If there are multiple compression types but none has been set, * an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported and that the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code>, it * returns <code>null</code>. * * @return an array of <code>String</code>s containing localized * descriptions of the compression quality levels. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * * @see #getCompressionQualityValues */ public String[] getCompressionQualityDescriptions() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } return null; } /** * Returns an array of <code>float</code>s that may be used along * with <code>getCompressionQualityDescriptions</code> as part of a user * interface for setting or displaying the compression quality * level. See {@link #getCompressionQualityDescriptions * <code>getCompressionQualityDescriptions</code>} for more information. * * <p> If no descriptions are available, <code>null</code> is * returned. If <code>null</code> is returned from * <code>getCompressionQualityDescriptions</code>, this method * must also return <code>null</code>. * * <p> If there are multiple compression types but none has been set, * an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported and that the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code>, it * returns <code>null</code>. * * @return an array of <code>float</code>s indicating the * boundaries between the compression quality levels as described * by the <code>String</code>s from * <code>getCompressionQualityDescriptions</code>. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * * @see #getCompressionQualityDescriptions */ public float[] getCompressionQualityValues() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } return null; }}Lines 1001–1471 of 1471. Previous lines
* * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception UnsupportedOperationException if there are no * settable compression types. * @exception IllegalArgumentException if * <code>compressionType</code> is non-<code>null</code> but is not * one of the values returned by <code>getCompressionTypes</code>. * * @see #getCompressionTypes * @see #getCompressionType * @see #unsetCompression */ public void setCompressionType(String compressionType) { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported"); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } String[] legalTypes = getCompressionTypes(); if (legalTypes == null) { throw new UnsupportedOperationException( "No settable compression types"); } if (compressionType != null) { boolean found = false; if (legalTypes != null) { for (int i = 0; i < legalTypes.length; i++) { if (compressionType.equals(legalTypes[i])) { found = true; break; } } } if (!found) { throw new IllegalArgumentException("Unknown compression type!"); } } this.compressionType = compressionType; } /** * Returns the currently set compression type, or * <code>null</code> if none has been set. The type is returned * as a <code>String</code> from among those returned by * <code>getCompressionTypes</code>. * If no compression type has been set, <code>null</code> is * returned. * * <p> The default implementation checks whether compression is * supported and the compression mode is * <code>MODE_EXPLICIT</code>. If so, it returns the value of the * <code>compressionType</code> instance variable. * * @return the current compression type as a <code>String</code>, * or <code>null</code> if no type is set. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * * @see #setCompressionType */ public String getCompressionType() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } return compressionType; } /** * Removes any previous compression type and quality settings. * * <p> The default implementation sets the instance variable * <code>compressionType</code> to <code>null</code>, and the * instance variable <code>compressionQuality</code> to * <code>1.0F</code>. * * @exception UnsupportedOperationException if the plug-in does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * * @see #setCompressionType * @see #setCompressionQuality */ public void unsetCompression() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported"); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } this.compressionType = null; this.compressionQuality = 1.0F; } /** * Returns a localized version of the name of the current * compression type, using the <code>Locale</code> returned by * <code>getLocale</code>. * * <p> The default implementation checks whether compression is * supported and the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>compressionType</code> is <code>non-null</code> the value * of <code>getCompressionType</code> is returned as a * convenience. * * @return a <code>String</code> containing a localized version of * the name of the current compression type. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if no compression type is set. */ public String getLocalizedCompressionTypeName() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if (getCompressionType() == null) { throw new IllegalStateException("No compression type set!"); } return getCompressionType(); } /** * Returns <code>true</code> if the current compression type * provides lossless compression. If a plug-in provides only * one mandatory compression type, then this method may be * called without calling <code>setCompressionType</code> first. * * <p> If there are multiple compression types but none has * been set, an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks whether compression is * supported and the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code> * <code>true</code> is returned as a convenience. * * @return <code>true</code> if the current compression type is * lossless. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. */ public boolean isCompressionLossless() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported"); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } return true; } /** * Sets the compression quality to a value between <code>0</code> * and <code>1</code>. Only a single compression quality setting * is supported by default; writers can provide extended versions * of <code>ImageWriteParam</code> that offer more control. For * lossy compression schemes, the compression quality should * control the tradeoff between file size and image quality (for * example, by choosing quantization tables when writing JPEG * images). For lossless schemes, the compression quality may be * used to control the tradeoff between file size and time taken * to perform the compression (for example, by optimizing row * filters and setting the ZLIB compression level when writing * PNG images). * * <p> A compression quality setting of 0.0 is most generically * interpreted as "high compression is important," while a setting of * 1.0 is most generically interpreted as "high image quality is * important." * * <p> If there are multiple compression types but none has been * set, an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported, and that the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> returns <code>null</code> or * <code>compressionType</code> is non-<code>null</code> it sets * the <code>compressionQuality</code> instance variable. * * @param quality a <code>float</code> between <code>0</code>and * <code>1</code> indicating the desired quality level. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * @exception IllegalArgumentException if <code>quality</code> is * not between <code>0</code>and <code>1</code>, inclusive. * * @see #getCompressionQuality */ public void setCompressionQuality(float quality) { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported"); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if (getCompressionTypes() != null && getCompressionType() == null) { throw new IllegalStateException("No compression type set!"); } if (quality < 0.0F || quality > 1.0F) { throw new IllegalArgumentException("Quality out-of-bounds!"); } this.compressionQuality = quality; } /** * Returns the current compression quality setting. * * <p> If there are multiple compression types but none has been * set, an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported and that the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code>, it * returns the value of the <code>compressionQuality</code> * instance variable. * * @return the current compression quality setting. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * * @see #setCompressionQuality */ public float getCompressionQuality() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } return compressionQuality; } /** * Returns a <code>float</code> indicating an estimate of the * number of bits of output data for each bit of input image data * at the given quality level. The value will typically lie * between <code>0</code> and <code>1</code>, with smaller values * indicating more compression. A special value of * <code>-1.0F</code> is used to indicate that no estimate is * available. * * <p> If there are multiple compression types but none has been set, * an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported and the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code>, and * <code>quality</code> is within bounds, it returns * <code>-1.0</code>. * * @param quality the quality setting whose bit rate is to be * queried. * * @return an estimate of the compressed bit rate, or * <code>-1.0F</code> if no estimate is available. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * @exception IllegalArgumentException if <code>quality</code> is * not between <code>0</code>and <code>1</code>, inclusive. */ public float getBitRate(float quality) { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } if (quality < 0.0F || quality > 1.0F) { throw new IllegalArgumentException("Quality out-of-bounds!"); } return -1.0F; } /** * Returns an array of <code>String</code>s that may be used along * with <code>getCompressionQualityValues</code> as part of a user * interface for setting or displaying the compression quality * level. The <code>String</code> with index <code>i</code> * provides a description of the range of quality levels between * <code>getCompressionQualityValues[i]</code> and * <code>getCompressionQualityValues[i + 1]</code>. Note that the * length of the array returned from * <code>getCompressionQualityValues</code> will always be one * greater than that returned from * <code>getCompressionQualityDescriptions</code>. * * <p> As an example, the strings "Good", "Better", and "Best" * could be associated with the ranges <code>[0, .33)</code>, * <code>[.33, .66)</code>, and <code>[.66, 1.0]</code>. In this * case, <code>getCompressionQualityDescriptions</code> would * return <code>{ "Good", "Better", "Best" }</code> and * <code>getCompressionQualityValues</code> would return * <code>{ 0.0F, .33F, .66F, 1.0F }</code>. * * <p> If no descriptions are available, <code>null</code> is * returned. If <code>null</code> is returned from * <code>getCompressionQualityValues</code>, this method must also * return <code>null</code>. * * <p> The descriptions should be localized for the * <code>Locale</code> returned by <code>getLocale</code>, if it * is non-<code>null</code>. * * <p> If there are multiple compression types but none has been set, * an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported and that the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code>, it * returns <code>null</code>. * * @return an array of <code>String</code>s containing localized * descriptions of the compression quality levels. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * * @see #getCompressionQualityValues */ public String[] getCompressionQualityDescriptions() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } return null; } /** * Returns an array of <code>float</code>s that may be used along * with <code>getCompressionQualityDescriptions</code> as part of a user * interface for setting or displaying the compression quality * level. See {@link #getCompressionQualityDescriptions * <code>getCompressionQualityDescriptions</code>} for more information. * * <p> If no descriptions are available, <code>null</code> is * returned. If <code>null</code> is returned from * <code>getCompressionQualityDescriptions</code>, this method * must also return <code>null</code>. * * <p> If there are multiple compression types but none has been set, * an <code>IllegalStateException</code> is thrown. * * <p> The default implementation checks that compression is * supported and that the compression mode is * <code>MODE_EXPLICIT</code>. If so, if * <code>getCompressionTypes()</code> is <code>null</code> or * <code>getCompressionType()</code> is non-<code>null</code>, it * returns <code>null</code>. * * @return an array of <code>float</code>s indicating the * boundaries between the compression quality levels as described * by the <code>String</code>s from * <code>getCompressionQualityDescriptions</code>. * * @exception UnsupportedOperationException if the writer does not * support compression. * @exception IllegalStateException if the compression mode is not * <code>MODE_EXPLICIT</code>. * @exception IllegalStateException if the set of legal * compression types is non-<code>null</code> and the current * compression type is <code>null</code>. * * @see #getCompressionQualityDescriptions */ public float[] getCompressionQualityValues() { if (!canWriteCompressed()) { throw new UnsupportedOperationException( "Compression not supported."); } if (getCompressionMode() != MODE_EXPLICIT) { throw new IllegalStateException ("Compression mode not MODE_EXPLICIT!"); } if ((getCompressionTypes() != null) && (getCompressionType() == null)) { throw new IllegalStateException("No compression type set!"); } return null; } }