Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Parameters.java @ 2773:ea03f26a7d50
Added concrete themes for maps.
flys-artifacts/trunk@4512 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 25 May 2012 08:57:14 +0000 |
parents | c1f2e792704a |
children | f87fcedbfa82 |
line wrap: on
line source
package de.intevation.flys.artifacts.model; import gnu.trove.TDoubleArrayList; import java.io.Serializable; public class Parameters implements Serializable { protected String [] columnNames; protected TDoubleArrayList [] columns; public Parameters() { } public Parameters(String [] columnNames) { if (columnNames == null || columnNames.length < 1) { throw new IllegalArgumentException("columnNames too short."); } this.columnNames = columnNames; columns = new TDoubleArrayList[columnNames.length]; for (int i = 0; i < columns.length; ++i) { columns[i] = new TDoubleArrayList(); } } public int columnIndex(String name) { for (int i = 0; i < columnNames.length; ++i) { if (name.equals(name)) { return i; } } return -1; } public int newRow() { int N = columns[0].size(); for (int i = 0; i < columns.length; ++i) { columns[i].add(Double.NaN); } return N; } public double get(int i, int index) { return columns[index].getQuick(i); } public double get(int i, String columnName) { int index = columnIndex(columnName); return index >= 0 ? columns[index].getQuick(i) : Double.NaN; } public void set(int i, String columnName, double value) { int idx = columnIndex(columnName); if (idx >= 0) { columns[i].setQuick(idx, value); } } public int size() { return columns[0].size(); } public int getNumberColumns() { return columnNames.length; } public String [] getColumnNames() { return columnNames; } public void removeNaNs() { W.removeNaNs(columns); } public int [] columnIndices(String [] columns) { int [] indices = new int[columns.length]; for (int i = 0; i < columns.length; ++i) { indices[i] = columnIndex(columns[i]); } return indices; } public void get(int row, int [] columnIndices, double [] values) { for (int i = 0; i < columnIndices.length; ++i) { int index = columnIndices[i]; values[i] = index >= 0 && index < columns.length ? columns[index].getQuick(row) : Double.NaN; } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :