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
|
public class Ligne extends EltPlan {
private static final int epaisseur = 8;
private int a, b;
private Ligne(int x, int y, int width, int height) {
super(x, y, width, height);
}
public static Ligne LigneHorizontal(int x, int y, int lgr) {
return new Ligne(x, y, lgr, epaisseur);
}
public static Ligne LigneVertical(int x, int y, int lgr) {
return new Ligne(x, y, epaisseur, lgr);
}
public void doBitmap() {
// Si la ligne est selectionné on l'encadre en rouge
if (isSelected()) {
setBitmap(Bitmap.createBitmap(getPixelsWidth() + 10,
getPixelsHeight() + 10, Config.ARGB_8888));
for (b = 5; b < getBitmap().getHeight() - 5; b++) {
for (a = 5; a < getBitmap().getWidth() - 5; a++)
getBitmap().setPixel(a, b, Color.GRAY);
}
for (a = 0; a < getBitmap().getWidth(); a++)
getBitmap().setPixel(a, 0, Color.RED);
for (a = 0; a < getBitmap().getWidth(); a++)
getBitmap().setPixel(a, getBitmap().getHeight() - 1, Color.RED);
for (b = 0; b < getBitmap().getHeight(); b++)
getBitmap().setPixel(0, b, Color.RED);
for (b = 0; b < getBitmap().getHeight(); b++)
getBitmap().setPixel(getBitmap().getWidth() - 1, b, Color.RED);
} else {
setBitmap(Bitmap.createBitmap(getPixelsWidth(), getPixelsHeight(),
Config.ARGB_8888));
for (b = 0; b < getBitmap().getHeight(); b++) {
for (a = 0; a < getBitmap().getWidth(); a++)
getBitmap().setPixel(a, b, Color.GRAY);
}
}
}
} |
Partager