当前位置: 首页>>代码示例>>Java>>正文


Java FontLib.getFont方法代码示例

本文整理汇总了Java中prefuse.util.FontLib.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java FontLib.getFont方法的具体用法?Java FontLib.getFont怎么用?Java FontLib.getFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在prefuse.util.FontLib的用法示例。


在下文中一共展示了FontLib.getFont方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeTextDimensions

import prefuse.util.FontLib; //导入方法依赖的package包/类
private String computeTextDimensions(
	VisualItem item, String text,
	double size )
{
	// put item font in temp member variable
	m_font = item.getFont();
	// scale the font as needed
	if ( size != 1 ) {
		m_font = FontLib.getFont(
			m_font.getName(), m_font.getStyle(),
			size * m_font.getSize()
		);
	}

	FontMetrics fm = DEFAULT_GRAPHICS.getFontMetrics( m_font );
	StringBuffer str = null;

	// compute the number of lines and the maximum width
	int nlines = 1, w = 0, start = 0, end = text.indexOf( m_delim );
	m_textDim.width = 0;
	String line;
	for ( ; end >= 0; ++nlines ) {
		w = fm.stringWidth( line = text.substring( start, end ) );
		// abbreviate line as needed
		if ( m_maxTextWidth > -1 && w > m_maxTextWidth ) {
			if ( str == null )
				str = new StringBuffer( text.substring( 0, start ) );
			str.append( StringLib.abbreviate( line, fm, m_maxTextWidth ) );
			str.append( m_delim );
			w = m_maxTextWidth;
		}
		else if ( str != null ) {
			str.append( line ).append( m_delim );
		}
		// update maximum width and substring indices
		m_textDim.width = Math.max( m_textDim.width, w );
		start = end + 1;
		end = text.indexOf( m_delim, start );
	}
	w = fm.stringWidth( line = text.substring( start ) );
	// abbreviate line as needed
	if ( m_maxTextWidth > -1 && w > m_maxTextWidth ) {
		if ( str == null )
			str = new StringBuffer( text.substring( 0, start ) );
		str.append( StringLib.abbreviate( line, fm, m_maxTextWidth ) );
		w = m_maxTextWidth;
	}
	else if ( str != null ) {
		str.append( line );
	}
	// update maximum width
	m_textDim.width = Math.max( m_textDim.width, w );

	// compute the text height
	m_textDim.height = fm.getHeight() * nlines;

	return str == null ? text : str.toString();
}
 
开发者ID:kartoFlane,项目名称:hiervis,代码行数:59,代码来源:StringRenderer.java

示例2: computeTextDimensions

import prefuse.util.FontLib; //导入方法依赖的package包/类
private String computeTextDimensions(VisualItem item, String text,
                                     double size)
{
    // put item font in temp member variable
    m_font = item.getFont();
    // scale the font as needed
    if ( size != 1 ) {
        m_font = FontLib.getFont(m_font.getName(), m_font.getStyle(),
                                 size*m_font.getSize());
    }
    m_font2 = FontLib.getFont(m_font.getName(), m_font.getStyle(),
            size*m_font.getSize() * 0.8);
    m_font_nic = FontLib.getFont(m_font.getName(), m_font.getStyle() | Font.ITALIC,
    		size*m_font.getSize());
    
    FontMetrics fm = DEFAULT_GRAPHICS.getFontMetrics(m_font);
    FontMetrics fm2 = DEFAULT_GRAPHICS.getFontMetrics(m_font2);
    StringBuffer str = null;
    
    // compute the number of lines and the maximum width
    int nlines = 1, w = 0, start = 0, end = text.indexOf(m_delim);
    if (text.endsWith("\n")) {
    	--nlines;
    }
    m_textDim.width = 0;
    m_headerDim.width = 0;
    String line;
    boolean f = true;
    for ( ; end >= 0; ++nlines ) {
        w = (f? fm : fm2).stringWidth(line=text.substring(start,end));
        f = false;
        // abbreviate line as needed
        if ( m_maxTextWidth > -1 && w > m_maxTextWidth ) {
            if ( str == null )
                str = new StringBuffer(text.substring(0,start));
            str.append(StringLib.abbreviate(line, fm, m_maxTextWidth));
            str.append(m_delim);
            w = m_maxTextWidth;
        } else if ( str != null ) {
            str.append(line).append(m_delim);
        }
        // update maximum width and substring indices
        m_textDim.width = Math.max(m_textDim.width, w);
        start = end+1;
        end = text.indexOf(m_delim, start);
    }
    w = (f? fm : fm2).stringWidth(line=text.substring(start));
    // abbreviate line as needed
    if ( m_maxTextWidth > -1 && w > m_maxTextWidth ) {
        if ( str == null )
            str = new StringBuffer(text.substring(0,start));
        str.append(StringLib.abbreviate(line, fm, m_maxTextWidth));
        w = m_maxTextWidth;
    } else if ( str != null ) {
        str.append(line);
    }
    // update maximum width
    m_textDim.width = Math.max(m_textDim.width, w);
    
    // compute the text height
    m_textDim.height = fm.getHeight() + fm2.getHeight() * (nlines - 1);
    
    m_headerDim.width = m_textDim.width;
    m_headerDim.height = fm.getHeight();
    
    return str==null ? text : str.toString();
}
 
