add drawing of paths

itemized2sql
Georg Lukas 2010-12-13 21:04:00 +01:00
rodzic c3585aa58d
commit 7e540160af
2 zmienionych plików z 44 dodań i 1 usunięć

Wyświetl plik

@ -2,7 +2,7 @@ package de.duenndns.aprsdroid
import _root_.android.content.{BroadcastReceiver, Context, Intent, IntentFilter}
import _root_.android.graphics.drawable.{Drawable, BitmapDrawable}
import _root_.android.graphics.{Canvas, Paint, Point, Rect, Typeface}
import _root_.android.graphics.{Canvas, Paint, Path, Point, Rect, Typeface}
import _root_.android.os.Bundle
import _root_.android.util.Log
import _root_.com.google.android.maps._
@ -74,6 +74,43 @@ class StationOverlay(icons : Drawable, db : StorageDatabase) extends ItemizedOve
(symbol(0) != '/' && symbol(0) != '\\')
}
def drawTrace(c : Canvas, m : MapView, call : String) : Unit = {
//Log.d(TAG, "drawing trace of %s".format(call))
val tracePaint = new Paint()
tracePaint.setARGB(200, 255, 128, 128)
tracePaint.setStyle(Paint.Style.STROKE)
tracePaint.setStrokeJoin(Paint.Join.ROUND)
tracePaint.setStrokeCap(Paint.Cap.ROUND)
tracePaint.setStrokeWidth(2)
tracePaint.setAntiAlias(true)
val path = new Path()
val point = new Point()
val cur = db.getStaPositions(call, "%d".format(System.currentTimeMillis() - 30*3600*1000))
if (cur.getCount() < 2) {
cur.close()
return
}
cur.moveToFirst()
var first = true
while (!cur.isAfterLast()) {
val lat = cur.getInt(cur.getColumnIndexOrThrow(StorageDatabase.Position.LAT))
val lon = cur.getInt(cur.getColumnIndexOrThrow(StorageDatabase.Position.LON))
m.getProjection().toPixels(new GeoPoint(lat, lon), point)
if (first) {
path.moveTo(point.x, point.y)
first = false
} else
path.lineTo(point.x, point.y)
cur.moveToNext()
}
cur.close()
c.drawPath(path, tracePaint)
}
override def draw(c : Canvas, m : MapView, shadow : Boolean) : Unit = {
if (shadow) return;

Wyświetl plik

@ -125,6 +125,12 @@ class StorageDatabase(context : Context) extends
Position.CALL, null, "_ID DESC", limit)
}
def getStaPositions(call : String, limit : String) : Cursor = {
getReadableDatabase().query(Position.TABLE, Position.COLUMNS,
"call LIKE ? AND TS > ?", Array(call, limit),
null, null, "_ID DESC", null)
}
def addPost(ts : Long, posttype : Int, status : String, message : String) {
val cv = new ContentValues()
cv.put(Post.TS, ts.asInstanceOf[java.lang.Long])