提交 fe7e8dd1 编写于 作者: D dav

6573289: api/java_awt/Color/index.html#CreateContextTesttestCase4,5,6,7 fail since JDK 7 b14

Summary: specify current behavior - not caching the painting context
Reviewed-by: flar, son
上级 a80da22c
...@@ -51,6 +51,7 @@ import java.awt.color.ColorSpace; ...@@ -51,6 +51,7 @@ import java.awt.color.ColorSpace;
* http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html * http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html
* </A>. * </A>.
* <p> * <p>
* @version 10 Feb 1997
* @author Sami Shaio * @author Sami Shaio
* @author Arthur van Hoff * @author Arthur van Hoff
* @see ColorSpace * @see ColorSpace
...@@ -1176,23 +1177,32 @@ public class Color implements Paint, java.io.Serializable { ...@@ -1176,23 +1177,32 @@ public class Color implements Paint, java.io.Serializable {
} }
/** /**
* Creates and returns a {@link PaintContext} used to generate a solid * Creates and returns a {@link PaintContext} used to
* color pattern. This enables a <code>Color</code> object to be used * generate a solid color field pattern.
* as an argument to any method requiring an object implementing the * See the {@link Paint#createContext specification} of the
* {@link Paint} interface. * method in the {@link Paint} interface for information
* The same <code>PaintContext</code> is returned, regardless of * on null parameter handling.
* whether or not <code>r</code>, <code>r2d</code>, *
* <code>xform</code>, or <code>hints</code> are <code>null</code>. * @param cm the preferred {@link ColorModel} which represents the most convenient
* @param cm the specified <code>ColorModel</code> * format for the caller to receive the pixel data, or {@code null}
* @param r the specified {@link Rectangle} * if there is no preference.
* @param r2d the specified {@link Rectangle2D} * @param r the device space bounding box
* @param xform the specified {@link AffineTransform} * of the graphics primitive being rendered.
* @param hints the specified {@link RenderingHints} * @param r2d the user space bounding box
* @return a <code>PaintContext</code> that is used to generate a * of the graphics primitive being rendered.
* solid color pattern. * @param xform the {@link AffineTransform} from user
* space into device space.
* @param hints the set of hints that the context object can use to
* choose between rendering alternatives.
* @return the {@code PaintContext} for
* generating color patterns.
* @see Paint * @see Paint
* @see PaintContext * @see PaintContext
* @see Graphics2D#setPaint * @see ColorModel
* @see Rectangle
* @see Rectangle2D
* @see AffineTransform
* @see RenderingHints
*/ */
public synchronized PaintContext createContext(ColorModel cm, Rectangle r, public synchronized PaintContext createContext(ColorModel cm, Rectangle r,
Rectangle2D r2d, Rectangle2D r2d,
......
...@@ -53,6 +53,7 @@ import java.awt.image.ColorModel; ...@@ -53,6 +53,7 @@ import java.awt.image.ColorModel;
* *
* @see Paint * @see Paint
* @see Graphics2D#setPaint * @see Graphics2D#setPaint
* @version 10 Feb 1997
*/ */
public class GradientPaint implements Paint { public class GradientPaint implements Paint {
...@@ -223,19 +224,32 @@ public class GradientPaint implements Paint { ...@@ -223,19 +224,32 @@ public class GradientPaint implements Paint {
} }
/** /**
* Creates and returns a context used to generate the color pattern. * Creates and returns a {@link PaintContext} used to
* @param cm {@link ColorModel} that receives * generate a linear color gradient pattern.
* the <code>Paint</code> data. This is used only as a hint. * See the {@link Paint#createContext specification} of the
* @param deviceBounds the device space bounding box of the * method in the {@link Paint} interface for information
* graphics primitive being rendered * on null parameter handling.
* @param userBounds the user space bounding box of the *
* graphics primitive being rendered * @param cm the preferred {@link ColorModel} which represents the most convenient
* format for the caller to receive the pixel data, or {@code null}
* if there is no preference.
* @param deviceBounds the device space bounding box
* of the graphics primitive being rendered.
* @param userBounds the user space bounding box
* of the graphics primitive being rendered.
* @param xform the {@link AffineTransform} from user * @param xform the {@link AffineTransform} from user
* space into device space * space into device space.
* @param hints the hints that the context object uses to choose * @param hints the set of hints that the context object can use to
* between rendering alternatives * choose between rendering alternatives.
* @return the {@link PaintContext} that generates color patterns. * @return the {@code PaintContext} for
* generating color patterns.
* @see Paint
* @see PaintContext * @see PaintContext
* @see ColorModel
* @see Rectangle
* @see Rectangle2D
* @see AffineTransform
* @see RenderingHints
*/ */
public PaintContext createContext(ColorModel cm, public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds, Rectangle deviceBounds,
......
...@@ -296,7 +296,32 @@ public final class LinearGradientPaint extends MultipleGradientPaint { ...@@ -296,7 +296,32 @@ public final class LinearGradientPaint extends MultipleGradientPaint {
} }
/** /**
* {@inheritDoc} * Creates and returns a {@link PaintContext} used to
* generate a linear color gradient pattern.
* See the {@link Paint#createContext specification} of the
* method in the {@link Paint} interface for information
* on null parameter handling.
*
* @param cm the preferred {@link ColorModel} which represents the most convenient
* format for the caller to receive the pixel data, or {@code null}
* if there is no preference.
* @param deviceBounds the device space bounding box
* of the graphics primitive being rendered.
* @param userBounds the user space bounding box
* of the graphics primitive being rendered.
* @param transform the {@link AffineTransform} from user
* space into device space.
* @param hints the set of hints that the context object can use to
* choose between rendering alternatives.
* @return the {@code PaintContext} for
* generating color patterns.
* @see Paint
* @see PaintContext
* @see ColorModel
* @see Rectangle
* @see Rectangle2D
* @see AffineTransform
* @see RenderingHints
*/ */
public PaintContext createContext(ColorModel cm, public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds, Rectangle deviceBounds,
......
...@@ -46,42 +46,58 @@ import java.awt.geom.Rectangle2D; ...@@ -46,42 +46,58 @@ import java.awt.geom.Rectangle2D;
* @see GradientPaint * @see GradientPaint
* @see TexturePaint * @see TexturePaint
* @see Graphics2D#setPaint * @see Graphics2D#setPaint
* @version 1.36, 06/05/07
*/ */
public interface Paint extends Transparency { public interface Paint extends Transparency {
/** /**
* Creates and returns a {@link PaintContext} used to * Creates and returns a {@link PaintContext} used to
* generate the color pattern. * generate the color pattern.
* Since the ColorModel argument to createContext is only a * The arguments to this method convey additional information
* hint, implementations of Paint should accept a null argument * about the rendering operation that may be
* for ColorModel. Note that if the application does not * used or ignored on various implementations of the {@code Paint} interface.
* prefer a specific ColorModel, the null ColorModel argument * A caller must pass non-{@code null} values for all of the arguments
* will give the Paint implementation full leeway in using the * except for the {@code ColorModel} argument which may be {@code null} to
* most efficient ColorModel it prefers for its raster processing. * indicate that no specific {@code ColorModel} type is preferred.
* <p> * Implementations of the {@code Paint} interface are allowed to use or ignore
* Since the API documentation was not specific about this in * any of the arguments as makes sense for their function, and are
* releases before 1.4, there may be implementations of * not constrained to use the specified {@code ColorModel} for the returned
* <code>Paint</code> that do not accept a null * {@code PaintContext}, even if it is not {@code null}.
* <code>ColorModel</code> argument. * Implementations are allowed to throw {@code NullPointerException} for
* If a developer is writing code which passes a null * any {@code null} argument other than the {@code ColorModel} argument,
* <code>ColorModel</code> argument to the * but are not required to do so.
* <code>createContext</code> method of <code>Paint</code> *
* objects from arbitrary sources it would be wise to code defensively * @param cm the preferred {@link ColorModel} which represents the most convenient
* by manufacturing a non-null <code>ColorModel</code> for those * format for the caller to receive the pixel data, or {@code null}
* objects which throw a <code>NullPointerException</code>. * if there is no preference.
* @param cm the {@link ColorModel} that receives the
* <code>Paint</code> data. This is used only as a hint.
* @param deviceBounds the device space bounding box * @param deviceBounds the device space bounding box
* of the graphics primitive being rendered * of the graphics primitive being rendered.
* Implementations of the {@code Paint} interface
* are allowed to throw {@code NullPointerException}
* for a {@code null} {@code deviceBounds}.
* @param userBounds the user space bounding box * @param userBounds the user space bounding box
* of the graphics primitive being rendered * of the graphics primitive being rendered.
* Implementations of the {@code Paint} interface
* are allowed to throw {@code NullPointerException}
* for a {@code null} {@code userBounds}.
* @param xform the {@link AffineTransform} from user * @param xform the {@link AffineTransform} from user
* space into device space * space into device space.
* @param hints the hint that the context object uses to * Implementations of the {@code Paint} interface
* choose between rendering alternatives * are allowed to throw {@code NullPointerException}
* @return the <code>PaintContext</code> for * for a {@code null} {@code xform}.
* generating color patterns * @param hints the set of hints that the context object can use to
* choose between rendering alternatives.
* Implementations of the {@code Paint} interface
* are allowed to throw {@code NullPointerException}
* for a {@code null} {@code hints}.
* @return the {@code PaintContext} for
* generating color patterns.
* @see PaintContext * @see PaintContext
* @see ColorModel
* @see Rectangle
* @see Rectangle2D
* @see AffineTransform
* @see RenderingHints
*/ */
public PaintContext createContext(ColorModel cm, public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds, Rectangle deviceBounds,
......
...@@ -543,7 +543,31 @@ public final class RadialGradientPaint extends MultipleGradientPaint { ...@@ -543,7 +543,31 @@ public final class RadialGradientPaint extends MultipleGradientPaint {
} }
/** /**
* {@inheritDoc} * Creates and returns a {@link PaintContext} used to
* generate a circular radial color gradient pattern.
* See the description of the {@link Paint#createContext createContext} method
* for information on null parameter handling.
*
* @param cm the preferred {@link ColorModel} which represents the most convenient
* format for the caller to receive the pixel data, or {@code null}
* if there is no preference.
* @param deviceBounds the device space bounding box
* of the graphics primitive being rendered.
* @param userBounds the user space bounding box
* of the graphics primitive being rendered.
* @param transform the {@link AffineTransform} from user
* space into device space.
* @param hints the set of hints that the context object can use to
* choose between rendering alternatives.
* @return the {@code PaintContext} for
* generating color patterns.
* @see Paint
* @see PaintContext
* @see ColorModel
* @see Rectangle
* @see Rectangle2D
* @see AffineTransform
* @see RenderingHints
*/ */
public PaintContext createContext(ColorModel cm, public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds, Rectangle deviceBounds,
......
...@@ -45,6 +45,7 @@ import java.awt.image.ColorModel; ...@@ -45,6 +45,7 @@ import java.awt.image.ColorModel;
* replicated <code>Rectangle2D</code>. * replicated <code>Rectangle2D</code>.
* @see Paint * @see Paint
* @see Graphics2D#setPaint * @see Graphics2D#setPaint
* @version 1.48, 06/05/07
*/ */
public class TexturePaint implements Paint { public class TexturePaint implements Paint {
...@@ -93,20 +94,32 @@ public class TexturePaint implements Paint { ...@@ -93,20 +94,32 @@ public class TexturePaint implements Paint {
} }
/** /**
* Creates and returns a context used to generate the color pattern. * Creates and returns a {@link PaintContext} used to
* @param cm the {@link ColorModel} that receives the * generate a tiled image pattern.
* <code>Paint</code> data. This is used only as a hint. * See the {@link Paint#createContext specification} of the
* @param deviceBounds the device space bounding box of the graphics * method in the {@link Paint} interface for information
* primitive being rendered * on null parameter handling.
* @param userBounds the user space bounding box of the graphics *
* primitive being rendered * @param cm the preferred {@link ColorModel} which represents the most convenient
* @param xform the {@link AffineTransform} from user space * format for the caller to receive the pixel data, or {@code null}
* into device space * if there is no preference.
* @param hints a {@link RenderingHints} object that can be used to * @param deviceBounds the device space bounding box
* specify how the pattern is ultimately rendered * of the graphics primitive being rendered.
* @return the {@link PaintContext} used for generating color * @param userBounds the user space bounding box
* patterns. * of the graphics primitive being rendered.
* @param xform the {@link AffineTransform} from user
* space into device space.
* @param hints the set of hints that the context object can use to
* choose between rendering alternatives.
* @return the {@code PaintContext} for
* generating color patterns.
* @see Paint
* @see PaintContext * @see PaintContext
* @see ColorModel
* @see Rectangle
* @see Rectangle2D
* @see AffineTransform
* @see RenderingHints
*/ */
public PaintContext createContext(ColorModel cm, public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds, Rectangle deviceBounds,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册