The RenderingHints class contains rendering hints that can be used by the java.awt.Graphics2D class, and classes that implement java.awt.image.BufferedImageOp and java.awt.image.Raster .
Constructs a new object with keys and values initialized from the specified Map object (which may be null).
Parameters
inita map of key/value pairs to initialize the hints or null if the object should be empty
Constructs a new object with the specified key/value pair.
Parameters
keythe key of the particular hint property
valuethe value of the hint property specified with key
Alpha interpolation hint key.
Antialiasing hint key.
Color rendering hint key.
Dithering hint key.
Font fractional metrics hint key.
Interpolation hint key.
Rendering hint key.
Stroke normalization control hint key.
Text antialiasing hint key.
Alpha interpolation hint value -- ALPHA_INTERPOLATION_DEFAULT.
Alpha interpolation hint value -- ALPHA_INTERPOLATION_QUALITY.
Alpha interpolation hint value -- ALPHA_INTERPOLATION_SPEED.
Antialiasing hint values -- rendering is done with the platform default antialiasing mode.
Antialiasing hint values -- rendering is done without antialiasing.
Antialiasing hint values -- rendering is done with antialiasing.
Color rendering hint value -- COLOR_RENDER_DEFAULT.
Color rendering hint value -- COLOR_RENDER_QUALITY.
Color rendering hint value -- COLOR_RENDER_SPEED.
Dithering hint values -- use the platform default for dithering.
Dithering hint values -- do not dither when rendering.
Dithering hint values -- dither when rendering, if needed.
Font fractional metrics hint values -- use the platform default for fractional metrics.
Font fractional metrics hint values -- fractional metrics disabled.
Font fractional metrics hint values -- fractional metrics enabled.
Interpolation hint value -- INTERPOLATION_BICUBIC.
Interpolation hint value -- INTERPOLATION_BILINEAR.
Interpolation hint value -- INTERPOLATION_NEAREST_NEIGHBOR.
Rendering hint values -- The platform default rendering algorithms are chosen.
Rendering hint values -- Appropriate rendering algorithms are chosen with a preference for output quality.
Rendering hint values -- Appropriate rendering algorithms are chosen with a preference for output speed.
Stroke normalization control hint value -- STROKE_DEFAULT.
Stroke normalization control hint value -- STROKE_NORMALIZE.
Stroke normalization control hint value -- STROKE_PURE.
Text antialiasing hint value -- text rendering is done using the platform default text antialiasing mode.
Text antialiasing hint value -- text rendering is done without antialiasing.
Text antialiasing hint value -- text rendering is done with antialiasing.
Adds all of the keys and corresponding values from the specified RenderingHints object to this RenderingHints object. Keys that are present in this RenderingHints object, but not in the specified RenderingHints object are not affected.
Parameters
hintsthe set of key/value pairs to be added to this RenderingHints object
Removes all mappings from this map (optional operation).
Throws
UnsupportedOperationExceptionclear is not supported by this map.
Creates a clone of this RenderingHints object that has the same contents as this RenderingHints object.
Return
a clone of this instance.
Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)
Parameters
keykey whose presence in this map is to be tested.
Return
true if this map contains a mapping for the specified key.
Throws
ClassCastExceptionif the key is of an inappropriate type for this map (optional).
NullPointerExceptionif the key is null and this map does not permit null keys (optional).
Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==null ? v==null : value.equals(v)). This operation will probably require time linear in the map size for most implementations of the Map interface.
Parameters
valuevalue whose presence in this map is to be tested.
Return
true if this map maps one or more keys to the specified value.
Throws
ClassCastExceptionif the value is of an inappropriate type for this map (optional).
NullPointerExceptionif the value is null and this map does not permit null values (optional).
Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry . The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
Return
a set view of the mappings contained in this map.
Compares the specified Object with this RenderingHints for equality. Returns true if the specified object is also a Map and the two Map objects represent the same mappings. More formally, two Map objects t1 and t2 represent the same mappings if t1.keySet().equals(t2.keySet()) and for every key k in t1.keySet(),
 (t1.get(k)==null ? t2.get(k)==null : t1.get(k).equals(t2.get(k)))
 
