@Test public void subArray1() { VNumberArray array = newVNumberArray(new ArrayDouble(1,2,3,4,5), newAlarm(AlarmSeverity.MINOR, "LOW"), newTime(Instant.ofEpochSecond(123, 123)), displayNone()); VNumberArray selection = subArray(array, 2); assertThat(selection.getData(), equalTo((ListNumber) new ArrayDouble(3))); assertThat(selection.getSizes(), equalTo((ListInt) new ArrayInt(1))); assertThat(selection.getDimensionDisplay().get(0).getCellBoundaries(), equalTo((ListNumber) new ArrayDouble(2,3))); }
public static VNumberArray subArray(VNumberArray array, int index) { if (array.getSizes().size() != 1) { throw new IllegalArgumentException("Array was not one-dimensional"); } if (index < 0 || array.getData().size() <= index) { throw new IllegalArgumentException("Index not in the array range"); } ArrayDimensionDisplay display = array.getDimensionDisplay().get(0); return ValueFactory.newVNumberArray(new ArrayDouble(array.getData().getDouble(index)), new ArrayInt(1), Arrays.asList(ValueFactory.newDisplay(new ArrayDouble(display.getCellBoundaries().getDouble(index), display.getCellBoundaries().getDouble(index+1)), display.getUnits())), array, array, array); }
ValueUtil { public static VNumberArray subArray(VNumberArray array, int index) { if (array.getSizes().size() != 1) { throw new IllegalArgumentException("Array was not one-dimensional"); } if (index < 0 || array.getData().size() <= index) { throw new IllegalArgumentException("Index not in the array range"); } ArrayDimensionDisplay display = array.getDimensionDisplay().get(0); return ValueFactory.newVNumberArray(new ArrayDouble(array.getData().getDouble(index)), new ArrayInt(1), Arrays.asList(ValueFactory.newDisplay(new ArrayDouble(display.getCellBoundaries().getDouble(index), display.getCellBoundaries().getDouble(index+1)), display.getUnits())), array, array, array); } }
ValueUtil { public static VNumberArray subArray(VNumberArray array, int index) { if (array.getSizes().size() != 1) { throw new IllegalArgumentException("Array was not one-dimensional"); } if (index < 0 || array.getData().size() <= index) { throw new IllegalArgumentException("Index not in the array range"); } ArrayDimensionDisplay display = array.getDimensionDisplay().get(0); return ValueFactory.newVNumberArray(new ArrayDouble(array.getData().getDouble(index)), new ArrayInt(1), Arrays.asList(ValueFactory.newDisplay(new ArrayDouble(display.getCellBoundaries().getDouble(index), display.getCellBoundaries().getDouble(index+1)), display.getUnits())), array, array, array); } private  ValueUtil(); }
ValueUtil { public static VNumberArray subArray(VNumberArray array, int index) { if (array.getSizes().size() != 1) { throw new IllegalArgumentException("Array was not one-dimensional"); } if (index < 0 || array.getData().size() <= index) { throw new IllegalArgumentException("Index not in the array range"); } ArrayDimensionDisplay display = array.getDimensionDisplay().get(0); return ValueFactory.newVNumberArray(new ArrayDouble(array.getData().getDouble(index)), new ArrayInt(1), Arrays.asList(ValueFactory.newDisplay(new ArrayDouble(display.getCellBoundaries().getDouble(index), display.getCellBoundaries().getDouble(index+1)), display.getUnits())), array, array, array); } private  ValueUtil(); static Class<?> typeOf(Object obj); static Alarm alarmOf(Object obj); static Alarm alarmOf(Object value, boolean connected); static Alarm highestSeverityOf(final List<Object> args, final boolean considerNull); static Time latestTimeOf(final List<Object> args); static Time latestValidTimeOrNowOf(final List<Object> args); static Time timeOf(Object obj); static Display displayOf(Object obj); static boolean displayHasValidDisplayLimits(Display display); static Double normalizedNumericValueOf(Object obj); static Double normalize(Number value, Display display); static Double normalize(Number value, Number lowValue, Number highValue); static Double numericValueOf(Object obj); static BufferedImage toImage(VImage vImage); static VImage toVImage(BufferedImage image); static boolean displayEquals(Display d1, Display d2); static void setAlarmSeverityColorMap(Map<AlarmSeverity, Integer> map); static int colorFor(AlarmSeverity severity); static DateTimeFormatter getDefaultTimestampFormat(); static void setDefaultTimestampFormat(DateTimeFormatter defaultTimestampFormat); static NumberFormat getDefaultNumberFormat(); static void setDefaultNumberFormat(NumberFormat defaultNumberFormat); static ValueFormat getDefaultValueFormat(); static void setDefaultValueFormat(ValueFormat defaultValueFormat); static ListNumber numericColumnOf(VTable table, String columnName); static List<String> stringColumnOf(VTable table, String columnName); static List<ArrayDimensionDisplay> defaultArrayDisplay(VNumberArray array); static List<ArrayDimensionDisplay> defaultArrayDisplay(ListInt sizes); static VNumberArray subArray(VNumberArray array, int index); }
ValueUtil { public static VNumberArray subArray(VNumberArray array, int index) { if (array.getSizes().size() != 1) { throw new IllegalArgumentException("Array was not one-dimensional"); } if (index < 0 || array.getData().size() <= index) { throw new IllegalArgumentException("Index not in the array range"); } ArrayDimensionDisplay display = array.getDimensionDisplay().get(0); return ValueFactory.newVNumberArray(new ArrayDouble(array.getData().getDouble(index)), new ArrayInt(1), Arrays.asList(ValueFactory.newDisplay(new ArrayDouble(display.getCellBoundaries().getDouble(index), display.getCellBoundaries().getDouble(index+1)), display.getUnits())), array, array, array); } private  ValueUtil(); static Class<?> typeOf(Object obj); static Alarm alarmOf(Object obj); static Alarm alarmOf(Object value, boolean connected); static Alarm highestSeverityOf(final List<Object> args, final boolean considerNull); static Time latestTimeOf(final List<Object> args); static Time latestValidTimeOrNowOf(final List<Object> args); static Time timeOf(Object obj); static Display displayOf(Object obj); static boolean displayHasValidDisplayLimits(Display display); static Double normalizedNumericValueOf(Object obj); static Double normalize(Number value, Display display); static Double normalize(Number value, Number lowValue, Number highValue); static Double numericValueOf(Object obj); static BufferedImage toImage(VImage vImage); static VImage toVImage(BufferedImage image); static boolean displayEquals(Display d1, Display d2); static void setAlarmSeverityColorMap(Map<AlarmSeverity, Integer> map); static int colorFor(AlarmSeverity severity); static DateTimeFormatter getDefaultTimestampFormat(); static void setDefaultTimestampFormat(DateTimeFormatter defaultTimestampFormat); static NumberFormat getDefaultNumberFormat(); static void setDefaultNumberFormat(NumberFormat defaultNumberFormat); static ValueFormat getDefaultValueFormat(); static void setDefaultValueFormat(ValueFormat defaultValueFormat); static ListNumber numericColumnOf(VTable table, String columnName); static List<String> stringColumnOf(VTable table, String columnName); static List<ArrayDimensionDisplay> defaultArrayDisplay(VNumberArray array); static List<ArrayDimensionDisplay> defaultArrayDisplay(ListInt sizes); static VNumberArray subArray(VNumberArray array, int index);  }