Here you can find the source of overwriteAlpha(Color c, float alpha)
Parameter | Description |
---|---|
c | color to overwrite |
alpha | a new value of alpha |
Color
object with a new specified alpha value
public static Color overwriteAlpha(Color c, float alpha)
//package com.java2s; /**//from ww w .j a va2s . co m * License Agreement. * * JBoss RichFaces - Ajax4jsf Component Library * * Copyright (C) 2007 Exadel, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ import java.awt.Color; public class Main { /** * Overwrites alpha value for given color. * * @param c color to overwrite * @param alpha a new value of alpha * @return a new <code>Color</code> object with a new specified alpha value */ public static Color overwriteAlpha(Color c, float alpha) { Color retVal = c; if (c != null) { retVal = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (alpha * 255 + 0.5)); } return retVal; } }