changeset 1458:802e47751653

RT-21826 ImagePattern exception/background image load
author "Joseph Andresen<joseph.andresen@oracle.com>"
date Thu, 12 Jul 2012 14:18:08 -0700
parents b7f67bf6f737
children 2ca0c5dc56ee
files javafx-ui-common/src/javafx/scene/paint/ImagePattern.java
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/paint/ImagePattern.java	Tue Jul 10 14:04:22 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/paint/ImagePattern.java	Thu Jul 12 14:18:08 2012 -0700
@@ -216,8 +216,16 @@
      * values are used for all other parameters.
      * 
      * @param image the image to be used as the paint.
+     * @throws NullPointerException if the image is null.
+     * @throws IllegalArgumentException if image is not done loading, 
+     * that is if progress is < 1.
      */
     public ImagePattern(Image image) {
+        if (image == null) {
+            throw new NullPointerException("Image must be non-null.");
+        } else if (image.getProgress() < 1.0) {
+            throw new IllegalArgumentException("Image not yet loaded");
+        }
         this.image = image;
     }
 
@@ -231,10 +239,18 @@
      * @param height the height of the anchor rectangle.
      * @param proportional whether the coordinates are proportional
      * to the shape which ImagePattern fills
+     * @throws NullPointerException if the image is null.
+     * @throws IllegalArgumentException if image is not done loading, 
+     * that is if progress is < 1.
      */
     public ImagePattern(Image image, double x, double y, double width,
             double height, boolean proportional) {
 
+        if (image == null) {
+            throw new NullPointerException("Image must be non-null.");
+        } else if (image.getProgress() < 1.0) {
+            throw new IllegalArgumentException("Image not yet loaded");
+        }
         this.image = image;
         this.x = x;
         this.y = y;