📄 threedcolor.java
字号:
/* * Copyright (c) 2002, 2003 Sun Microsystems, Inc. All Rights Reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of Sun Microsystems, Inc., 'Java', 'Java'-based * names, or the names of contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN * MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * You acknowledge that this software is not designed, licensed or * intended for use in the design, construction, operation or maintenance * of any nuclear facility. $Id: ThreeDColor.java,v 1.3 2003/05/29 22:28:06 wildcard Exp $ */package com.sun.j2me.blueprints.jbricks;/** * This class provides support for pseudo-3D coloring. * Each of the defined colors can used as a base color, * and the brighter() and darker() methods can be used * to retrieve the appropriately highlighted or shadowed * version of that color. The getRGB() method is used to * retrieve the actual RGB value of the color, the returned * value can be passed to Graphics.setColor(). */public class ThreeDColor { public static ThreeDColor lightGray = new ThreeDColor(0xc0c0c0); public static ThreeDColor lightPurple = new ThreeDColor(0xb000ff); public static ThreeDColor black = new ThreeDColor(0x000000); public static ThreeDColor gray = new ThreeDColor(0x808080); public static ThreeDColor blue = new ThreeDColor(0x0000ff); public static ThreeDColor red = new ThreeDColor(0xff0000); public static ThreeDColor yellow = new ThreeDColor(0xffff00); public static ThreeDColor white = new ThreeDColor(0xffffff); public static ThreeDColor orange = new ThreeDColor(0xffc800); public static ThreeDColor green = new ThreeDColor(0x00ff00); public static ThreeDColor purple = new ThreeDColor(0x8000c0); public static ThreeDColor darkCyan = new ThreeDColor(0x00b2b2); public static ThreeDColor pink = new ThreeDColor(0xffafaf); public static ThreeDColor darkGray = new ThreeDColor(0x404040); public static ThreeDColor darkGreen = new ThreeDColor(0x00b200); public static ThreeDColor darkOrange = new ThreeDColor(0xb28c00); public static ThreeDColor darkPurple = new ThreeDColor(0x500080); public static ThreeDColor darkRed = new ThreeDColor(0xb20000); private int rgb; private ThreeDColor brighter; private ThreeDColor darker; static { lightGray.brighter = white; lightGray.darker = gray; lightPurple.brighter = white; lightPurple.darker = purple; black.brighter = darkGray; black.darker = black; gray.brighter = lightGray; gray.darker = darkGray; blue.brighter = darkCyan; blue.darker = darkGray; red.brighter = pink; red.darker = darkRed; yellow.brighter = white; yellow.darker = orange; white.brighter = white; white.darker = lightGray; orange.brighter = yellow; orange.darker = darkOrange; green.brighter = yellow; green.darker = darkGreen; purple.brighter = lightPurple; purple.darker = darkPurple; darkCyan.brighter = lightPurple; darkCyan.darker = darkGray; pink.brighter = white; pink.darker = red; darkGray.brighter = gray; darkGray.darker = black; darkGreen.brighter = green; darkGreen.darker = darkGray; darkOrange.brighter = orange; darkOrange.darker = darkGray; darkPurple.brighter = purple; darkPurple.darker = darkGray; darkRed.brighter = red; darkRed.darker = darkGray; } private ThreeDColor(int rgb) { this.rgb = rgb; } public ThreeDColor brighter() { return brighter; } public ThreeDColor darker() { return darker; } public int getRGB() { return rgb; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -