# HG changeset patch # User Raimund Renkert # Date 1404213946 -7200 # Node ID 62befca02480139d73b397f5e6d45a480543b70f # Parent 45cced06490c9f5309d44b857b631c7b7a75f765 Moved MiddleBedHeight classes to minfo package. Facet now returns double[][] data. diff -r 45cced06490c -r 62befca02480 artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightCalculation.java Mon Jun 30 11:29:45 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.artifacts.model; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -import org.dive4elements.artifacts.Artifact; -import org.dive4elements.artifacts.common.utils.DateUtils; - -import org.dive4elements.river.model.BedHeightSingle; -import org.dive4elements.river.model.BedHeightSingleValue; -import org.dive4elements.river.model.TimeInterval; - -import org.dive4elements.river.artifacts.access.BedHeightAccess; - - -public class MiddleBedHeightCalculation extends Calculation { - - private static final Logger logger = - Logger.getLogger(MiddleBedHeightCalculation.class); - - - public CalculationResult calculate(BedHeightAccess access) { - logger.info("MiddleBedHeightCalculation.calculate"); - - int[] singleIds = access.getBedHeightSingleIDs(); - - - if (logger.isDebugEnabled()) { - Artifact artifact = access.getArtifact(); - - logger.debug("Artifact '" + artifact.identifier() + "' contains:"); - if (singleIds != null) { - logger.debug(" " + singleIds.length + " single bedheight ids"); - } - } - - List singles = getSingles(access, singleIds); - - return buildCalculationResult(access, singles); - } - - - protected List getSingles( - BedHeightAccess access, - int[] ids - ) { - List singles = new ArrayList(); - - for (int id: ids) { - BedHeightSingle s = BedHeightSingle.getBedHeightSingleById(id); - - if (s != null) { - singles.add(s); - } - else { - logger.warn("Cannot find Single by id: " + id); - // TODO ADD WARNING - } - } - - return singles; - } - - - protected CalculationResult buildCalculationResult( - BedHeightAccess access, - List singles - ) { - logger.info("MiddleBedHeightCalculation.buildCalculationResult"); - - double kmLo = access.getLowerKM(); - double kmHi = access.getUpperKM(); - - List data = new ArrayList(); - - for (BedHeightSingle single: singles) { - MiddleBedHeightData d = prepareSingleData(single, kmLo, kmHi); - - if (d != null) { - data.add(d); - } - } - - logger.debug("Calculation results in " + data.size() + " data objects."); - - return new CalculationResult((MiddleBedHeightData[]) - data.toArray(new MiddleBedHeightData[data.size()]), this); - } - - - protected MiddleBedHeightData prepareSingleData( - BedHeightSingle single, - double kmLo, - double kmHi - ) { - logger.debug("Prepare data for single: " + single.getDescription()); - - List values = - BedHeightSingleValue.getBedHeightSingleValues(single, kmLo, kmHi); - - int year = single.getYear() != null ? single.getYear() : 0; - - MiddleBedHeightData data = new MiddleBedHeightData( - year, - year, - single.getEvaluationBy(), - single.getDescription()); - - for (BedHeightSingleValue value: values) { - if (value.getHeight() != null) { - double uncert = value.getUncertainty() != null ? - value.getUncertainty().doubleValue() : Double.NaN; - double sounding = value.getSoundingWidth() != null ? - value.getSoundingWidth().doubleValue() : Double.NaN; - double gap = value.getDataGap() != null ? - value.getDataGap().doubleValue() : Double.NaN; - data.addAll(value.getStation().doubleValue(), - value.getHeight().doubleValue(), - uncert, - sounding, - gap, - value.getWidth().doubleValue(), - false); - } - else { - data.addAll(value.getStation().doubleValue(), - 0, - 0, - 0, - 0, - 0, - true); - } - } - - logger.debug("Single contains " + values.size() + " values"); - - return data; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 45cced06490c -r 62befca02480 artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java Mon Jun 30 11:29:45 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,221 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.artifacts.model; - -import java.io.Serializable; - -import java.util.ArrayList; - -import gnu.trove.TDoubleArrayList; - -import org.dive4elements.artifacts.CallContext; - -import org.dive4elements.river.artifacts.resources.Resources; - -import org.apache.log4j.Logger; - - -public class MiddleBedHeightData implements Serializable, - Comparable { - - /** Very private logger. */ - private static final Logger logger = Logger.getLogger(MiddleBedHeightData.class); - - public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single"; - public static final String I18N_EPOCH_NAME = "facet.bedheight_middle.epoch"; - - private int startYear; - private int endYear; - private String evaluatedBy; - private String description; - - private TDoubleArrayList km; - private TDoubleArrayList middleHeight; - private TDoubleArrayList uncertainty; - private TDoubleArrayList soundingWidth; - private TDoubleArrayList dataGap; - private TDoubleArrayList width; - private ArrayList empty; - - - protected MiddleBedHeightData(int start, int end, String eval, String desc) { - this.startYear = start; - this.endYear = end; - this.evaluatedBy = eval; - this.description = desc; - - this.km = new TDoubleArrayList(); - this.middleHeight = new TDoubleArrayList(); - this.uncertainty = new TDoubleArrayList(); - this.soundingWidth = new TDoubleArrayList(); - this.dataGap = new TDoubleArrayList(); - this.width = new TDoubleArrayList(); - this.empty = new ArrayList(); - } - - public void addAll(double station, double height, double uncertainty, - double soundingWidth, double dataGap, double width, boolean isEmpty) { - addKM(station); - addMiddleHeight(height); - addUncertainty(uncertainty); - addSoundingWidth(soundingWidth); - addDataGap(dataGap); - addWidth(width); - addIsEmpty(isEmpty); - } - - - public int getStartYear() { - return startYear; - } - - public int getEndYear() { - return endYear; - } - - public String getEvaluatedBy() { - return evaluatedBy; - } - - public String getDescription() { - return description; - } - - - protected void addKM(double km) { - this.km.add(km); - } - - public double getKM(int idx) { - return km.get(idx); - } - - protected void addMiddleHeight(double middleHeight) { - this.middleHeight.add(middleHeight); - } - - public double getMiddleHeight(int idx) { - return middleHeight.get(idx); - } - - protected void addUncertainty(double uncertainty) { - this.uncertainty.add(uncertainty); - } - - public double getUncertainty(int idx) { - return uncertainty.get(idx); - } - - protected void addSoundingWidth(double soundingWidth) { - this.soundingWidth.add(soundingWidth); - } - - public double getSoundingWidth(int idx) { - return soundingWidth.get(idx); - } - - protected void addDataGap(double gap) { - this.dataGap.add(gap); - } - - public double getDataGap(int idx) { - return dataGap.get(idx); - } - - protected void addIsEmpty(boolean empty) { - this.empty.add(empty); - } - - public boolean isEmpty(int idx) { - return (Boolean) empty.get(idx); - } - - - protected void addWidth(double width) { - this.width.add(width); - } - - public double getWidth(int idx) { - return width.get(idx); - } - - public int size() { - return km.size(); - } - - - /** - * Get the points, ready to be drawn - * @return [[km1, km2,...],[height1,height2,...]] - */ - public double[][] getMiddleHeightsPoints() { - double[][] points = new double[2][size()]; - - for (int i = 0, n = size(); i < n; i++) { - if (isEmpty(i)) { - points[0][i] = getKM(i); - points[1][i] = Double.NaN; - } - else { - points[0][i] = getKM(i); - points[1][i] = getMiddleHeight(i); - } - } - - return points; - } - - - public String getSoundingName(CallContext context) { - if (getStartYear() == getEndYear()) { - return Resources.getMsg( - context.getMeta(), - I18N_SINGLE_NAME, - I18N_SINGLE_NAME, - new Object[] { getStartYear() } - ); - } - else { - return Resources.getMsg( - context.getMeta(), - I18N_EPOCH_NAME, - I18N_EPOCH_NAME, - new Object[] { getStartYear(), getEndYear() } - ); - } - } - - @Override - public int compareTo(MiddleBedHeightData other) { - - int descCompared = description.compareTo(other.getDescription()); - - if (descCompared != 0) { - return descCompared; - } - - if (size() == 0 || other.size() == 0) { - if (size() == 0 && other.size() > 0) { - return 1; - } else if (size() > 0 && other.size() == 0) { - return -1; - } else if (size() == 0 && other.size() == 0) { - return 0; - } - } - - if (getKM(0) < other.getKM(0)) { - return -1; - } else if (getKM(0) > other.getKM(0)) { - return 1; - } - return 0; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 45cced06490c -r 62befca02480 artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightFacet.java Mon Jun 30 11:29:45 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.artifacts.model; - -import org.dive4elements.artifactdatabase.state.Facet; - -import org.dive4elements.artifacts.Artifact; -import org.dive4elements.artifacts.CallContext; - -import org.dive4elements.river.artifacts.D4EArtifact; - -import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; - -import org.apache.log4j.Logger; - - -/** - * Facet of a MiddleBedHeight curve. - */ -public class MiddleBedHeightFacet extends DataFacet { - - private static Logger logger = Logger.getLogger(MiddleBedHeightFacet.class); - - - public MiddleBedHeightFacet() { - // required for clone operation deepCopy() - } - - - public MiddleBedHeightFacet( - int idx, - String name, - String description, - ComputeType type, - String stateId, - String hash - ) { - super(idx, name, description, type, hash, stateId); - this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); - this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label"); - } - - - public Object getData(Artifact artifact, CallContext context) { - logger.debug("Get data for middle bed height at index: " + index); - - D4EArtifact flys = (D4EArtifact) artifact; - - CalculationResult res = (CalculationResult) - flys.compute(context, hash, stateId, type, false); - - MiddleBedHeightData[] data = (MiddleBedHeightData[]) res.getData(); - - return data[index]; - } - - - /** Copy deeply. */ - @Override - public Facet deepCopy() { - MiddleBedHeightFacet copy = new MiddleBedHeightFacet(); - copy.set(this); - copy.type = type; - copy.hash = hash; - copy.stateId = stateId; - return copy; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 45cced06490c -r 62befca02480 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java Tue Jul 01 13:25:46 2014 +0200 @@ -0,0 +1,154 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.model.minfo; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.common.utils.DateUtils; + +import org.dive4elements.river.model.BedHeightSingle; +import org.dive4elements.river.model.BedHeightSingleValue; +import org.dive4elements.river.model.TimeInterval; + +import org.dive4elements.river.artifacts.access.BedHeightAccess; +import org.dive4elements.river.artifacts.model.Calculation; +import org.dive4elements.river.artifacts.model.CalculationResult; +import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightData; + + +public class MiddleBedHeightCalculation extends Calculation { + + private static final Logger logger = + Logger.getLogger(MiddleBedHeightCalculation.class); + + + public CalculationResult calculate(BedHeightAccess access) { + logger.info("MiddleBedHeightCalculation.calculate"); + + int[] singleIds = access.getBedHeightSingleIDs(); + + + if (logger.isDebugEnabled()) { + Artifact artifact = access.getArtifact(); + + logger.debug("Artifact '" + artifact.identifier() + "' contains:"); + if (singleIds != null) { + logger.debug(" " + singleIds.length + " single bedheight ids"); + } + } + + List singles = getSingles(access, singleIds); + + return buildCalculationResult(access, singles); + } + + + protected List getSingles( + BedHeightAccess access, + int[] ids + ) { + List singles = new ArrayList(); + + for (int id: ids) { + BedHeightSingle s = BedHeightSingle.getBedHeightSingleById(id); + + if (s != null) { + singles.add(s); + } + else { + logger.warn("Cannot find Single by id: " + id); + // TODO ADD WARNING + } + } + + return singles; + } + + + protected CalculationResult buildCalculationResult( + BedHeightAccess access, + List singles + ) { + logger.info("MiddleBedHeightCalculation.buildCalculationResult"); + + double kmLo = access.getLowerKM(); + double kmHi = access.getUpperKM(); + + List data = new ArrayList(); + + for (BedHeightSingle single: singles) { + MiddleBedHeightData d = prepareSingleData(single, kmLo, kmHi); + + if (d != null) { + data.add(d); + } + } + + logger.debug("Calculation results in " + data.size() + " data objects."); + + return new CalculationResult((MiddleBedHeightData[]) + data.toArray(new MiddleBedHeightData[data.size()]), this); + } + + + protected MiddleBedHeightData prepareSingleData( + BedHeightSingle single, + double kmLo, + double kmHi + ) { + logger.debug("Prepare data for single: " + single.getDescription()); + + List values = + BedHeightSingleValue.getBedHeightSingleValues(single, kmLo, kmHi); + + int year = single.getYear() != null ? single.getYear() : 0; + + MiddleBedHeightData data = new MiddleBedHeightData( + year, + year, + single.getEvaluationBy(), + single.getDescription()); + + for (BedHeightSingleValue value: values) { + if (value.getHeight() != null) { + double uncert = value.getUncertainty() != null ? + value.getUncertainty().doubleValue() : Double.NaN; + double sounding = value.getSoundingWidth() != null ? + value.getSoundingWidth().doubleValue() : Double.NaN; + double gap = value.getDataGap() != null ? + value.getDataGap().doubleValue() : Double.NaN; + data.addAll(value.getStation().doubleValue(), + value.getHeight().doubleValue(), + uncert, + sounding, + gap, + value.getWidth().doubleValue(), + false); + } + else { + data.addAll(value.getStation().doubleValue(), + 0, + 0, + 0, + 0, + 0, + true); + } + } + + logger.debug("Single contains " + values.size() + " values"); + + return data; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 45cced06490c -r 62befca02480 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightData.java Tue Jul 01 13:25:46 2014 +0200 @@ -0,0 +1,225 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.model.minfo; + +import java.io.Serializable; + +import java.util.ArrayList; + +import gnu.trove.TDoubleArrayList; + +import org.dive4elements.artifacts.CallContext; + +import org.dive4elements.river.artifacts.resources.Resources; + +import org.apache.log4j.Logger; + + +public class MiddleBedHeightData implements Serializable, + Comparable { + + /** Very private logger. */ + private static final Logger logger = Logger.getLogger(MiddleBedHeightData.class); + + public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single"; + public static final String I18N_EPOCH_NAME = "facet.bedheight_middle.epoch"; + + private int startYear; + private int endYear; + private String evaluatedBy; + private String description; + + private TDoubleArrayList km; + private TDoubleArrayList middleHeight; + private TDoubleArrayList uncertainty; + private TDoubleArrayList soundingWidth; + private TDoubleArrayList dataGap; + private TDoubleArrayList width; + private ArrayList empty; + + + protected MiddleBedHeightData(int start, int end, String eval, String desc) { + this.startYear = start; + this.endYear = end; + this.evaluatedBy = eval; + this.description = desc; + + this.km = new TDoubleArrayList(); + this.middleHeight = new TDoubleArrayList(); + this.uncertainty = new TDoubleArrayList(); + this.soundingWidth = new TDoubleArrayList(); + this.dataGap = new TDoubleArrayList(); + this.width = new TDoubleArrayList(); + this.empty = new ArrayList(); + } + + public void addAll(double station, double height, double uncertainty, + double soundingWidth, double dataGap, double width, boolean isEmpty) { + addKM(station); + addMiddleHeight(height); + addUncertainty(uncertainty); + addSoundingWidth(soundingWidth); + addDataGap(dataGap); + addWidth(width); + addIsEmpty(isEmpty); + } + + + public int getStartYear() { + return startYear; + } + + public int getEndYear() { + return endYear; + } + + public String getEvaluatedBy() { + return evaluatedBy; + } + + public String getDescription() { + return description; + } + + + protected void addKM(double km) { + this.km.add(km); + } + + public double getKM(int idx) { + return km.get(idx); + } + + public TDoubleArrayList getStations() { + return this.km; + } + + protected void addMiddleHeight(double middleHeight) { + this.middleHeight.add(middleHeight); + } + + public double getMiddleHeight(int idx) { + return middleHeight.get(idx); + } + + protected void addUncertainty(double uncertainty) { + this.uncertainty.add(uncertainty); + } + + public double getUncertainty(int idx) { + return uncertainty.get(idx); + } + + protected void addSoundingWidth(double soundingWidth) { + this.soundingWidth.add(soundingWidth); + } + + public double getSoundingWidth(int idx) { + return soundingWidth.get(idx); + } + + protected void addDataGap(double gap) { + this.dataGap.add(gap); + } + + public double getDataGap(int idx) { + return dataGap.get(idx); + } + + protected void addIsEmpty(boolean empty) { + this.empty.add(empty); + } + + public boolean isEmpty(int idx) { + return (Boolean) empty.get(idx); + } + + + protected void addWidth(double width) { + this.width.add(width); + } + + public double getWidth(int idx) { + return width.get(idx); + } + + public int size() { + return km.size(); + } + + + /** + * Get the points, ready to be drawn + * @return [[km1, km2,...],[height1,height2,...]] + */ + public double[][] getMiddleHeightsPoints() { + double[][] points = new double[2][size()]; + + for (int i = 0, n = size(); i < n; i++) { + if (isEmpty(i)) { + points[0][i] = getKM(i); + points[1][i] = Double.NaN; + } + else { + points[0][i] = getKM(i); + points[1][i] = getMiddleHeight(i); + } + } + + return points; + } + + + public String getSoundingName(CallContext context) { + if (getStartYear() == getEndYear()) { + return Resources.getMsg( + context.getMeta(), + I18N_SINGLE_NAME, + I18N_SINGLE_NAME, + new Object[] { getStartYear() } + ); + } + else { + return Resources.getMsg( + context.getMeta(), + I18N_EPOCH_NAME, + I18N_EPOCH_NAME, + new Object[] { getStartYear(), getEndYear() } + ); + } + } + + @Override + public int compareTo(MiddleBedHeightData other) { + + int descCompared = description.compareTo(other.getDescription()); + + if (descCompared != 0) { + return descCompared; + } + + if (size() == 0 || other.size() == 0) { + if (size() == 0 && other.size() > 0) { + return 1; + } else if (size() > 0 && other.size() == 0) { + return -1; + } else if (size() == 0 && other.size() == 0) { + return 0; + } + } + + if (getKM(0) < other.getKM(0)) { + return -1; + } else if (getKM(0) > other.getKM(0)) { + return 1; + } + return 0; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 45cced06490c -r 62befca02480 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightFacet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightFacet.java Tue Jul 01 13:25:46 2014 +0200 @@ -0,0 +1,79 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.model.minfo; + +import org.dive4elements.artifactdatabase.state.Facet; + +import org.dive4elements.artifacts.Artifact; +import org.dive4elements.artifacts.CallContext; + +import org.dive4elements.river.artifacts.D4EArtifact; + +import org.dive4elements.river.artifacts.model.CalculationResult; +import org.dive4elements.river.artifacts.model.DataFacet; +import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; + +import org.apache.log4j.Logger; + + +/** + * Facet of a MiddleBedHeight curve. + */ +public class MiddleBedHeightFacet extends DataFacet { + + private static Logger logger = Logger.getLogger(MiddleBedHeightFacet.class); + + + public MiddleBedHeightFacet() { + // required for clone operation deepCopy() + } + + + public MiddleBedHeightFacet( + int idx, + String name, + String description, + ComputeType type, + String stateId, + String hash + ) { + super(idx, name, description, type, hash, stateId); + this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); + this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label"); + } + + + public Object getData(Artifact artifact, CallContext context) { + logger.debug("Get data for middle bed height at index: " + index); + + D4EArtifact flys = (D4EArtifact) artifact; + + CalculationResult res = (CalculationResult) + flys.compute(context, hash, stateId, type, false); + + MiddleBedHeightData[] resultData = + (MiddleBedHeightData[]) res.getData(); + MiddleBedHeightData data = resultData[index]; + + return data.getMiddleHeightsPoints(); + } + + + /** Copy deeply. */ + @Override + public Facet deepCopy() { + MiddleBedHeightFacet copy = new MiddleBedHeightFacet(); + copy.set(this); + copy.type = type; + copy.hash = hash; + copy.stateId = stateId; + return copy; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 45cced06490c -r 62befca02480 artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java Mon Jun 30 11:29:45 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java Tue Jul 01 13:25:46 2014 +0200 @@ -22,9 +22,9 @@ import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.model.DataFacet; import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.artifacts.model.MiddleBedHeightData; -import org.dive4elements.river.artifacts.model.MiddleBedHeightFacet; -import org.dive4elements.river.artifacts.model.MiddleBedHeightCalculation; +import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightCalculation; +import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightData; +import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightFacet; /** State in which Middle Bed Heights are generated. */ diff -r 45cced06490c -r 62befca02480 artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java Mon Jun 30 11:29:45 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java Tue Jul 01 13:25:46 2014 +0200 @@ -22,7 +22,7 @@ import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.model.CalculationResult; -import org.dive4elements.river.artifacts.model.MiddleBedHeightData; +import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightData; import org.dive4elements.river.model.River; diff -r 45cced06490c -r 62befca02480 artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java Mon Jun 30 11:29:45 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java Tue Jul 01 13:25:46 2014 +0200 @@ -17,9 +17,9 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.artifacts.model.MiddleBedHeightData; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.model.FacetTypes; +import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightData; import org.dive4elements.river.themes.ThemeDocument; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.StyledSeriesBuilder; @@ -47,17 +47,21 @@ ThemeDocument theme, boolean visible) { CallContext context = generator.getCallContext(); - logger.debug("Processing: " + bundle.getFacetName()); Map metaData = bundle.getFacet().getMetaData(); yAxisLabel = metaData.get("Y"); - MiddleBedHeightData data = - (MiddleBedHeightData) bundle.getData(context); + Object raw = bundle.getData(context); + if (!(raw instanceof double[][])) { + logger.error("Unkonwn data type: " + raw.getClass().getName()); + return; + } + + double[][] data = (double[][])raw; StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); series.putMetaData(metaData, bundle.getArtifact(), context); - StyledSeriesBuilder.addPoints(series, data.getMiddleHeightsPoints(), + StyledSeriesBuilder.addPoints(series, data, false, 0.110d); generator.addAxisSeries(series, axisName, visible);