StyleHelper.java :  » XML-UI » XUI » net » xoetrope » optional » resources » Java Open Source

Java Open Source » XML UI » XUI 
XUI » net » xoetrope » optional » resources » StyleHelper.java
package net.xoetrope.optional.resources;

import java.awt.Font;
import net.xoetrope.xui.style.XStyle;

/**
 * A helper for conversion of xstyles to some more useful types.
 * <p> Copyright (c) Xoetrope Ltd., 2002-2004</p>
 * <p> $Revision: 1.1 $</p>
 * <p> License: see License.txt</p>
 */
public class StyleHelper
{
  public static Font getFont( XStyle style )
  {
    String fontface = style.getStyleAsString( style.FONT_FACE );
    int fontsize = style.getStyleAsInt( style.FONT_SIZE );
    int fontitalic = style.getStyleAsInt( style.FONT_ITALIC );
    int fontweight = style.getStyleAsInt( style.FONT_WEIGHT );
    int fontStyle = 0;
    if ( fontweight == 1 )
      fontStyle = Font.BOLD;
    if ( fontitalic == 1 )
      fontStyle = fontStyle | Font.ITALIC;

    return new Font( fontface, fontStyle, fontsize );
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.