src/share/classes/sun/awt/image/ImagingLib.java

Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr


  44  * This class provides a hook to access platform-specific
  45  * imaging code.
  46  *
  47  * If the implementing class cannot handle the op, tile format or
  48  * image format, the method will return null;
  49  * If there is an error when processing the
  50  * data, the implementing class may either return null
  51  * (in which case our java code will be executed) or may throw
  52  * an exception.
  53  */
  54 public class ImagingLib {
  55 
  56     static boolean useLib = true;
  57     static boolean verbose = false;
  58 
  59     private static final int NUM_NATIVE_OPS = 3;
  60     private static final int LOOKUP_OP   = 0;
  61     private static final int AFFINE_OP   = 1;
  62     private static final int CONVOLVE_OP = 2;
  63 
  64     private static Class[] nativeOpClass = new Class[NUM_NATIVE_OPS];
  65 
  66     /**
  67      * Returned value indicates whether the library initailization was
  68      * succeded.
  69      *
  70      * There could be number of reasons to failure:
  71      * - failed to load library.
  72      * - failed to get all required entry points.
  73      */
  74     private static native boolean init();
  75 
  76     static public native int transformBI(BufferedImage src, BufferedImage dst,
  77                                          double[] matrix, int interpType);
  78     static public native int transformRaster(Raster src, Raster dst,
  79                                              double[] matrix,
  80                                              int interpType);
  81     static public native int convolveBI(BufferedImage src, BufferedImage dst,
  82                                         Kernel kernel, int edgeHint);
  83     static public native int convolveRaster(Raster src, Raster dst,
  84                                             Kernel kernel, int edgeHint);


 117             nativeOpClass[LOOKUP_OP] =
 118                 Class.forName("java.awt.image.LookupOp");
 119         } catch (ClassNotFoundException e) {
 120             System.err.println("Could not find class: "+e);
 121         }
 122         try {
 123             nativeOpClass[AFFINE_OP] =
 124                 Class.forName("java.awt.image.AffineTransformOp");
 125         } catch (ClassNotFoundException e) {
 126             System.err.println("Could not find class: "+e);
 127         }
 128         try {
 129             nativeOpClass[CONVOLVE_OP] =
 130                 Class.forName("java.awt.image.ConvolveOp");
 131         } catch (ClassNotFoundException e) {
 132             System.err.println("Could not find class: "+e);
 133         }
 134 
 135     }
 136 
 137     private static int getNativeOpIndex(Class opClass) {
 138         //
 139         // Search for this class in cached list of
 140         // classes supplying native acceleration
 141         //
 142         int opIndex = -1;
 143         for (int i=0; i<NUM_NATIVE_OPS; i++) {
 144             if (opClass == nativeOpClass[i]) {
 145                 opIndex = i;
 146                 break;
 147             }
 148         }
 149         return opIndex;
 150     }
 151 
 152 
 153     public static WritableRaster filter(RasterOp op, Raster src,
 154                                         WritableRaster dst) {
 155         if (useLib == false) {
 156             return null;
 157         }




  44  * This class provides a hook to access platform-specific
  45  * imaging code.
  46  *
  47  * If the implementing class cannot handle the op, tile format or
  48  * image format, the method will return null;
  49  * If there is an error when processing the
  50  * data, the implementing class may either return null
  51  * (in which case our java code will be executed) or may throw
  52  * an exception.
  53  */
  54 public class ImagingLib {
  55 
  56     static boolean useLib = true;
  57     static boolean verbose = false;
  58 
  59     private static final int NUM_NATIVE_OPS = 3;
  60     private static final int LOOKUP_OP   = 0;
  61     private static final int AFFINE_OP   = 1;
  62     private static final int CONVOLVE_OP = 2;
  63 
  64     private static Class<?>[] nativeOpClass = new Class<?>[NUM_NATIVE_OPS];
  65 
  66     /**
  67      * Returned value indicates whether the library initailization was
  68      * succeded.
  69      *
  70      * There could be number of reasons to failure:
  71      * - failed to load library.
  72      * - failed to get all required entry points.
  73      */
  74     private static native boolean init();
  75 
  76     static public native int transformBI(BufferedImage src, BufferedImage dst,
  77                                          double[] matrix, int interpType);
  78     static public native int transformRaster(Raster src, Raster dst,
  79                                              double[] matrix,
  80                                              int interpType);
  81     static public native int convolveBI(BufferedImage src, BufferedImage dst,
  82                                         Kernel kernel, int edgeHint);
  83     static public native int convolveRaster(Raster src, Raster dst,
  84                                             Kernel kernel, int edgeHint);


 117             nativeOpClass[LOOKUP_OP] =
 118                 Class.forName("java.awt.image.LookupOp");
 119         } catch (ClassNotFoundException e) {
 120             System.err.println("Could not find class: "+e);
 121         }
 122         try {
 123             nativeOpClass[AFFINE_OP] =
 124                 Class.forName("java.awt.image.AffineTransformOp");
 125         } catch (ClassNotFoundException e) {
 126             System.err.println("Could not find class: "+e);
 127         }
 128         try {
 129             nativeOpClass[CONVOLVE_OP] =
 130                 Class.forName("java.awt.image.ConvolveOp");
 131         } catch (ClassNotFoundException e) {
 132             System.err.println("Could not find class: "+e);
 133         }
 134 
 135     }
 136 
 137     private static int getNativeOpIndex(Class<?> opClass) {
 138         //
 139         // Search for this class in cached list of
 140         // classes supplying native acceleration
 141         //
 142         int opIndex = -1;
 143         for (int i=0; i<NUM_NATIVE_OPS; i++) {
 144             if (opClass == nativeOpClass[i]) {
 145                 opIndex = i;
 146                 break;
 147             }
 148         }
 149         return opIndex;
 150     }
 151 
 152 
 153     public static WritableRaster filter(RasterOp op, Raster src,
 154                                         WritableRaster dst) {
 155         if (useLib == false) {
 156             return null;
 157         }