|
17 | 17 | package com.esri.samples.add_graphics_with_renderer; |
18 | 18 |
|
19 | 19 | import com.esri.arcgisruntime.ArcGISRuntimeEnvironment; |
| 20 | +import com.esri.arcgisruntime.geometry.AngularUnit; |
| 21 | +import com.esri.arcgisruntime.geometry.AngularUnitId; |
20 | 22 | import com.esri.arcgisruntime.geometry.CubicBezierSegment; |
21 | 23 | import com.esri.arcgisruntime.geometry.EllipticArcSegment; |
| 24 | +import com.esri.arcgisruntime.geometry.GeodesicEllipseParameters; |
22 | 25 | import com.esri.arcgisruntime.geometry.Geometry; |
| 26 | +import com.esri.arcgisruntime.geometry.GeometryEngine; |
| 27 | +import com.esri.arcgisruntime.geometry.GeometryType; |
| 28 | +import com.esri.arcgisruntime.geometry.LinearUnit; |
| 29 | +import com.esri.arcgisruntime.geometry.LinearUnitId; |
23 | 30 | import com.esri.arcgisruntime.geometry.Part; |
24 | 31 | import com.esri.arcgisruntime.geometry.Point; |
| 32 | +import com.esri.arcgisruntime.geometry.Polygon; |
25 | 33 | import com.esri.arcgisruntime.geometry.PolygonBuilder; |
26 | 34 | import com.esri.arcgisruntime.geometry.PolylineBuilder; |
27 | 35 | import com.esri.arcgisruntime.geometry.SpatialReference; |
@@ -136,6 +144,15 @@ public void start(Stage stage) { |
136 | 144 | curvedGraphicOverlay.getGraphics().add(heartGraphic); |
137 | 145 | mapView.getGraphicsOverlays().add(curvedGraphicOverlay); |
138 | 146 |
|
| 147 | + // purple ellipse polygon graphic |
| 148 | + GraphicsOverlay ellipseGraphicOverlay = new GraphicsOverlay(); |
| 149 | + SimpleFillSymbol ellipseSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, ColorUtil.colorToArgb(Color.PURPLE), null); |
| 150 | + SimpleRenderer ellipseRenderer = new SimpleRenderer(ellipseSymbol); |
| 151 | + ellipseGraphicOverlay.setRenderer(ellipseRenderer); |
| 152 | + Graphic ellipseGraphic = new Graphic(makeEllipse()); |
| 153 | + ellipseGraphicOverlay.getGraphics().add(ellipseGraphic); |
| 154 | + mapView.getGraphicsOverlays().add(ellipseGraphicOverlay); |
| 155 | + |
139 | 156 | // add the map view to stack pane |
140 | 157 | stackPane.getChildren().add(mapView); |
141 | 158 |
|
@@ -194,6 +211,29 @@ private Geometry makeHeartGeometry(Point centerOfHeart) { |
194 | 211 | return heartShape.toGeometry(); |
195 | 212 | } |
196 | 213 |
|
| 214 | + /** |
| 215 | + * Create an ellipse shaped polygon. |
| 216 | + * |
| 217 | + * @return ellipse shaped polygon |
| 218 | + */ |
| 219 | + private Polygon makeEllipse() { |
| 220 | + // create and set all the parameters so that the ellipse has a major axis of 400 kilometres, |
| 221 | + // a minor axis of 200 kilometres and is rotated at an angle of -45 degrees. |
| 222 | + GeodesicEllipseParameters parameters = new GeodesicEllipseParameters(); |
| 223 | + |
| 224 | + parameters.setCenter(new Point(40e5,25e5, SpatialReferences.getWebMercator())); |
| 225 | + parameters.setGeometryType(GeometryType.POLYGON); |
| 226 | + parameters.setSemiAxis1Length(200); |
| 227 | + parameters.setSemiAxis2Length(400); |
| 228 | + parameters.setAxisDirection(-45); |
| 229 | + parameters.setMaxPointCount(100); |
| 230 | + parameters.setAngularUnit(new AngularUnit(AngularUnitId.DEGREES)); |
| 231 | + parameters.setLinearUnit(new LinearUnit(LinearUnitId.KILOMETERS)); |
| 232 | + parameters.setMaxSegmentLength(20); |
| 233 | + |
| 234 | + return (Polygon) GeometryEngine.ellipseGeodesic(parameters); |
| 235 | + } |
| 236 | + |
197 | 237 | /** |
198 | 238 | * Stops and releases all resources used in application. |
199 | 239 | */ |
|
0 commit comments