本文整理汇总了Java中edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator.drawString方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsDecorator.drawString方法的具体用法?Java GraphicsDecorator.drawString怎么用?Java GraphicsDecorator.drawString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator
的用法示例。
在下文中一共展示了GraphicsDecorator.drawString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderSet
import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void renderSet(
RenderContext<ViwnNode, ViwnEdge> rc,
Point2D p,
ViwnNodeSet node) {
GraphicsDecorator g = rc.getGraphicsContext();
String text = "" + node.getSynsets().size();
Font f = new Font("Sansserif", Font.BOLD, 14);
Font old_font = g.getFont();
g.setFont(f);
FontMetrics metrics = g.getFontMetrics(g.getFont());
int width = metrics.stringWidth(text);
int height = metrics.getHeight();
g.setColor(Color.black);
g.drawString(text,
(int) p.getX() - width / 2,
(int) p.getY());
width = metrics.stringWidth("...");
g.drawString("...",
(int) p.getX() - width / 2,
(int) p.getY() + 0.25f * height);
g.setFont(old_font);
}
示例2: renderLexiconMarker
import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void renderLexiconMarker(ViwnNodeSynset node, Point2D.Float pos,
GraphicsDecorator g) {
Shape lexicon = new Area(new RoundRectangle2D.Float(pos.x - 40, pos.y - 17, 23, 10, 12.5f, 5));
g.setColor(ViwnNodeSynset.PosBgColors.get(node.getPos()));
g.fillRoundRect(Math.round(pos.x - 40), Math.round(pos.y - 17), 23, 10, 12, 5);
g.setColor(Color.black);
g.draw(lexicon);
Font smallFont = new Font("Tahoma", Font.BOLD, 6);
g.setFont(smallFont);
g.drawString(node.getLexiconLabel(), pos.x - 38, pos.y - 10);
}
示例3: renderWord
import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void renderWord(
RenderContext<ViwnNode, ViwnEdge> rc,
Point2D p,
ViwnNodeWord node) {
GraphicsDecorator g = rc.getGraphicsContext();
String text = node.getLabel();
FontMetrics metrics = g.getFontMetrics(g.getFont());
int width = metrics.stringWidth(text);
g.setColor(Color.black);
g.drawString(text,
(int) p.getX() - width / 2,
(int) p.getY() + 5);
}
示例4: labelEdge
import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
@Override
public void labelEdge(RenderContext<V, E> rc, Layout<V, E> layout, E e, String label) {
if (Strings.isNullOrEmpty(label)) {
return;
}
Shape edgeShape = JungUtils.getTransformedEdgeShape(rc, layout, e);
if (edgeShape == null) {
return;
}
Line2D line = JungUtils.getLineInMiddle(edgeShape);
GraphicsDecorator g = rc.getGraphicsContext();
Font font = rc.getEdgeFontTransformer().transform(e);
double width = font.getStringBounds(label, g.getFontRenderContext()).getWidth();
AffineTransform old = g.getTransform();
AffineTransform trans = new AffineTransform(old);
double angle = Math.atan2(line.getY2() - line.getY1(), line.getX2() - line.getX1());
if (angle < -Math.PI / 2) {
angle += Math.PI;
} else if (angle > Math.PI / 2) {
angle -= Math.PI;
}
trans.translate(line.getX1(), line.getY1());
trans.rotate(angle);
g.setTransform(trans);
g.setColor(rc.getPickedEdgeState().isPicked(e) ? Color.GREEN : Color.BLACK);
g.setFont(rc.getEdgeFontTransformer().transform(e));
g.drawString(label, (int) (-width / 2), 0);
g.setTransform(old);
}