Java Code Examples for java.awt.peer.FontPeer

The following are top voted examples for showing how to use java.awt.peer.FontPeer. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: cn1   File: LinuxFontManager.java   View source code 6 votes vote down vote up
public FontPeer createPhysicalFontPeer(String name, int style, int size) {
    LinuxFont peer;
    int familyIndex = getFamilyIndex(name);
    if (familyIndex != -1){
        // !! we use family names from the list with cached families because 
        // they are differ from the family names in xlfd structure, in xlfd 
        // family names mostly in lower case.
        peer = new LinuxFont(getFamily(familyIndex), style, size);
        peer.setFamily(getFamily(familyIndex));
        return peer;
    }
    int faceIndex = getFaceIndex(name); 
    if (faceIndex != -1){
        style |= LinuxNativeFont.getFontStyle(faceIndex);
        name = LinuxNativeFont.getFamilyFromFaceIndex(faceIndex);

        peer = new LinuxFont(name, style, size);
        return peer;
    }
    
    return null;
}
 
Example 2
Project: cn1   File: WinFontManager.java   View source code 6 votes vote down vote up
@Override
public FontPeer createPhysicalFontPeer(String name, int style, int size) {
    WindowsFont peer;
    if (isFamilyExist(name)){
        peer = new WindowsFont(name, style, size);
        peer.setFamily(name);
        return peer;
    }
    int faceIndex = getFaceIndex(name); 
    if (faceIndex != -1){
        style |= NativeFont.fontStyles[faceIndex];
        name = NativeFont.getFamily(faceIndex);

        peer = new WindowsFont(name, style, size);
        return peer;
    }
    
    return null;
}
 
Example 3
Project: cn1   File: FontManager.java   View source code 6 votes vote down vote up
/**
 * Returns default font peer class with "Default" name that is usually 
 * used when font with specified font names and style doesn't exsist 
 * on a system. 
 * 
 * @param style style of the font
 * @param size size of the font
 */
public FontPeer getDefaultFont(int style, int size){
    updateFontsTable();
    
    FontPeer peer = null;
    String key = DEFAULT_NAME.concat(String.valueOf(style)).
                concat(String.valueOf(size));
    
    HashMapReference hmr   = fontsTable.get(key);
    if (hmr != null) {
        peer = hmr.get();
    }

    if (peer == null) {
        peer = createDefaultFont(style, size);
        
        ((FontPeerImpl)peer).setFamily(DEFAULT_NAME);
        ((FontPeerImpl)peer).setPSName(DEFAULT_NAME);
        ((FontPeerImpl)peer).setFontName(DEFAULT_NAME);

        fontsTable.put(key, new HashMapReference(key, peer, queue));
    }

    return peer;
}
 
Example 4
Project: cn1   File: FLFontManager.java   View source code 6 votes vote down vote up
@Override
public FontPeer createPhysicalFontPeer(String name, int style, int size) {
    FontPeerImpl peer = null;        
    
    if (isFontExistInList(name, style)){         
        try {
            peer = new FLFontPeer(name, style, size);
            
            peer.setFamily(name);
        } catch(NullPointerException e) {
            peer = new FLFontPeer(DEFAULT_NAME, style, size);
            
            peer.setFamily(DEFAULT_NAME);
        }
    } else {
        peer = new FLFontPeer(DEFAULT_NAME, style, size);
        
        peer.setFamily(DEFAULT_NAME);
    }
    
    return peer;
}
 
Example 5
Project: cn1   File: FLFontManager.java   View source code 6 votes vote down vote up
/**
 * Returns default font peer class with "Default" name that is usually 
 * used when font with specified font names and style doesn't exsist 
 * on a system. 
 * 
 * @param style style of the font
 * @param size size of the font
 */
