⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colorconvertion.java

📁 It is all about project scheduling. GanttProject is a tool for creating a project schedule by means
💻 JAVA
字号:
/*************************************************************************** ColorConvertion.java  ------------------------------------------ begin                : 6 juil. 2004 copyright            : (C) 2004 by Thomas Alexandre email                : alexthomas@ganttproject.org ***************************************************************************//*************************************************************************** *                                                                         * *   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 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/package net.sourceforge.ganttproject.util;import java.awt.Color;import java.util.regex.Pattern;import net.sourceforge.ganttproject.GanttGraphicArea;/** * @author athomas Convert the color format from and to differents versions */public class ColorConvertion {    /** @return the color as hexadecimal version like #RRGGBB */    public static String getColor(Color color) {        String res = "#";        if (color.getRed() <= 15)            res += "0";        res += Integer.toHexString(color.getRed());        if (color.getGreen() <= 15)            res += "0";        res += Integer.toHexString(color.getGreen());        if (color.getBlue() <= 15)            res += "0";        res += Integer.toHexString(color.getBlue());        return res;    }    /** parse a string as hew and return the corresponding color. */    public static Color determineColor(String hexString) {        if (!Pattern.matches("#[0-9abcdefABCDEF]{6}+", hexString)) {            return GanttGraphicArea.taskDefaultColor;        }        int r, g, b;        r = Integer.valueOf(hexString.substring(1, 3), 16).intValue();        g = Integer.valueOf(hexString.substring(3, 5), 16).intValue();        b = Integer.valueOf(hexString.substring(5, 7), 16).intValue();        return new Color(r, g, b);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -