Example usage for javax.media.j3d J3DGraphics2D getColor

List of usage examples for javax.media.j3d J3DGraphics2D getColor

Introduction

In this page you can find the example usage for javax.media.j3d J3DGraphics2D getColor.

Prototype

public abstract Color getColor();

Source Link

Document

Gets this graphics context's current color.

Usage

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 . ja v  a  2 s  .  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);
}