@Override
public FontPeer getDefaultFont(int style, int size){
    
    FontPeer peer = null;
    String key = DEFAULT_NAME.concat(String.valueOf(style)).
                concat(String.valueOf(size));
    
    HashMapReference hmr   = fontsTable.get(key);
    if (hmr != null) {
        peer = hmr.get();
    }

    if (peer == null) {
        peer = createDefaultFont(style, size);
        
        ((FontPeerImpl)peer).setFamily(DEFAULT_NAME);
        ((FontPeerImpl)peer).setPSName(DEFAULT_NAME);
        ((FontPeerImpl)peer).setFontName(DEFAULT_NAME);

        fontsTable.put(key, new HashMapReference(key, peer, queue));
    }

    return peer;
}
 
Example 6
Project: freeVM   File: LinuxFontManager.java   View source code 6 votes vote down vote up
public FontPeer createPhysicalFontPeer(String name, int style, int size) {
    LinuxFont peer;
    int familyIndex = getFamilyIndex(name);
    if (familyIndex != -1){
        // !! we use family names from the list with cached families because 
        // they are differ from the family names in xlfd structure, in xlfd 
        // family names mostly in lower case.
        peer = new LinuxFont(getFamily(familyIndex), style, size);
        peer.setFamily(getFamily(familyIndex));
        return peer;
    }
    int faceIndex = getFaceIndex(name); 
    if (faceIndex != -1){
        style |= LinuxNativeFont.getFontStyle(faceIndex);
        name = LinuxNativeFont.getFamilyFromFaceIndex(faceIndex);

        peer = new LinuxFont(name, style, size);
        return peer;
    }
    
    return null;
}
 
Example 7
Project: freeVM   File: WinFontManager.java   View source code 6 votes vote down vote up
@Override
public FontPeer createPhysicalFontPeer(String name, int style, int size) {
    WindowsFont peer;
    if (isFamilyExist(name)){
        peer = new WindowsFont(name, style, size);
        peer.setFamily(name);
        return peer;
    }
    int faceIndex = getFaceIndex(name); 
    if (faceIndex != -1){
        style |= NativeFont.fontStyles[faceIndex];
        name = NativeFont.getFamily(faceIndex);

        peer = new WindowsFont(name, style, size);
        return peer;
    }
    
    return null;
}
 
Example 8
Project: freeVM   File: FontManager.java   View source code 6 votes vote down vote up
/**
 * Returns default font peer class with "Default" name that is usually 
 * used when font with specified font names and style doesn't exsist 
 * on a system. 
 * 
 * @param style style of the font
 * @param size size of the font
 */
public FontPeer getDefaultFont(int style, int size){
    updateFontsTable();
    
    FontPeer peer = null;
    String key = DEFAULT_NAME.concat(String.valueOf(style)).
                concat(String.valueOf(size));
    
    HashMapReference hmr   = fontsTable.get(key);
    if (hmr != null) {
        peer = hmr.get();
    }

    if (peer == null) {
        peer = createDefaultFont(style, size);
        
        ((FontPeerImpl)peer).setFamily(DEFAULT_NAME);
        ((FontPeerImpl)peer).setPSName(DEFAULT_NAME);
        ((FontPeerImpl)peer).setFontName(DEFAULT_NAME);

        fontsTable.put(key, new HashMapReference(key, peer, queue));
    }

    return peer;
}
 
Example 9
Project: freeVM   File: LinuxFontManager.java   View source code 6 votes vote down vote up
public FontPeer createPhysicalFontPeer(String name, int style, int size) {
    LinuxFont peer;
    int familyIndex = getFamilyIndex(name);
    if (familyIndex != -1){
        // !! we use family names from the list with cached families because 
        // they are differ from the family names in xlfd structure, in xlfd 
        // family names mostly in lower case.
        peer = new LinuxFont(getFamily(familyIndex), style, size);
        peer.setFamily(getFamily(familyIndex));
        return peer;
    }
    int faceIndex = getFaceIndex(name); 
    if (faceIndex != -1){
        style |= LinuxNativeFont.getFontStyle(faceIndex);
        name = LinuxNativeFont.getFamilyFromFaceIndex(faceIndex);

        peer = new LinuxFont(name, style, size);
        return peer;
    }
    
    return null;
}
 
