src/share/classes/sun/java2d/loops/GraphicsPrimitiveMgr.java

Print this page
rev 9629 : 8038644: Fix raw and unchecked warnings in sun.java2d.*
Reviewed-by:


  28  */
  29 
  30 package sun.java2d.loops;
  31 
  32 import java.util.Comparator;
  33 import java.util.Arrays;
  34 import sun.java2d.SunGraphics2D;
  35 
  36 /**
  37  *   GraphicsComponentMgr provides services to
  38  *   1. register primitives for later use
  39  *   2. locate an instance of a primitve based on characteristics
  40  */
  41 public final class GraphicsPrimitiveMgr {
  42 
  43     private static final boolean debugTrace = false;
  44     private static GraphicsPrimitive primitives[];
  45     private static GraphicsPrimitive generalPrimitives[];
  46     private static boolean needssort = true;
  47 
  48     private static native void initIDs(Class GP, Class ST, Class CT,
  49                                        Class SG2D, Class Color, Class AT,
  50                                        Class XORComp, Class AlphaComp,
  51                                        Class Path2D, Class Path2DFloat,
  52                                        Class SHints);
  53     private static native void registerNativeLoops();
  54 
  55     static {
  56         initIDs(GraphicsPrimitive.class,
  57                 SurfaceType.class,
  58                 CompositeType.class,
  59                 SunGraphics2D.class,
  60                 java.awt.Color.class,
  61                 java.awt.geom.AffineTransform.class,
  62                 XORComposite.class,
  63                 java.awt.AlphaComposite.class,
  64                 java.awt.geom.Path2D.class,
  65                 java.awt.geom.Path2D.Float.class,
  66                 sun.awt.SunHints.class);
  67         CustomComponent.register();
  68         GeneralRenderer.register();
  69         registerNativeLoops();
  70     }
  71 
  72     private static class PrimitiveSpec {
  73         public int uniqueID;
  74     }
  75 
  76     private static Comparator primSorter = new Comparator() {
  77         public int compare(Object o1, Object o2) {
  78             int id1 = ((GraphicsPrimitive) o1).getUniqueID();
  79             int id2 = ((GraphicsPrimitive) o2).getUniqueID();

  80 
  81             return (id1 == id2 ? 0 : (id1 < id2 ? -1 : 1));
  82         }
  83     };
  84 
  85     private static Comparator primFinder = new Comparator() {
  86         public int compare(Object o1, Object o2) {
  87             int id1 = ((GraphicsPrimitive) o1).getUniqueID();
  88             int id2 = ((PrimitiveSpec) o2).uniqueID;
  89 
  90             return (id1 == id2 ? 0 : (id1 < id2 ? -1 : 1));
  91         }
  92     };
  93 
  94     /**
  95      * Ensure that noone can instantiate this class.
  96      */
  97     private GraphicsPrimitiveMgr() {
  98     }
  99 
 100     public synchronized static void register(GraphicsPrimitive[] newPrimitives)
 101     {
 102         GraphicsPrimitive[] devCollection = primitives;
 103         int oldSize = 0;
 104         int newSize = newPrimitives.length;
 105         if (debugTrace) {




  28  */
  29 
  30 package sun.java2d.loops;
  31 
  32 import java.util.Comparator;
  33 import java.util.Arrays;
  34 import sun.java2d.SunGraphics2D;
  35 
  36 /**
  37  *   GraphicsComponentMgr provides services to
  38  *   1. register primitives for later use
  39  *   2. locate an instance of a primitve based on characteristics
  40  */
  41 public final class GraphicsPrimitiveMgr {
  42 
  43     private static final boolean debugTrace = false;
  44     private static GraphicsPrimitive primitives[];
  45     private static GraphicsPrimitive generalPrimitives[];
  46     private static boolean needssort = true;
  47 
  48     private static native void initIDs(Class<?> GP, Class<?> ST, Class<?> CT,
  49                                        Class<?> SG2D, Class<?> Color, Class<?> AT,
  50                                        Class<?> XORComp, Class<?> AlphaComp,
  51                                        Class<?> Path2D, Class<?> Path2DFloat,
  52                                        Class<?> SHints);
  53     private static native void registerNativeLoops();
  54 
  55     static {
  56         initIDs(GraphicsPrimitive.class,
  57                 SurfaceType.class,
  58                 CompositeType.class,
  59                 SunGraphics2D.class,
  60                 java.awt.Color.class,
  61                 java.awt.geom.AffineTransform.class,
  62                 XORComposite.class,
  63                 java.awt.AlphaComposite.class,
  64                 java.awt.geom.Path2D.class,
  65                 java.awt.geom.Path2D.Float.class,
  66                 sun.awt.SunHints.class);
  67         CustomComponent.register();
  68         GeneralRenderer.register();
  69         registerNativeLoops();
  70     }
  71 
  72     private static class PrimitiveSpec {
  73         public int uniqueID;
  74     }
  75 
  76     private static Comparator<GraphicsPrimitive> primSorter =
  77             new Comparator<GraphicsPrimitive>() {
  78         public int compare(GraphicsPrimitive o1, GraphicsPrimitive o2) {
  79             int id1 = o1.getUniqueID();
  80             int id2 = o2.getUniqueID();
  81 
  82             return (id1 == id2 ? 0 : (id1 < id2 ? -1 : 1));
  83         }
  84     };
  85 
  86     private static Comparator<Object> primFinder = new Comparator<Object>() {
  87         public int compare(Object o1, Object o2) {
  88             int id1 = ((GraphicsPrimitive) o1).getUniqueID();
  89             int id2 = ((PrimitiveSpec) o2).uniqueID;
  90 
  91             return (id1 == id2 ? 0 : (id1 < id2 ? -1 : 1));
  92         }
  93     };
  94 
  95     /**
  96      * Ensure that noone can instantiate this class.
  97      */
  98     private GraphicsPrimitiveMgr() {
  99     }
 100 
 101     public synchronized static void register(GraphicsPrimitive[] newPrimitives)
 102     {
 103         GraphicsPrimitive[] devCollection = primitives;
 104         int oldSize = 0;
 105         int newSize = newPrimitives.length;
 106         if (debugTrace) {