]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/ColorImageDescriptor.java
Implement ImageDescriptor.getImageData(int zoom)
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / gfx / ColorImageDescriptor.java
index eca35f1fce9bd634689a8562344c1556488ab4f1..6c0f26d4e809bc3611898a4e9559e64a94e17707 100644 (file)
@@ -36,28 +36,44 @@ public class ColorImageDescriptor extends ImageDescriptor {
                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);