Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 2998:4b6fb6d91192
issue417: duration curve main values as line(s) to curve.
flys-artifacts/trunk@4553 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 29 May 2012 14:59:04 +0000 |
parents | 60f13d966ee3 |
children | 33c167d6fff6 |
comparison
equal
deleted
inserted
replaced
2997:60f13d966ee3 | 2998:4b6fb6d91192 |
---|---|
785 } | 785 } |
786 } | 786 } |
787 | 787 |
788 | 788 |
789 /** | 789 /** |
790 * Create a line from a axis to a given point. | |
791 * @param axis The "simple" axis. | |
792 * @param fromD1 from-location in first dimension. | |
793 * @param toD2 to-location in second dimension. | |
794 * @param area helper to calculate offsets. | |
795 * @param lineStyle optional line style. | |
796 */ | |
797 protected static XYLineAnnotation createStickyLineAnnotation( | |
798 StickyAxisAnnotation.SimpleAxis axis, float fromD1, float toD2, | |
799 Area area, ThemeAccess.LineStyle lineStyle | |
800 ) { | |
801 double anchorX1 = 0d, anchorX2 = 0d, anchorY1 = 0d, anchorY2 = 0d; | |
802 switch(axis) { | |
803 case X_AXIS: | |
804 anchorX1 = fromD1; | |
805 anchorX2 = fromD1; | |
806 anchorY1 = area.atGround(); | |
807 anchorY2 = toD2; | |
808 break; | |
809 case Y_AXIS: | |
810 anchorX1 = area.atLeft(); | |
811 anchorX2 = toD2; | |
812 anchorY1 = fromD1; | |
813 anchorY2 = fromD1; | |
814 break; | |
815 case Y_AXIS2: | |
816 anchorX1 = area.atRight(); | |
817 anchorX2 = toD2; | |
818 anchorY1 = fromD1; | |
819 anchorY2 = fromD1; | |
820 break; | |
821 } | |
822 // Style the line. | |
823 if (lineStyle != null) { | |
824 return new XYLineAnnotation( | |
825 anchorX1, anchorY1, | |
826 anchorX2, anchorY2, | |
827 new BasicStroke(lineStyle.getWidth()), lineStyle.getColor()); | |
828 } | |
829 else { | |
830 return new XYLineAnnotation( | |
831 anchorX1, anchorY1, | |
832 anchorX2, anchorY2); | |
833 } | |
834 } | |
835 | |
836 | |
837 /** | |
790 * Add a text and a line annotation. | 838 * Add a text and a line annotation. |
791 * @param area convenience to determine positions in plot. | 839 * @param area convenience to determine positions in plot. |
792 * @param theme (optional) theme document | 840 * @param theme (optional) theme document |
793 */ | 841 */ |
794 public void addStickyAnnotation( | 842 public void addStickyAnnotation( |
843 annotation.getText(), area2.ofRight(TEXT_OFF), annotation.getPos()); | 891 annotation.getText(), area2.ofRight(TEXT_OFF), annotation.getPos()); |
844 textAnnotation.setRotationAnchor(TextAnchor.CENTER_RIGHT); | 892 textAnnotation.setRotationAnchor(TextAnchor.CENTER_RIGHT); |
845 textAnnotation.setTextAnchor(TextAnchor.CENTER_RIGHT); | 893 textAnnotation.setTextAnchor(TextAnchor.CENTER_RIGHT); |
846 lineAnnotation = createRightStickAnnotation( | 894 lineAnnotation = createRightStickAnnotation( |
847 area2, annotation.getPos(), lineStyle); | 895 area2, annotation.getPos(), lineStyle); |
848 // TODO line to curve | |
849 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { | 896 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { |
850 // New line annotation to hit curve. | 897 // New line annotation to hit curve. |
851 // TODO include more style information | |
852 if (ThemeUtil.parseShowVerticalLine(theme)) { | 898 if (ThemeUtil.parseShowVerticalLine(theme)) { |
853 // createRightStickAnnotaiton .... | 899 XYLineAnnotation hitLineAnnotation = |
854 XYLineAnnotation hitLineAnnotation = new XYLineAnnotation( | 900 createStickyLineAnnotation( |
855 area2.atRight(), annotation.getPos(), | 901 StickyAxisAnnotation.SimpleAxis.X_AXIS, |
856 annotation.getHitPoint(), annotation.getPos()); | 902 annotation.getPos(), annotation.getHitPoint(), |
903 area, lineStyle); | |
857 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, | 904 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, |
858 org.jfree.ui.Layer.BACKGROUND); | 905 org.jfree.ui.Layer.BACKGROUND); |
859 } | 906 } |
860 if (ThemeUtil.parseShowHorizontalLine(theme)) { | 907 if (ThemeUtil.parseShowHorizontalLine(theme)) { |
861 // createGroundStickAnnotation | 908 XYLineAnnotation lineBackAnnotation = |
862 XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( | 909 createStickyLineAnnotation( |
863 annotation.getHitPoint(), annotation.getPos(), | 910 StickyAxisAnnotation.SimpleAxis.Y_AXIS2, |
864 annotation.getHitPoint(), area2.atGround()); | 911 annotation.getPos(), annotation.getHitPoint(), |
912 area, lineStyle); | |
865 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, | 913 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, |
866 org.jfree.ui.Layer.BACKGROUND); | 914 org.jfree.ui.Layer.BACKGROUND); |
867 } | 915 } |
868 } | 916 } |
869 } | 917 } |
872 annotation.getText(), area.ofLeft(TEXT_OFF), annotation.getPos()); | 920 annotation.getText(), area.ofLeft(TEXT_OFF), annotation.getPos()); |
873 textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT); | 921 textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT); |
874 textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT); | 922 textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT); |
875 lineAnnotation = createLeftStickAnnotation(area, annotation.getPos(), lineStyle); | 923 lineAnnotation = createLeftStickAnnotation(area, annotation.getPos(), lineStyle); |
876 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { | 924 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { |
877 // TODO include more style information | |
878 // New line annotation to hit curve. | 925 // New line annotation to hit curve. |
879 if (ThemeUtil.parseShowHorizontalLine(theme)) { | 926 if (ThemeUtil.parseShowHorizontalLine(theme)) { |
880 // createLeftStickAnnotaiton | 927 XYLineAnnotation hitLineAnnotation = |
881 XYLineAnnotation hitLineAnnotation = new XYLineAnnotation(area.atLeft(), | 928 createStickyLineAnnotation( |
882 annotation.getPos(), annotation.getHitPoint(), annotation.getPos()); | 929 StickyAxisAnnotation.SimpleAxis.Y_AXIS, |
930 annotation.getPos(), annotation.getHitPoint(), | |
931 area, lineStyle); | |
883 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, | 932 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, |
884 org.jfree.ui.Layer.BACKGROUND); | 933 org.jfree.ui.Layer.BACKGROUND); |
885 } | 934 } |
886 if (ThemeUtil.parseShowVerticalLine(theme)) { | 935 if (ThemeUtil.parseShowVerticalLine(theme)) { |
887 // createGroundStickAnnotation | 936 XYLineAnnotation lineBackAnnotation = |
888 XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( | 937 createStickyLineAnnotation( |
889 annotation.getHitPoint(), annotation.getPos(), | 938 StickyAxisAnnotation.SimpleAxis.X_AXIS, |
890 annotation.getHitPoint(), area.atGround()); | 939 annotation.getHitPoint(), annotation.getPos(), |
940 area, lineStyle); | |
891 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, | 941 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, |
892 org.jfree.ui.Layer.BACKGROUND); | 942 org.jfree.ui.Layer.BACKGROUND); |
893 } | 943 } |
894 } | 944 } |
895 } | 945 } |