modules/graphics/src/main/java/com/sun/glass/ui/Pixels.java

Print this page




  63     // Need:
  64     // Clipboard:
  65     //    public Pixels(final int width, final int height, final byte[] data)
  66     //
  67     // Robot:
  68     //    public Pixels(final int width, final int height, final int[] data)
  69     //
  70     // PixelUtils == Prism == GlassToolkit :
  71     //    public Pixels(final int width, final int height, final ByteBuffer)
  72     //    public Pixels(final int width, final int height, final IntBuffer)
  73 
  74     // The following fields are safe to be protected, since they are final
  75     protected final int width;
  76     protected final int height;
  77     protected final int bytesPerComponent;
  78 
  79     // The following fields are safe to be protected, since they are final
  80     protected final ByteBuffer bytes;
  81     protected final IntBuffer ints;
  82 
  83     private final float scale;

  84 
  85     protected Pixels(final int width, final int height, final ByteBuffer pixels) {
  86         this.width = width;
  87         this.height = height;
  88         this.bytesPerComponent = 1;
  89         this.bytes = pixels.slice();
  90         if ((this.width <= 0) || (this.height <= 0) || ((this.width * this.height * 4) > this.bytes.capacity())) {
  91             throw new IllegalArgumentException("Too small byte buffer size "+this.width+"x"+this.height+" ["+(this.width*this.height*4)+"] > "+this.bytes.capacity());
  92         }
  93 
  94         this.ints = null;
  95         this.scale = 1.0f;

  96     }
  97 
  98     protected Pixels(final int width, final int height, IntBuffer pixels) {
  99         this.width = width;
 100         this.height = height;
 101         this.bytesPerComponent = 4;
 102         this.ints = pixels.slice();
 103         if ((this.width <= 0) || (this.height <= 0) || ((this.width * this.height) > this.ints.capacity())) {
 104             throw new IllegalArgumentException("Too small int buffer size "+this.width+"x"+this.height+" ["+(this.width*this.height)+"] > "+this.ints.capacity());
 105         }
 106 
 107         this.bytes = null;
 108         this.scale = 1.0f;

 109     }
 110 
 111     protected Pixels(final int width, final int height, IntBuffer pixels, float scale) {
 112         this.width = width;
 113         this.height = height;
 114         this.bytesPerComponent = 4;
 115         this.ints = pixels.slice();
 116         if ((this.width <= 0) || (this.height <= 0) || ((this.width * this.height) > this.ints.capacity())) {
 117             throw new IllegalArgumentException("Too small int buffer size "+this.width+"x"+this.height+" ["+(this.width*this.height)+"] > "+this.ints.capacity());
 118         }
 119 
 120         this.bytes = null;
 121         this.scale = scale;

 122     }
 123 
 124     public final float getScale() {
 125         Application.checkEventThread();
 126         return this.scale;
 127     }
 128 
 129     public final float getScaleUnsafe() {
 130         return this.scale;









 131     }
 132 
 133     public final int getWidth() {
 134         Application.checkEventThread();
 135         return this.width;
 136     }
 137 
 138     public final int getWidthUnsafe() {
 139         return this.width;
 140     }
 141 
 142     public final int getHeight() {
 143         Application.checkEventThread();
 144         return this.height;
 145     }
 146 
 147     public final int getHeightUnsafe() {
 148         return this.height;
 149     }
 150 




  63     // Need:
  64     // Clipboard:
  65     //    public Pixels(final int width, final int height, final byte[] data)
  66     //
  67     // Robot:
  68     //    public Pixels(final int width, final int height, final int[] data)
  69     //
  70     // PixelUtils == Prism == GlassToolkit :
  71     //    public Pixels(final int width, final int height, final ByteBuffer)
  72     //    public Pixels(final int width, final int height, final IntBuffer)
  73 
  74     // The following fields are safe to be protected, since they are final
  75     protected final int width;
  76     protected final int height;
  77     protected final int bytesPerComponent;
  78 
  79     // The following fields are safe to be protected, since they are final
  80     protected final ByteBuffer bytes;
  81     protected final IntBuffer ints;
  82 
  83     private final float scalex;
  84     private final float scaley;
  85 
  86     protected Pixels(final int width, final int height, final ByteBuffer pixels) {
  87         this.width = width;
  88         this.height = height;
  89         this.bytesPerComponent = 1;
  90         this.bytes = pixels.slice();
  91         if ((this.width <= 0) || (this.height <= 0) || ((this.width * this.height * 4) > this.bytes.capacity())) {
  92             throw new IllegalArgumentException("Too small byte buffer size "+this.width+"x"+this.height+" ["+(this.width*this.height*4)+"] > "+this.bytes.capacity());
  93         }
  94 
  95         this.ints = null;
  96         this.scalex = 1.0f;
  97         this.scaley = 1.0f;
  98     }
  99 
 100     protected Pixels(final int width, final int height, IntBuffer pixels) {
 101         this.width = width;
 102         this.height = height;
 103         this.bytesPerComponent = 4;
 104         this.ints = pixels.slice();
 105         if ((this.width <= 0) || (this.height <= 0) || ((this.width * this.height) > this.ints.capacity())) {
 106             throw new IllegalArgumentException("Too small int buffer size "+this.width+"x"+this.height+" ["+(this.width*this.height)+"] > "+this.ints.capacity());
 107         }
 108 
 109         this.bytes = null;
 110         this.scalex = 1.0f;
 111         this.scaley = 1.0f;
 112     }
 113 
 114     protected Pixels(final int width, final int height, IntBuffer pixels, float scalex, float scaley) {
 115         this.width = width;
 116         this.height = height;
 117         this.bytesPerComponent = 4;
 118         this.ints = pixels.slice();
 119         if ((this.width <= 0) || (this.height <= 0) || ((this.width * this.height) > this.ints.capacity())) {
 120             throw new IllegalArgumentException("Too small int buffer size "+this.width+"x"+this.height+" ["+(this.width*this.height)+"] > "+this.ints.capacity());
 121         }
 122 
 123         this.bytes = null;
 124         this.scalex = scalex;
 125         this.scaley = scaley;
 126     }
 127 
 128     public final float getScaleX() {
 129         Application.checkEventThread();
 130         return this.scalex;
 131     }
 132 
 133     public final float getScaleY() {
 134         Application.checkEventThread();
 135         return this.scaley;
 136     }
 137 
 138     public final float getScaleXUnsafe() {
 139         return this.scalex;
 140     }
 141 
 142     public final float getScaleYUnsafe() {
 143         return this.scaley;
 144     }
 145 
 146     public final int getWidth() {
 147         Application.checkEventThread();
 148         return this.width;
 149     }
 150 
 151     public final int getWidthUnsafe() {
 152         return this.width;
 153     }
 154 
 155     public final int getHeight() {
 156         Application.checkEventThread();
 157         return this.height;
 158     }
 159 
 160     public final int getHeightUnsafe() {
 161         return this.height;
 162     }
 163