/** * Constructor. * * @param mapView the mapview reference. * @param doCut if <code>true</code>, do cut as opposed to extend. */ public CutExtendTool(MapView mapView, boolean doCut) { super(mapView); this.doCut = doCut; editingViewProjection = new SliderDrawProjection(mapView, EditManager.INSTANCE.getEditingView()); point = new Point(); positionBeforeDraw = new Point(); // Context context = GeopaparazziApplication.getInstance().getApplicationContext(); // SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); drawingPaintFill.setAntiAlias(true); drawingPaintFill.setColor(Color.RED); // drawingPaintFill.setAlpha(80); drawingPaintFill.setStyle(Paint.Style.FILL); drawingPaintStroke.setAntiAlias(true); drawingPaintStroke.setStrokeWidth(5f); drawingPaintStroke.setColor(Color.RED); drawingPaintStroke.setStyle(Paint.Style.STROKE); int previewStroke = ColorUtilities.getColor(ColorUtilities.preview_stroke); int previewFill = ColorUtilities.getColor(ColorUtilities.preview_fill); selectedPreviewGeometryPaintFill.setAntiAlias(true); selectedPreviewGeometryPaintFill.setColor(previewFill); selectedPreviewGeometryPaintFill.setAlpha(180); selectedPreviewGeometryPaintFill.setStyle(Paint.Style.FILL); selectedPreviewGeometryPaintStroke.setAntiAlias(true); selectedPreviewGeometryPaintStroke.setStrokeWidth(5f); selectedPreviewGeometryPaintStroke.setColor(previewStroke); selectedPreviewGeometryPaintStroke.setStyle(Paint.Style.STROKE); }
@Override public void onViewChanged() { EditingView editingView = EditManager.INSTANCE.getEditingView(); try { readData(editingView); } catch (IOException e) { GPLog.error(this, null, e); } }
/** * Constructor. * * @param mapView the mapview reference. */ public SelectionTool(MapView mapView) { super(mapView); editingViewProjection = new SliderDrawProjection(mapView, EditManager.INSTANCE.getEditingView()); int stroke = ColorUtilities.toColor(ToolColors.selection_stroke.getHex()); int fill = ColorUtilities.toColor(ToolColors.selection_fill.getHex()); selectRectPaintFill.setAntiAlias(true); selectRectPaintFill.setColor(fill); selectRectPaintFill.setAlpha(80); selectRectPaintFill.setStyle(Paint.Style.FILL); selectRectPaintStroke.setAntiAlias(true); selectRectPaintStroke.setStrokeWidth(1.5f); selectRectPaintStroke.setColor(stroke); selectRectPaintStroke.setStyle(Paint.Style.STROKE); }
/** * Constructor. * * @param mapView the mapview reference. */ public GpsLogInfoTool(MapView mapView) throws IOException { super(mapView); Context context = GeopaparazziApplication.getInstance().getApplicationContext(); pixel = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 16, context.getResources().getDisplayMetrics()); timeString = context.getString(R.string.utctime); lonString = context.getString(R.string.lon); latString = context.getString(R.string.lat); altimString = context.getString(R.string.altim); EditingView editingView = EditManager.INSTANCE.getEditingView(); projection = new SliderDrawProjection(mapView, editingView); readData(editingView); whiteBoxPaint.setAntiAlias(false); whiteBoxPaint.setColor(Color.argb(160, 255, 255, 255)); whiteBoxPaint.setStyle(Paint.Style.FILL); }
private void select(final double n, final double w, final double s, final double e) { ILayer editLayer = EditManager.INSTANCE.getEditLayer(); SpatialVectorTableLayer layer = (SpatialVectorTableLayer) editLayer; final SpatialVectorTable spatialVectorTable = layer.getSpatialVectorTable(); final Context context = EditManager.INSTANCE.getEditingView().getContext(); infoProgressDialog = new ProgressDialog(context); infoProgressDialog.setCancelable(true); infoProgressDialog.setTitle("SELECT"); infoProgressDialog.setMessage("Selecting features..."); infoProgressDialog.setCancelable(false); infoProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); infoProgressDialog.setIndeterminate(true); infoProgressDialog.show(); // TODO fix this asynctask new AsyncTask<String, Integer, String>() { private List<Feature> features = new ArrayList<>(); protected String doInBackground(String... params) { try { features.clear(); double north = n; double south = s; if (n - s == 0) { south = n - 1; } double west = w; double east = e; if (e - w == 0) { west = e - 1; } String query = SpatialiteUtilities.getBboxIntersectingFeaturesQuery( LibraryConstants.SRID_WGS84_4326, spatialVectorTable, north, south, east, west); features = FeatureUtilities.buildFeatures(query, spatialVectorTable); return ""; } catch (Exception e) { GPLog.error(this, null, e); // $NON-NLS-1$ return "ERROR: " + e.getLocalizedMessage(); } } protected void onProgressUpdate(Integer... progress) { // on UI thread! if (infoProgressDialog != null && infoProgressDialog.isShowing()) infoProgressDialog.incrementProgressBy(progress[0]); } protected void onPostExecute(String response) { // on UI thread! GPDialogs.dismissProgressDialog(infoProgressDialog); if (response.startsWith("ERROR")) { GPDialogs.warningDialog(context, response, null); } else if (response.startsWith("CANCEL")) { return; } else { if (features.size() > 0) { try { int geomsCount = 0; for (Feature feature : features) { Geometry geometry = FeatureUtilities.getGeometry(feature); if (geometry != null) geomsCount = geomsCount + geometry.getNumGeometries(); } if (spatialVectorTable.isPolygon()) { GPDialogs.toast( context, String.format( context.getString(R.string.selected_features_in_layer), features.size(), geomsCount), Toast.LENGTH_SHORT); PolygonOnSelectionToolGroup selectionGroup = new PolygonOnSelectionToolGroup(mapView, features); EditManager.INSTANCE.setActiveToolGroup(selectionGroup); } else if (spatialVectorTable.isLine()) { GPDialogs.toast( context, String.format( context.getString(R.string.selected_line_features_in_layer), features.size(), geomsCount), Toast.LENGTH_SHORT); LineOnSelectionToolGroup selectionGroup = new LineOnSelectionToolGroup(mapView, features); EditManager.INSTANCE.setActiveToolGroup(selectionGroup); } } catch (java.lang.Exception e) { GPLog.error(this, null, e); // $NON-NLS-1$ } } else { rect.setEmpty(); EditManager.INSTANCE.invalidateEditingView(); } } } }.execute((String) null); }
private void select( final double n, final double w, final double s, final double e, // final com.vividsolutions.jts.geom.Point startPoint, final com.vividsolutions.jts.geom.Point endPoint) { ILayer editLayer = EditManager.INSTANCE.getEditLayer(); SpatialVectorTableLayer layer = (SpatialVectorTableLayer) editLayer; final SpatialVectorTable spatialVectorTable = layer.getSpatialVectorTable(); final Context context = EditManager.INSTANCE.getEditingView().getContext(); final ProgressDialog infoProgressDialog = new ProgressDialog(context); infoProgressDialog.setCancelable(true); infoProgressDialog.setTitle("SELECT"); infoProgressDialog.setMessage("Selecting features..."); infoProgressDialog.setCancelable(false); infoProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); infoProgressDialog.setIndeterminate(true); infoProgressDialog.show(); new AsyncTask<String, Integer, String>() { protected String doInBackground(String... params) { try { double north = n; double south = s; if (n - s == 0) { south = n - 1; } double west = w; double east = e; if (e - w == 0) { west = e - 1; } String query = SpatialiteUtilities.getBboxIntersectingFeaturesQuery( LibraryConstants.SRID_WGS84_4326, spatialVectorTable, north, south, east, west); List<Feature> features = FeatureUtilities.buildFeatures(query, spatialVectorTable); Geometry startGeometry = null; Geometry endGeometry = null; for (Feature feature : features) { if (startGeometry != null && endGeometry != null) break; Geometry geometry = FeatureUtilities.getGeometry(feature); if (startGeometry == null && geometry.intersects(startPoint)) { startGeometry = geometry; startFeature = feature; } else if (endGeometry == null && geometry.intersects(endPoint)) { endGeometry = geometry; endFeature = feature; } } if (!doCut) { previewGeometry = startGeometry.union(endGeometry); } else { previewGeometry = startGeometry.difference(endGeometry); } return ""; } catch (Exception e) { GPLog.error(this, null, e); // $NON-NLS-1$ return "ERROR: " + e.getLocalizedMessage(); } } protected void onProgressUpdate(Integer... progress) { // on UI thread! if (infoProgressDialog != null && infoProgressDialog.isShowing()) infoProgressDialog.incrementProgressBy(progress[0]); } protected void onPostExecute(String response) { // on UI thread! Utilities.dismissProgressDialog(infoProgressDialog); if (response.startsWith("ERROR")) { Utilities.messageDialog(context, response, null); } else { Utilities.toast( context, context.getString(R.string.preview_mode_save_warning), Toast.LENGTH_SHORT); EditManager.INSTANCE.invalidateEditingView(); ToolGroup activeToolGroup = EditManager.INSTANCE.getActiveToolGroup(); if (activeToolGroup != null) { activeToolGroup.onToolFinished(CutExtendTool.this); } } } }.execute((String) null); }