Skip to content

Commit 1129ef0

Browse files
committed
Add possibility to control Placemark label visibility via PlacemarkAttributes.
1 parent 9377485 commit 1129ef0

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

worldwind/src/main/java/gov/nasa/worldwind/shape/Placemark.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,8 +994,8 @@ protected void prepareDrawableLeader(RenderContext rc, DrawableLines drawable) {
994994
* @return True if there is a valid label and label attributes.
995995
*/
996996
protected boolean mustDrawLabel(RenderContext rc) {
997-
return this.label != null
998-
&& !this.label.isEmpty()
997+
return this.activeAttributes.drawLabel
998+
&& this.label != null && !this.label.isEmpty()
999999
&& this.activeAttributes.labelAttributes != null;
10001000
}
10011001

worldwind/src/main/java/gov/nasa/worldwind/shape/PlacemarkAttributes.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class PlacemarkAttributes {
2525

2626
protected double minimumImageScale;
2727

28+
protected boolean drawLabel;
29+
2830
protected boolean drawLeader;
2931

3032
protected boolean depthTest;
@@ -43,6 +45,7 @@ public PlacemarkAttributes() {
4345
this.imageOffset = Offset.center();
4446
this.imageScale = 1;
4547
this.minimumImageScale = 0;
48+
this.drawLabel = true;
4649
this.drawLeader = false;
4750
this.depthTest = true;
4851
this.labelAttributes = new TextAttributes();
@@ -68,6 +71,7 @@ public PlacemarkAttributes(PlacemarkAttributes attributes) {
6871
this.imageOffset = new Offset(attributes.imageOffset);
6972
this.imageScale = attributes.imageScale;
7073
this.minimumImageScale = attributes.minimumImageScale;
74+
this.drawLabel = attributes.drawLabel;
7175
this.drawLeader = attributes.drawLeader;
7276
this.depthTest = attributes.depthTest;
7377
this.labelAttributes = attributes.labelAttributes != null ? new TextAttributes(attributes.labelAttributes) : null;
@@ -85,6 +89,7 @@ public PlacemarkAttributes set(PlacemarkAttributes attributes) {
8589
this.imageOffset.set(attributes.imageOffset);
8690
this.imageScale = attributes.imageScale;
8791
this.minimumImageScale = attributes.minimumImageScale;
92+
this.drawLabel = attributes.drawLabel;
8893
this.drawLeader = attributes.drawLeader;
8994
this.depthTest = attributes.depthTest;
9095

@@ -135,6 +140,7 @@ public boolean equals(Object o) {
135140
&& this.imageOffset.equals(that.imageOffset)
136141
&& this.imageScale == that.imageScale
137142
&& this.minimumImageScale == that.minimumImageScale
143+
&& this.drawLabel == that.drawLabel
138144
&& this.drawLeader == that.drawLeader
139145
&& this.depthTest == that.depthTest
140146
&& ((this.labelAttributes == null) ? (that.labelAttributes == null) : this.labelAttributes.equals(that.labelAttributes))
@@ -152,6 +158,7 @@ public int hashCode() {
152158
result = 31 * result + (int) (temp ^ (temp >>> 32));
153159
temp = Double.doubleToLongBits(this.minimumImageScale);
154160
result = 31 * result + (int) (temp ^ (temp >>> 32));
161+
result = 31 * result + (this.drawLabel ? 1 : 0);
155162
result = 31 * result + (this.drawLeader ? 1 : 0);
156163
result = 31 * result + (this.depthTest ? 1 : 0);
157164
result = 31 * result + (this.labelAttributes != null ? this.labelAttributes.hashCode() : 0);
@@ -263,6 +270,23 @@ public PlacemarkAttributes setMinimumImageScale(double minimumImageScale) {
263270
return this;
264271
}
265272

273+
/**
274+
* Returns whether to draw a placemark's label.
275+
*/
276+
public boolean isDrawLabel() {
277+
return drawLabel;
278+
}
279+
280+
/**
281+
* Sets whether to draw a placemark's label.
282+
*
283+
* @param drawLabel The new draw label setting.
284+
*/
285+
public PlacemarkAttributes setDrawLabel(boolean drawLabel) {
286+
this.drawLabel = drawLabel;
287+
return this;
288+
}
289+
266290
/**
267291
* Returns whether to draw a line from the placemark's geographic position to the ground.
268292
*/

0 commit comments

Comments
 (0)