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%2FAlphaAdjustmentImageDescriptor.java;h=80b39a73bfe6e5abc855b87b8265e4c9157aec16;hp=104dd88c7c8db4023d51ed30cce98418c23939d8;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/AlphaAdjustmentImageDescriptor.java b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/AlphaAdjustmentImageDescriptor.java index 104dd88c7..80b39a73b 100644 --- a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/AlphaAdjustmentImageDescriptor.java +++ b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/gfx/AlphaAdjustmentImageDescriptor.java @@ -1,102 +1,102 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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 - *******************************************************************************/ -/* - * 22.12.2006 - */ -package org.simantics.utils.ui.gfx; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.ImageData; - -/** - * AlphaAdjustmentImageDescriptor multiplies alpha by (adjustment value/256) - *

- * Usage: - * ImageDescriptor icon; - * icon = AlphaAdjustmentImageDescriptor.adjustAlpha(icon, 128); - * - * @author Toni Kalajainen - */ -public class AlphaAdjustmentImageDescriptor extends ImageDescriptor { - - public static ImageDescriptor adjustAlpha(ImageDescriptor desc, int alphaAdjustment) - { - if (alphaAdjustment==256) return desc; - return new AlphaAdjustmentImageDescriptor(desc, alphaAdjustment); - } - - int alphaAdjustment; - ImageDescriptor desc; - - /** - * - * @param original - * @param alphaAdjustment 0..256 - */ - public AlphaAdjustmentImageDescriptor(ImageDescriptor original, int alphaAdjustment) - { - assert(alphaAdjustment>=0 && alphaAdjustment<=256); - assert(original!=null); - this.alphaAdjustment = alphaAdjustment; - this.desc = original; - } - - @SuppressWarnings("deprecation") - @Override - public ImageData getImageData() { - ImageData orig = ImageCache.getInstance().getImage(desc).getImageData(); - ImageData id = new ImageData(orig.width, orig.height, orig.depth, orig.palette); - id.setAlpha(0,0,0); - - if (orig.getTransparencyType()==SWT.TRANSPARENCY_ALPHA || - orig.getTransparencyType()==SWT.TRANSPARENCY_NONE) - { - for (int x=0; x> 8; - id.setAlpha(x, y, alpha); - } - } else - if (orig.getTransparencyType()==SWT.TRANSPARENCY_MASK || - orig.getTransparencyType()==SWT.TRANSPARENCY_PIXEL) { - ImageData mask = orig.getTransparencyMask(); - for (int x=0; x + * Usage: + * ImageDescriptor icon; + * icon = AlphaAdjustmentImageDescriptor.adjustAlpha(icon, 128); + * + * @author Toni Kalajainen + */ +public class AlphaAdjustmentImageDescriptor extends ImageDescriptor { + + public static ImageDescriptor adjustAlpha(ImageDescriptor desc, int alphaAdjustment) + { + if (alphaAdjustment==256) return desc; + return new AlphaAdjustmentImageDescriptor(desc, alphaAdjustment); + } + + int alphaAdjustment; + ImageDescriptor desc; + + /** + * + * @param original + * @param alphaAdjustment 0..256 + */ + public AlphaAdjustmentImageDescriptor(ImageDescriptor original, int alphaAdjustment) + { + assert(alphaAdjustment>=0 && alphaAdjustment<=256); + assert(original!=null); + this.alphaAdjustment = alphaAdjustment; + this.desc = original; + } + + @SuppressWarnings("deprecation") + @Override + public ImageData getImageData() { + ImageData orig = ImageCache.getInstance().getImage(desc).getImageData(); + ImageData id = new ImageData(orig.width, orig.height, orig.depth, orig.palette); + id.setAlpha(0,0,0); + + if (orig.getTransparencyType()==SWT.TRANSPARENCY_ALPHA || + orig.getTransparencyType()==SWT.TRANSPARENCY_NONE) + { + for (int x=0; x> 8; + id.setAlpha(x, y, alpha); + } + } else + if (orig.getTransparencyType()==SWT.TRANSPARENCY_MASK || + orig.getTransparencyType()==SWT.TRANSPARENCY_PIXEL) { + ImageData mask = orig.getTransparencyMask(); + for (int x=0; x