@@ -24,58 +24,47 @@ public static class AppFrame extends ApplicationTemplate.AppFrame
24
24
{
25
25
public AppFrame ()
26
26
{
27
- // Create an object to generate random attributes.
28
- final RandomShapeAttributes randomAttrs = new RandomShapeAttributes ();
27
+ ShapefileLayerFactory factory = new ShapefileLayerFactory ();
29
28
30
- // Spawn a thread to load the shapefile.
31
- Thread t = new Thread (new Runnable ()
29
+ // Specify an attribute delegate to assign random attributes to each shapefile record.
30
+ final RandomShapeAttributes randomAttrs = new RandomShapeAttributes ();
31
+ factory .setAttributeDelegate (new ShapefileRenderable .AttributeDelegate ()
32
32
{
33
33
@ Override
34
- public void run ()
34
+ public void assignAttributes (ShapefileRecord shapefileRecord ,
35
+ ShapefileRenderable .Record renderableRecord )
35
36
{
36
- ShapefileLayerFactory factory = new ShapefileLayerFactory ();
37
+ renderableRecord .setAttributes (randomAttrs .nextAttributes ().asShapeAttributes ());
38
+ }
39
+ });
37
40
38
- // Specify an attribute delegate to assign attributes for each shapefile record.
39
- factory .setAttributeDelegate (new ShapefileRenderable .AttributeDelegate ()
41
+ // Load the shapefile. Define the completion callback.
42
+ factory .createFromShapefileSource ("testData/shapefiles/TM_WORLD_BORDERS-0.3.shp" ,
43
+ new ShapefileLayerFactory .CompletionCallback ()
44
+ {
45
+ @ Override
46
+ public void completion (Object result )
40
47
{
41
- @ Override
42
- public void assignAttributes (ShapefileRecord shapefileRecord ,
43
- ShapefileRenderable .Record renderableRecord )
44
- {
45
- renderableRecord .setAttributes (randomAttrs .nextAttributes ().asShapeAttributes ());
46
- }
47
- });
48
+ final Layer layer = (Layer ) result ; // the result is the layer the factory created
49
+ layer .setName (WWIO .getFilename (layer .getName ()));
48
50
49
- // Load the shapefile. Define the completion callback.
50
- factory .createFromShapefileSource ("testData/shapefiles/TM_WORLD_BORDERS-0.3.shp" ,
51
- new ShapefileLayerFactory .CompletionCallback ()
51
+ // Add the layer to the World Window's layer list on the Event Dispatch Thread.
52
+ SwingUtilities .invokeLater (new Runnable ()
52
53
{
53
54
@ Override
54
- public void completion ( Object result )
55
+ public void run ( )
55
56
{
56
- final Layer layer = (Layer ) result ; // the result is the layer the factory created
57
- layer .setName (WWIO .getFilename (layer .getName ()));
58
-
59
- // Add the layer to the World Window's layer list on the Event Dispatch Thread.
60
- SwingUtilities .invokeLater (new Runnable ()
61
- {
62
- @ Override
63
- public void run ()
64
- {
65
- AppFrame .this .getWwd ().getModel ().getLayers ().add (layer );
66
- }
67
- });
68
- }
69
-
70
- @ Override
71
- public void exception (Exception e )
72
- {
73
- Logging .logger ().log (java .util .logging .Level .SEVERE , e .getMessage (), e );
57
+ AppFrame .this .getWwd ().getModel ().getLayers ().add (layer );
74
58
}
75
59
});
76
- }
77
- });
78
- t .start ();
60
+ }
61
+
62
+ @ Override
63
+ public void exception (Exception e )
64
+ {
65
+ Logging .logger ().log (java .util .logging .Level .SEVERE , e .getMessage (), e );
66
+ }
67
+ });
79
68
}
80
69
}
81
70
0 commit comments