src/java.desktop/share/classes/java/awt/image/DataBufferFloat.java
author tvaleev
Thu, 04 Oct 2018 12:40:55 -0700
changeset 52248 2e330da7cbf4
parent 47216 71c04702a3d5
permissions -rw-r--r--
8211300: Convert C-style array declarations in JDK client code Reviewed-by: prr, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
52248
2e330da7cbf4 8211300: Convert C-style array declarations in JDK client code
tvaleev
parents: 47216
diff changeset
     2
 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt.image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import static sun.java2d.StateTrackable.State.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    31
 * This class extends {@code DataBuffer} and stores data internally
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    32
 * in {@code float} form.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
45025
9ad3afa82b5e 8179596: Update java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
    34
 * <a id="optimizations">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Note that some implementations may function more efficiently
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * if they can maintain control over how the data for an image is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * stored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * For example, optimizations such as caching an image in video
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * memory require that the implementation track all modifications
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * to that data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Other implementations may operate better if they can store the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * data in locations other than a Java array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * To maintain optimum compatibility with various optimizations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * it is best to avoid constructors and methods which expose the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * underlying storage as a Java array as noted below in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * documentation for those methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * </a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
public final class DataBufferFloat extends DataBuffer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /** The array of data banks. */
52248
2e330da7cbf4 8211300: Convert C-style array declarations in JDK client code
tvaleev
parents: 47216
diff changeset
    55
    float[][] bankdata;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /** A reference to the default data bank. */
