<commit_before>/* Copyright 2015 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.esri.arcgisruntime.sample.addgraphicssymbols;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.PointCollection;
import com.esri.arcgisruntime.geometry.Polygon;
import com.esri.arcgisruntime.geometry.Polyline;
import com.esri.arcgisruntime.geometry.SpatialReference;
import com.esri.arcgisruntime.mapping.BasemapType;
import com.esri.arcgisruntime.mapping.Map;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.RgbColor;
import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import com.esri.arcgisruntime.symbology.TextSymbol;

public class MainActivity extends AppCompatActivity {

    private MapView mMapView;
    private final SpatialReference wgs84 = SpatialReference.create(4326);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // inflate MapView from layout
        mMapView = (MapView) findViewById(R.id.mapView);

        // create a map with the BasemapType topographic
        Map map = new Map(BasemapType.OCEANS, 56.075844, -2.681572, 11);
        // set the map to be displayed in this view
        mMapView.setMap(map);
        // add graphics overlay to MapView.
        GraphicsOverlay graphicsOverlay = addGraphicsOverlay(mMapView);
        //add some buoy positions to the graphics overlay
        addBuoyPoints(graphicsOverlay);
        //add boat trip polyline to graphics overlay
        addBoatTrip(graphicsOverlay);
        //add nesting ground polygon to graphics overlay
        addNestingGround(graphicsOverlay);
        //add text symbols and points to graphics overlay
        addText(graphicsOverlay);

    }

    @Override
    protected void onPause(){
        super.onPause();
        mMapView.pause();
    }

    @Override
    protected void onResume(){
        super.onResume();
        mMapView.resume();
    }

    private GraphicsOverlay addGraphicsOverlay(MapView mapView) {
        //create the graphics overlay
        GraphicsOverlay graphicsOverlay = new GraphicsOverlay();

        //add the overlay to the map view
        mapView.getGraphicsOverlays().add(graphicsOverlay);

        return graphicsOverlay;
    }

    private void addBuoyPoints(GraphicsOverlay graphicOverlay) {
        //define the buoy locations
        Point buoy1Loc = new Point(-2.712642647560347, 56.062812566811544, wgs84);
        Point buoy2Loc = new Point(-2.6908416959572303, 56.06444173689877, wgs84);
        Point buoy3Loc = new Point(-2.6697273884990937, 56.064250073402874, wgs84);
        Point buoy4Loc = new Point(-2.6395150461199726, 56.06127916736989, wgs84);

        //create a marker symbol
        SimpleMarkerSymbol buoyMarker = new SimpleMarkerSymbol(new RgbColor(255, 0, 0, 255), 10, SimpleMarkerSymbol.Style.CIRCLE);

        //create graphics
        Graphic buoyGraphic1 = new Graphic(buoy1Loc, buoyMarker);
        Graphic buoyGraphic2 = new Graphic(buoy2Loc, buoyMarker);
        Graphic buoyGraphic3 = new Graphic(buoy3Loc, buoyMarker);
        Graphic buoyGraphic4 = new Graphic(buoy4Loc, buoyMarker);

        //add the graphics to the graphics overlay
        graphicOverlay.getGraphics().add(buoyGraphic1);
        graphicOverlay.getGraphics().add(buoyGraphic2);
        graphicOverlay.getGraphics().add(buoyGraphic3);
        graphicOverlay.getGraphics().add(buoyGraphic4);

    }

    private void addText(GraphicsOverlay graphicOverlay) {
        //create a point geometry
        Point bassLocation = new Point(-2.640631, 56.078083,wgs84);
        Point craigleithLocation = new Point (-2.720324, 56.073569,wgs84);

        //create text symbols
        TextSymbol bassRockSymbol =
                new TextSymbol(
                        10, "B<NAME>", new RgbColor(0, 0, 230, 255),
                        TextSymbol.HorizontalAlignment.LEFT, TextSymbol.VerticalAlignment.BOTTOM);
        TextSymbol craigleithSymbol =
                new TextSymbol(
                        10, "Craigleith", new RgbColor(0, 0, 230, 255),
                        TextSymbol.HorizontalAlignment.RIGHT, TextSymbol.VerticalAlignment.TOP);

        //define a graphic from the geometry and symbol
        Graphic bassRockGraphic = new Graphic(bassLocation, bassRockSymbol);
        Graphic craigleithGraphic = new Graphic(craigleithLocation, craigleithSymbol);

        //add the text to the graphics overlay
        graphicOverlay.getGraphics().add(bassRockGraphic);
        graphicOverlay.getGraphics().add(craigleithGraphic);
    }

    private void addBoatTrip(GraphicsOverlay graphicOverlay) {
        //define a polyline for the boat trip
        Polyline boatRoute = getBoatTripGeometry();

        //define a line symbol
        SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.DASH, new RgbColor(128, 0, 128, 255), 4, 1.0f);

        //create the graphic
        Graphic boatTripGraphic = new Graphic(boatRoute, lineSymbol);

        //add to the graphic overlay
        graphicOverlay.getGraphics().add(boatTripGraphic);

    }

    private void addNestingGround(GraphicsOverlay graphicOverlay) {

        //define the polygon for the nesting ground
        Polygon nestingGround = getNestingGroundGeometry();

        //define the fill symbol and outline
        SimpleLineSymbol outlineSymbol =
                new SimpleLineSymbol(
                        SimpleLineSymbol.Style.DASH,
                        new RgbColor(0, 0, 128, 255), 1, 1.0f);
        SimpleFillSymbol fillSymbol =
                new SimpleFillSymbol(
                        new RgbColor(0, 80, 0, 255),
                        SimpleFillSymbol.Style.DIAGONAL_CROSS,
                        outlineSymbol, 1.0f);

        //define graphic
        Graphic nestingGraphic = new Graphic(nestingGround,fillSymbol);<commit_msg>refactored BasemapType to Basemap.Type & symbol ctor<commit_after>/* Copyright 2015 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.esri.arcgisruntime.sample.addgraphicssymbols;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.PointCollection;
import com.esri.arcgisruntime.geometry.Polygon;
import com.esri.arcgisruntime.geometry.Polyline;
import com.esri.arcgisruntime.geometry.SpatialReference;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.Map;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.RgbColor;
import com.esri.arcgisruntime.symbology.SimpleFillSymbol;
import com.esri.arcgisruntime.symbology.SimpleLineSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import com.esri.arcgisruntime.symbology.TextSymbol;

public class MainActivity extends AppCompatActivity {

    private MapView mMapView;
    private final SpatialReference wgs84 = SpatialReference.create(4326);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // inflate MapView from layout
        mMapView = (MapView) findViewById(R.id.mapView);

        // create a map with the BasemapType topographic
        Map map = new Map(Basemap.Type.OCEANS, 56.075844, -2.681572, 11);
        // set the map to be displayed in this view
        mMapView.setMap(map);
        // add graphics overlay to MapView.
        GraphicsOverlay graphicsOverlay = addGraphicsOverlay(mMapView);
        //add some buoy positions to the graphics overlay
        addBuoyPoints(graphicsOverlay);
        //add boat trip polyline to graphics overlay
        addBoatTrip(graphicsOverlay);
        //add nesting ground polygon to graphics overlay
        addNestingGround(graphicsOverlay);
        //add text symbols and points to graphics overlay
        addText(graphicsOverlay);

    }

    @Override
    protected void onPause(){
        super.onPause();
        mMapView.pause();
    }

    @Override
    protected void onResume(){
        super.onResume();
        mMapView.resume();
    }

    private GraphicsOverlay addGraphicsOverlay(MapView mapView) {
        //create the graphics overlay
        GraphicsOverlay graphicsOverlay = new GraphicsOverlay();

        //add the overlay to the map view
        mapView.getGraphicsOverlays().add(graphicsOverlay);

        return graphicsOverlay;
    }

    private void addBuoyPoints(GraphicsOverlay graphicOverlay) {
        //define the buoy locations
        Point buoy1Loc = new Point(-2.712642647560347, 56.062812566811544, wgs84);
        Point buoy2Loc = new Point(-2.6908416959572303, 56.06444173689877, wgs84);
        Point buoy3Loc = new Point(-2.6697273884990937, 56.064250073402874, wgs84);
        Point buoy4Loc = new Point(-2.6395150461199726, 56.06127916736989, wgs84);

        //create a marker symbol
        SimpleMarkerSymbol buoyMarker = new SimpleMarkerSymbol(new RgbColor(255, 0, 0, 255), 10, SimpleMarkerSymbol.Style.CIRCLE);

        //create graphics
        Graphic buoyGraphic1 = new Graphic(buoy1Loc, buoyMarker);
        Graphic buoyGraphic2 = new Graphic(buoy2Loc, buoyMarker);
        Graphic buoyGraphic3 = new Graphic(buoy3Loc, buoyMarker);
        Graphic buoyGraphic4 = new Graphic(buoy4Loc, buoyMarker);

        //add the graphics to the graphics overlay
        graphicOverlay.getGraphics().add(buoyGraphic1);
        graphicOverlay.getGraphics().add(buoyGraphic2);
        graphicOverlay.getGraphics().add(buoyGraphic3);
        graphicOverlay.getGraphics().add(buoyGraphic4);

    }

    private void addText(GraphicsOverlay graphicOverlay) {
        //create a point geometry
        Point bassLocation = new Point(-2.640631, 56.078083,wgs84);
        Point craigleithLocation = new Point (-2.720324, 56.073569,wgs84);

        //create text symbols
        TextSymbol bassRockSymbol =
                new TextSymbol(
                        10, "Bass Rock", new RgbColor(0, 0, 230, 255),
                        TextSymbol.HorizontalAlignment.LEFT, TextSymbol.VerticalAlignment.BOTTOM);
        TextSymbol craigleithSymbol =
                new TextSymbol(
                        10, "Craigleith", new RgbColor(0, 0, 230, 255),
                        TextSymbol.HorizontalAlignment.RIGHT, TextSymbol.VerticalAlignment.TOP);

        //define a graphic from the geometry and symbol
        Graphic bassRockGraphic = new Graphic(bassLocation, bassRockSymbol);
        Graphic craigleithGraphic = new Graphic(craigleithLocation, craigleithSymbol);

        //add the text to the graphics overlay
        graphicOverlay.getGraphics().add(bassRockGraphic);
        graphicOverlay.getGraphics().add(craigleithGraphic);
    }

    private void addBoatTrip(GraphicsOverlay graphicOverlay) {
        //define a polyline for the boat trip
        Polyline boatRoute = getBoatTripGeometry();

        //define a line symbol
        SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.DASH, new RgbColor(128, 0, 128, 255), 4);

        //create the graphic
        Graphic boatTripGraphic = new Graphic(boatRoute, lineSymbol);

        //add to the graphic overlay
        graphicOverlay.getGraphics().add(boatTripGraphic);

    }

    private void addNestingGround(GraphicsOverlay graphicOverlay) {

        //define the polygon for the nesting ground
        Polygon nestingGround = getNestingGroundGeometry();

        //define the fill symbol and outline
        SimpleLineSymbol outlineSymbol =
                new SimpleLineSymbol(
                        SimpleLineSymbol.Style.DASH,
                        new RgbColor(0, 0, 128, 255), 1);
        SimpleFillSymbol fillSymbol =
                new SimpleFillSymbol(
                        new RgbColor(0, 80, 0, 255),
                        SimpleFillSymbol.Style.DIAGONAL_CROSS,
                        outlineSymbol);

        //define graphic
        Graphic nestingGraphic = new Graphic(nestingGround,fillSymbol);
{'fraction_non_alphanumeric': 0.080713866039953, 'fraction_numerical': 0.041568742655699174, 'mean_word_length': 2.924207492795389, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2684312', 'n_tokens_mistral': 4279, 'n_tokens_neox': 3823, 'n_words': 986}