|
|
|
@ -10,12 +10,14 @@ import android.os.Build;
|
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.MotionEvent;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
import android.view.WindowManager;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
|
import androidx.core.view.MotionEventCompat;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
@ -35,32 +37,35 @@ public class PlateauView extends View implements ObserverCV {
|
|
|
|
|
|
|
|
|
|
public PlateauView(Context context, @Nullable AttributeSet attrs) {
|
|
|
|
|
super(context, attrs);
|
|
|
|
|
Log.d("fragment","constructeur");
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PlateauView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
|
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
|
|
|
|
public PlateauView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
|
|
|
super(context, attrs, defStyleAttr, defStyleRes);
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Paint paint = new Paint();
|
|
|
|
|
private int colones;
|
|
|
|
|
private int lignes;
|
|
|
|
|
private int dethColor = Color.BLACK;
|
|
|
|
|
private int width;
|
|
|
|
|
private int height;
|
|
|
|
|
|
|
|
|
|
public PlateauView(Context context, int colones, int lignes){
|
|
|
|
|
super(context);
|
|
|
|
|
colors = new HashMap<>();
|
|
|
|
|
paint = new Paint();
|
|
|
|
|
this.colones = colones;
|
|
|
|
|
this.lignes = lignes;
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void init(){
|
|
|
|
|
colors = new HashMap<>();
|
|
|
|
|
paint = new Paint();
|
|
|
|
|
this.dethColor = Color.BLACK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -72,13 +77,14 @@ public class PlateauView extends View implements ObserverCV {
|
|
|
|
|
Rect rect;
|
|
|
|
|
for(int i=0; i<lignes; ++i){
|
|
|
|
|
for(int j=0; j<colones; ++j){
|
|
|
|
|
//tmp = colors.get(p);
|
|
|
|
|
Position p = new Position(j, i);
|
|
|
|
|
tmp = colors.get(p);
|
|
|
|
|
paint.setColor(dethColor);
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
if(tmp instanceof Integer){
|
|
|
|
|
paint.setColor(tmp);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int width = LauncherActivity.width;
|
|
|
|
|
Log.d("affichage",""+LauncherActivity.isPortrait);
|
|
|
|
|
if (LauncherActivity.isPortrait) {
|
|
|
|
@ -104,6 +110,10 @@ public class PlateauView extends View implements ObserverCV {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addPosCell(int x, int y){
|
|
|
|
|
//TODO: Récup la céllue et ajouter dans colors
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setColones(int value) throws IllegalArgumentException{
|
|
|
|
|
if(value < 0){
|
|
|
|
|
throw new IllegalArgumentException("La valeur des colones doit être supperieur à 0");
|
|
|
|
@ -117,12 +127,4 @@ public class PlateauView extends View implements ObserverCV {
|
|
|
|
|
}
|
|
|
|
|
lignes = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setWidth(int width) {
|
|
|
|
|
this.width = width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setHeight(int height) {
|
|
|
|
|
this.height = height;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|