1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
public void drawElement(int width, int height) {
double nbPixelByTwo = (2 * Wall.getNbMetre_by_pixel());
double scaleModify = (Plan.getScale() / Plan.getScaleStd());
if (isSelected()) {
if (bitmapWall != null) {
bitmapWall.recycle();
bitmapWall = null;
}
bitmapWall = Bitmap.createBitmap(width, height,
Config.ARGB_8888);
canvasWall = new Canvas(bitmapWall);
paintWall = new Paint();
/** Couleur du Mur selectionne **/
paintWall.setColor(Color.RED);
/** Epaisseur du trait **/
paintWall.setStrokeWidth(getPixelsThickness_Elt());
/** Longueur du Mur **/
double lengthWall = Math.sqrt(Math.pow(
Math.abs(getPosX_FinElt() - getPosX_DebElt()), 2)
+ (Math.pow(
Math.abs(getPosY_FinElt() - getPosY_DebElt()),
2)));
/** Dessine le Mur **/
canvasWall
.drawLine(
(float) ((getPosX_DebElt() / nbPixelByTwo) * scaleModify),
(float) ((getPosY_DebElt() / nbPixelByTwo) * scaleModify),
(float) ((getPosX_FinElt() / nbPixelByTwo) * scaleModify),
(float) ((getPosY_FinElt() / nbPixelByTwo) * scaleModify),
paintWall);
} else {
if (bitmapWall != null) {
bitmapWall.recycle();
bitmapWall = null;
}
bitmapWall = Bitmap.createBitmap(width, height,
Config.ARGB_8888);
canvasWall = new Canvas(bitmapWall);
paintWall = new Paint();
/** Couleur du Mur **/
paintWall.setColor(Color.GRAY);
/** Definir une épaisseur de trait **/
paintWall.setStrokeWidth(getPixelsThickness_Elt());
/** Longueur du Mur **/
double lengthWall = Math.sqrt(Math.pow(
Math.abs(getPosX_FinElt() - getPosX_DebElt()), 2)
+ (Math.pow(
Math.abs(getPosY_FinElt() - getPosY_DebElt()),
2)));
/** Dessine le Mur **/
canvasWall
.drawLine(
(float) ((getPosX_DebElt() / nbPixelByTwo) * scaleModify),
(float) ((getPosY_DebElt() / nbPixelByTwo) * scaleModify),
(float) ((getPosX_FinElt() / nbPixelByTwo) * scaleModify),
(float) ((getPosY_FinElt() / nbPixelByTwo) * scaleModify),
paintWall);
}
} |
Partager