コード例 #1
0
  private void refreshList() {
    if (GPLog.LOG_HEAVY) GPLog.addLogEntry(this, "refreshing notes list"); // $NON-NLS-1$
    try {

      List<INote> allNotesList = new ArrayList<INote>();
      List<Note> notesList = DaoNotes.getNotesList();
      allNotesList.addAll(notesList);
      List<Image> imagesList = DaoImages.getImagesList();
      allNotesList.addAll(imagesList);
      Collections.sort(allNotesList, notesSorter);

      notesNames = new String[allNotesList.size()];
      notesMap.clear();
      int index = 0;
      for (INote note : allNotesList) {
        String name = note.getName();
        notesMap.put(name, note);
        notesNames[index] = name;
        index++;
      }
    } catch (IOException e) {
      GPLog.error(this, e.getLocalizedMessage(), e);
      e.printStackTrace();
    }

    redoAdapter();
  }
コード例 #2
0
  private void filterList(String filterText) {
    if (GPLog.LOG_HEAVY) GPLog.addLogEntry(this, "filter notes list"); // $NON-NLS-1$
    try {
      List<INote> allNotesList = new ArrayList<INote>();
      List<Note> notesList = DaoNotes.getNotesList();
      allNotesList.addAll(notesList);
      List<Image> imagesList = DaoImages.getImagesList();
      allNotesList.addAll(imagesList);
      Collections.sort(allNotesList, notesSorter);

      notesMap.clear();
      filterText = ".*" + filterText.toLowerCase() + ".*"; // $NON-NLS-1$ //$NON-NLS-2$
      List<String> namesList = new ArrayList<String>();
      for (INote note : allNotesList) {
        String name = note.getName();
        String nameLower = name.toLowerCase();
        if (nameLower.matches(filterText)) {
          namesList.add(name);
          notesMap.put(name, note);
        }
      }

      notesNames = namesList.toArray(new String[0]);
    } catch (IOException e) {
      GPLog.error(this, e.getLocalizedMessage(), e);
      e.printStackTrace();
    }

    redoAdapter();
  }
コード例 #3
0
 @Override
 public void onViewChanged() {
   EditingView editingView = EditManager.INSTANCE.getEditingView();
   try {
     readData(editingView);
   } catch (IOException e) {
     GPLog.error(this, null, e);
   }
 }
コード例 #4
0
  public void onClick(View v) {
    if (v == selectAllButton) {
      Tool currentTool = EditManager.INSTANCE.getActiveTool();
      if (currentTool != null && currentTool instanceof InfoTool) {
        // if the same tool is re-selected, it is disabled
        EditManager.INSTANCE.setActiveTool(null);
      } else {
        // check maps enablement
        try {
          final Collection<SpatialVectorTable> spatialTables =
              SpatialiteSourcesManager.INSTANCE.getSpatialiteMaps2TablesMap().values();
          boolean atLeastOneEnabled = false;
          for (SpatialVectorTable spatialVectorTable : spatialTables) {
            if (spatialVectorTable.getStyle().enabled == 1) {
              atLeastOneEnabled = true;
              break;
            }
          }
          if (!atLeastOneEnabled) {
            LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
            if (parent != null) {
              Context context = parent.getContext();
              GPDialogs.warningDialog(
                  context, context.getString(R.string.no_queriable_layer_is_visible), null);
            }
            return;
          }
        } catch (Exception e) {
          GPLog.error(this, null, e);
        }

        Tool activeTool = new InfoTool(this, mapView);
        EditManager.INSTANCE.setActiveTool(activeTool);
      }
    } else if (v == selectEditableButton) {
      Tool currentTool = EditManager.INSTANCE.getActiveTool();
      if (currentTool != null && currentTool instanceof SelectionTool) {
        // if the same tool is re-selected, it is disabled
        EditManager.INSTANCE.setActiveTool(null);
      } else {
        Tool activeTool = new SelectionTool(mapView);
        EditManager.INSTANCE.setActiveTool(activeTool);
      }
    } else if (v == createFeatureButton) {
      ToolGroup createFeatureToolGroup = new LineCreateFeatureToolGroup(mapView, null);
      EditManager.INSTANCE.setActiveToolGroup(createFeatureToolGroup);
    } else if (v == undoButton) {
      //            if (cutExtendProcessedFeature != null) {
      //                EditManager.INSTANCE.setActiveTool(null);
      //                commitButton.setVisibility(View.GONE);
      //                undoButton.setVisibility(View.GONE);
      //                EditManager.INSTANCE.invalidateEditingView();
      //            }
    }

    handleToolIcons(v);
  }
