如何繪製路徑上從數據庫中存儲的座標帆布的Android ..如何繪製路徑機器人在畫布上
我曾試圖fingerpaint但是當我從數據庫中獲取的座標 其從不同的位置繪製路徑,如果我已經把一個點把它畫吸引了來自最近的畫圖到這個點線..
下面是代碼從數據庫中讀取的座標....
public Cursor read() {
Cursor cur = db.query("path_new", null, null, null, null, null, null);
StringBuffer sbx_read, sby_read;
cur.moveToFirst();
float x1 = 0, y1 = 0;
int pid_read = 1;
int cur_pid;
float mX1 = 0, mY1 = 0;
do {
sbx_read = new StringBuffer();
sbx_read.append(cur.getString(0));
sby_read = new StringBuffer();
sby_read.append(cur.getString(1));
cur.moveToNext();
Log.d("X", sbx_read.toString());
Log.d("Y", sby_read.toString());
Path mPath1 = new Path();
String[] sbx_read_array = sbx_read.toString().trim().split(",");
String[] sby_read_array = sby_read.toString().trim().split(",");
// mPath.moveTo(x1, y1);
for (int i = 0; i < sbx_read_array.length; i++) {
x1 = Float.parseFloat(sbx_read_array[i].toString());
y1 = Float.parseFloat(sby_read_array[i].toString());
mPath1.moveTo(x1, y1);
// mPath.reset();
// mX1 = x1;
// mY1 = y1;
float dx = Math.abs(x1 - mX1);
float dy = Math.abs(y1 - mY1);
if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
mPath.reset();
mPath1.quadTo(mX1, mY1, (x1 + mX1)/2, (y1 + mY1)/2);
mX1 = x1;
mY1 = y1;
// Log.d("X1", String.valueOf(x1));
// Log.d("mX1", String.valueOf(mX1));
// Log.d("Y1", String.valueOf(y1));
// Log.d("mY1", String.valueOf(mY1));
mPath1.lineTo(mX1, mY1);
mCanvas.drawPath(mPath1, mPaint);
}
}
} while (cur.moveToNext());
cur.close();
return cur;
}
這裏我正在尋找路徑從數據庫到StringBuffer的&轉換成字符串數組,以便不同的路徑可以在不同的記錄存儲器..
我的表...
X-cordinatrs TEXT, Y-cordinatrs TEXT, Path_id INTEGER, PAGE_NO INTEGER
我不知道答案,但你檢查api演示中的手指畫? – Farhan 2012-03-16 05:50:38
是的,我已檢查其顯示如何通過手指或筆畫.. 它不顯示如何繪製從數據庫中提取的座標的路徑...... – Wolverine 2012-03-16 05:57:59