com.esri.core.symbol.SimpleLineSymbol Java Examples

The following examples show how to use com.esri.core.symbol.SimpleLineSymbol. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RasterAnalysisHelper.java    From arcgis-runtime-demos-android with Apache License 2.0 6 votes vote down vote up
private void setRenderer4LOS(LineOfSight los) {
  UniqueValue visible = new UniqueValue();
  visible.setValue(new Integer[]{1});
  visible.setLabel("visible");
  visible.setSymbol(new SimpleLineSymbol(Color.GREEN, 6));
  UniqueValue invisible = new UniqueValue();
  invisible.setValue(new Integer[]{0});
  invisible.setLabel("invisible");
  invisible.setSymbol(new SimpleLineSymbol(Color.RED, 6));
  UniqueValue nodata = new UniqueValue();
  nodata.setValue(new Integer[]{-1});
  nodata.setLabel("nodata");
  nodata.setSymbol(new SimpleLineSymbol(Color.YELLOW, 6));
  UniqueValueRenderer lineRenderer = new UniqueValueRenderer();
  lineRenderer.setField1("visibility");
  lineRenderer.addUniqueValue(visible);
  lineRenderer.addUniqueValue(invisible);
  lineRenderer.addUniqueValue(nodata);
  los.setSightRenderers(null, lineRenderer);
}
 
Example #2
Source File: GeoJsonApp.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
/**
 * Parse GeoJSON file and add the features to a graphics layer.
 * @param graphicsLayer layer to which the features should be added.
 */
private void addGeoJsonFeatures(GraphicsLayer graphicsLayer) {
  try {
    // create an instance of the parser
    GeoJsonParser geoJsonParser = new GeoJsonParser();
    
    // provide the symbology for the features
    CompositeSymbol symbol = new CompositeSymbol();
    symbol.add(new SimpleFillSymbol(new Color(0, 255, 0, 70)));
    symbol.add(new SimpleLineSymbol(Color.BLACK, 2));
    geoJsonParser.setSymbol(symbol).setOutSpatialReference(map.getSpatialReference());
    
    // parse geojson data
    File geoJsonFile = new File(GEOJSON_DATA_FILE);
    List<Feature> features = geoJsonParser.parseFeatures(geoJsonFile);
    
    // add parsed features to a layer
    for (Feature f : features) {
     graphicsLayer.addGraphic(new Graphic(f.getGeometry(), f.getSymbol(), f.getAttributes()));
    }
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
}
 
Example #3
Source File: MyMapApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
protected void solveRoute() {
  // ROUTING
  RoutingTask task = new RoutingTask(
      "http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World", 
      credentials);

  RoutingTaskParameters parameters = new RoutingTaskParameters();
  stops.setSpatialReference(map.getSpatialReference());
  parameters.setStops(stops);
  parameters.setOutSpatialReference(map.getSpatialReference());
  task.solveAsync(parameters, new CallbackListener<RoutingResult>() {

    @Override
    public void onError(Throwable e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(map.getParent(),
          "An error has occured. "+e.getLocalizedMessage(), "", JOptionPane.WARNING_MESSAGE);
    }

    @Override
    public void onCallback(RoutingResult result) {
      if (result != null ) {
        Route topRoute = result.getRoutes().get(0);
        Graphic routeGraphic = new Graphic(topRoute.getRoute().getGeometry(),
            new SimpleLineSymbol(Color.BLUE, 2.0f));
        stopGraphics.addGraphic(routeGraphic);
      }
    }
  });
}
 
Example #4
Source File: DemoTheatreApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
private void handleAddGraphic(MouseEvent mapEvent) {
  Point p = jMap.toMapPoint(mapEvent.getPoint().x, mapEvent.getPoint().y);
  // Tip: use the right symbol for geometry
  // SimpleMarkerSymbol s = new SimpleMarkerSymbol(Color.RED, 14, Style.CROSS);
  SimpleLineSymbol s = new SimpleLineSymbol(Color.RED, 10);
  graphicsLayer.addGraphic(new Graphic(p, s));  
}
 
Example #5
Source File: MainActivity.java    From arcgis-runtime-demos-android with Apache License 2.0 4 votes vote down vote up
@Override
        public boolean onDoubleTap(MotionEvent point) {

            // Return default behavior if we did not initialize properly.
            if (mRouteTask == null) {
                Log.d(TAG,"RouteTask uninitialized : "+"true");
                return super.onDoubleTap(point);
            }

            try {

                // Set the correct input spatial reference on the stops and the
                // desired output spatial reference on the RouteParameters object.
                SpatialReference mapRef = mMapView.getSpatialReference();
                RouteParameters params = mRouteTask.retrieveDefaultRouteTaskParameters();
                params.setOutSpatialReference(mapRef);
                mStops.setSpatialReference(mapRef);

                // Set the stops and since we want driving directions,
                // returnDirections==true
                params.setStops(mStops);
                params.setReturnDirections(true);

                // Perform the solve
                RouteResult results = mRouteTask.solve(params);

                // Grab the results; for offline routing, there will only be one
                // result returned on the output.
                Route result = results.getRoutes().get(0);

                // Remove any previous route Graphics
                if (routeHandle != -1)
                    mGraphicsLayer.removeGraphic(routeHandle);

                // Add the route shape to the graphics layer
                Geometry geom = result.getRouteGraphic().getGeometry();
                routeHandle = mGraphicsLayer.addGraphic(new Graphic(geom, new SimpleLineSymbol(0x99990055, 5)));
                mMapView.getCallout().hide();

                // Get the list of directions from the result
                List<RouteDirection> directions = result.getRoutingDirections();

                // enable spinner to receive directions
//                dSpinner.setEnabled(true);

                // Iterate through all of the individual directions items and
                // create a nicely formatted string for each.
                List<String> formattedDirections = new ArrayList<String>();
                for (int i = 0; i < directions.size(); i++) {
                    RouteDirection direction = directions.get(i);
                    formattedDirections.add(String.format("%s\nGo %.2f %s For %.2f Minutes", direction.getText(),
                            direction.getLength(), params.getDirectionsLengthUnit().name(), direction.getMinutes()));
                }

                // Add a summary String
                formattedDirections.add(0, String.format("Total time: %.2f Mintues", result.getTotalMinutes()));

                // Create a simple array adapter to visualize the directions in
                // the Spinner
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(),
                        android.R.layout.simple_spinner_item, formattedDirections);
                adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//                dSpinner.setAdapter(adapter);

                // Add a custom OnItemSelectedListener to the spinner to allow
                // panning to each directions item.
//                dSpinner.setOnItemSelectedListener(new DirectionsItemListener(directions));

            } catch (Exception e) {

                e.printStackTrace();
            }
            return true;
        }
 
Example #6
Source File: UI.java    From arcgis-runtime-demo-java with Apache License 2.0 4 votes vote down vote up
public static SimpleLineSymbol createRouteSym() {
Random random = new Random();
return new SimpleLineSymbol(
  colors[random.nextInt(colors.length)], 4, SimpleLineSymbol.Style.DASH);
}
 
Example #7
Source File: UI.java    From arcgis-runtime-demo-java with Apache License 2.0 4 votes vote down vote up
public static SimpleLineSymbol createRouteSym() {
Random random = new Random();
return new SimpleLineSymbol(
  colors[random.nextInt(colors.length)], 4, SimpleLineSymbol.Style.DASH);
}