Skip to content

Commit d68c721

Browse files
committed
Add strikethrough label option
1 parent 191cb4e commit d68c721

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed
29.9 KB
Loading

doc/releases.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ Store tiles in any JDBC database (like H2, Postgres, or SQLite) in the familiar
7676

7777
.. image:: images/h2_1.png
7878

79+
The Label Symbolizer now has a strikethrough property::
80+
81+
def statesShp = new Shapefile("states.shp")
82+
statesShp.style = (new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5)) +
83+
(new Shape("#66CCff", 6, "circle").stroke("#004080") + new Transform("centroid(the_geom)")).zindex(1) +
84+
(new Label("STATE_NAME").strikethrough(true).font(new Font("normal", "bold", 10, "serif")).fill(new Fill("#004080")))
85+
86+
def map = new Map(
87+
width: 600,
88+
height: 400,
89+
bounds: new Bounds(-114.675293,37.317752,-83.078613,49.210420,"EPSG:4326"),
90+
fixAspectRatio: true
91+
)
92+
map.proj = "EPSG:4326"
93+
map.addLayer(statesShp)
94+
map.render(new File("states_label_strikethrough.png"))
95+
96+
.. image:: images/states_label_strikethrough.png
97+
7998
The Label Symbolizer now has wordSpacing and characterSpacing properties::
8099

81100
def statesShp = new Shapefile("states.shp")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import geoscript.layer.Shapefile
2+
import geoscript.render.Map
3+
import geoscript.style.*
4+
import geoscript.geom.Bounds
5+
6+
def statesShp = new Shapefile("states.shp")
7+
statesShp.style = (new Fill("#E6E6E6") + new Stroke("#4C4C4C",0.5)) +
8+
(new Shape("#66CCff", 6, "circle").stroke("#004080") + new Transform("centroid(the_geom)")).zindex(1) +
9+
(new Label("STATE_NAME").strikethrough(true).font(new Font("normal", "bold", 10, "serif")).fill(new Fill("#004080")))
10+
11+
def map = new Map(
12+
width: 600,
13+
height: 400,
14+
bounds: new Bounds(-114.675293,37.317752,-83.078613,49.210420,"EPSG:4326"),
15+
fixAspectRatio: true
16+
)
17+
map.proj = "EPSG:4326"
18+
map.addLayer(statesShp)
19+
map.render(new File("states_label_strikethrough.png"))

src/main/groovy/geoscript/style/Label.groovy

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,16 @@ class Label extends Symbolizer {
343343
this
344344
}
345345

346+
/**
347+
* Set whether the Label should strike through the text or not
348+
* @param shouldStrikeThrough Whether the label text should be underlined
349+
* @return This label
350+
*/
351+
Label strikethrough(boolean shouldStrikeThrough) {
352+
options.strikethroughText = String.valueOf(shouldStrikeThrough)
353+
this
354+
}
355+
346356
/**
347357
* Set the spacing between words
348358
* @param spacing The spacing

src/test/groovy/geoscript/style/LabelTestCase.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ class LabelTestCase {
111111
assertTrue label.underline(true) instanceof Label
112112
assertTrue label.options.underlineText as boolean
113113

114+
// strikethrough text
115+
assertTrue label.strikethrough(true) instanceof Label
116+
assertTrue label.options.strikethroughText as boolean
117+
114118
// Word Spacing
115119
assertTrue label.wordSpacing(5) instanceof Label
116120
assertEquals 5, label.options.wordSpacing as int

0 commit comments

Comments
 (0)