styleconstants.java

来自「linux下建立JAVA虚拟机的源码KAFFE」· Java 代码 · 共 1,073 行 · 第 1/3 页

JAVA
1,073
字号
/* StyleConstants.java --   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath 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 Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package javax.swing.text;import java.awt.Color;import java.awt.Component;import javax.swing.Icon;/** * Represents standard attribute keys.  This class also contains a set of  * useful static utility methods for querying and populating an  * {@link AttributeSet}. *  * @since 1.2 */public class StyleConstants{  /**    * A value representing left alignment for the    * {@link ParagraphConstants#Alignment} attribute.    */  public static final int ALIGN_LEFT = 0;  /**    * A value representing center alignment for the    * {@link ParagraphConstants#Alignment} attribute.    */  public static final int ALIGN_CENTER = 1;  /**    * A value representing right alignment for the    * {@link ParagraphConstants#Alignment} attribute.    */  public static final int ALIGN_RIGHT = 2;  /**    * A value representing ful justification for the    * {@link ParagraphConstants#Alignment} attribute.    */  public static final int ALIGN_JUSTIFIED = 3;  /** An alias for {@link CharacterConstants#Background}. */  public static final Object Background = CharacterConstants.Background;  /** An alias for {@link CharacterConstants#BidiLevel}. */  public static final Object BidiLevel = CharacterConstants.BidiLevel;    /** An alias for {@link CharacterConstants#Bold}. */  public static final Object Bold = CharacterConstants.Bold;    /** An alias for {@link CharacterConstants#ComponentAttribute}. */  public static final Object ComponentAttribute       = CharacterConstants.ComponentAttribute;    /** An alias for {@link CharacterConstants#Family}. */  public static final Object Family = CharacterConstants.Family;    /** An alias for {@link CharacterConstants#Family}. */  public static final Object FontFamily = CharacterConstants.Family;      /** An alias for {@link CharacterConstants#Size}. */  public static final Object FontSize = CharacterConstants.Size;    /** An alias for {@link CharacterConstants#Foreground}. */  public static final Object Foreground = CharacterConstants.Foreground;    /** An alias for {@link CharacterConstants#IconAttribute}. */  public static final Object IconAttribute = CharacterConstants.IconAttribute;    /** An alias for {@link CharacterConstants#Italic}. */  public static final Object Italic = CharacterConstants.Italic;    /** An alias for {@link CharacterConstants#Size}. */  public static final Object Size = CharacterConstants.Size;    /** An alias for {@link CharacterConstants#StrikeThrough}. */  public static final Object StrikeThrough = CharacterConstants.StrikeThrough;    /** An alias for {@link CharacterConstants#Subscript}. */  public static final Object Subscript = CharacterConstants.Subscript;    /** An alias for {@link CharacterConstants#Superscript}. */  public static final Object Superscript = CharacterConstants.Superscript;    /** An alias for {@link CharacterConstants#Underline}. */  public static final Object Underline = CharacterConstants.Underline;  /** An alias for {@link ParagraphConstants#Alignment}. */  public static final Object Alignment = ParagraphConstants.Alignment;    /** An alias for {@link ParagraphConstants#FirstLineIndent}. */  public static final Object FirstLineIndent       = ParagraphConstants.FirstLineIndent;    /** An alias for {@link ParagraphConstants#LeftIndent}. */  public static final Object LeftIndent = ParagraphConstants.LeftIndent;    /** An alias for {@link ParagraphConstants#LineSpacing}. */  public static final Object LineSpacing = ParagraphConstants.LineSpacing;    /** An alias for {@link ParagraphConstants#Orientation}. */  public static final Object Orientation = ParagraphConstants.Orientation;    /** An alias for {@link ParagraphConstants#RightIndent}. */  public static final Object RightIndent = ParagraphConstants.RightIndent;    /** An alias for {@link ParagraphConstants#SpaceAbove}. */  public static final Object SpaceAbove = ParagraphConstants.SpaceAbove;    /** An alias for {@link ParagraphConstants#SpaceBelow}. */  public static final Object SpaceBelow = ParagraphConstants.SpaceBelow;    /** An alias for {@link ParagraphConstants#TabSet}. */  public static final Object TabSet = ParagraphConstants.TabSet;  public static final String ComponentElementName = "component";  public static final String IconElementName = "icon";  public static final Object ComposedTextAttribute       = new StyleConstants("composed text");    public static final Object ModelAttribute = new StyleConstants("model");    public static final Object NameAttribute = new StyleConstants("name");    public static final Object ResolveAttribute = new StyleConstants("resolver");  String keyname;  // Package-private to avoid accessor constructor for use by  // subclasses.  StyleConstants(String k)   {    keyname = k;  }  /**   * Returns a string representation of the attribute key.   *    * @return A string representation of the attribute key.   */  public String toString()  {    return keyname;  }  /**   * Returns the alignment specified in the given attributes, or    * {@link #ALIGN_LEFT} if no alignment is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).   *    * @return The alignment (typically one of {@link #ALIGN_LEFT},    *         {@link #ALIGN_RIGHT}, {@link #ALIGN_CENTER} or    *         {@link #ALIGN_JUSTIFIED}).   *            * @see #setAlignment(MutableAttributeSet, int)   */  public static int getAlignment(AttributeSet a)  {    Integer i = (Integer) a.getAttribute(Alignment);    if (i != null)      return i.intValue();    else      return ALIGN_LEFT;        }   /**   * Returns the background color specified in the given attributes, or   * {@link Color#BLACK} if no background color is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).   *    * @return The background color.   *    * @see #setBackground(MutableAttributeSet, Color)   */  public static Color getBackground(AttributeSet a)  {    Color c = (Color) a.getAttribute(Background);    if (c != null)       return c;    else      return Color.BLACK;  }   /**   * Returns the bidi level specified in the given attributes, or    * <code>0</code> if no bidi level is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).   *    * @return The bidi level.   *    * @see #setBidiLevel(MutableAttributeSet, int)   */    public static int getBidiLevel(AttributeSet a)  {    Integer i = (Integer) a.getAttribute(BidiLevel);    if (i != null)      return i.intValue();    else      return 0;  }   /**   * Returns the component specified in the given attributes, or    * <code>null</code> if no component is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).   *    * @return The component (possibly <code>null</code>).   *    * @see #setComponent(MutableAttributeSet, Component)   */      public static Component getComponent(AttributeSet a)  {    Component c = (Component) a.getAttribute(ComponentAttribute);    if (c != null)      return c;    else      return null;  }   /**   * Returns the indentation specified in the given attributes, or    * <code>0.0f</code> if no indentation is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).   *    * @return The indentation.   *    * @see #setFirstLineIndent(MutableAttributeSet, float)   */      public static float getFirstLineIndent(AttributeSet a)  {    Float f = (Float) a.getAttribute(FirstLineIndent);    if (f != null)      return f.floatValue();    else      return 0.0f;  }   /**   * Returns the font family specified in the given attributes, or    * <code>Monospaced</code> if no font family is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).   *    * @return The font family.   *    * @see #setFontFamily(MutableAttributeSet, String)   */      public static String getFontFamily(AttributeSet a)  {    String ff = (String) a.getAttribute(FontFamily);    if (ff != null)      return ff;    else      return "Monospaced";  }   /**   * Returns the font size specified in the given attributes, or    * <code>12</code> if no font size is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).   *    * @return The font size.   *    * @see #setFontSize(MutableAttributeSet, int)   */    public static int getFontSize(AttributeSet a)  {    Integer i = (Integer) a.getAttribute(FontSize);    if (i != null)      return i.intValue();    else      return 12;  }   /**   * Returns the foreground color specified in the given attributes, or   * {@link Color#BLACK} if no foreground color is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).   *    * @return The foreground color.   *    * @see #setForeground(MutableAttributeSet, Color)   */  public static Color getForeground(AttributeSet a)  {    Color c = (Color) a.getAttribute(Foreground);    if (c != null)      return c;    else      return Color.BLACK;  }   /**   * Returns the icon specified in the given attributes, or    * <code>null</code> if no icon is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).   *    * @return The icon (possibly <code>null</code>).   *    * @see #setIcon(MutableAttributeSet, Icon)   */      public static Icon getIcon(AttributeSet a)  {    return (Icon) a.getAttribute(IconAttribute);  }   /**   * Returns the left indentation specified in the given attributes, or    * <code>0.0f</code> if no left indentation is specified.   *    * @param a  the attribute set (<code>null</code> not permitted).

⌨️ 快捷键说明

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