Example 10
Project: freeVM   File: WinFontManager.java   View source code 6 votes vote down vote up
@Override
public FontPeer createPhysicalFontPeer(String name, int style, int size) {
    WindowsFont peer;
    if (isFamilyExist(name)){
        peer = new WindowsFont(name, style, size);
        peer.setFamily(name);
        return peer;
    }
    int faceIndex = getFaceIndex(name); 
    if (faceIndex != -1){
        style |= NativeFont.fontStyles[faceIndex];
        name = NativeFont.getFamily(faceIndex);

        peer = new WindowsFont(name, style, size);
        return peer;
    }
    
    return null;
}
 
Example 11
Project: freeVM   File: FontManager.java   View source code 6 votes vote down vote up
/**
 * Returns default font peer class with "Default" name that is usually 
 * used when font with specified font names and style doesn't exsist 
 * on a system. 
 * 
 * @param style style of the font
 * @param size size of the font
 */
public FontPeer getDefaultFont(int style, int size){
    updateFontsTable();
    
    FontPeer peer = null;
    String key = DEFAULT_NAME.concat(String.valueOf(style)).
                concat(String.valueOf(size));
    
    HashMapReference hmr   = fontsTable.get(key);
    if (hmr != null) {
        peer = hmr.get();
    }

    if (peer == null) {
        peer = createDefaultFont(style, size);
        
        ((FontPeerImpl)peer).setFamily(DEFAULT_NAME);
        ((FontPeerImpl)peer).setPSName(DEFAULT_NAME);
        ((FontPeerImpl)peer).setFontName(DEFAULT_NAME);

        fontsTable.put(key, new HashMapReference(key, peer, queue));
    }

    return peer;
}
 
Example 12
Project: freeVM   File: FLFontManager.java   View source code 6 votes vote down vote up
@Override
public FontPeer createPhysicalFontPeer(String name, int style, int size) {
    FontPeerImpl peer = null;        
    
    if (isFontExistInList(name, style)){         
        try {
            peer = new FLFontPeer(name, style, size);
            
            peer.setFamily(name);
        } catch(NullPointerException e) {
            peer = new FLFontPeer(DEFAULT_NAME, style, size);
            
            peer.setFamily(DEFAULT_NAME);
        }
    } else {
        peer = new FLFontPeer(DEFAULT_NAME, style, size);
        
        peer.setFamily(DEFAULT_NAME);
    }
    
    return peer;
}
 
Example 13
Project: freeVM   File: FLFontManager.java   View source code 6 votes vote down vote up
/**
 * Returns default font peer class with "Default" name that is usually 
 * used when font with specified font names and style doesn't exsist 
 * on a system. 
 * 
 * @param style style of the font
 * @param size size of the font
 */
@Override
public FontPeer getDefaultFont(int style, int size){
    
    FontPeer peer = null;
    String key = DEFAULT_NAME.concat(String.valueOf(style)).
                concat(String.valueOf(size));
    
    HashMapReference hmr   = fontsTable.get(key);
    if (hmr != null) {
        peer = hmr.get();
    }

    if (peer == null) {
        peer = createDefaultFont(style, size);
        
        ((FontPeerImpl)peer).setFamily(DEFAULT_NAME);
        ((FontPeerImpl)peer).setPSName(DEFAULT_NAME);
        ((FontPeerImpl)peer).setFontName(DEFAULT_NAME);

        fontsTable.put(key, new HashMapReference(key, peer, queue));
    }

    return peer;
}
 
Example 14
Project: OpenJSharp   File: Font.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 15
Project: OpenJSharp   File: Font.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 16
Project: jdk8u-jdk   File: Font.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 17
Project: openjdk-jdk10   File: Font.java   View source code 5 votes vote down vote up
/**
 * Gets the peer of this {@code Font}.
 *
 * @return the peer of the {@code Font}.
 */
