Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 2996:55f91fae8a7b
Respect new theme setting when drawing line to curve.
flys-artifacts/trunk@4551 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 29 May 2012 08:23:03 +0000 |
parents | 772d0c8100d3 |
children | 60f13d966ee3 |
comparison
equal
deleted
inserted
replaced
2995:7d33aec0b61d | 2996:55f91fae8a7b |
---|---|
48 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation; | 48 import de.intevation.flys.jfree.CollisionFreeXYTextAnnotation; |
49 import de.intevation.flys.jfree.StyledAreaSeriesCollection; | 49 import de.intevation.flys.jfree.StyledAreaSeriesCollection; |
50 import de.intevation.flys.jfree.StyledXYSeries; | 50 import de.intevation.flys.jfree.StyledXYSeries; |
51 | 51 |
52 import de.intevation.flys.utils.ThemeAccess; | 52 import de.intevation.flys.utils.ThemeAccess; |
53 import de.intevation.flys.utils.ThemeUtil; | |
53 | 54 |
54 import de.intevation.flys.artifacts.model.HYKFactory; | 55 import de.intevation.flys.artifacts.model.HYKFactory; |
55 | 56 |
56 import org.json.JSONArray; | 57 import org.json.JSONArray; |
57 import org.json.JSONException; | 58 import org.json.JSONException; |
766 } | 767 } |
767 | 768 |
768 /** | 769 /** |
769 * Add a text and a line annotation. | 770 * Add a text and a line annotation. |
770 * @param area convenience to determine positions in plot. | 771 * @param area convenience to determine positions in plot. |
772 * @param theme (optional) theme document | |
771 */ | 773 */ |
772 public void addStickyAnnotation( | 774 public void addStickyAnnotation( |
773 StickyAxisAnnotation annotation, | 775 StickyAxisAnnotation annotation, |
774 XYPlot plot, | 776 XYPlot plot, |
775 Area area, | 777 Area area, |
776 ThemeAccess.LineStyle lineStyle, | 778 ThemeAccess.LineStyle lineStyle, |
777 ThemeAccess.TextStyle textStyle | 779 ThemeAccess.TextStyle textStyle, |
780 Document theme | |
778 ) { | 781 ) { |
779 // OPTIMIZE pre-calculate area-related values | 782 // OPTIMIZE pre-calculate area-related values |
780 final float TEXT_OFF = 0.03f; | 783 final float TEXT_OFF = 0.03f; |
781 | 784 |
782 XYLineAnnotation lineAnnotation = null; | 785 XYLineAnnotation lineAnnotation = null; |
821 textAnnotation.setRotationAnchor(TextAnchor.CENTER_RIGHT); | 824 textAnnotation.setRotationAnchor(TextAnchor.CENTER_RIGHT); |
822 textAnnotation.setTextAnchor(TextAnchor.CENTER_RIGHT); | 825 textAnnotation.setTextAnchor(TextAnchor.CENTER_RIGHT); |
823 lineAnnotation = createRightStickAnnotation( | 826 lineAnnotation = createRightStickAnnotation( |
824 area2, annotation.getPos(), lineStyle); | 827 area2, annotation.getPos(), lineStyle); |
825 // TODO line to curve | 828 // TODO line to curve |
826 if (!Float.isNaN(annotation.getHitPoint())) { | 829 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { |
827 // TODO let line be styled and respect X/Y-ness. | |
828 // New line annotation to hit curve. | 830 // New line annotation to hit curve. |
829 XYLineAnnotation hitLineAnnotation = new XYLineAnnotation( | 831 // TODO include more style information |
830 area2.atRight(), annotation.getPos(), | 832 if (ThemeUtil.parseShowVerticalLine(theme)) { |
831 annotation.getHitPoint(), annotation.getPos()); | 833 XYLineAnnotation hitLineAnnotation = new XYLineAnnotation( |
832 XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( | 834 area2.atRight(), annotation.getPos(), |
833 annotation.getHitPoint(), annotation.getPos(), | 835 annotation.getHitPoint(), annotation.getPos()); |
834 annotation.getHitPoint(), area2.atGround()); | 836 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, |
835 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, | 837 org.jfree.ui.Layer.BACKGROUND); |
836 org.jfree.ui.Layer.BACKGROUND); | 838 } |
837 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, | 839 if (ThemeUtil.parseShowHorizontalLine(theme)) { |
838 org.jfree.ui.Layer.BACKGROUND); | 840 XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( |
841 annotation.getHitPoint(), annotation.getPos(), | |
842 annotation.getHitPoint(), area2.atGround()); | |
843 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, | |
844 org.jfree.ui.Layer.BACKGROUND); | |
845 } | |
839 } | 846 } |
840 } | 847 } |
841 else { | 848 else { |
842 textAnnotation = new CollisionFreeXYTextAnnotation( | 849 textAnnotation = new CollisionFreeXYTextAnnotation( |
843 annotation.getText(), area.ofLeft(TEXT_OFF), annotation.getPos()); | 850 annotation.getText(), area.ofLeft(TEXT_OFF), annotation.getPos()); |
844 textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT); | 851 textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT); |
845 textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT); | 852 textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT); |
846 lineAnnotation = createLeftStickAnnotation(area, annotation.getPos(), lineStyle); | 853 lineAnnotation = createLeftStickAnnotation(area, annotation.getPos(), lineStyle); |
847 // TODO line to curve | 854 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { |
848 if (!Float.isNaN(annotation.getHitPoint())) { | 855 // TODO include more style information |
849 // TODO let line be styled and respect X/Y-ness. | |
850 // New line annotation to hit curve. | 856 // New line annotation to hit curve. |
851 XYLineAnnotation hitLineAnnotation = new XYLineAnnotation(area.atLeft(), | 857 if (ThemeUtil.parseShowHorizontalLine(theme)) { |
852 annotation.getPos(), annotation.getHitPoint(), annotation.getPos()); | 858 XYLineAnnotation hitLineAnnotation = new XYLineAnnotation(area.atLeft(), |
853 XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( | 859 annotation.getPos(), annotation.getHitPoint(), annotation.getPos()); |
854 annotation.getHitPoint(), annotation.getPos(), | 860 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, |
855 annotation.getHitPoint(), area.atGround()); | 861 org.jfree.ui.Layer.BACKGROUND); |
856 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, | 862 } |
857 org.jfree.ui.Layer.BACKGROUND); | 863 if (ThemeUtil.parseShowVerticalLine(theme)) { |
858 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, | 864 XYLineAnnotation lineBackAnnotation = new XYLineAnnotation( |
859 org.jfree.ui.Layer.BACKGROUND); | 865 annotation.getHitPoint(), annotation.getPos(), |
866 annotation.getHitPoint(), area.atGround()); | |
867 plot.getRenderer(rendererIndex).addAnnotation(lineBackAnnotation, | |
868 org.jfree.ui.Layer.BACKGROUND); | |
869 } | |
860 } | 870 } |
861 } | 871 } |
862 } | 872 } |
863 | 873 |
864 // Style the text. | 874 // Style the text. |
926 } | 936 } |
927 } | 937 } |
928 | 938 |
929 // The 'Sticky' Annotations (at axis, with line and text). | 939 // The 'Sticky' Annotations (at axis, with line and text). |
930 for (StickyAxisAnnotation sta: fa.getAxisTextAnnotations()) { | 940 for (StickyAxisAnnotation sta: fa.getAxisTextAnnotations()) { |
931 addStickyAnnotation(sta, plot, area, lineStyle, textStyle); | 941 addStickyAnnotation( |
942 sta, plot, area, lineStyle, textStyle, theme); | |
932 } | 943 } |
933 | 944 |
934 // Other Text Annotations (e.g. labels of manual points). | 945 // Other Text Annotations (e.g. labels of manual points). |
935 for (XYTextAnnotation ta: fa.getTextAnnotations()) { | 946 for (XYTextAnnotation ta: fa.getTextAnnotations()) { |
936 // Style the text. | 947 // Style the text. |