annotate artifacts/src/main/java/org/dive4elements/river/themes/TextStyle.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3464
diff changeset
9 package org.dive4elements.river.themes;
3464
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3464
diff changeset
11 import org.dive4elements.river.jfree.StableXYDifferenceRenderer;
3464
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
12
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
13 import java.awt.Color;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
14 import java.awt.Font;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
15
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 6911
diff changeset
16 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 6911
diff changeset
17 import org.apache.logging.log4j.LogManager;
3464
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
18 import org.jfree.chart.annotations.XYTextAnnotation;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
19
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
20 public class TextStyle {
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
21 @SuppressWarnings("unused")
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 6911
diff changeset
22 private static Logger log = LogManager.getLogger(TextStyle.class);
3464
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
23
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
24 protected Color textColor;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
25 protected Font font;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
26 protected Color bgColor;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
27 protected boolean showBg;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
28 protected boolean isVertical;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
29
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
30 public TextStyle(Color fgColor, Font font, Color bgColor,
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
31 boolean showBg, boolean isVertical
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
32 ) {
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
33 this.textColor = fgColor;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
34 this.font = font;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
35 this.bgColor = bgColor;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
36 this.showBg = showBg;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
37 this.isVertical = isVertical;
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
38 }
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
39
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
40 public void apply(XYTextAnnotation ta) {
6911
1f1acbe5f243 Artifacts: Make TextStyle Make more robust.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
41 if (textColor != null) {
1f1acbe5f243 Artifacts: Make TextStyle Make more robust.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
42 ta.setPaint(textColor);
1f1acbe5f243 Artifacts: Make TextStyle Make more robust.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
43 }
1f1acbe5f243 Artifacts: Make TextStyle Make more robust.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
44 if (font != null) {
1f1acbe5f243 Artifacts: Make TextStyle Make more robust.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
45 ta.setFont(font);
1f1acbe5f243 Artifacts: Make TextStyle Make more robust.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
46 }
1f1acbe5f243 Artifacts: Make TextStyle Make more robust.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
47 if (showBg) {
3464
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
48 ta.setBackgroundPaint(bgColor);
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
49 }
6911
1f1acbe5f243 Artifacts: Make TextStyle Make more robust.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
50 if (isVertical) {
3464
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
51 ta.setRotationAngle(270f*Math.PI/180f);
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
52 }
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
53 else {
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
54 ta.setRotationAngle(0);
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
55 }
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
56 }
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
57
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
58 public void apply(StableXYDifferenceRenderer renderer) {
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
59 renderer.setLabelColor(textColor);
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
60 renderer.setLabelFont(font);
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
61 if (this.showBg) {
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
62 renderer.setLabelBGColor(bgColor);
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
63 }
0b9b2a0c4e64 Point labels can have a background color now.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
64 }
6911
1f1acbe5f243 Artifacts: Make TextStyle Make more robust.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
65 }

http://dive4elements.wald.intevation.org