I have a custom imageView where i have a matrix and i can drag, zoom and now i can paint and delete points(coordinates)over it too.
The problem is: how can i move that points after zoom or drag the matrix
I have saved all the points in (Mark and Marking are custom clases with just 2 variables(x,y) float or int for save coordinates
static ArrayList <Marking> listaPtos = new ArrayList<Marking>();
static ArrayList <Mark> listaMarcas = new ArrayList<Mark>();
how i save the coordinates? using mapPoints?I try it but i dont know the correct formula
void saveCoordinates(float x, float y){
Log.i("guardaCoordenadas","de float");
Mark m = new Mark(x,y);
listaMarcas.add(m);
Log.i("marca",""+m.x+"-"+m.y);
Main.txtCont.setText(x+"-"+y);
guardaCoordenadas(lastTouchX,lastTouchY);
}
void guardaCoordenadas(int x, int y){
Log.i("guardaCoordenadas","de int");
Marking m = new Marking(x,y);
listaPtos.add(m);
Log.i("listaPtos0",""+m.x+"-"+m.y);
}
this is my onDraw
public void onDraw(Canvas c){
Log.d("onDraw","pinta="+pinta);
c.drawBitmap(bitmap, matrix, paintFondo);
c.drawPath(path,new Paint());
if(pinta){
Log.d("activando","clickPinta");
//this.setOnTouchListener(null);
this.setOnTouchListener(clickPinta);
}
else{
Log.d("activando","clickImagen");
//this.setOnTouchListener(null);
this.setOnTouchListener(clickImagen);
}
if(listaPtos!=null){
Log.i("pintando",listaPtos.size()+" puntos");
/*for(Marking mark:listaPtos){
c.drawBitmap(cruz, mark.x, mark.y, paintPuntos);
//c.drawCircle(mark.x, mark.y, 20, new Paint());
}*/
for(Mark mark:listaMarcas){
//c.drawBitmap(cruz, mark.x, mark.y, paintPuntos);
c.drawBitmap(cruz, mark.x, mark.y, new Paint());
}
}
}
and this is the method which i try use for move points:
void moveCoordenadas(float x, float y){
if (mode==DRAG){
for (int i=0; i<listaMarcas.size();i++){
Mark mark = listaMarcas.get(i);
float [] coor = new float[2];
coor[0]=mark.x;
coor[1]=mark.y;
matrix.mapPoints(coor);
mark.x=coor[0];
mark.y=coor[1];
listaMarcas.set(i, mark);
}
}
if (mode==ZOOM){
}
}
Im trying just with drag at first because is easier
thx for your help and your time, if you need more code, just say it
If somebody have the same problem, I solve it with matrix.mapPoints()
(mapPoints convert absolute coordinates to relatives)
Here the code: