Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java @ 7081:3c4efd4b2c19 generator-refactoring
Simplyfy / unify "invert axis" logic
- DataUtil now can check if two datasets are in the same direction
- In the case of WKM data a no means that the Water flows Right to Left
- If the water flows from right to left do inversion of diagrams
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 20 Sep 2013 17:36:11 +0200 |
parents | 7f600001c807 |
children | f0731aa7b735 |
comparison
equal
deleted
inserted
replaced
7080:02a704a37323 | 7081:3c4efd4b2c19 |
---|---|
1081 | 1081 |
1082 protected String axisIndexToName(int index) { | 1082 protected String axisIndexToName(int index) { |
1083 return diagramAttributes.getAxisName(index); | 1083 return diagramAttributes.getAxisName(index); |
1084 } | 1084 } |
1085 | 1085 |
1086 /** Guess if the axis should be inverted to ensure ltr diagram water flow. | |
1087 * | |
1088 * A processor should decide if it is appropiate to activate this | |
1089 * handling in a diagram by calling this function. | |
1090 * | |
1091 * Merke: In Deutschland fliesst Wasser in Diagrammen immer von | |
1092 * links nach rechts!!! | |
1093 */ | |
1094 public void handleLTRWaterFlowInversion(WKms wkms) | |
1095 { | |
1096 boolean wsUp = wkms.guessWaterIncreasing(); | |
1097 boolean kmUp = DataUtil.guessWaterIncreasing(wkms.allKms()); | |
1098 int size = wkms.size(); | |
1099 boolean inv = ((wsUp && kmUp) || (!wsUp && !kmUp)) && size > 1; | |
1100 | |
1101 if (logger.isDebugEnabled()) { | |
1102 logger.debug("handleLTRWaterFlowInversion: (Wkms)Values : " + size); | |
1103 if (size > 0) { | |
1104 logger.debug("Start km: " + wkms.getKm(0)); | |
1105 logger.debug("End km: " + wkms.getKm(size-1)); | |
1106 } | |
1107 logger.debug("wsUp: " + wsUp); | |
1108 logger.debug("kmUp: " + kmUp); | |
1109 if (size == 1) { | |
1110 logger.debug("Not inverting because we have just one km"); | |
1111 } | |
1112 logger.debug("inv: " + inv); | |
1113 } | |
1114 setInverted(inv); | |
1115 } | |
1116 | |
1117 /** Add the acutal data to the diagram according to the processors. | 1086 /** Add the acutal data to the diagram according to the processors. |
1118 * For every outable facets, this function is | 1087 * For every outable facets, this function is |
1119 * called and handles the data accordingly. */ | 1088 * called and handles the data accordingly. */ |
1120 @Override | 1089 @Override |
1121 public void doOut( | 1090 public void doOut( |