📄 listcolour.java
字号:
/*====================================================================*\ListColour.javaList colour enumeration.------------------------------------------------------------------------This file is part of FuncPlotter, a combined Java application and appletfor plotting explicit functions in one variable.Copyright 2005-2007 Andy Morgan-Richards.FuncPlotter is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation, either version 3 of the License, or (at youroption) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith this program. If not, see <http://www.gnu.org/licenses/>.\*====================================================================*/// PACKAGEpackage gui;//----------------------------------------------------------------------// IMPORTSimport java.awt.Color;import javax.swing.UIManager;//----------------------------------------------------------------------// LIST COLOUR ENUMERATIONpublic enum ListColour{////////////////////////////////////////////////////////////////////////// Constants//////////////////////////////////////////////////////////////////////// BACKGROUND ( "background", new Color( 240, 240, 232 ) ), SELECTION_BACKGROUND( "selectionBackground", new Color( 176, 192, 208 ) ), FOREGROUND ( "foreground", Color.BLACK ), SELECTION_FOREGROUND( "selectionForeground", Color.BLACK ); private static final String KEY_PREFIX = "List.";////////////////////////////////////////////////////////////////////////// Constructors//////////////////////////////////////////////////////////////////////// private ListColour( String key, Color defaultColour ) { this.key = key; this.defaultColour = defaultColour; } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Class methods//////////////////////////////////////////////////////////////////////// private static void init( ) { int numColours = 0; Color[] colours = new Color[values( ).length]; for ( int i = 0; i < colours.length; ++i ) { colours[i] = UIManager.getColor( KEY_PREFIX + values( )[i].key ); if ( colours[i] == null ) break; ++numColours; } for ( int i = 0; i < colours.length; ++i ) { ListColour value = values( )[i]; value.colour = (numColours == values( ).length) ? colours[i] : value.defaultColour; } } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance methods//////////////////////////////////////////////////////////////////////// public Color getColour( ) { if ( colour == null ) init( ); return colour; } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance variables//////////////////////////////////////////////////////////////////////// private String key; private Color defaultColour; private Color colour;}//----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -