Ejemplo n.º 1
0
 public void draw(Canvas canvas, MapView mapview, boolean flag) {
   Projection projection = mapview.getProjection();
   Paint paint = new Paint();
   Point point = new Point();
   projection.toPixels(gp1, point);
   paint.setColor(color);
   Point point1 = new Point();
   projection.toPixels(gp2, point1);
   paint.setStrokeWidth(5F);
   paint.setAlpha(120);
   canvas.drawLine(point.x, point.y, point1.x, point1.y, paint);
   super.draw(canvas, mapview, flag);
 }
Ejemplo n.º 2
0
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    super.onKeyDown(keyCode, event);
    if (mode == 0) {
      switch (keyCode) {
          /** navigation key commands * */
        case KeyEvent.KEYCODE_DPAD_UP:
          Globals.maze.walk(1);
          Globals.mv.invalidate();
          Log.v("walkstage", "complete");
          return true;
        case KeyEvent.KEYCODE_DPAD_DOWN:
          // Globals.gw.ArrayInit();
          Globals.maze.walk(-1);
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
          // Globals.gw.ArrayInit();
          Globals.maze.rotate(-1);
          mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_DPAD_LEFT:
          // Globals.gw.ArrayInit();
          Log.v("keypadleft", "down");
          Globals.maze.rotate(1);
          Log.v("rotate", "finished");
          Globals.mv.invalidate();
          return true;

          /** Map view key commands * */
        case KeyEvent.KEYCODE_M:
          Log.v("mapkey", "pressed");
          Globals.maze.map_mode = !Globals.maze.map_mode;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_Z:
          Globals.maze.showMaze = !Globals.maze.showMaze;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_S:
          Globals.maze.showSolution = !Globals.maze.showSolution;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_PLUS:
          Log.v("keycode", "plus");
          if (Globals.maze.showMaze) {
            Globals.maze.mapdrawer.incrementMapScale();
            Log.v("inside", "plus keycode");
            Globals.mv.invalidate();
          }
          return true;
        case KeyEvent.KEYCODE_MINUS:
          if (Globals.maze.showMaze) {
            Globals.maze.mapdrawer.decrementMapScale();
            Globals.mv.invalidate();
          }
          return true;

        case KeyEvent.KEYCODE_BACK:
          Toast.makeText(this, "Back to Start", Toast.LENGTH_SHORT).show();
          Intent i = new Intent(StatePlay.this, AMazeActivity.class);
          startActivity(i);
          return true;
      }

    } else {
      /** this is in a non-manual mode * */
      switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
          Toast.makeText(this, "Back to Start", Toast.LENGTH_SHORT).show();
          Intent i = new Intent(StatePlay.this, AMazeActivity.class);
          startActivity(i);
          return true;
        case KeyEvent.KEYCODE_M:
          Log.v("mapkey", "pressed");
          Globals.maze.map_mode = !Globals.maze.map_mode;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_Z:
          Globals.maze.showMaze = !Globals.maze.showMaze;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_S:
          Globals.maze.showSolution = !Globals.maze.showSolution;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_PLUS:
          Log.v("keycode", "plus");
          if (Globals.maze.showMaze) {
            Globals.maze.mapdrawer.incrementMapScale();
            Log.v("inside", "plus keycode");
            Globals.mv.invalidate();
          } //
          return true;
        case KeyEvent.KEYCODE_MINUS:
          if (Globals.maze.showMaze) {
            Globals.maze.mapdrawer.decrementMapScale();
            Globals.mv.invalidate();
          }
          return true;
      }
    }

    return false;
  }