this.selected = selected;
}
+ @Override
+ public ImageData getImageData(int zoom) {
+ int w = width;
+ int h = height;
+ if (zoom > 100) {
+ float s = zoom / 100.0f;
+ w = Math.round(width * s);
+ h = Math.round(height * s);
+ }
+ return getImageData(w, h);
+ }
+
@Override
public ImageData getImageData() {
- ImageData id = new ImageData(width, height, 24, PALETTEDATA);
- int cx = width / 2;
- int cy = height / 2;
- int dst = height * width / 23;
- for (int x=0; x<width; x++) {
- for (int y=0; y<height; y++) {
- int color = c;
- boolean border = x==0||x==width-1||y==0||y==height-1;
- if ( border ) color = 0;
- if (selected) {
- int dist = (x-cx)*(x-cx)+(y-cy)*(y-cy);
- if ( dist < dst ) color = 0xcccccc;
- }
- id.setPixel(x, y, color);
- }
- }
-
+ return getImageData(100);
+ }
+
+ private ImageData getImageData(int width, int height) {
+ ImageData id = new ImageData(width, height, 24, PALETTEDATA);
+ int cx = width / 2;
+ int cy = height / 2;
+ int dst = height * width / 23;
+ for (int x=0; x<width; x++) {
+ for (int y=0; y<height; y++) {
+ int color = c;
+ boolean border = x==0||x==width-1||y==0||y==height-1;
+ if ( border ) color = 0;
+ if (selected) {
+ int dist = (x-cx)*(x-cx)+(y-cy)*(y-cy);
+ if ( dist < dst ) color = 0xcccccc;
+ }
+ id.setPixel(x, y, color);
+ }
+ }
+
return id;
}
-
+
@Override
public int hashCode() {
return c + 7*width + 13*height + (selected?234234:4235);