List of usage examples for javax.media.j3d J3DGraphics2D drawString
public abstract void drawString(String str, int x, int y);
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
public void drawLocal2D(J3DGraphics2D vGraphics, LocalToWindow ltw, int w, int h) { if (titles == null || titles.isEmpty()) { return;/*w ww . jav a 2s . c om*/ } Font f = vGraphics.getFont(); Color c = vGraphics.getColor(); for (Title title : titles) { float fh = h * title.getFontHeight(); if (fh < 5) { fh = 5; } Font actualFont = title.getFont().deriveFont(fh); vGraphics.setFont(actualFont); FontMetrics fm = vGraphics.getFontMetrics(); int strWidth = fm.stringWidth(title.getTitle()); vGraphics.setColor(title.getColor()); int xPos = w / 50; if (title.getHorizontalPosition() == Title.CENTER) { xPos = (w - strWidth) / 2; } if (title.getHorizontalPosition() == Title.RIGHT) { xPos = w - strWidth - getWidth() / 50; } vGraphics.drawString(title.getTitle(), xPos, (int) (effectiveHeight * title.getVerticalPosition()) + actualFont.getSize()); } vGraphics.setFont(f); vGraphics.setColor(c); }