Home » openjdk-7 » java » awt » image » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   /**
   18    * @author Igor V. Stolyarov
   19    * Created on 23.11.2005
   20    *
   21    */
   22   package java.awt.image;
   23   
   24   import java.awt.Image;
   25   import java.awt.image.DataBuffer;
   26   import java.awt.image.DataBufferByte;
   27   import java.awt.image.DataBufferDouble;
   28   import java.awt.image.DataBufferFloat;
   29   import java.awt.image.DataBufferInt;
   30   import java.awt.image.DataBufferShort;
   31   import java.awt.image.DataBufferUShort;
   32   
   33   import org.apache.harmony.awt.gl.AwtImageBackdoorAccessor;
   34   import org.apache.harmony.awt.gl.GLVolatileImage;
   35   import org.apache.harmony.awt.gl.Surface;
   36   import org.apache.harmony.awt.gl.image.DataBufferListener;
   37   import org.apache.harmony.awt.internal.nls.Messages;
   38   
   39   /**
   40    * This class not part of public API. It useful for receiving package private
   41    * data from other packages.
   42    */
   43   class AwtImageBackdoorAccessorImpl extends AwtImageBackdoorAccessor {
   44   
   45       static void init(){
   46           inst = new AwtImageBackdoorAccessorImpl();
   47       }
   48   
   49       @Override
   50       public Surface getImageSurface(Image image) {
   51           if (image instanceof BufferedImage){
   52               return ((BufferedImage)image).getImageSurface();
   53           } else if (image instanceof GLVolatileImage){
   54               return ((GLVolatileImage)image).getImageSurface();
   55           }
   56           return null;
   57       }
   58   
   59       @Override
   60       public boolean isGrayPallete(IndexColorModel icm){
   61           return icm.isGrayPallete();
   62       }
   63   
   64       @Override
   65       public Object getData(DataBuffer db) {
   66           if (db instanceof DataBufferByte){
   67               return ((DataBufferByte)db).getData();
   68           } else if (db instanceof DataBufferUShort){
   69               return ((DataBufferUShort)db).getData();
   70           } else if (db instanceof DataBufferShort){
   71               return ((DataBufferShort)db).getData();
   72           } else if (db instanceof DataBufferInt){
   73               return ((DataBufferInt)db).getData();
   74           } else if (db instanceof DataBufferFloat){
   75               return ((DataBufferFloat)db).getData();
   76           } else if (db instanceof DataBufferDouble){
   77               return ((DataBufferDouble)db).getData();
   78           } else {
   79               // awt.235=Wrong Data Buffer type : {0}
   80               throw new IllegalArgumentException(Messages.getString("awt.235", //$NON-NLS-1$
   81                       db.getClass()));
   82           }
   83       }
   84   
   85       @Override
   86       public int[] getDataInt(DataBuffer db) {
   87           if (db instanceof DataBufferInt){
   88               return ((DataBufferInt)db).getData();
   89           }
   90           return null;
   91       }
   92   
   93       @Override
   94       public byte[] getDataByte(DataBuffer db) {
   95           if (db instanceof DataBufferByte){
   96               return ((DataBufferByte)db).getData();
   97           }
   98           return null;
   99       }
  100   
  101       @Override
  102       public short[] getDataShort(DataBuffer db) {
  103           if (db instanceof DataBufferShort){
  104               return ((DataBufferShort)db).getData();
  105           }
  106           return null;
  107       }
  108   
  109       @Override
  110       public short[] getDataUShort(DataBuffer db) {
  111           if (db instanceof DataBufferUShort){
  112               return ((DataBufferUShort)db).getData();
  113           }
  114           return null;
  115       }
  116   
  117       @Override
  118       public double[] getDataDouble(DataBuffer db) {
  119           if (db instanceof DataBufferDouble){
  120               return ((DataBufferDouble)db).getData();
  121           }
  122           return null;
  123       }
  124   
  125       @Override
  126       public float[] getDataFloat(DataBuffer db) {
  127           if (db instanceof DataBufferFloat){
  128               return ((DataBufferFloat)db).getData();
  129           }
  130           return null;
  131       }
  132   
  133       @Override
  134       public void addDataBufferListener(DataBuffer db, DataBufferListener listener) {
  135           db.addDataBufferListener(listener);
  136       }
  137   
  138       @Override
  139       public void removeDataBufferListener(DataBuffer db) {
  140           db.removeDataBufferListener();
  141       }
  142   
  143       @Override
  144       public void validate(DataBuffer db) {
  145           db.validate();
  146       }
  147   
  148       @Override
  149       public void releaseData(DataBuffer db) {
  150           db.releaseData();
  151       }
  152   }

Home » openjdk-7 » java » awt » image » [javadoc | source]