# HG changeset patch # User Raimund Renkert # Date 1400230559 -7200 # Node ID 43f18dc56c5a8b5f75eec8382f59276955cb3ef7 # Parent 5951d6430ade0c264995c34db7ec8d4d407a201d Fixed subtitle handling and added flowvelocity subtitle. diff -r 5951d6430ade -r 43f18dc56c5a artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Fri May 16 09:32:51 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Fri May 16 10:55:59 2014 +0200 @@ -686,6 +686,9 @@ if (chartSettings != null) { String subTitle = getChartSubtitle(chartSettings); + if (subTitle == null) { + return getDefaultChartSubtitle(); + } String defSubTitle = getDefaultChartSubtitle(); if (defSubTitle != null && !defSubTitle.isEmpty() && diff -r 5951d6430ade -r 43f18dc56c5a artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Fri May 16 09:32:51 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Fri May 16 10:55:59 2014 +0200 @@ -1046,15 +1046,27 @@ @Override public String getDefaultChartSubtitle() { String parts = ""; + DiagramAttributes.Title dTitle = diagramAttributes.getSubtitle(); + if (dTitle == null && + (subTitleParts == null || subTitleParts.isEmpty())) { + /* Subtitle is optional */ + return null; + } if (subTitleParts != null && !subTitleParts.isEmpty()) { + boolean first = true; + if (dTitle != null) { + first = false; + } for (String p : subTitleParts) { - parts += ", " + p; + if (!first) { + parts += ", "; + } + parts += p; + first = false; } } - DiagramAttributes.Title dTitle = diagramAttributes.getSubtitle(); - if (dTitle == null) { - /* Subtitle is optional */ - return null; + if (dTitle == null && parts.length() > 0) { + return parts; } return dTitle.evaluate((D4EArtifact)getMaster(), context) + parts; } diff -r 5951d6430ade -r 43f18dc56c5a artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java Fri May 16 09:32:51 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java Fri May 16 10:55:59 2014 +0200 @@ -63,22 +63,29 @@ * actually does the output and accesses the facet data. */ D4EArtifact artifact = (D4EArtifact)bundle.getArtifact(); - + if (context.getContextValue("bounds_defined") != null && + (Boolean)context.getContextValue("bounds_defined")) { + super.doOut(bundle, theme, visible); + return; + } if (getXBounds(0) != null && getDomainAxisRange() != null) { Bounds bounds = calculateZoom(getXBounds(0), getDomainAxisRange()); context.putContextValue("startkm", bounds.getLower()); context.putContextValue("endkm", bounds.getUpper()); + context.putContextValue("bounds_defined", true); } else if (getXBounds(0) != null && getDomainAxisRange() == null) { context.putContextValue("startkm", getXBounds(0).getLower()); context.putContextValue("endkm", getXBounds(0).getUpper()); + context.putContextValue("bounds_defined", true); } else if (getXBounds(0) == null && getDomainAxisRange() == null) { RangeAccess access = new RangeAccess(artifact); if (access.hasFrom() && access.hasTo()) { context.putContextValue("startkm", access.getFrom()); context.putContextValue("endkm", access.getTo()); + context.putContextValue("bounds_defined", true); } } else if (getXBounds(0) == null && getDomainAxisRange() != null){ @@ -89,6 +96,7 @@ calculateZoom(b, getDomainAxisRange()); context.putContextValue("startkm", bounds.getLower()); context.putContextValue("endkm", bounds.getUpper()); + context.putContextValue("bounds_defined", true); } } super.doOut(bundle, theme, visible); diff -r 5951d6430ade -r 43f18dc56c5a artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java Fri May 16 09:32:51 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java Fri May 16 10:55:59 2014 +0200 @@ -13,7 +13,11 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RiverAccess; +import org.dive4elements.river.artifacts.context.RiverContext; import org.dive4elements.river.artifacts.model.FacetTypes; +import org.dive4elements.river.artifacts.model.ZoomScale; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.jfree.StyledXYSeries; @@ -21,6 +25,7 @@ import org.dive4elements.river.model.FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue; import org.dive4elements.river.artifacts.model.FlowVelocityData; +import org.dive4elements.river.artifacts.resources.Resources; public class FlowVelocityProcessor extends DefaultProcessor { @@ -31,6 +36,8 @@ "chart.flow_velocity.section.yaxis.label"; public static final String I18N_AXIS_LABEL_DEFAULT = "Geschwindigkeit v [m/s]"; + public static final String I18N_SUBTITLE_RADIUS = + "chart.subtitle.radius"; @Override public void doOut( @@ -68,7 +75,24 @@ return; } StyledSeriesBuilder.addPoints(series, points, true); + Double start = (Double)context.getContextValue("startkm"); + Double end = (Double)context.getContextValue("endkm"); + if (start != null && end != null) { + logger.debug("start: " + start + " end: " + end); + D4EArtifact artifact = (D4EArtifact)bundle.getArtifact(); + RiverContext fc = (RiverContext)context.globalContext(); + // Adaptive smoothing, based on zoom factor/diagram extents. + ZoomScale scales = (ZoomScale)fc.get("zoomscale"); + RiverAccess access = new RiverAccess((D4EArtifact)artifact); + String river = access.getRiverName(); + double radius = scales.getRadius(river, start, end); + logger.debug("add a subtitle"); + generator.addSubtitle(Resources.getMsg( + context.getMeta(), + I18N_SUBTITLE_RADIUS, + new Object[] { radius })); + } generator.addAxisSeries(series, axisName, visible); }