2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
;
9 import gov
.nasa
.worldwind
.geom
.*;
11 import javax
.media
.opengl
.*;
14 import java
.util
.List
;
18 * @version $Id: SectorGeometryList.java 1994 2007-06-11 16:33:33Z dcollins $
20 public class SectorGeometryList
extends ArrayList
<SectorGeometry
>
22 private PickSupport pickSupport
= new PickSupport();
24 public SectorGeometryList()
28 public SectorGeometryList(SectorGeometryList list
)
33 public List
<SectorGeometry
> getIntersectingSectors(Sector sector
)
35 ArrayList
<SectorGeometry
> list
= null;
37 for (SectorGeometry sg
: this)
39 if (sg
.getSector().intersects(sector
))
42 list
= new ArrayList
<SectorGeometry
>();
47 // System.out.println("no intersection");
54 public void pick(DrawContext dc
, java
.awt
.Point pickPoint
)
56 this.pickSupport
.clearPickList();
57 this.pickSupport
.beginPicking(dc
);
60 gl
.glPushAttrib(GL
.GL_LIGHTING_BIT
| GL
.GL_DEPTH_BUFFER_BIT
| GL
.GL_ENABLE_BIT
| GL
.GL_CURRENT_BIT
);
61 gl
.glEnable(GL
.GL_DEPTH_TEST
);
62 gl
.glShadeModel(GL
.GL_FLAT
);
63 gl
.glDisable(GL
.GL_CULL_FACE
);
67 // render each sector in unique color
68 for (SectorGeometry sector
: this)
70 Color color
= dc
.getUniquePickColor();
71 dc
.getGL().glColor3ub((byte) color
.getRed(), (byte) color
.getGreen(), (byte) color
.getBlue());
73 // lat/lon/elevation not used in this case
74 this.pickSupport
.addPickableObject(color
.getRGB(), sector
, Position
.ZERO
, true);
77 PickedObject pickedSector
= this.pickSupport
.getTopObject(dc
, pickPoint
, null);
78 if (pickedSector
== null || pickedSector
.getObject() == null)
79 return; // no sector picked
81 SectorGeometry sector
= (SectorGeometry
) pickedSector
.getObject();
82 gl
.glDepthFunc(GL
.GL_LEQUAL
);
83 sector
.pick(dc
, pickPoint
);
88 this.pickSupport
.endPicking(dc
);
89 this.pickSupport
.clearPickList();
93 public Vec4
getSurfacePoint(Position position
)
95 return this.getSurfacePoint(position
.getLatitude(), position
.getLongitude(), position
.getElevation());
98 public Vec4
getSurfacePoint(Angle latitude
, Angle longitude
)
100 return this.getSurfacePoint(latitude
, longitude
, 0d
);
103 public Vec4
getSurfacePoint(Angle latitude
, Angle longitude
, double metersOffset
)
105 if (latitude
== null || longitude
== null)
107 String msg
= WorldWind
.retrieveErrMsg("nullValue.LatLonIsNull");
108 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
109 throw new IllegalArgumentException(msg
);
112 for (SectorGeometry sg
: this)
114 if (sg
.getSector().contains(latitude
, longitude
))
116 Vec4 point
= sg
.getSurfacePoint(latitude
, longitude
, metersOffset
);