comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 4432:e8a4d2fd25cc

Merged.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 07 Nov 2012 09:47:44 +0100
parents 8b4988815974
children 5b8919ef601d
comparison
equal deleted inserted replaced
4431:83fe6eeba83a 4432:e8a4d2fd25cc
252 * Return left most data points x value (on first axis). 252 * Return left most data points x value (on first axis).
253 * Shortcut, especially to be overridden in (LS) charts where 253 * Shortcut, especially to be overridden in (LS) charts where
254 * axis could be inverted. 254 * axis could be inverted.
255 */ 255 */
256 protected double getLeftX() { 256 protected double getLeftX() {
257 // TODO if the range null...
258 //return (Double)getDomainAxisRange().getLowerBound();
257 return (Double)getXBounds(0).getLower(); 259 return (Double)getXBounds(0).getLower();
258 } 260 }
259 261
260 262
261 /** 263 /**
262 * Return right most data points x value (on first axis). 264 * Return right most data points x value (on first axis).
263 * Shortcut, especially to be overridden in (LS) charts where 265 * Shortcut, especially to be overridden in (LS) charts where
264 * axis could be inverted. 266 * axis could be inverted.
265 */ 267 */
266 protected double getRightX() { 268 protected double getRightX() {
267 return (Double)getXBounds(0).getUpper(); 269 return (Double)getXBounds(0).getLower();
268 } 270 //return (Double)getDomainAxisRange().getUpperBound();
269 271 }
272
273 protected double getBottomY() {
274 Range zoomedRange = getValueAxisRange();
275 return (zoomedRange != null)
276 ? zoomedRange.getLowerBound()
277 : (Double)getYBounds(0).getLower();
278 }
279
280 protected double getTopY() {
281 Range zoomedRange = getValueAxisRange();
282 return (zoomedRange != null)
283 ? zoomedRange.getUpperBound()
284 : (Double)getYBounds(0).getUpper();
285 }
270 286
271 /** Add a logo as background annotation to plot. */ 287 /** Add a logo as background annotation to plot. */
272 protected void addLogo(XYPlot plot) { 288 protected void addLogo(XYPlot plot) {
289 // TODO getValue/DomainAxisRange, so that the current zoom level is respected
273 String logo = showLogo(); 290 String logo = showLogo();
274 if (logo == null) { 291 if (logo == null) {
275 logger.debug("No logo to show chosen"); 292 logger.debug("No logo to show chosen");
276 return; 293 return;
277 } 294 }
297 else { // TODO else if ... 314 else { // TODO else if ...
298 imageURL = XYChartGenerator.class.getResource("/images/bfg_logo.gif"); 315 imageURL = XYChartGenerator.class.getResource("/images/bfg_logo.gif");
299 } 316 }
300 imageIcon = new ImageIcon(imageURL); 317 imageIcon = new ImageIcon(imageURL);
301 318
302
303 double xPos = 0d, yPos = 0d; 319 double xPos = 0d, yPos = 0d;
304 320
305 String placeh = logoHPlace(); 321 String placeh = logoHPlace();
306 String placev = logoVPlace(); 322 String placev = logoVPlace();
307 323
308 if (placev == null || placev.equals("none")) { 324 if (placev == null || placev.equals("none")) {
309 placev = "top"; 325 placev = "top";
310 } 326 }
311 if (placev.equals("top")) { 327 if (placev.equals("top")) {
312 yPos = (Double)getYBounds(0).getUpper(); 328 yPos = getTopY();
313 } 329 }
314 else if (placev.equals("bottom")) { 330 else if (placev.equals("bottom")) {
315 yPos = (Double)getYBounds(0).getLower(); 331 yPos = getBottomY();
316 } 332 }
317 else if (placev.equals("center")) { 333 else if (placev.equals("center")) {
318 yPos = ((Double)getYBounds(0).getUpper() + (Double)getYBounds(0).getLower())/2d; 334 yPos = (getTopY() + getBottomY())/2d;
319 } 335 }
320 else { 336 else {
321 logger.debug("Unknown place-v value: " + placev); 337 logger.debug("Unknown place-v value: " + placev);
322 } 338 }
323 339
329 } 345 }
330 else if (placeh.equals("right")) { 346 else if (placeh.equals("right")) {
331 xPos = getRightX(); 347 xPos = getRightX();
332 } 348 }
333 else if (placeh.equals("center")) { 349 else if (placeh.equals("center")) {
350 // TODO: Hier noch
334 xPos = ((Double)getXBounds(0).getUpper() + (Double)getXBounds(0).getLower())/2d; 351 xPos = ((Double)getXBounds(0).getUpper() + (Double)getXBounds(0).getLower())/2d;
352 // ->->-> (getDomainAxisRange().getUpperBound() + getDomainAxisRange().getLowerBound())/2d;
335 } 353 }
336 else { 354 else {
337 logger.debug("Unknown place-h value: " + placeh); 355 logger.debug("Unknown place-h value: " + placeh);
338 } 356 }
339 357
683 zoomY(plot, yaxis, getYBounds(Integer.valueOf(i)), yrange); 701 zoomY(plot, yaxis, getYBounds(Integer.valueOf(i)), yrange);
684 } 702 }
685 } 703 }
686 704
687 705
706 /** Return range of domain axis. */
688 protected Range getDomainAxisRange() { 707 protected Range getDomainAxisRange() {
689 String[] ranges = getDomainAxisRangeFromRequest(); 708 String[] ranges = getDomainAxisRangeFromRequest();
690 709
691 if (ranges == null || ranges.length < 2) { 710 if (ranges == null || ranges.length < 2) {
692 logger.debug("No zoom range for domain axis specified."); 711 logger.debug("No zoom range for domain axis specified.");
722 741
723 protected Range getValueAxisRange() { 742 protected Range getValueAxisRange() {
724 String[] ranges = getValueAxisRangeFromRequest(); 743 String[] ranges = getValueAxisRangeFromRequest();
725 744
726 if (ranges == null || ranges.length < 2) { 745 if (ranges == null || ranges.length < 2) {
727 logger.debug("No range specified. Lower and upper Y == 0"); 746 logger.warn("No range (or not enogh) specified.");
747 if (ranges == null) logger.warn("ranges is null here");
748 else logger.warn("ranges has just one element.");
728 return null; 749 return null;
729 } 750 }
730 751
731 if (ranges[0].length() > 0 && ranges[1].length() > 0) { 752 if (ranges[0].length() > 0 && ranges[1].length() > 0) {
732 try { 753 try {
745 catch (NumberFormatException nfe) { 766 catch (NumberFormatException nfe) {
746 logger.warn("Wrong values for value axis range."); 767 logger.warn("Wrong values for value axis range.");
747 } 768 }
748 } 769 }
749 770
771 logger.warn("One of the range elements is zero length text.");
750 return null; 772 return null;
751 } 773 }
752 774
753 775
754 protected boolean zoomX(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) { 776 protected boolean zoomX(XYPlot plot, ValueAxis axis, Bounds bounds, Range x) {
1032 1054
1033 // WQ.java holds example of using regex Matcher/Pattern. 1055 // WQ.java holds example of using regex Matcher/Pattern.
1034 1056
1035 return hash; 1057 return hash;
1036 } 1058 }
1037
1038 } 1059 }
1039 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 1060 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org