X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.utils.ui%2Fsrc%2Forg%2Fsimantics%2Futils%2Fui%2Fgfx%2FColorImageDescriptor.java;h=6c0f26d4e809bc3611898a4e9559e64a94e17707;hp=63c1dabe839320f07427e164b27f9de6caf3028b;hb=399abb1d550786b9077895ea1587d3f556fb0ed0;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/ColorImageDescriptor.java b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/ColorImageDescriptor.java index 63c1dabe8..6c0f26d4e 100644 --- a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/ColorImageDescriptor.java +++ b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/ColorImageDescriptor.java @@ -1,77 +1,93 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.utils.ui.gfx; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.PaletteData; - -/** - * Colored rectangle with black borders. - * - * @author toni.kalajainen - */ -public class ColorImageDescriptor extends ImageDescriptor { - static final PaletteData PALETTEDATA = new PaletteData(0x00ff0000, 0x0000ff00, 0x000000ff); - - int width; - int height; - int c; - boolean selected; - - public ColorImageDescriptor(int red, int green, int blue, int width, int height, boolean selected) - { - c = (red<<16) | (green<<8) | (blue); - this.width = width; - this.height = height; - this.selected = selected; - } - - @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 100) { + float s = zoom / 100.0f; + w = Math.round(width * s); + h = Math.round(height * s); + } + return getImageData(w, h); + } + + @Override + public ImageData getImageData() { + 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