appfont.java

来自「FuncPlotter is a combined Java applicati」· Java 代码 · 共 156 行

JAVA
156
字号
/*====================================================================*\AppFont.javaApplication font 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/>.\*====================================================================*/// IMPORTSimport gui.FontEx;import java.awt.Component;import java.awt.Font;//----------------------------------------------------------------------// APPLICATION FONT ENUMERATIONpublic enum AppFont{//////////////////////////////////////////////////////////////////////////  Constants////////////////////////////////////////////////////////////////////////    MAIN        ( "main",       "Main" ),    TEXT_FIELD  ( "textField",  "Text field" ),    COMBO_BOX   ( "comboBox",   "Combo box" ),    PLOT        ( "plot",       "Plot" );//////////////////////////////////////////////////////////////////////////  Constructors////////////////////////////////////////////////////////////////////////    private AppFont( String key,                     String text )    {        this.key = key;        this.text = text;    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Class methods////////////////////////////////////////////////////////////////////////    public static int getNumFonts( )    {        return values( ).length;    }    //------------------------------------------------------------------    public static AppFont get( int index )    {        return ( ((index >= 0) && (index < values( ).length)) ? values( )[index] : null );    }    //------------------------------------------------------------------    public static String[] getKeys( )    {        String[] keys = new String[values( ).length];        for ( int i = 0; i < keys.length; ++i )            keys[i] = values( )[i].key;        return keys;    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods : overriding methods////////////////////////////////////////////////////////////////////////    public String toString( )    {        return text;    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods////////////////////////////////////////////////////////////////////////    public String getKey( )    {        return key;    }    //------------------------------------------------------------------    public Font getFont( )    {        return FontEx.getFont( ordinal( ) );    }    //------------------------------------------------------------------    public FontEx getFontEx( )    {        return FontEx.getFontEx( ordinal( ) );    }    //------------------------------------------------------------------    public void setFont( Component component )    {        FontEx.setFont( component, ordinal( ) );    }    //------------------------------------------------------------------    public void setFontEx( FontEx font )    {        FontEx.setFontEx( ordinal( ), font );    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance variables////////////////////////////////////////////////////////////////////////    private String  key;    private String  text;}//----------------------------------------------------------------------

⌨️ 快捷键说明

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