コード例 #5
0
  @Override
  public void onClick(View view) {
    try {
      File sdcardDir = ResourcesManager.getInstance(getContext()).getSdcardDir();
      Intent browseIntent = new Intent(getContext(), DirectoryBrowserActivity.class);
      browseIntent.putExtra(
          DirectoryBrowserActivity.PUT_PATH_PREFERENCE, PREFS_KEY_CUSTOM_MAPSFOLDER);
      browseIntent.putExtra(DirectoryBrowserActivity.EXTENSIONS, DirectoryBrowserActivity.FOLDER);
      browseIntent.putExtra(DirectoryBrowserActivity.STARTFOLDERPATH, sdcardDir.getAbsolutePath());

      context.startActivity(browseIntent);
    } catch (Exception e) {
      GPLog.error(this, null, e); // $NON-NLS-1$
    }
  }
コード例 #6
0
  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);
    }
  }
コード例 #7
0
  public void onToolDraw(Canvas canvas) {
    int cWidth = canvas.getWidth();
    int cHeight = canvas.getHeight();

    int upper = 70;

    if (gpsLogInfo == null) return;

    GpsLogInfo logInfo = gpsLogInfo;
    int color = Color.BLACK;
    try {
      color = Color.parseColor(logInfo.color);
    } catch (Exception e) {
      // ignore
    }
    linePaint.setAntiAlias(true);
    linePaint.setColor(color);
    linePaint.setStrokeWidth(3f);
    linePaint.setStyle(Paint.Style.STROKE);

    colorBoxPaint.setAntiAlias(false);
    colorBoxPaint.setColor(color);
    colorBoxPaint.setStyle(Paint.Style.FILL);

    measureTextPaint.setAntiAlias(true);
    measureTextPaint.setTextSize(pixel);
    measureTextPaint.setColor(color);
    measureTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));

    String name = logInfo.logName;
    String ts = " - ";
    try {
      ts = TimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(new Date(logInfo.timestamp));
    } catch (Exception e) {
      GPLog.error(this, "Error in timestamp: " + logInfo.timestamp, e);
    }
    String time = timeString + ts;
    Coordinate pointXYZ = logInfo.pointXYZ;
    if (pointXYZ == null) pointXYZ = new Coordinate(-999, -999);
    String lon = lonString + coordFormatter.format(pointXYZ.x);
    String lat = latString + coordFormatter.format(pointXYZ.y);
    String altim = altimString + elevFormatter.format(pointXYZ.z);

    String[] texts = {name, time, lon, lat, altim};

    int runningY = upper;
    int textWidth = 0;
    for (String text : texts) {
      measureTextPaint.getTextBounds(text, 0, text.length(), rect);
      int textHeight = rect.height();
      runningY += textHeight + 3;
    }

    canvas.drawRect(0, 0, cWidth, runningY + 10, whiteBoxPaint);
    canvas.drawRect(0, runningY, cWidth, runningY + 10, colorBoxPaint);

    runningY = upper;
    for (String text : texts) {
      measureTextPaint.getTextBounds(text, 0, text.length(), rect);
      textWidth = rect.width();
      int textHeight = rect.height();
      int x = cWidth / 2 - textWidth / 2;
      canvas.drawText(text, x, runningY, measureTextPaint);
      runningY += textHeight + 7;
    }

    GeoPoint geoPoint = new GeoPoint(pointXYZ.y, pointXYZ.x);
    Point point = projection.toPixels(geoPoint, null);
    canvas.drawLine(point.x, point.y, cWidth / 2, runningY, linePaint);
  }
コード例 #8
0
  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);
  }