public void onOkClick(View view) {

    String color = (String) colorSpinner.getSelectedItem();
    spatialTable.getStyle().strokecolor = color;

    String sizeString = (String) sizeSpinner.getSelectedItem();
    float size = Float.parseFloat(sizeString);
    spatialTable.getStyle().size = size;

    String widthString = (String) widthSpinner.getSelectedItem();
    float width = Float.parseFloat(widthString);
    spatialTable.getStyle().width = width;

    String alphaString = (String) alphaSpinner.getSelectedItem();
    float alpha100 = Float.parseFloat(alphaString);
    spatialTable.getStyle().strokealpha = alpha100 / 100f;

    String fillColor = (String) fillColorSpinner.getSelectedItem();
    spatialTable.getStyle().fillcolor = fillColor;

    String fillAlphaString = (String) fillAlphaSpinner.getSelectedItem();
    float fillAlpha100 = Float.parseFloat(fillAlphaString);
    spatialTable.getStyle().fillalpha = fillAlpha100 / 100f;

    String shapeColor = (String) shapesSpinner.getSelectedItem();
    spatialTable.getStyle().shape = shapeColor;

    String minZoom = (String) minZoomSpinner.getSelectedItem();
    spatialTable.getStyle().minZoom = Integer.parseInt(minZoom);

    String maxZoom = (String) maxZoomSpinner.getSelectedItem();
    spatialTable.getStyle().maxZoom = Integer.parseInt(maxZoom);

    String dashPatternString = dashPatternText.getText().toString();
    spatialTable.getStyle().dashPattern = dashPatternString;

    try {
      SpatialDatabasesManager.getInstance().updateStyle(spatialTable);
      finish();
    } catch (Exception e) {
      GPLog.error(this, null, e);
    }
  }
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.data_point_properties);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    Bundle extras = getIntent().getExtras();
    String tableName = extras.getString(SpatialiteLibraryConstants.PREFS_KEY_TEXT);
    try {
      spatialTable = SpatialDatabasesManager.getInstance().getVectorTableByName(tableName);
    } catch (Exception e) {
      GPLog.error(this, null, e);
    }

    shapesSpinner = (Spinner) findViewById(R.id.shape_spinner);
    String shape = spatialTable.getStyle().shape;
    int count = shapesSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (shapesSpinner.getItemAtPosition(i).equals(shape)) {
        shapesSpinner.setSelection(i);
        break;
      }
    }
    String size = String.valueOf((int) spatialTable.getStyle().size);
    sizeSpinner = (Spinner) findViewById(R.id.size_spinner);
    count = sizeSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (sizeSpinner.getItemAtPosition(i).equals(size)) {
        sizeSpinner.setSelection(i);
        break;
      }
    }

    colorSpinner = (Spinner) findViewById(R.id.color_spinner);
    String strokecolor = spatialTable.getStyle().strokecolor;
    count = colorSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (colorSpinner.getItemAtPosition(i).equals(strokecolor)) {
        colorSpinner.setSelection(i);
        break;
      }
    }
    String width = String.valueOf((int) spatialTable.getStyle().width);
    widthSpinner = (Spinner) findViewById(R.id.width_spinner);
    count = widthSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (widthSpinner.getItemAtPosition(i).equals(width)) {
        widthSpinner.setSelection(i);
        break;
      }
    }
    String alpha = String.valueOf((int) (spatialTable.getStyle().strokealpha * 100f));
    alphaSpinner = (Spinner) findViewById(R.id.alpha_spinner);
    count = alphaSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (alphaSpinner.getItemAtPosition(i).equals(alpha)) {
        alphaSpinner.setSelection(i);
        break;
      }
    }

    fillColorSpinner = (Spinner) findViewById(R.id.fill_color_spinner);
    String fillcolor = spatialTable.getStyle().fillcolor;
    count = fillColorSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (fillColorSpinner.getItemAtPosition(i).equals(fillcolor)) {
        fillColorSpinner.setSelection(i);
        break;
      }
    }

    String fillAlpha = String.valueOf((int) (spatialTable.getStyle().fillalpha * 100f));
    fillAlphaSpinner = (Spinner) findViewById(R.id.fill_alpha_spinner);
    count = fillAlphaSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (fillAlphaSpinner.getItemAtPosition(i).equals(fillAlpha)) {
        fillAlphaSpinner.setSelection(i);
        break;
      }
    }

    int minZoom = spatialTable.getMinZoom();
    int tableMinZoom = 0; // spatialTable.getMinZoom();
    int tableMaxZoom = 22; // spatialTable.getMaxZoom();
    ArrayList<String> minMaxSequence = new ArrayList<String>();
    for (int i = tableMinZoom; i <= tableMaxZoom; i++) {
      minMaxSequence.add(String.valueOf(i));
    }
    minZoomSpinner = (Spinner) findViewById(R.id.minzoom_spinner);
    ArrayAdapter<String> queryAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, minMaxSequence);
    queryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    minZoomSpinner.setAdapter(queryAdapter);
    count = minZoomSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (minZoomSpinner.getItemAtPosition(i).equals(String.valueOf(minZoom))) {
        minZoomSpinner.setSelection(i);
        break;
      }
    }

    int maxZoom = spatialTable.getMaxZoom();
    maxZoomSpinner = (Spinner) findViewById(R.id.maxzoom_spinner);
    queryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    maxZoomSpinner.setAdapter(queryAdapter);
    count = maxZoomSpinner.getCount();
    for (int i = 0; i < count; i++) {
      if (maxZoomSpinner.getItemAtPosition(i).equals(String.valueOf(maxZoom))) {
        maxZoomSpinner.setSelection(i);
        break;
      }
    }

    String dashPattern = spatialTable.getStyle().dashPattern;
    dashPatternText = (EditText) findViewById(R.id.dashpattern_text);
    dashPatternText.setText(dashPattern);
  }
  private void infoDialog(final double n, final double w, final double s, final double e) {
    try {
      final SpatialDatabasesManager sdbManager = SpatialDatabasesManager.getInstance();
      final List<SpatialVectorTable> spatialTables = sdbManager.getSpatialVectorTables(false);

      final Context context = getContext();
      final ProgressDialog importDialog = new ProgressDialog(context);
      importDialog.setCancelable(true);
      importDialog.setTitle("INFO");
      importDialog.setMessage("Extracting information...");
      importDialog.setCancelable(true);
      importDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
      importDialog.setProgress(0);
      importDialog.setMax(spatialTables.size());
      importDialog.show();

      new AsyncTask<String, Void, String>() {

        protected String doInBackground(String... params) {
          try {
            boolean oneEnabled = false;
            for (SpatialVectorTable spatialTable : spatialTables) {
              if (spatialTable.getStyle().enabled == 0) {
                continue;
              }
              oneEnabled = true;
              break;
            }
            StringBuilder sb = new StringBuilder();
            if (oneEnabled) {
              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;
              }

              for (SpatialVectorTable spatialTable : spatialTables) {
                if (spatialTable.getStyle().enabled == 0) {
                  continue;
                }
                StringBuilder sbTmp = new StringBuilder();
                sdbManager.intersectionToString(
                    "4326", spatialTable, north, south, east, west, sbTmp, "\t");
                sb.append(spatialTable.getName()).append("\n");
                sb.append(sbTmp);
                sb.append("\n----------------------\n");

                onProgressUpdate(0);
              }
            }
            return sb.toString();
          } catch (Exception e) {
            return "ERROR: " + e.getLocalizedMessage();
          }
        }

        protected void onProgressUpdate(Integer... progress) { // on UI thread!
          importDialog.incrementProgressBy(1);
        }

        protected void onPostExecute(String response) { // on UI thread!
          importDialog.dismiss();
          if (response.length() == 0) {
            Utilities.messageDialog(context, "No queriable layer is visible.", null);
          } else if (response.startsWith("ERROR")) {
            Utilities.messageDialog(context, response, null);
          } else {
            Utilities.messageDialog(context, response, null);
          }
        }
      }.execute((String) null);

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }