RadarPoints.java :  » Game » iseek » org » mixare » gui » Android Open Source

Android Open Source » Game » iseek 
iseek » org » mixare » gui » RadarPoints.java
/*
 * Copyright (C) 2010- Peer internet solutions
 * 
 * This file is part of mixare.
 * 
 * This program is free software: you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 * for more details. 
 * 
 * You should have received a copy of the GNU General Public License along with 
 * this program. If not, see <http://www.gnu.org/licenses/>
 */
package org.mixare.gui;

import org.mixare.DataView;
import org.mixare.Marker;

import android.graphics.Color;

/** Takes care of the small radar in the top left corner and of its points
 * @author daniele
 *
 */
public class RadarPoints implements ScreenObj {
  /** The screen */
  public DataView view;
  /** The radar's range */
  float range;
  /** Radius in pixel on screen */
  public static float RADIUS = 40;
  /** Position on screen */
  static float originX = 0 , originY = 0;
  /** Color */
  static int radarColor = Color.argb(100, 0, 0, 200);
  
  public void paint(PaintScreen dw) {
    /** radius in state is in KM. */
    range = Float.parseFloat(view.state.radius) * 1000;
    /** Draw the radar */
    dw.setFill(true);
    dw.setColor(radarColor);
    dw.paintCircle(originX + RADIUS, originY + RADIUS, RADIUS);

    /** put the markers in it */
    float scale = range / RADIUS;

    for (int i = 0; i < view.state.jLayer.markers.size(); i++) {
      Marker pm = view.state.jLayer.markers.get(i);
      float x = pm.loc.x / scale;
      float y = pm.loc.z / scale;

      if (x * x + y * y < RADIUS * RADIUS) {
        dw.setFill(true);
        dw.setColor(Color.rgb(255, 255, 255));
        dw.paintRect(x + RADIUS - 1, y + RADIUS - 1, 2, 2);
      }
    }
  }

  /** Width on screen */
  public float getWidth() {
    return RADIUS * 2;
  }

  /** Height on screen */
  public float getHeight() {
    return RADIUS * 2;
  }
}

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.