private FontPeer getFontPeer() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        if (tk instanceof ComponentFactory) {
            peer = ((ComponentFactory) tk).getFontPeer(name, style);
        }
    }
    return peer;
}
 
Example 18
Project: openjdk-jdk10   File: HeadlessToolkit.java   View source code 5 votes vote down vote up
@Override
public FontPeer getFontPeer(String name, int style) {
    if (componentFactory != null) {
        return componentFactory.getFontPeer(name, style);
    }
    return null;
}
 
Example 19
Project: openjdk9   File: Font.java   View source code 5 votes vote down vote up
/**
 * Gets the peer of this {@code Font}.
 *
 * @return the peer of the {@code Font}.
 */
private FontPeer getFontPeer() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        if (tk instanceof ComponentFactory) {
            peer = ((ComponentFactory) tk).getFontPeer(name, style);
        }
    }
    return peer;
}
 
Example 20
Project: openjdk9   File: HeadlessToolkit.java   View source code 5 votes vote down vote up
@Override
public FontPeer getFontPeer(String name, int style) {
    if (componentFactory != null) {
        return componentFactory.getFontPeer(name, style);
    }
    return null;
}
 
Example 21
Project: Java8CN   File: Font.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 22
Project: jdk8u_jdk   File: Font.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 23
Project: lookaside_java-1.8.0-openjdk   File: Font.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 24
Project: javify   File: XGraphics2D.java   View source code 5 votes vote down vote up
public void setFont(Font f)
{
  super.setFont(f);
  FontPeer p = getFont().getPeer();
  if (p instanceof XFontPeer)
    {
      XFontPeer xFontPeer = (XFontPeer) p;
      xgc.set_font(xFontPeer.getXFont());
    }
}
 
Example 25
Project: javify   File: XGraphics2D.java   View source code 5 votes vote down vote up
public void drawString(String s, int x, int y)
{
  FontPeer p = getFont().getPeer();
  if (p instanceof XFontPeer)
    {
      int tx = (int) transform.getTranslateX();
      int ty = (int) transform.getTranslateY();
      xdrawable.text(xgc, x + tx, y + ty, s);
    }
  else
    {
      super.drawString(s, x, y);
    }
}
 
Example 26
Project: javify   File: GtkToolkit.java   View source code 5 votes vote down vote up
/**
 * Private method that allows size to be set at initialization time.
 */
private FontPeer getFontPeer (String name, int style, int size)
{
  Map<TextAttribute,Object> attrs = new HashMap<TextAttribute,Object>();
  ClasspathFontPeer.copyStyleToAttrs (style, attrs);
  ClasspathFontPeer.copySizeToAttrs (size, attrs);
  return getClasspathFontPeer (name, attrs);
}
 
Example 27
Project: javify   File: QtToolkit.java   View source code 5 votes vote down vote up
protected FontPeer getFontPeer(String name,
                               int style)
{
  Map attrs = new HashMap ();
  ClasspathFontPeer.copyStyleToAttrs(style, attrs);
  ClasspathFontPeer.copySizeToAttrs(12, attrs); // Default size is 12.
  return getClasspathFontPeer (name, attrs);
}
 
Example 28
Project: jvm-stm   File: XGraphics2D.java   View source code 5 votes vote down vote up
public void setFont(Font f)
{
  super.setFont(f);
  FontPeer p = getFont().getPeer();
  if (p instanceof XFontPeer)
    {
      XFontPeer xFontPeer = (XFontPeer) p;
      xgc.set_font(xFontPeer.getXFont());
    }
}
 
Example 29
Project: jvm-stm   File: XGraphics2D.java   View source code 5 votes vote down vote up
public void drawString(String s, int x, int y)
{
  FontPeer p = getFont().getPeer();
  if (p instanceof XFontPeer)
    {
      int tx = (int) transform.getTranslateX();
      int ty = (int) transform.getTranslateY();
      xdrawable.text(xgc, x + tx, y + ty, s);
    }
  else
    {
      super.drawString(s, x, y);
    }
}
 
