< prev index next >

src/java.desktop/share/classes/javax/imageio/ImageWriteParam.java

Print this page
rev 50037 : 8202745: Remove hyphens from "out-of-bounds".


1226      * compression types is non-{@code null} and the current
1227      * compression type is {@code null}.
1228      * @exception IllegalArgumentException if {@code quality} is
1229      * not between {@code 0} and {@code 1}, inclusive.
1230      *
1231      * @see #getCompressionQuality
1232      */
1233     public void setCompressionQuality(float quality) {
1234         if (!canWriteCompressed()) {
1235             throw new UnsupportedOperationException(
1236                 "Compression not supported");
1237         }
1238         if (getCompressionMode() != MODE_EXPLICIT) {
1239             throw new IllegalStateException
1240                 ("Compression mode not MODE_EXPLICIT!");
1241         }
1242         if (getCompressionTypes() != null && getCompressionType() == null) {
1243             throw new IllegalStateException("No compression type set!");
1244         }
1245         if (quality < 0.0F || quality > 1.0F) {
1246             throw new IllegalArgumentException("Quality out-of-bounds!");
1247         }
1248         this.compressionQuality = quality;
1249     }
1250 
1251     /**
1252      * Returns the current compression quality setting.
1253      *
1254      * <p> If there are multiple compression types but none has been
1255      * set, an {@code IllegalStateException} is thrown.
1256      *
1257      * <p> The default implementation checks that compression is
1258      * supported and that the compression mode is
1259      * {@code MODE_EXPLICIT}.  If so, if
1260      * {@code getCompressionTypes()} is {@code null} or
1261      * {@code getCompressionType()} is non-{@code null}, it
1262      * returns the value of the {@code compressionQuality}
1263      * instance variable.
1264      *
1265      * @return the current compression quality setting.
1266      *


1324      * @exception IllegalStateException if the set of legal
1325      * compression types is non-{@code null} and the current
1326      * compression type is {@code null}.
1327      * @exception IllegalArgumentException if {@code quality} is
1328      * not between {@code 0} and {@code 1}, inclusive.
1329      */
1330     public float getBitRate(float quality) {
1331         if (!canWriteCompressed()) {
1332             throw new UnsupportedOperationException(
1333                 "Compression not supported.");
1334         }
1335         if (getCompressionMode() != MODE_EXPLICIT) {
1336             throw new IllegalStateException
1337                 ("Compression mode not MODE_EXPLICIT!");
1338         }
1339         if ((getCompressionTypes() != null) &&
1340             (getCompressionType() == null)) {
1341             throw new IllegalStateException("No compression type set!");
1342         }
1343         if (quality < 0.0F || quality > 1.0F) {
1344             throw new IllegalArgumentException("Quality out-of-bounds!");
1345         }
1346         return -1.0F;
1347     }
1348 
1349     /**
1350      * Returns an array of {@code String}s that may be used along
1351      * with {@code getCompressionQualityValues} as part of a user
1352      * interface for setting or displaying the compression quality
1353      * level.  The {@code String} with index {@code i}
1354      * provides a description of the range of quality levels between
1355      * {@code getCompressionQualityValues[i]} and
1356      * {@code getCompressionQualityValues[i + 1]}.  Note that the
1357      * length of the array returned from
1358      * {@code getCompressionQualityValues} will always be one
1359      * greater than that returned from
1360      * {@code getCompressionQualityDescriptions}.
1361      *
1362      * <p> As an example, the strings "Good", "Better", and "Best"
1363      * could be associated with the ranges {@code [0, .33)},
1364      * {@code [.33, .66)}, and {@code [.66, 1.0]}.  In this




1226      * compression types is non-{@code null} and the current
1227      * compression type is {@code null}.
1228      * @exception IllegalArgumentException if {@code quality} is
1229      * not between {@code 0} and {@code 1}, inclusive.
1230      *
1231      * @see #getCompressionQuality
1232      */
1233     public void setCompressionQuality(float quality) {
1234         if (!canWriteCompressed()) {
1235             throw new UnsupportedOperationException(
1236                 "Compression not supported");
1237         }
1238         if (getCompressionMode() != MODE_EXPLICIT) {
1239             throw new IllegalStateException
1240                 ("Compression mode not MODE_EXPLICIT!");
1241         }
1242         if (getCompressionTypes() != null && getCompressionType() == null) {
1243             throw new IllegalStateException("No compression type set!");
1244         }
1245         if (quality < 0.0F || quality > 1.0F) {
1246             throw new IllegalArgumentException("Quality out of bounds!");
1247         }
1248         this.compressionQuality = quality;
1249     }
1250 
1251     /**
1252      * Returns the current compression quality setting.
1253      *
1254      * <p> If there are multiple compression types but none has been
1255      * set, an {@code IllegalStateException} is thrown.
1256      *
1257      * <p> The default implementation checks that compression is
1258      * supported and that the compression mode is
1259      * {@code MODE_EXPLICIT}.  If so, if
1260      * {@code getCompressionTypes()} is {@code null} or
1261      * {@code getCompressionType()} is non-{@code null}, it
1262      * returns the value of the {@code compressionQuality}
1263      * instance variable.
1264      *
1265      * @return the current compression quality setting.
1266      *


1324      * @exception IllegalStateException if the set of legal
1325      * compression types is non-{@code null} and the current
1326      * compression type is {@code null}.
1327      * @exception IllegalArgumentException if {@code quality} is
1328      * not between {@code 0} and {@code 1}, inclusive.
1329      */
1330     public float getBitRate(float quality) {
1331         if (!canWriteCompressed()) {
1332             throw new UnsupportedOperationException(
1333                 "Compression not supported.");
1334         }
1335         if (getCompressionMode() != MODE_EXPLICIT) {
1336             throw new IllegalStateException
1337                 ("Compression mode not MODE_EXPLICIT!");
1338         }
1339         if ((getCompressionTypes() != null) &&
1340             (getCompressionType() == null)) {
1341             throw new IllegalStateException("No compression type set!");
1342         }
1343         if (quality < 0.0F || quality > 1.0F) {
1344             throw new IllegalArgumentException("Quality out of bounds!");
1345         }
1346         return -1.0F;
1347     }
1348 
1349     /**
1350      * Returns an array of {@code String}s that may be used along
1351      * with {@code getCompressionQualityValues} as part of a user
1352      * interface for setting or displaying the compression quality
1353      * level.  The {@code String} with index {@code i}
1354      * provides a description of the range of quality levels between
1355      * {@code getCompressionQualityValues[i]} and
1356      * {@code getCompressionQualityValues[i + 1]}.  Note that the
1357      * length of the array returned from
1358      * {@code getCompressionQualityValues} will always be one
1359      * greater than that returned from
1360      * {@code getCompressionQualityDescriptions}.
1361      *
1362      * <p> As an example, the strings "Good", "Better", and "Best"
1363      * could be associated with the ranges {@code [0, .33)},
1364      * {@code [.33, .66)}, and {@code [.66, 1.0]}.  In this


< prev index next >