ingo@2713: package de.intevation.flys.artifacts.model; ingo@2713: ingo@2713: import java.io.Serializable; ingo@2713: felix@3924: import java.util.ArrayList; felix@3924: ingo@2713: import gnu.trove.TDoubleArrayList; ingo@2713: ingo@2714: import de.intevation.artifacts.CallContext; ingo@2714: ingo@2714: import de.intevation.flys.artifacts.resources.Resources; ingo@2714: felix@3924: import org.apache.log4j.Logger; felix@3924: ingo@2713: ingo@2713: public class MiddleBedHeightData implements Serializable { ingo@2713: felix@3924: /** Very private logger. */ felix@3924: private static final Logger logger = Logger.getLogger(MiddleBedHeightData.class); felix@3924: ingo@2714: public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single"; ingo@2714: public static final String I18N_EPOCH_NAME = "facet.bedheight_middle.epoch"; ingo@2714: ingo@2713: private int startYear; ingo@2713: private int endYear; ingo@2713: private String evaluatedBy; ingo@2713: private String description; ingo@2713: ingo@2713: private TDoubleArrayList km; ingo@2713: private TDoubleArrayList middleHeight; ingo@2713: private TDoubleArrayList uncertainty; ingo@2713: private TDoubleArrayList soundingWidth; ingo@2713: private TDoubleArrayList dataGap; ingo@2713: private TDoubleArrayList width; felix@3924: private ArrayList empty; ingo@2713: ingo@2713: ingo@2713: protected MiddleBedHeightData(int start, int end, String eval, String desc) { ingo@2713: this.startYear = start; ingo@2713: this.endYear = end; ingo@2713: this.evaluatedBy = eval; ingo@2713: this.description = desc; ingo@2713: ingo@2713: this.km = new TDoubleArrayList(); ingo@2713: this.middleHeight = new TDoubleArrayList(); ingo@2713: this.uncertainty = new TDoubleArrayList(); ingo@2713: this.soundingWidth = new TDoubleArrayList(); ingo@2713: this.dataGap = new TDoubleArrayList(); ingo@2713: this.width = new TDoubleArrayList(); felix@3924: this.empty = new ArrayList(); felix@3924: } felix@3924: felix@3924: public void addAll(double station, double height, double uncertainty, felix@3924: double soundingWidth, double dataGap, double width, boolean isEmpty) { felix@3924: addKM(station); felix@3924: addMiddleHeight(height); felix@3924: addUncertainty(uncertainty); felix@3924: addSoundingWidth(soundingWidth); felix@3924: addDataGap(dataGap); felix@3924: addWidth(width); felix@3924: addIsEmpty(isEmpty); ingo@2713: } ingo@2713: ingo@2713: ingo@2713: public int getStartYear() { ingo@2713: return startYear; ingo@2713: } ingo@2713: ingo@2713: public int getEndYear() { ingo@2713: return endYear; ingo@2713: } ingo@2713: ingo@2713: public String getEvaluatedBy() { ingo@2713: return evaluatedBy; ingo@2713: } ingo@2713: ingo@2713: public String getDescription() { ingo@2713: return description; ingo@2713: } ingo@2713: ingo@2713: felix@3924: protected void addKM(double km) { ingo@2713: this.km.add(km); ingo@2713: } ingo@2713: ingo@2713: public double getKM(int idx) { ingo@2713: return km.get(idx); ingo@2713: } ingo@2713: felix@3924: protected void addMiddleHeight(double middleHeight) { ingo@2713: this.middleHeight.add(middleHeight); ingo@2713: } ingo@2713: ingo@2713: public double getMiddleHeight(int idx) { ingo@2713: return middleHeight.get(idx); ingo@2713: } ingo@2713: felix@3924: protected void addUncertainty(double uncertainty) { ingo@2713: this.uncertainty.add(uncertainty); ingo@2713: } ingo@2713: ingo@2713: public double getUncertainty(int idx) { ingo@2713: return uncertainty.get(idx); ingo@2713: } ingo@2713: felix@3924: protected void addSoundingWidth(double soundingWidth) { ingo@2713: this.soundingWidth.add(soundingWidth); ingo@2713: } ingo@2713: ingo@2713: public double getSoundingWidth(int idx) { ingo@2713: return soundingWidth.get(idx); ingo@2713: } ingo@2713: felix@3924: protected void addDataGap(double gap) { ingo@2713: this.dataGap.add(gap); ingo@2713: } ingo@2713: ingo@2713: public double getDataGap(int idx) { ingo@2713: return dataGap.get(idx); ingo@2713: } ingo@2713: felix@3924: protected void addIsEmpty(boolean empty) { felix@3924: this.empty.add(empty); felix@3924: } felix@3924: felix@3924: public boolean isEmpty(int idx) { felix@3924: return (Boolean) empty.get(idx); felix@3924: } felix@3924: felix@3924: felix@3924: protected void addWidth(double width) { ingo@2713: this.width.add(width); ingo@2713: } ingo@2713: ingo@2713: public double getWidth(int idx) { ingo@2713: return width.get(idx); ingo@2713: } ingo@2713: ingo@2713: public int size() { ingo@2713: return km.size(); ingo@2713: } ingo@2713: ingo@2713: felix@3924: /** felix@3924: * Get the points, ready to be drawn felix@3924: * @return [[km1, km2,...],[height1,height2,...]] felix@3924: */ ingo@2713: public double[][] getMiddleHeightsPoints() { ingo@2713: double[][] points = new double[2][size()]; ingo@2713: ingo@2713: for (int i = 0, n = size(); i < n; i++) { felix@3924: if (isEmpty(i)) { felix@3924: points[0][i] = getKM(i); felix@3924: points[1][i] = Double.NaN; felix@3924: } felix@3924: else { felix@3924: points[0][i] = getKM(i); felix@3924: points[1][i] = getMiddleHeight(i); felix@3924: } ingo@2713: } ingo@2713: ingo@2713: return points; ingo@2713: } ingo@2714: ingo@2714: ingo@2714: public String getSoundingName(CallContext context) { ingo@2714: if (getStartYear() == getEndYear()) { ingo@2714: return Resources.getMsg( ingo@2714: context.getMeta(), ingo@2714: I18N_SINGLE_NAME, ingo@2714: I18N_SINGLE_NAME, ingo@2714: new Object[] { getStartYear() } ingo@2714: ); ingo@2714: } ingo@2714: else { ingo@2714: return Resources.getMsg( ingo@2714: context.getMeta(), ingo@2714: I18N_EPOCH_NAME, ingo@2714: I18N_EPOCH_NAME, ingo@2714: new Object[] { getStartYear(), getEndYear() } ingo@2714: ); ingo@2714: } ingo@2714: } ingo@2713: } sascha@3083: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :