Spec-Zone .ru
спецификации, руководства, описания, API
|
001/* 002 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025package javafx.collections; 026 027/** 028 * A float[] array that allows listeners to track changes when they occur. To achieve 029 * that internal array is encapsulated and there is no direct access available 030 * from outside. Bulk operations are supported but they always do copy of the 031 * data range. 032 * 033 * @see ArrayChangeListener 034 */ 035public interface ObservableFloatArray extends ObservableArray<ObservableFloatArray> { 036 037 /** 038 * Copies specified portion of array into {@code dest} array. Throws 039 * the same exceptions as {@link System#arraycopy(java.lang.Object, 040 * int, java.lang.Object, int, int) } 041 * @param srcIndex starting position in the observable array 042 * @param dest destination array 043 * @param destIndex starting position in destination array 044 * @param length length of portion to copy 045 */ 046 public void copyTo(int srcIndex, float[] dest, int destIndex, int length); 047 public void copyTo(int srcIndex, ObservableFloatArray dest, int destIndex, int length); 048 049 /** 050 * Gets a single value of array. This is generally as fast as direct access 051 * to an array and eliminates necessity to make a copy of array. 052 * @param index index of element to get 053 * @return value at the given index 054 * @throws ArrayIndexOutOfBoundsException if {@code index} is outside 055 * array bounds 056 */ 057 public float get(int index); 058 059 public void addAll(float... elements); 060 public void addAll(ObservableFloatArray src); 061 public void addAll(float[] src, int srcIndex, int length); 062 public void addAll(ObservableFloatArray src, int srcIndex, int length); 063 064 /** 065 * Sets observable array to a copy of given array 066 * @param elements source array to copy. 067 * @throws NullPointerException if {@code array} is null 068 */ 069 public void setAll(float... elements); 070 public void setAll(ObservableFloatArray src); 071 public void setAll(float[] src, int srcIndex, int length); 072 public void setAll(ObservableFloatArray src, int srcIndex, int length); 073 074 /** 075 * Sets portion of observable array to a copy of given array. Throws 076 * the same exceptions as {@link System#arraycopy(java.lang.Object, 077 * int, java.lang.Object, int, int) } 078 * @param destIndex the starting destination index in this observable array 079 * @param src source array to copy 080 * @param srcIndex starting position in source array 081 * @param length length of portion to copy 082 */ 083 public void set(int destIndex, float[] src, int srcIndex, int length); 084 public void set(int destIndex, ObservableFloatArray src, int srcIndex, int length); 085 086 /** 087 * Sets a single value in the array. Avoid using this method if many values 088 * are updated, use {@linkplain #set(int, float[], int, int)} update method 089 * instead with as minimum number of invocations as possible. 090 * @param index index of the value to set 091 * @param value new value for the given index 092 * @throws ArrayIndexOutOfBoundsException if {@code index} is outside 093 * array bounds 094 */ 095 public void set(int index, float value); 096 097 /** 098 * Returns an array containing copy of the observable array. 099 * If the observable array fits in the specified array, it is copied therein. 100 * Otherwise, a new array is allocated with the size of the observable array. 101 * 102 * @param array the array into which the observable array to be copied, 103 * if it is big enough; otherwise, a new float array is allocated. 104 * Ignored, if null. 105 * @return a float array containing the copy of the observable array 106 */ 107 public float[] toArray(float[] dest); 108 109 /** 110 * Returns an array containing copy of specified portion of the observable array. 111 * If specified portion of the observable array fits in the specified array, 112 * it is copied therein. Otherwise, a new array of given length is allocated. 113 * 114 * @param srcIndex starting position in the observable array 115 * @param dest the array into which specified portion of the observable array 116 * to be copied, if it is big enough; 117 * otherwise, a new float array is allocated. 118 * Ignored, if null. 119 * @param length length of portion to copy 120 * @return a float array containing the copy of specified portion the observable array 121 */ 122 public float[] toArray(int srcIndex, float[] dest, int length); 123 124}