Skip to content

Commit c3a94db

Browse files
committed
SurfaceTextTest functional tests.
Added a new class called SurfaceTextTest that contains the functional tests for the SurfaceText class. This class can be run to visually inspect whether the SurfaceText rotations and offsets are correctly calculated as well as whether the text is contained within the bounding-sector.
1 parent ea5af36 commit c3a94db

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (C) 2012 United States Government as represented by the Administrator of the
3+
* National Aeronautics and Space Administration.
4+
* All Rights Reserved.
5+
*/
6+
7+
package gov.nasa.worldwind.render;
8+
9+
import gov.nasa.worldwind.Configuration;
10+
import gov.nasa.worldwind.WorldWind;
11+
import gov.nasa.worldwind.avlist.AVKey;
12+
import gov.nasa.worldwind.geom.Angle;
13+
import gov.nasa.worldwind.geom.Position;
14+
import gov.nasa.worldwind.layers.RenderableLayer;
15+
import gov.nasa.worldwindx.examples.ApplicationTemplate;
16+
17+
/**
18+
* Test of {@link SurfaceText} rotation and offset calculations. This test creates
19+
* several SurfaceText objects with different rotation and offset configurations.
20+
* The SurfaceText objects can be visually inspected to confirm that the rotations
21+
* and placements are correctly calculated, and that all of them are located
22+
* within their respective bounding-sectors.
23+
*
24+
* @author pabercrombie
25+
* @version $Id: SurfaceTextTest.java 1171 2013-02-11 21:45:02Z dcollins $
26+
*/
27+
public class SurfaceTextTest extends ApplicationTemplate
28+
{
29+
private static Position center = Position.fromDegrees(38.9345, -120.1670, 50000);
30+
31+
public static class AppFrame extends ApplicationTemplate.AppFrame
32+
{
33+
public AppFrame()
34+
{
35+
super(true, true, false);
36+
37+
RenderableLayer layer = new RenderableLayer();
38+
39+
PointPlacemarkAttributes attributes = new PointPlacemarkAttributes();
40+
attributes.setLabelColor("ffffffff");
41+
attributes.setLineColor("ff0000ff");
42+
attributes.setUsePointAsDefaultImage(true);
43+
attributes.setScale(5d);
44+
45+
int j = 0;
46+
for (double x = -1.0; x <= 0.0; x += 0.5, j++)
47+
{
48+
for (double y = -1.0; y <= 0.0; y += 0.5, j++)
49+
{
50+
for (int i = 0; i <= 12; i++)
51+
{
52+
double latitude = center.latitude.degrees + ((j - 4) / 5.0);
53+
double longitude = center.longitude.degrees + ((i - 6) / 5.0);
54+
Position position = Position.fromDegrees(latitude, longitude, 0);
55+
56+
SurfaceText surfaceText = new SurfaceText("Test Label Description", position);
57+
surfaceText.setDrawBoundingSectors(true);
58+
surfaceText.setHeading(Angle.fromDegrees(i * 30));
59+
surfaceText.setOffset(Offset.fromFraction(x, y));
60+
layer.addRenderable(surfaceText);
61+
62+
PointPlacemark placemark = new PointPlacemark(position);
63+
placemark.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
64+
placemark.setAttributes(attributes);
65+
layer.addRenderable(placemark);
66+
}
67+
}
68+
}
69+
70+
this.getWwd().getModel().getLayers().add(layer);
71+
}
72+
}
73+
74+
public static void main(String[] args)
75+
{
76+
Configuration.setValue(AVKey.INITIAL_LATITUDE, center.latitude.degrees);
77+
Configuration.setValue(AVKey.INITIAL_LONGITUDE, center.longitude.degrees);
78+
Configuration.setValue(AVKey.INITIAL_ALTITUDE, center.elevation);
79+
80+
ApplicationTemplate.start("WorldWind Surface Text", AppFrame.class);
81+
}
82+
}

0 commit comments

Comments
 (0)