本文整理汇总了Java中prefuse.visual.VisualItem.getFont方法的典型用法代码示例。如果您正苦于以下问题:Java VisualItem.getFont方法的具体用法?Java VisualItem.getFont怎么用?Java VisualItem.getFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.visual.VisualItem
的用法示例。
在下文中一共展示了VisualItem.getFont方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
public void render(Graphics2D g, VisualItem item) {
// render the edge line
super.render(g, item);
// Add label:
Shape s = getShape(item);
if (s != null) {
Rectangle2D r = s.getBounds2D();
boolean useInt = 1.5 > Math.max(g.getTransform().getScaleX(), g.getTransform().getScaleY());
if (m_font == null)
m_font = item.getFont();
// scale the font as needed
FontMetrics fm = DEFAULT_GRAPHICS.getFontMetrics(m_font);
if (item.canGetString("name")) {
g.setFont(m_font);
g.setPaint(ColorLib.getColor(item.getTextColor()));
drawString(g, fm, item.getString("name"), useInt, r.getX(), r.getY(), r.getWidth(), r.getHeight());
}
}
}
示例2: process
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* @see prefuse.action.ItemAction#process(prefuse.visual.VisualItem, double)
*/
public void process(VisualItem item, double frac) {
Font f = getFont(item);
Font o = item.getFont();
item.setStartFont(o);
item.setEndFont(f);
item.setFont(f);
}
示例3: computeTextDimensions
import prefuse.visual.VisualItem; //导入方法依赖的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();
}
示例4: computeTextDimensions
import prefuse.visual.VisualItem; //导入方法依赖的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();
}
示例5: computeTextDimensions
import prefuse.visual.VisualItem; //导入方法依赖的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();
}
示例6: getRawShape
import prefuse.visual.VisualItem; //导入方法依赖的package包/类
/**
* @see prefuse.render.AbstractShapeRenderer#getRawShape(prefuse.visual.VisualItem)
*/
protected Shape getRawShape(VisualItem item) {
double x1 = item.getDouble(VisualItem.X);
double y1 = item.getDouble(VisualItem.Y);
double x2 = item.getDouble(VisualItem.X2);
double y2 = item.getDouble(VisualItem.Y2);
m_line.setLine(x1,y1,x2,y2);
if ( !item.canGetString(VisualItem.LABEL) )
return m_line;
String label = item.getString(VisualItem.LABEL);
if ( label == null ) return m_line;
AwtFontMetrics fm = new AwtFontMetrics( item.getFont()) ;
m_ascent = fm.getAscent() + 1; // TODO for Dritan: check why is it necesary to add 1 pixel to the ascent?
int h = fm.getHeight();
int w = fm.stringWidth(label);
double tx, ty;
// get text x-coord
switch ( m_xalign ) {
case Constants.FAR_RIGHT:
tx = x2 + 2;
break;
case Constants.FAR_LEFT:
tx = x1 - w - 2;
break;
case Constants.CENTER:
tx = x1 + (x2-x1)/2 - w/2;
break;
case Constants.RIGHT:
tx = x2 - w;
break;
case Constants.LEFT:
default:
tx = x1;
}
// get text y-coord
switch ( m_yalign ) {
case Constants.FAR_TOP:
ty = y1-h;
break;
case Constants.FAR_BOTTOM:
ty = y2;
break;
case Constants.CENTER:
ty = y1 + (y2-y1)/2 - h/2;
break;
case Constants.TOP:
ty = y1;
break;
case Constants.BOTTOM:
default:
ty = y2-h;
}
m_box.setFrame(tx,ty,w,h);
return m_box;
}