52248
2e330da7cbf4 8211300: Convert C-style array declarations in JDK client code
tvaleev
parents: 47216
diff changeset
    58
    float[] data;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    61
     * Constructs a {@code float}-based {@code DataBuffer}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * with a specified size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param size The number of elements in the DataBuffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public DataBufferFloat(int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        super(STABLE, TYPE_FLOAT, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        data = new float[size];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        bankdata = new float[1][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        bankdata[0] = data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    74
     * Constructs a {@code float}-based {@code DataBuffer}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * with a specified number of banks, all of which are of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * specified size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @param size The number of elements in each bank of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    79
     * {@code DataBuffer}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @param numBanks The number of banks in the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    81
     *        {@code DataBuffer}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public DataBufferFloat(int size, int numBanks) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        super(STABLE, TYPE_FLOAT, size, numBanks);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        bankdata = new float[numBanks][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        for (int i= 0; i < numBanks; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            bankdata[i] = new float[size];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        data = bankdata[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    93
     * Constructs a {@code float}-based {@code DataBuffer}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * with the specified data array.  Only the first
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    95
     * {@code size} elements are available for use by this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    96
     * {@code DataBuffer}.  The array must be large enough to
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    97
     * hold {@code size} elements.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Note that {@code DataBuffer} objects created by this constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * may be incompatible with <a href="#optimizations">performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * optimizations</a> used by some implementations (such as caching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * an associated image in video memory).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   104
     * @param dataArray An array of {@code float}s to be used as the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   105
     *                  first and only bank of this {@code DataBuffer}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @param size The number of elements of the array to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
52248
2e330da7cbf4 8211300: Convert C-style array declarations in JDK client code
tvaleev
parents: 47216
diff changeset
   108
    public DataBufferFloat(float[] dataArray, int size) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        super(UNTRACKABLE, TYPE_FLOAT, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        data = dataArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        bankdata = new float[1][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        bankdata[0] = data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   116
     * Constructs a {@code float}-based {@code DataBuffer}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * with the specified data array.  Only the elements between
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   118
     * {@code offset} and {@code offset + size - 1} are
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   119
     * available for use by this {@code DataBuffer}.  The array
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   120
     * must be large enough to hold {@code offset + size}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Note that {@code DataBuffer} objects created by this constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * may be incompatible with <a href="#optimizations">performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * optimizations</a> used by some implementations (such as caching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * an associated image in video memory).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   128
     * @param dataArray An array of {@code float}s to be used as the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   129
     *                  first and only bank of this {@code DataBuffer}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @param size The number of elements of the array to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param offset The offset of the first element of the array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *               that will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
52248
2e330da7cbf4 8211300: Convert C-style array declarations in JDK client code
tvaleev
parents: 47216
diff changeset
   134
    public DataBufferFloat(float[] dataArray, int size, int offset) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        super(UNTRACKABLE, TYPE_FLOAT, size, 1, offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        data = dataArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        bankdata = new float[1][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        bankdata[0] = data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   142
     * Constructs a {@code float}-based {@code DataBuffer}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * with the specified data arrays.  Only the first
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   144
     * {@code size} elements of each array are available for use
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   145
     * by this {@code DataBuffer}.  The number of banks will be
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   146
     * equal to {@code dataArray.length}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Note that {@code DataBuffer} objects created by this constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * may be incompatible with <a href="#optimizations">performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * optimizations</a> used by some implementations (such as caching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * an associated image in video memory).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   153
     * @param dataArray An array of arrays of {@code float}s to be
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   154
     *                  used as the banks of this {@code DataBuffer}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @param size The number of elements of each array to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     */
52248
2e330da7cbf4 8211300: Convert C-style array declarations in JDK client code
tvaleev
parents: 47216
diff changeset
   157
    public DataBufferFloat(float[][] dataArray, int size) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        super(UNTRACKABLE, TYPE_FLOAT, size, dataArray.length);
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 5506
diff changeset
   159
        bankdata = dataArray.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        data = bankdata[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   164
     * Constructs a {@code float}-based {@code DataBuffer}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * with the specified data arrays, size, and per-bank offsets.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   166
     * The number of banks is equal to {@code dataArray.length}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   167
     * Each array must be at least as large as {@code size} plus the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * corresponding offset.  There must be an entry in the offsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * array for each data array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Note that {@code DataBuffer} objects created by this constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * may be incompatible with <a href="#optimizations">performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * optimizations</a> used by some implementations (such as caching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * an associated image in video memory).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   176
     * @param dataArray An array of arrays of {@code float}s to be
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   177
     *                  used as the banks of this {@code DataBuffer}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @param size The number of elements of each array to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @param offsets An array of integer offsets, one for each bank.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
52248
2e330da7cbf4 8211300: Convert C-style array declarations in JDK client code
tvaleev
parents: 47216
diff changeset
   181
    public DataBufferFloat(float[][] dataArray, int size, int[] offsets) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        super(UNTRACKABLE, TYPE_FLOAT, size,dataArray.length, offsets);
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 5506
diff changeset
   183
        bankdata = dataArray.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        data = bankdata[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   188
     * Returns the default (first) {@code float} data array.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * Note that calling this method may cause this {@code DataBuffer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * object to be incompatible with <a href="#optimizations">performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * optimizations</a> used by some implementations (such as caching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * an associated image in video memory).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @return the first float data array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public float[] getData() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        theTrackable.setUntrackable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        return data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * Returns the data array for the specified bank.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Note that calling this method may cause this {@code DataBuffer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * object to be incompatible with <a href="#optimizations">performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * optimizations</a> used by some implementations (such as caching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * an associated image in video memory).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @param bank the data array
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   211
     * @return the data array specified by {@code bank}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public float[] getData(int bank) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        theTrackable.setUntrackable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return bankdata[bank];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Returns the data array for all banks.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Note that calling this method may cause this {@code DataBuffer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * object to be incompatible with <a href="#optimizations">performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * optimizations</a> used by some implementations (such as caching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * an associated image in video memory).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @return all data arrays for this data buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    public float[][] getBankData() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        theTrackable.setUntrackable();
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 5506
diff changeset
   230
        return bankdata.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * Returns the requested data array element from the first
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   235
     * (default) bank as an {@code int}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   239
     * @return The data entry as an {@code int}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @see #setElem(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @see #setElem(int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public int getElem(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        return (int)(data[i+offset]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * Returns the requested data array element from the specified
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   249
     * bank as an {@code int}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @param bank The bank number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   254
     * @return The data entry as an {@code int}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @see #setElem(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @see #setElem(int, int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    public int getElem(int bank, int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        return (int)(bankdata[bank][i+offsets[bank]]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * Sets the requested data array element in the first (default)
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   264
     * bank to the given {@code int}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @param val The value to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @see #getElem(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @see #getElem(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    public void setElem(int i, int val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        data[i+offset] = (float)val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        theTrackable.markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Sets the requested data array element in the specified bank to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   278
     * the given {@code int}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @param bank The bank number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @param val The value to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @see #getElem(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @see #getElem(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    public void setElem(int bank, int i, int val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        bankdata[bank][i+offsets[bank]] = (float)val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        theTrackable.markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * Returns the requested data array element from the first
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   293
     * (default) bank as a {@code float}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   297
     * @return The data entry as a {@code float}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @see #setElemFloat(int, float)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * @see #setElemFloat(int, int, float)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    public float getElemFloat(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        return data[i+offset];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * Returns the requested data array element from the specified
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   307
     * bank as a {@code float}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @param bank The bank number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   312
     * @return The data entry as a {@code float}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @see #setElemFloat(int, float)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @see #setElemFloat(int, int, float)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    public float getElemFloat(int bank, int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        return bankdata[bank][i+offsets[bank]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * Sets the requested data array element in the first (default)
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   322
     * bank to the given {@code float}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @param val The value to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @see #getElemFloat(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @see #getElemFloat(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    public void setElemFloat(int i, float val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        data[i+offset] = val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        theTrackable.markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * Sets the requested data array element in the specified bank to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   336
     * the given {@code float}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @param bank The bank number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @param val The value to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * @see #getElemFloat(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * @see #getElemFloat(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    public void setElemFloat(int bank, int i, float val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        bankdata[bank][i+offsets[bank]] = val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        theTrackable.markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * Returns the requested data array element from the first
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   351
     * (default) bank as a {@code double}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   355
     * @return The data entry as a {@code double}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @see #setElemDouble(int, double)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @see #setElemDouble(int, int, double)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    public double getElemDouble(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        return (double)data[i+offset];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * Returns the requested data array element from the specified
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   365
     * bank as a {@code double}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @param bank The bank number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   370
     * @return The data entry as a {@code double}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @see #setElemDouble(int, double)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @see #setElemDouble(int, int, double)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    public double getElemDouble(int bank, int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        return (double)bankdata[bank][i+offsets[bank]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * Sets the requested data array element in the first (default)
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   380
     * bank to the given {@code double}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * @param val The value to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @see #getElemDouble(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @see #getElemDouble(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    public void setElemDouble(int i, double val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        data[i+offset] = (float)val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        theTrackable.markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * Sets the requested data array element in the specified bank to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   394
     * the given {@code double}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * @param bank The bank number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @param i The desired data array element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @param val The value to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @see #getElemDouble(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @see #getElemDouble(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    public void setElemDouble(int bank, int i, double val) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        bankdata[bank][i+offsets[bank]] = (float)val;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        theTrackable.markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
}