. This ensures that the equals method works properly across different implementations of the Map interface.
Parameters
oObject to be compared for equality with this RenderingHints.
Return
true if the specified Object is equal to this RenderingHints.
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

Parameters
keykey whose associated value is to be returned.
Return
the value to which this map maps the specified key, or null if the map contains no mapping for this key.
Throws
ClassCastExceptionif the key is of an inappropriate type for this map (optional).
NullPointerExceptionif the key is null and this map does not permit null keys (optional).
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
Returns the hash code value for this RenderingHints. The hash code of a RenderingHints is defined to be the sum of the hashCodes of each Entry in the RenderingHints object's entrySet view. This ensures that t1.equals(t2) implies that t1.hashCode()==t2.hashCode() for any two Map objects t1 and t2, as required by the general contract of Object.hashCode.
Return
the hash code value for this RenderingHints.
Returns true if this map contains no key-value mappings.
Return
true if this map contains no key-value mappings.
Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.
Return
a set view of the keys contained in this map.
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for this key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.))
Parameters
keykey with which the specified value is to be associated.
valuevalue to be associated with the specified key.
Return
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
Throws
UnsupportedOperationExceptionif the put operation is not supported by this map.
ClassCastExceptionif the class of the specified key or value prevents it from being stored in this map.
IllegalArgumentExceptionif some aspect of this key or value prevents it from being stored in this map.
NullPointerExceptionif this map does not permit null keys or values, and the specified key or value is null.
Maps the specified key to the specified value in this RenderingHints object. Neither the key nor the value can be null. The value can be retrieved by calling the get method with a key that is equal to the original key.
Parameters
keythe rendering hint key.
valuethe rendering hint value.
Return
the previous value of the specified key in this object or null if it did not have one.
Throws
NullPointerExceptionif the key or value is null.
ClassCastExceptionkey is not of type RenderingHints.Key.
IllegalArgumentExceptionvalue is not appropriate for the specified key.
See Also
Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is unspecified if the specified map is modified while the operation is in progress.
Parameters
tMappings to be stored in this map.
Throws
UnsupportedOperationExceptionif the putAll method is not supported by this map.
ClassCastExceptionif the class of a key or value in the specified map prevents it from being stored in this map.
IllegalArgumentExceptionsome aspect of a key or value in the specified map prevents it from being stored in this map.
NullPointerExceptionif the specified map is null, or if this map does not permit null keys or values, and the specified map contains null keys or values.
Removes the mapping for this key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that (key==null ? k==null : key.equals(k)), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which the map previously associated the key, or null if the map contained no mapping for this key. (A null return can also indicate that the map previously associated null with the specified key if the implementation supports null values.) The map will not contain a mapping for the specified key once the call returns.

Parameters
keykey whose mapping is to be removed from the map.
Return
previous value associated with specified key, or null if there was no mapping for key.
Throws
ClassCastExceptionif the key is of an inappropriate type for this map (optional).
NullPointerExceptionif the key is null and this map does not permit null keys (optional).
UnsupportedOperationExceptionif the remove method is not supported by this map.
Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
Return
the number of key-value mappings in this map.
Returns a rather long string representation of the hashmap which contains the mappings of keys to values for this RenderingHints object.
Return
a string representation of this object.
Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
Return
a collection view of the values contained in this map.
Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait();
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Throws
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

  • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
  • Some other thread invokes the notifyAll method for this object.
  • Some other thread interrupts thread T.
  • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout);
         ... // Perform action appropriate to condition
     }
 
(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Parameters
timeoutthe maximum time to wait in milliseconds.
Throws
IllegalArgumentExceptionif the value of timeout is negative.
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

 1000000*timeout+nanos

In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

  • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
  • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout, nanos);
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Parameters
timeoutthe maximum time to wait in milliseconds.
nanosadditional time, in nanoseconds range 0-999999.
Throws
IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.