它应该是一个简单的白板工具,具有缩放/平移效果.
除了缩放/平移之外,路径部分的整个绘制都可以.
当对白板应用变焦时,无论我采用何种方式,应用变焦后的所有线条都会相对于我实际上进行了抚摸的位置而移位.
我会尝试尽可能好地公开细节,而不会显示不必要的代码,仍然是一个很长的帖子,拜托,请耐心等待.
由于图像胜过千言万语,我将说明情况:




所以,我尝试了很多不同的方法,没有任何成功.
现在到技术部分,这就是我现在正在做的事情:
它实现了扩展View.
我只使用onDraw方法来执行正在应用的笔划的"动画":
@Override
public void onDraw(Canvas canvas)
{
super.onDraw(canvas);
if(isDrawing)
{
canvas.drawPath(mPath, mPaint);
canvas.drawBitmap(mBitmap, 0, 0, mPaint);
}
}
Run Code Online (Sandbox Code Playgroud)
我有两个ImageViews,用于在执行绘图和缩放后立即放置生成的位图.我使用两个视图的原因是交换它们,以便在绘图渲染时始终拥有一个可用视图.
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:visibility="visible"
android:scaleType="matrix" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:visibility="visible"
android:scaleType="matrix" />
Run Code Online (Sandbox Code Playgroud)
将某些内容绘制到画布后,我将给定的位图发送到我的视图,然后清理画布以将其全新设置为更多图形:
private void sendImage2BackView()
{
//veeery extensive and boring code surpressed here
//set the entire hocus-pocus' resulting bitmap as a resource for my view
mView.setImageBitmap(tempBmp);
mView.bringToFront();
}
Run Code Online (Sandbox Code Playgroud)
我实现了一个扩展ScaleGestureDetector.SimpleOnScaleGestureListener的ScaleListener类
在onScale的时刻,我告诉我的画布我的scalling比例是多少:
@Override
public boolean onScale(ScaleGestureDetector detector)
{ …Run Code Online (Sandbox Code Playgroud) 我目前正在使用 mongoose v.5.25,而不是 mongoDB v.3.6。
我的应用程序应该从许多不同的视图查询数据,例如,我当前在数据库中拥有的一个视图:db.joboffers_view.find()
将返回从不同集合聚合的许多记录。
对于普通的集合模型,我像这样查询它:
const model = db.model(attribute);
/*where attribute, can be any registered schema */
model.find().
then((result) => {
resolve(result);
}).
catch((err) => {
reject(err);
});
Run Code Online (Sandbox Code Playgroud)
然后我注册模型的方式是这样的(简化代码):
//...
//abstracting boring connection methods
const db = mongoose.connection
//...
//simple model schema
const users_schema = {
_id: ObjectId,
another_field: String
};
//here I'm registering a schema for a VIEW, instead of normal collection
const view_schema = {
_id: ObjectId,
another_field: String
};
//...
//then
db.model('users', users_schema); …Run Code Online (Sandbox Code Playgroud)