< prev index next >

src/java.desktop/share/classes/java/awt/image/DataBufferDouble.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2017, 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


  35  * Note that some implementations may function more efficiently
  36  * if they can maintain control over how the data for an image is
  37  * stored.
  38  * For example, optimizations such as caching an image in video
  39  * memory require that the implementation track all modifications
  40  * to that data.
  41  * Other implementations may operate better if they can store the
  42  * data in locations other than a Java array.
  43  * To maintain optimum compatibility with various optimizations
  44  * it is best to avoid constructors and methods which expose the
  45  * underlying storage as a Java array as noted below in the
  46  * documentation for those methods.
  47  * </a>
  48  *
  49  * @since 1.4
  50  */
  51 
  52 public final class DataBufferDouble extends DataBuffer {
  53 
  54     /** The array of data banks. */
  55     double bankdata[][];
  56 
  57     /** A reference to the default data bank. */
  58     double data[];
  59 
  60     /**
  61      * Constructs a {@code double}-based {@code DataBuffer}
  62      * with a specified size.
  63      *
  64      * @param size The number of elements in the {@code DataBuffer}.
  65      */
  66     public DataBufferDouble(int size) {
  67         super(STABLE, TYPE_DOUBLE, size);
  68         data = new double[size];
  69         bankdata = new double[1][];
  70         bankdata[0] = data;
  71     }
  72 
  73     /**
  74      * Constructs a {@code double}-based {@code DataBuffer}
  75      * with a specified number of banks, all of which are of a
  76      * specified size.
  77      *
  78      * @param size The number of elements in each bank of the


  87         }
  88         data = bankdata[0];
  89     }
  90 
  91     /**
  92      * Constructs a {@code double}-based {@code DataBuffer}
  93      * with the specified data array.  Only the first
  94      * {@code size} elements are available for use by this
  95      * {@code DataBuffer}.  The array must be large enough to
  96      * hold {@code size} elements.
  97      * <p>
  98      * Note that {@code DataBuffer} objects created by this constructor
  99      * may be incompatible with <a href="#optimizations">performance
 100      * optimizations</a> used by some implementations (such as caching
 101      * an associated image in video memory).
 102      *
 103      * @param dataArray An array of {@code double}s to be used as the
 104      *                  first and only bank of this {@code DataBuffer}.
 105      * @param size The number of elements of the array to be used.
 106      */
 107     public DataBufferDouble(double dataArray[], int size) {
 108         super(UNTRACKABLE, TYPE_DOUBLE, size);
 109         data = dataArray;
 110         bankdata = new double[1][];
 111         bankdata[0] = data;
 112     }
 113 
 114     /**
 115      * Constructs a {@code double}-based {@code DataBuffer}
 116      * with the specified data array.  Only the elements between
 117      * {@code offset} and {@code offset + size - 1} are
 118      * available for use by this {@code DataBuffer}.  The array
 119      * must be large enough to hold {@code offset + size} elements.
 120      * <p>
 121      * Note that {@code DataBuffer} objects created by this constructor
 122      * may be incompatible with <a href="#optimizations">performance
 123      * optimizations</a> used by some implementations (such as caching
 124      * an associated image in video memory).
 125      *
 126      * @param dataArray An array of {@code double}s to be used as the
 127      *                  first and only bank of this {@code DataBuffer}.
 128      * @param size The number of elements of the array to be used.
 129      * @param offset The offset of the first element of the array
 130      *               that will be used.
 131      */
 132     public DataBufferDouble(double dataArray[], int size, int offset) {
 133         super(UNTRACKABLE, TYPE_DOUBLE, size, 1, offset);
 134         data = dataArray;
 135         bankdata = new double[1][];
 136         bankdata[0] = data;
 137     }
 138 
 139     /**
 140      * Constructs a {@code double}-based {@code DataBuffer}
 141      * with the specified data arrays.  Only the first
 142      * {@code size} elements of each array are available for use
 143      * by this {@code DataBuffer}.  The number of banks will be
 144      * equal {@code to dataArray.length}.
 145      * <p>
 146      * Note that {@code DataBuffer} objects created by this constructor
 147      * may be incompatible with <a href="#optimizations">performance
 148      * optimizations</a> used by some implementations (such as caching
 149      * an associated image in video memory).
 150      *
 151      * @param dataArray An array of arrays of {@code double}s to be
 152      *        used as the banks of this {@code DataBuffer}.
 153      * @param size The number of elements of each array to be used.
 154      */
 155     public DataBufferDouble(double dataArray[][], int size) {
 156         super(UNTRACKABLE, TYPE_DOUBLE, size, dataArray.length);
 157         bankdata = dataArray.clone();
 158         data = bankdata[0];
 159     }
 160 
 161     /**
 162      * Constructs a {@code double}-based {@code DataBuffer}
 163      * with the specified data arrays, size, and per-bank offsets.
 164      * The number of banks is equal to dataArray.length.  Each array
 165      * must be at least as large as {@code size} plus the
 166      * corresponding offset.  There must be an entry in the
 167      * {@code offsets} array for each data array.
 168      * <p>
 169      * Note that {@code DataBuffer} objects created by this constructor
 170      * may be incompatible with <a href="#optimizations">performance
 171      * optimizations</a> used by some implementations (such as caching
 172      * an associated image in video memory).
 173      *
 174      * @param dataArray An array of arrays of {@code double}s to be
 175      *        used as the banks of this {@code DataBuffer}.
 176      * @param size The number of elements of each array to be used.
 177      * @param offsets An array of integer offsets, one for each bank.
 178      */
 179     public DataBufferDouble(double dataArray[][], int size, int offsets[]) {
 180         super(UNTRACKABLE, TYPE_DOUBLE, size, dataArray.length, offsets);
 181         bankdata = dataArray.clone();
 182         data = bankdata[0];
 183     }
 184 
 185     /**
 186      * Returns the default (first) {@code double} data array.
 187      * <p>
 188      * Note that calling this method may cause this {@code DataBuffer}
 189      * object to be incompatible with <a href="#optimizations">performance
 190      * optimizations</a> used by some implementations (such as caching
 191      * an associated image in video memory).
 192      *
 193      * @return the first double data array.
 194      */
 195     public double[] getData() {
 196         theTrackable.setUntrackable();
 197         return data;
 198     }
 199 


   1 /*
   2  * Copyright (c) 2000, 2018, 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


  35  * Note that some implementations may function more efficiently
  36  * if they can maintain control over how the data for an image is
  37  * stored.
  38  * For example, optimizations such as caching an image in video
  39  * memory require that the implementation track all modifications
  40  * to that data.
  41  * Other implementations may operate better if they can store the
  42  * data in locations other than a Java array.
  43  * To maintain optimum compatibility with various optimizations
  44  * it is best to avoid constructors and methods which expose the
  45  * underlying storage as a Java array as noted below in the
  46  * documentation for those methods.
  47  * </a>
  48  *
  49  * @since 1.4
  50  */
  51 
  52 public final class DataBufferDouble extends DataBuffer {
  53 
  54     /** The array of data banks. */
  55     double[][] bankdata;
  56 
  57     /** A reference to the default data bank. */
  58     double[] data;
  59 
  60     /**
  61      * Constructs a {@code double}-based {@code DataBuffer}
  62      * with a specified size.
  63      *
  64      * @param size The number of elements in the {@code DataBuffer}.
  65      */
  66     public DataBufferDouble(int size) {
  67         super(STABLE, TYPE_DOUBLE, size);
  68         data = new double[size];
  69         bankdata = new double[1][];
  70         bankdata[0] = data;
  71     }
  72 
  73     /**
  74      * Constructs a {@code double}-based {@code DataBuffer}
  75      * with a specified number of banks, all of which are of a
  76      * specified size.
  77      *
  78      * @param size The number of elements in each bank of the


  87         }
  88         data = bankdata[0];
  89     }
  90 
  91     /**
  92      * Constructs a {@code double}-based {@code DataBuffer}
  93      * with the specified data array.  Only the first
  94      * {@code size} elements are available for use by this
  95      * {@code DataBuffer}.  The array must be large enough to
  96      * hold {@code size} elements.
  97      * <p>
  98      * Note that {@code DataBuffer} objects created by this constructor
  99      * may be incompatible with <a href="#optimizations">performance
 100      * optimizations</a> used by some implementations (such as caching
 101      * an associated image in video memory).
 102      *
 103      * @param dataArray An array of {@code double}s to be used as the
 104      *                  first and only bank of this {@code DataBuffer}.
 105      * @param size The number of elements of the array to be used.
 106      */
 107     public DataBufferDouble(double[] dataArray, int size) {
 108         super(UNTRACKABLE, TYPE_DOUBLE, size);
 109         data = dataArray;
 110         bankdata = new double[1][];
 111         bankdata[0] = data;
 112     }
 113 
 114     /**
 115      * Constructs a {@code double}-based {@code DataBuffer}
 116      * with the specified data array.  Only the elements between
 117      * {@code offset} and {@code offset + size - 1} are
 118      * available for use by this {@code DataBuffer}.  The array
 119      * must be large enough to hold {@code offset + size} elements.
 120      * <p>
 121      * Note that {@code DataBuffer} objects created by this constructor
 122      * may be incompatible with <a href="#optimizations">performance
 123      * optimizations</a> used by some implementations (such as caching
 124      * an associated image in video memory).
 125      *
 126      * @param dataArray An array of {@code double}s to be used as the
 127      *                  first and only bank of this {@code DataBuffer}.
 128      * @param size The number of elements of the array to be used.
 129      * @param offset The offset of the first element of the array
 130      *               that will be used.
 131      */
 132     public DataBufferDouble(double[] dataArray, int size, int offset) {
 133         super(UNTRACKABLE, TYPE_DOUBLE, size, 1, offset);
 134         data = dataArray;
 135         bankdata = new double[1][];
 136         bankdata[0] = data;
 137     }
 138 
 139     /**
 140      * Constructs a {@code double}-based {@code DataBuffer}
 141      * with the specified data arrays.  Only the first
 142      * {@code size} elements of each array are available for use
 143      * by this {@code DataBuffer}.  The number of banks will be
 144      * equal {@code to dataArray.length}.
 145      * <p>
 146      * Note that {@code DataBuffer} objects created by this constructor
 147      * may be incompatible with <a href="#optimizations">performance
 148      * optimizations</a> used by some implementations (such as caching
 149      * an associated image in video memory).
 150      *
 151      * @param dataArray An array of arrays of {@code double}s to be
 152      *        used as the banks of this {@code DataBuffer}.
 153      * @param size The number of elements of each array to be used.
 154      */
 155     public DataBufferDouble(double[][] dataArray, int size) {
 156         super(UNTRACKABLE, TYPE_DOUBLE, size, dataArray.length);
 157         bankdata = dataArray.clone();
 158         data = bankdata[0];
 159     }
 160 
 161     /**
 162      * Constructs a {@code double}-based {@code DataBuffer}
 163      * with the specified data arrays, size, and per-bank offsets.
 164      * The number of banks is equal to dataArray.length.  Each array
 165      * must be at least as large as {@code size} plus the
 166      * corresponding offset.  There must be an entry in the
 167      * {@code offsets} array for each data array.
 168      * <p>
 169      * Note that {@code DataBuffer} objects created by this constructor
 170      * may be incompatible with <a href="#optimizations">performance
 171      * optimizations</a> used by some implementations (such as caching
 172      * an associated image in video memory).
 173      *
 174      * @param dataArray An array of arrays of {@code double}s to be
 175      *        used as the banks of this {@code DataBuffer}.
 176      * @param size The number of elements of each array to be used.
 177      * @param offsets An array of integer offsets, one for each bank.
 178      */
 179     public DataBufferDouble(double[][] dataArray, int size, int[] offsets) {
 180         super(UNTRACKABLE, TYPE_DOUBLE, size, dataArray.length, offsets);
 181         bankdata = dataArray.clone();
 182         data = bankdata[0];
 183     }
 184 
 185     /**
 186      * Returns the default (first) {@code double} data array.
 187      * <p>
 188      * Note that calling this method may cause this {@code DataBuffer}
 189      * object to be incompatible with <a href="#optimizations">performance
 190      * optimizations</a> used by some implementations (such as caching
 191      * an associated image in video memory).
 192      *
 193      * @return the first double data array.
 194      */
 195     public double[] getData() {
 196         theTrackable.setUntrackable();
 197         return data;
 198     }
 199 


< prev index next >