本文整理汇总了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();
}
示例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();
}
示例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();
}
示例4: getFont
import prefuse.util.FontLib; //导入方法依赖的package包/类
@Override
public Font getFont(VisualItem item) {
return FontLib.getFont(this.name, item.getDouble(fontSizeFieldName));
}