1
edit
Changes
→Drawing Application
}
return true;
</repre>
*Clearing the screen is simply deleting all the fields in the manager
*Resizing the brush is done by simply dividing our original bitmap size(or multiplying).
*Setting the brush to a marker (translucent colors) or paintbrush was done with a simple global flag checking if it was true or false.
*Usage
<pre>
doMenuEvent(menuEvent(touchX, touchY));
</pre>
*MenuEvent
<pre>
private int menuEvent(int x, int y){
int rc = -1;
for(int i = 0;i < 4; i++){
if( x > grid.getFieldAtIndex(i).getContentLeft() &&
x < (grid.getFieldAtIndex(i).getContentLeft() + bitmap.getWidth()) &&
y > (displayHeight -(grid.getFieldAtIndex(0).getContentTop())) &&
y < (displayHeight)){
rc = i;
break;
}
}
return rc;
}
</pre>
*doMenuEvent
<pre>
private boolean doMenuEvent(int n){
boolean rc = false;
if(n == 0){
rc = true;
if(!added){
tempScreenHolder = screen;
super.delete(screen);
screenHolder.insert(colorGrid, 0);
super.insert(screenHolder, 0);
added = !added;
}
else{
screenHolder.delete(colorGrid);
super.delete(screenHolder);
super.insert(tempScreenHolder, 0);
added = !added;
}
}
else if(n == 1){
rc = true;
alphaSwitch = !alphaSwitch;
grid.delete(0, 1);
if(alphaSwitch)
grid.insert(new BitmapField(Bitmap.getBitmapResource("marker.png")),1);
else
grid.insert(new BitmapField(Bitmap.getBitmapResource("paint.png")),1);
int columnWidth = (displayWidth / 4) -
(grid.getColumnPadding()+(grid.getBorder().getLeft())/2);
for(int j = 0; j < 4; j++) {
grid.setColumnProperty(j, GridFieldManager.FIXED_SIZE, columnWidth);
}
}
else if(n == 2){
rc = true;
screen.deleteAll();
}
else if(n == 3){
rc = true;
Bitmap bm = Bitmap.getBitmapResource("square.png");
if(counter > 2){
height = bm.getHeight();
width = bm.getWidth();
counter--;
}
else if(counter > 0){
height = bm.getHeight()/2;
width = bm.getWidth()/2;
counter--;
}
else{
counter = 4;
height = bm.getHeight()/12;
width = bm.getWidth()/12;
}
}
return rc;
}
</pre>
*Drawing was done in an odd way. The simplest solution we came up with, was to use a square bitmap and recolor its background if any different colors were chosen, and resize accordingly. This worked well for the most part, tho we do run into some performance issues if there are too many bitmaps on the screen at once
*The program works with both touch events and scroll wheel events, tho scroll wheel events are still buggy.