Here you can find the source of brighter(Color col, double FACTOR)
Parameter | Description |
---|---|
col | a parameter |
FACTOR | 0 for white, 1 for no change |
public static Color brighter(Color col, double FACTOR)
//package com.java2s; /*// w w w . jav a 2 s.c om * Spirit, a study/biosample management tool for research. * Copyright (C) 2018 Idorsia Pharmaceuticals Ltd., Hegenheimermattweg 91, * CH-4123 Allschwil, Switzerland. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> * * @author Joel Freyss */ import java.awt.Color; import java.util.HashMap; import java.util.Map; public class Main { private static Map<Integer, Color> colorMap = new HashMap<Integer, Color>(); /** * Makes the color darker * @param col * @param FACTOR 0 for white, 1 for no change * @return */ public static Color brighter(Color col, double FACTOR) { return getColor(255 - (int) ((255 - col.getRed()) * FACTOR), 255 - (int) ((255 - col.getGreen()) * FACTOR), 255 - (int) ((255 - col.getBlue()) * FACTOR), 0); } /** * Get Colors from (small) cache */ public static Color getColor(int r, int g, int b) { return getColor(r, g, b, 255); } public static Color getColor(Color color, int alpha) { return getColor(color.getRed(), color.getGreen(), color.getBlue(), alpha); } public static Color getColor(int r, int g, int b, int alpha) { int rgb = ((alpha & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | ((b & 0xFF) << 0); return getColor(rgb); } public static Color getColor(int rgb) { Color res = colorMap.get(rgb); if (res == null) { if (colorMap.size() > 1000) colorMap.clear(); res = new Color(rgb, true); colorMap.put(rgb, res); } return res; } }