Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ChartHelper.java @ 3247:638b1da85450
New ChartHelper method to expand bounds added.
flys-artifacts/trunk@4880 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 06 Jul 2012 09:36:03 +0000 |
parents | bece6f604899 |
children | b2ea89a665bc |
comparison
equal
deleted
inserted
replaced
3246:229e9b27ce15 | 3247:638b1da85450 |
---|---|
153 return null; | 153 return null; |
154 } | 154 } |
155 | 155 |
156 | 156 |
157 /** | 157 /** |
158 * Expand bounds by percent. | |
159 * | |
160 * @param bounds The bounds to expand. | |
161 * @param percent The percentage to expand. | |
162 * | |
163 * @param a new, expanded bounds. | |
164 */ | |
165 public static Bounds expandBounds(Bounds bounds, double percent) { | |
166 if (bounds == null) { | |
167 return null; | |
168 } | |
169 | |
170 double value = (Double) bounds.getLower(); | |
171 double expand = Math.abs(value / 100 * percent); | |
172 | |
173 return expand != 0 | |
174 ? new DoubleBounds(value-expand, value+expand) | |
175 : new DoubleBounds(-0.01 * percent, 0.01 * percent); | |
176 } | |
177 | |
178 | |
179 /** | |
158 * Expand range by percent. | 180 * Expand range by percent. |
159 * | 181 * |
160 * @param range The range to expand. | 182 * @param range The range to expand. |
161 * @param percent The percentage to expand. | 183 * @param percent The percentage to expand. |
162 * | 184 * |
163 * @param an expanded range. | 185 * @param a new, expanded range. |
164 */ | 186 */ |
165 public static Range expandRange(Range range, double percent) { | 187 public static Range expandRange(Range range, double percent) { |
166 if (range == null) { | 188 if (range == null) { |
167 return null; | 189 return null; |
168 } | 190 } |