List of usage examples for org.apache.commons.lang ArrayUtils clone
public static boolean[] clone(boolean[] array)
Clones an array returning a typecast result and handling null
.
From source file:org.dspace.sort.SortOption.java
/** * @return a 3 element array of the metadata bits */ public String[] getMdBits() { return (String[]) ArrayUtils.clone(mdBits); }
From source file:org.dspace.statistics.Dataset.java
public Dataset(float[][] matrix) { this.matrix = (String[][]) ArrayUtils.clone(matrix); nbRows = matrix.length;/*from w w w . j a v a2s . com*/ if (0 < matrix.length && 0 < matrix[0].length) { nbCols = matrix[0].length; } initColumnLabels(nbCols); initRowLabels(nbRows); }
From source file:org.eclipse.dataset.InterpolatedPoint.java
public static Dataset remapOneAxis(Dataset dataset, int axisIndex, Dataset corrections, Dataset originalAxisForCorrection, Dataset outputAxis) { int[] stop = dataset.getShape(); int[] start = new int[stop.length]; int[] step = new int[stop.length]; int[] resultSize = new int[stop.length]; for (int i = 0; i < start.length; i++) { start[i] = 0;/*from w w w.j a v a2 s . c o m*/ step[i] = 1; resultSize[i] = stop[i]; } resultSize[axisIndex] = outputAxis.getShapeRef()[0]; DoubleDataset result = new DoubleDataset(resultSize); step[axisIndex] = dataset.getShapeRef()[axisIndex]; IndexIterator iter = dataset.getSliceIterator(start, stop, step); int[] pos = iter.getPos(); int[] posEnd = new int[pos.length]; while (iter.hasNext()) { for (int i = 0; i < posEnd.length; i++) { posEnd[i] = pos[i] + 1; } posEnd[axisIndex] = stop[axisIndex]; // get the dataset Dataset slice = dataset.getSlice(pos, posEnd, null).squeeze(); int[] correctionPos = new int[pos.length - 1]; int index = 0; for (int j = 0; j < pos.length; j++) { if (j != axisIndex) { correctionPos[index] = pos[j]; index++; } } Dataset axis = Maths.subtract(originalAxisForCorrection, corrections.getDouble(correctionPos)); Dataset remapped = remap1D(slice, axis, outputAxis); int[] ref = ArrayUtils.clone(pos); for (int k = 0; k < result.getShapeRef()[axisIndex]; k++) { ref[axisIndex] = k; result.set(remapped.getDouble(k), ref); } } return result; }
From source file:org.eclipse.dataset.InterpolatedPoint.java
public static Dataset remapAxis(Dataset dataset, int axisIndex, Dataset originalAxisForCorrection, Dataset outputAxis) {/*from w w w. j a va 2s . c o m*/ if (!dataset.isCompatibleWith(originalAxisForCorrection)) { throw new IllegalArgumentException("Datasets must be of the same shape"); } int[] stop = dataset.getShapeRef(); int[] start = new int[stop.length]; int[] step = new int[stop.length]; int[] resultSize = new int[stop.length]; for (int i = 0; i < start.length; i++) { start[i] = 0; step[i] = 1; resultSize[i] = stop[i]; } resultSize[axisIndex] = outputAxis.getShapeRef()[0]; DoubleDataset result = new DoubleDataset(resultSize); step[axisIndex] = dataset.getShapeRef()[axisIndex]; IndexIterator iter = dataset.getSliceIterator(start, stop, step); int[] pos = iter.getPos(); int[] posEnd = new int[pos.length]; while (iter.hasNext()) { for (int i = 0; i < posEnd.length; i++) { posEnd[i] = pos[i] + 1; } posEnd[axisIndex] = stop[axisIndex]; // get the dataset Dataset slice = dataset.getSlice(pos, posEnd, null).squeeze(); Dataset axis = originalAxisForCorrection.getSlice(pos, posEnd, null).squeeze(); Dataset remapped = remap1D(slice, axis, outputAxis); int[] ref = ArrayUtils.clone(pos); for (int k = 0; k < result.shape[axisIndex]; k++) { ref[axisIndex] = k; result.set(remapped.getDouble(k), ref); } } return result; }
From source file:org.eclipse.january.dataset.InterpolatedPoint.java
public static Dataset remapOneAxis(Dataset dataset, int axisIndex, Dataset corrections, Dataset originalAxisForCorrection, Dataset outputAxis) { int[] stop = dataset.getShape(); int[] start = new int[stop.length]; int[] step = new int[stop.length]; int[] resultSize = new int[stop.length]; for (int i = 0; i < start.length; i++) { start[i] = 0;//from w w w . jav a 2 s. c om step[i] = 1; resultSize[i] = stop[i]; } resultSize[axisIndex] = outputAxis.getShapeRef()[0]; DoubleDataset result = DatasetFactory.zeros(DoubleDataset.class, resultSize); step[axisIndex] = dataset.getShapeRef()[axisIndex]; IndexIterator iter = dataset.getSliceIterator(start, stop, step); int[] pos = iter.getPos(); int[] posEnd = new int[pos.length]; while (iter.hasNext()) { for (int i = 0; i < posEnd.length; i++) { posEnd[i] = pos[i] + 1; } posEnd[axisIndex] = stop[axisIndex]; // get the dataset Dataset slice = dataset.getSlice(pos, posEnd, null).squeeze(); int[] correctionPos = new int[pos.length - 1]; int index = 0; for (int j = 0; j < pos.length; j++) { if (j != axisIndex) { correctionPos[index] = pos[j]; index++; } } Dataset axis = Maths.subtract(originalAxisForCorrection, corrections.getDouble(correctionPos)); Dataset remapped = remap1D(slice, axis, outputAxis); int[] ref = ArrayUtils.clone(pos); for (int k = 0; k < result.getShapeRef()[axisIndex]; k++) { ref[axisIndex] = k; result.set(remapped.getDouble(k), ref); } } return result; }
From source file:org.eclipse.january.dataset.InterpolatedPoint.java
public static Dataset remapAxis(Dataset dataset, int axisIndex, Dataset originalAxisForCorrection, Dataset outputAxis) {/*from w ww.j a v a 2 s. com*/ if (!dataset.isCompatibleWith(originalAxisForCorrection)) { throw new IllegalArgumentException("Datasets must be of the same shape"); } int[] stop = dataset.getShapeRef(); int[] start = new int[stop.length]; int[] step = new int[stop.length]; int[] resultSize = new int[stop.length]; for (int i = 0; i < start.length; i++) { start[i] = 0; step[i] = 1; resultSize[i] = stop[i]; } resultSize[axisIndex] = outputAxis.getShapeRef()[0]; DoubleDataset result = DatasetFactory.zeros(DoubleDataset.class, resultSize); step[axisIndex] = dataset.getShapeRef()[axisIndex]; IndexIterator iter = dataset.getSliceIterator(start, stop, step); int[] pos = iter.getPos(); int[] posEnd = new int[pos.length]; while (iter.hasNext()) { for (int i = 0; i < posEnd.length; i++) { posEnd[i] = pos[i] + 1; } posEnd[axisIndex] = stop[axisIndex]; // get the dataset Dataset slice = dataset.getSlice(pos, posEnd, null).squeeze(); Dataset axis = originalAxisForCorrection.getSlice(pos, posEnd, null).squeeze(); Dataset remapped = remap1D(slice, axis, outputAxis); int[] ref = ArrayUtils.clone(pos); for (int k = 0; k < result.shape[axisIndex]; k++) { ref[axisIndex] = k; result.set(remapped.getDouble(k), ref); } } return result; }
From source file:org.eclipse.wb.tests.designer.rcp.model.layout.form.gef.FormLayoutAlignmentTest.java
private static String[] getLines_twoButtons_typical(String[] constraints_1, String[] constraints_2) { constraints_1 = (String[]) ArrayUtils.clone(constraints_1); constraints_2 = (String[]) ArrayUtils.clone(constraints_2); for (int i = 0; i < constraints_1.length; i++) { constraints_1[i] = " data_1." + constraints_1[i]; }//from w w w . ja v a 2 s . c o m for (int i = 0; i < constraints_2.length; i++) { constraints_2[i] = " data_2." + constraints_2[i]; } String[] lines = new String[] { "public class Test extends Shell {", " private Button button_1;", " private Button button_2;", " public Test() {", " setLayout(new FormLayout());", " {", " button_1 = new Button(this, SWT.NONE);", " {", " FormData data_1 = new FormData();" }; lines = (String[]) ArrayUtils.addAll(lines, constraints_1); lines = (String[]) ArrayUtils.addAll(lines, new String[] { " button_1.setLayoutData(data_1);", " }", " }", " {", " button_2 = new Button(this, SWT.NONE);", " {", " FormData data_2 = new FormData();" }); lines = (String[]) ArrayUtils.addAll(lines, constraints_2); lines = (String[]) ArrayUtils.addAll(lines, new String[] { " button_2.setLayoutData(data_2);", " }", " }", " }", "}" }); return lines; }
From source file:org.eclipse.wb.tests.designer.swt.model.layouts.AbsoluteLayoutTest.java
/** * generic check for bounds changing./*from w w w.j ava 2 s. c om*/ */ private void check_changeBounds(String[] initial, String[] expected, Point location, Dimension size) throws Exception { String[] initialCode = new String[] { "class Test extends Shell {", " public Test() {", " setLayout(null);", " Button button = new Button(this, SWT.NONE);", " button.setText(\"test\");", " }", "}" }; // prepare initial code String[] initialLines = (String[]) ArrayUtils.clone(initialCode); for (int i = 0; i < initial.length; i++) { if (!StringUtils.isEmpty(initial[i])) { initialLines = (String[]) ArrayUtils.add(initialLines, 4 + i, initial[i]); } } // prepare expected code String[] expectedLines = (String[]) ArrayUtils.clone(initialCode); for (int i = 0; i < expected.length; i++) { if (!StringUtils.isEmpty(expected[i])) { expectedLines = (String[]) ArrayUtils.add(expectedLines, 4 + i, expected[i]); } } // prepare model CompositeInfo shellInfo = parseComposite(initialLines); shellInfo.refresh(); ControlInfo buttonInfo = shellInfo.getChildrenControls().get(0); AbsoluteLayoutInfo layoutInfo = (AbsoluteLayoutInfo) shellInfo.getLayout(); // perform code modifications layoutInfo.commandChangeBounds(buttonInfo, location, size); // check the results assertEditor(expectedLines); }
From source file:org.epochx.epox.Node.java
/** * Returns an array of this node's children. Modifying this array will not * change the set of children, but modifying the nodes will alter the nodes * of the tree./*from w w w . jav a 2 s. c om*/ * * @return an array of this node's children */ public Node[] getChildren() { return (Node[]) ArrayUtils.clone(children); }
From source file:org.fosstrak.ale.server.readers.test.TestAdaptor.java
/** * a handle to the tags contained in the test adapter. * @return the tags. */ public Tag[] getTags() { return (Tag[]) ArrayUtils.clone(tagsAsArray); }