comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java @ 2104:bb0dede9294f

Implementation towards areas at other than first axis (flys/issue441). flys-artifacts/trunk@3661 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 12 Jan 2012 12:29:56 +0000
parents a026d005accd
children ce9b15673f3f
comparison
equal deleted inserted replaced
2103:b9f7ec9bda18 2104:bb0dede9294f
15 import de.intevation.artifactdatabase.state.ArtifactAndFacet; 15 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
16 import de.intevation.artifactdatabase.state.Facet; 16 import de.intevation.artifactdatabase.state.Facet;
17 17
18 import de.intevation.flys.artifacts.FLYSArtifact; 18 import de.intevation.flys.artifacts.FLYSArtifact;
19 19
20 import de.intevation.flys.artifacts.model.AreaFacet;
20 import de.intevation.flys.artifacts.model.FacetTypes; 21 import de.intevation.flys.artifacts.model.FacetTypes;
21 import de.intevation.flys.artifacts.model.WKms; 22 import de.intevation.flys.artifacts.model.WKms;
22 import de.intevation.flys.artifacts.model.WQKms; 23 import de.intevation.flys.artifacts.model.WQKms;
23 24
24 import de.intevation.flys.jfree.FLYSAnnotation; 25 import de.intevation.flys.jfree.FLYSAnnotation;
280 * not inverted, otherwise it is. 281 * not inverted, otherwise it is.
281 * 282 *
282 * @param xaxis The domain axis. 283 * @param xaxis The domain axis.
283 */ 284 */
284 protected void invertXAxis(ValueAxis xaxis) { 285 protected void invertXAxis(ValueAxis xaxis) {
285
286 if (inverted) { 286 if (inverted) {
287 logger.debug("X-Axis.setInverted(true)"); 287 logger.debug("X-Axis.setInverted(true)");
288 xaxis.setInverted(true); 288 xaxis.setInverted(true);
289 } 289 }
290 } 290 }
327 } 327 }
328 else if (name.equals(STATIC_WKMS) 328 else if (name.equals(STATIC_WKMS)
329 || name.equals(HEIGHTMARKS_POINTS) 329 || name.equals(HEIGHTMARKS_POINTS)
330 || name.equals(STATIC_WQKMS)) { 330 || name.equals(STATIC_WQKMS)) {
331 doWOut((WKms) artifactAndFacet.getData(context), facet, attr, visible); 331 doWOut((WKms) artifactAndFacet.getData(context), facet, attr, visible);
332 }
333 else if (name.equals(STATIC_WQKMS_W)) {
334 doWOut((WQKms) artifactAndFacet.getData(context), facet, attr, visible);
335 }
336 else if (name.equals(STATIC_WQKMS_Q)) {
337 doQOut((WQKms) artifactAndFacet.getData(context), facet, attr, visible);
332 } 338 }
333 else if (name.equals(W_DIFFERENCES)) { 339 else if (name.equals(W_DIFFERENCES)) {
334 doWDifferencesOut( 340 doWDifferencesOut(
335 (WKms) artifactAndFacet.getData(context), 341 (WKms) artifactAndFacet.getData(context),
336 facet, 342 facet,
491 ? prefix + "(" + name +")" 497 ? prefix + "(" + name +")"
492 : name; 498 : name;
493 } 499 }
494 500
495 501
502 /** Look up the axis identifier for a given facet type. */
503 public int axisIdxForFacet(String facetName) {
504 if (FacetTypes.IS.W(facetName)) {
505 return YAXIS.W.idx;
506 }
507 else if (FacetTypes.IS.Q(facetName)) {
508 return YAXIS.Q.idx;
509 }
510 else {
511 logger.warn("Could not find axis for facet " + facetName);
512 return YAXIS.W.idx;
513 }
514 }
515
496 /** 516 /**
497 * Do Area out. 517 * Do Area out.
498 */ 518 */
499 protected void doArea( 519 protected void doArea(
500 Object o, 520 Object o,
503 boolean visible 523 boolean visible
504 ) { 524 ) {
505 logger.debug("LongitudinalSectionGenerator.doArea"); 525 logger.debug("LongitudinalSectionGenerator.doArea");
506 StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme); 526 StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme);
507 527
508 // TODO make this more stable. 528 AreaFacet.Data data = (AreaFacet.Data) o;
509 Object[] doubles = (Object[]) o; 529
510 XYSeries up = null; 530 XYSeries up = null;
511 XYSeries down = null; 531 XYSeries down = null;
512 532
513 if (doubles[1] != null) { 533 if (data.getUpperData() != null) {
514 up = new StyledXYSeries(seriesName, false, theme); 534 up = new StyledXYSeries(seriesName, false, theme);
515 if (doubles[1] instanceof WKms) { 535 if (data.getUpperData() instanceof WQKms) {
516 StyledSeriesBuilder.addPoints(up, (WKms) doubles[1]); 536 if (FacetTypes.IS.Q(data.getRootFacetName())) {
517 } 537 StyledSeriesBuilder.addPointsKmQ(up, (WQKms) data.getUpperData());
518 else if (doubles[1] instanceof double[][]) { 538 }
519 StyledSeriesBuilder.addPoints(up, (double [][]) doubles[1]); 539 else {
540 StyledSeriesBuilder.addPoints(up, (WKms) data.getUpperData());
541 }
542 }
543 else if (data.getUpperData() instanceof double[][]) {
544 StyledSeriesBuilder.addPoints(up, (double [][]) data.getUpperData());
520 } 545 }
521 else { 546 else {
522 logger.error("Do not know how to deal with (up) area info from: " 547 logger.error("Do not know how to deal with (up) area info from: "
523 + doubles[1]); 548 + data.getUpperData());
524 } 549 }
525 } 550 }
526 551
527 if (doubles[0] != null) { 552 if (data.getLowerData() != null) {
528 // TODO: Sort this out: when the two series have the same name, 553 // TODO: Sort this out: when the two series have the same name,
529 // the renderer (or anything in between) will not work correctly. 554 // the renderer (or anything in between) will not work correctly.
530 down = new StyledXYSeries(seriesName + " ", false, theme); 555 down = new StyledXYSeries(seriesName + " ", false, theme);
531 if (doubles[0] instanceof WQKms) { 556 if (data.getLowerData() instanceof WQKms) {
532 StyledSeriesBuilder.addPoints(down, (WKms) doubles[0]); 557 if (FacetTypes.IS.Q(data.getRootFacetName())) {
533 } 558 StyledSeriesBuilder.addPointsKmQ(down, (WQKms) data.getLowerData());
534 else if (doubles[0] instanceof double[][]) { 559 }
535 StyledSeriesBuilder.addPoints(down, (double[][]) doubles[0]); 560 else {
561 StyledSeriesBuilder.addPoints(down, (WQKms) data.getLowerData());
562 }
563 }
564 else if (data.getLowerData() instanceof double[][]) {
565 StyledSeriesBuilder.addPoints(down, (double[][]) data.getLowerData());
536 } 566 }
537 else { 567 else {
538 logger.error("Do not know how to deal with (down) area info from: " 568 logger.error("Do not know how to deal with (down) area info from: "
539 + doubles[0]); 569 + data.getLowerData());
540 } 570 }
541
542 } 571 }
543 572
544 if (up == null && down != null) { 573 if (up == null && down != null) {
545 area.setMode(StyledAreaSeriesCollection.FILL_MODE.ABOVE); 574 area.setMode(StyledAreaSeriesCollection.FILL_MODE.ABOVE);
546 down.setKey(seriesName); 575 down.setKey(seriesName);
549 else if (up != null && down == null) { 578 else if (up != null && down == null) {
550 area.setMode(StyledAreaSeriesCollection.FILL_MODE.UNDER); 579 area.setMode(StyledAreaSeriesCollection.FILL_MODE.UNDER);
551 area.addSeries(up); 580 area.addSeries(up);
552 } 581 }
553 else if (up != null && down != null) { 582 else if (up != null && down != null) {
554 area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN); 583 if (data.doPaintBetween()) {
584 area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN);
585 }
586 else {
587 area.setMode(StyledAreaSeriesCollection.FILL_MODE.ABOVE);
588 }
555 area.addSeries(up); 589 area.addSeries(up);
556 area.addSeries(down); 590 area.addSeries(down);
557 } 591 }
558 addAreaSeries(area, 0, visible); 592 // Add area to the respective axis.
593 addAreaSeries(area, axisIdxForFacet(data.getRootFacetName()), visible);
559 } 594 }
560 } 595 }
561 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 596 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org