开发者ID:P15,项目名称:jailer,代码行数:68,代码来源:TableRenderer.java

示例3: computeTextDimensions

import prefuse.util.FontLib; //导入方法依赖的package包/类
private String computeTextDimensions(VisualItem item, String text,
                                     double size)
{
    // put item font in temp member variable
    m_font = item.getFont();
    // scale the font as needed
    if ( size != 1 ) {
        m_font = FontLib.getFont(m_font.getName(), m_font.getStyle(),
                                 size*m_font.getSize());
    }
    
    AwtFontMetrics fm = new AwtFontMetrics(m_font);
    StringBuffer str = null;
    
    // compute the number of lines and the maximum width
    int nlines = 1, w = 0, start = 0, end = text.indexOf(m_delim);
    m_textDim.width = 0;
    String line;
    for ( ; end >= 0; ++nlines ) {
        w = fm.stringWidth(line=text.substring(start,end));
        // abbreviate line as needed
        if ( m_maxTextWidth > -1 && w > m_maxTextWidth ) {
            if ( str == null )
                str = new StringBuffer(text.substring(0,start));
            str.append(StringLib.abbreviate(line, fm, m_maxTextWidth));
            str.append(m_delim);
            w = m_maxTextWidth;
        } else if ( str != null ) {
            str.append(line).append(m_delim);
        }
        // update maximum width and substring indices
        m_textDim.width = Math.max(m_textDim.width, w);
        start = end+1;
        end = text.indexOf(m_delim, start);
    }
    w = fm.stringWidth(line=text.substring(start));
    // abbreviate line as needed
    if ( m_maxTextWidth > -1 && w > m_maxTextWidth ) {
        if ( str == null )
            str = new StringBuffer(text.substring(0,start));
        str.append(StringLib.abbreviate(line, fm, m_maxTextWidth));
        w = m_maxTextWidth;
    } else if ( str != null ) {
        str.append(line);
    }
    // update maximum width
    m_textDim.width = Math.max(m_textDim.width, w);
    
    // compute the text height
    m_textDim.height = fm.getHeight() * nlines;
    
    return str==null ? text : str.toString();
}
 
开发者ID:dritanlatifi,项目名称:AndroidPrefuse,代码行数:54,代码来源:LabelRenderer.java

示例4: getFont

import prefuse.util.FontLib; //导入方法依赖的package包/类
@Override
public Font getFont(VisualItem item) {
	return FontLib.getFont(this.name, item.getDouble(fontSizeFieldName));
}
 
开发者ID:jdepend,项目名称:cooper,代码行数:5,代码来源:JDepnedFontAction.java


注:本文中的prefuse.util.FontLib.getFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。