Example 30
Project: jvm-stm   File: GtkToolkit.java   View source code 5 votes vote down vote up
/**
 * Private method that allows size to be set at initialization time.
 */
private FontPeer getFontPeer (String name, int style, int size) 
{
  Map<TextAttribute,Object> attrs = new HashMap<TextAttribute,Object>();
  ClasspathFontPeer.copyStyleToAttrs (style, attrs);
  ClasspathFontPeer.copySizeToAttrs (size, attrs);
  return getClasspathFontPeer (name, attrs);
}
 
Example 31
Project: jvm-stm   File: QtToolkit.java   View source code 5 votes vote down vote up
protected FontPeer getFontPeer(String name,
		 int style)
{
  Map attrs = new HashMap ();
  ClasspathFontPeer.copyStyleToAttrs(style, attrs);
  ClasspathFontPeer.copySizeToAttrs(12, attrs); // Default size is 12.
  return getClasspathFontPeer (name, attrs);
}
 
Example 32
Project: VarJ   File: Font.java   View source code 5 votes vote down vote up
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 33
Project: jdk-1.7-annotated   File: Font.java   View source code 5 votes vote down vote up
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 34
Project: infobip-open-jdk-8   File: Font.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 35
Project: jdk8u-dev-jdk   File: Font.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 36
Project: jdk7-jdk   File: Font.java   View source code 5 votes vote down vote up
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 37
Project: openjdk-source-code-learn   File: Font.java   View source code 5 votes vote down vote up
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 38
Project: OLD-OpenJDK8   File: Font.java   View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() {
    if(peer == null) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.peer = tk.getFontPeer(name, style);
    }
    return peer;
}
 
Example 39
Project: cn1   File: FontManager.java   View source code 5 votes vote down vote up
/**
 * Returns platform-dependent Font peer created from the specified 
 * Font object from the table with cached FontPeers instances.
 * 
 * Note, this method checks whether FontPeer with specified parameters 
 * exists in the table with cached FontPeers' instances. If there is no needed 
 * instance - it is created and cached.
 * 
 * @param fontName name of the font 
 * @param _fontStyle style of the font 
 * @param size font size
 * 
 * @return platform dependent FontPeer implementation created from 
 * the specified parameters
 */
public FontPeer getFontPeer(String fontName, int _fontStyle, int size) {
    
    updateFontsTable();
    
    FontPeer peer = null;
    String key; 
    String name;
    int fontStyle = _fontStyle;
    
    int logicalIndex = getLogicalFaceIndex(fontName);
    
    if (logicalIndex != -1){
        name = getLogicalFaceFromFont(fontStyle, logicalIndex);
        fontStyle = getStyleFromLogicalFace(name);
        key = name.concat(String.valueOf(size));
    } else {
        name = fontName;
        key = name.concat(String.valueOf(fontStyle)).
                concat(String.valueOf(size));
    }
    
    HashMapReference hmr   = fontsTable.get(key);
    if (hmr != null) {
        peer = hmr.get();
    }

    if (peer == null) {
        peer = createFontPeer(name, fontStyle, size, logicalIndex);
        if (peer == null){
            peer = getFontPeer(DIALOG_NAME, fontStyle, size);
        }
        fontsTable.put(key, new HashMapReference(key, peer, queue));
    }

    return peer;
}
 
Example 40
Project: cn1   File: FontManager.java   View source code 5 votes vote down vote up
/**
 * Returns instance of font peer (logical or physical) according to the 
 * specified parameters.
 * 
 * @param name font face name
 * @param style style of the font
 * @param size size of the font
 * @param logicalIndex index of the logical face name in LOGICAL_FONT_FACES 
 * array or -1 if desired font peer is not logical.
 */
protected FontPeer createFontPeer(String name, int style, int size, int logicalIndex){
    FontPeer peer;
    if (logicalIndex != -1){
        peer = createLogicalFontPeer(name, style, size);
    }else {
        peer = createPhysicalFontPeer(name, style, size);
    }
    
    return peer;
}