1 /*
   2  * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package test.com.sun.javafx.pgstub;
  27 
  28 import com.sun.javafx.tk.PlatformImage;
  29 import java.nio.Buffer;
  30 import java.nio.ByteBuffer;
  31 import java.nio.IntBuffer;
  32 import javafx.scene.image.PixelFormat;
  33 import javafx.scene.image.PixelReader;
  34 import javafx.scene.image.WritablePixelFormat;
  35 
  36 public final class StubPlatformImage implements PlatformImage {
  37     private final StubImageLoader imageLoader;
  38     private final int frame;
  39 
  40     public StubPlatformImage(final StubImageLoader imageLoader,
  41                              final int frame) {
  42         this.imageLoader = imageLoader;
  43         this.frame = frame;
  44     }
  45 
  46     public int getFrame() {
  47         return frame;
  48     }
  49 
  50     @Override
  51     public float getPixelScale() {
  52         return 1.0f;
  53     }
  54 
  55     public StubImageLoader getImageLoader() {
  56         return imageLoader;
  57     }
  58 
  59     public StubPlatformImageInfo getImageInfo() {
  60         return imageLoader.getImageInfo();
  61     }
  62 
  63     public Object getSource() {
  64         return imageLoader.getSource();
  65     }
  66 
  67     @Override
  68     public PixelFormat getPlatformPixelFormat() {
  69         throw new UnsupportedOperationException("Not supported yet.");
  70     }
  71 
  72     @Override
  73     public boolean isWritable() {
  74         throw new UnsupportedOperationException("Not supported yet.");
  75     }
  76 
  77     @Override
  78     public PlatformImage promoteToWritableImage() {
  79         throw new UnsupportedOperationException("Not supported yet.");
  80     }
  81 
  82     @Override
  83     public int getArgb(int x, int y) {
  84         throw new UnsupportedOperationException("Not supported yet.");
  85     }
  86 
  87     @Override
  88     public void setArgb(int x, int y, int argb) {
  89         throw new UnsupportedOperationException("Not supported yet.");
  90     }
  91 
  92     @Override
  93     public <T extends Buffer> void getPixels(int x, int y, int w, int h,
  94                                              WritablePixelFormat<T> pixelformat,
  95                                              T pixels, int scanlineBytes)
  96     {
  97         throw new UnsupportedOperationException("Not supported yet.");
  98     }
  99 
 100     @Override
 101     public void getPixels(int x, int y, int w, int h,
 102                           WritablePixelFormat<ByteBuffer> pixelformat,
 103                           byte[] pixels, int offset, int scanlineBytes)
 104     {
 105         throw new UnsupportedOperationException("Not supported yet.");
 106     }
 107 
 108     @Override
 109     public void getPixels(int x, int y, int w, int h,
 110                           WritablePixelFormat<IntBuffer> pixelformat,
 111                           int[] pixels, int offset, int scanlineInts)
 112     {
 113         throw new UnsupportedOperationException("Not supported yet.");
 114     }
 115 
 116     @Override
 117     public <T extends Buffer> void setPixels(int x, int y, int w, int h,
 118                                              PixelFormat<T> pixelformat,
 119                                              T pixels, int scanlineBytes)
 120     {
 121         throw new UnsupportedOperationException("Not supported yet.");
 122     }
 123 
 124     @Override
 125     public void setPixels(int x, int y, int w, int h,
 126                           PixelFormat<ByteBuffer> pixelformat,
 127                           byte[] pixels, int offset, int scanlineBytes)
 128     {
 129         throw new UnsupportedOperationException("Not supported yet.");
 130     }
 131 
 132     @Override
 133     public void setPixels(int x, int y, int w, int h,
 134                           PixelFormat<IntBuffer> pixelformat,
 135                           int[] pixels, int offset, int scanlineInts)
 136     {
 137         throw new UnsupportedOperationException("Not supported yet.");
 138     }
 139 
 140     @Override
 141     public void setPixels(int dstx, int dsty, int w, int h,
 142                           PixelReader reader, int srcx, int srcy)
 143     {
 144         throw new UnsupportedOperationException("Not supported yet.");
 145     }
 146 
 147     @Override
 148     public String toString() {
 149         final StringBuilder sb = new StringBuilder();
 150 
 151         sb.append("StubPlatformImage[source = ")
 152           .append(imageLoader.getSource())
 153           .append(", width = ").append(imageLoader.getWidth())
 154           .append(", height = ").append(imageLoader.getHeight())
 155           .append(", frame = ").append(frame)
 156           .append("]");
 157 
 158         return sb.toString();
 159     }
 160 }