List of usage examples for java.awt.font LineMetrics getUnderlineOffset
public abstract float getUnderlineOffset();
From source file:ded.ui.DiagramController.java
/** The core of the paint routine, after we decide whether to interpose * another buffer. *//*from ww w .j a v a 2s .c o m*/ private void innerPaint(Graphics g) { super.paint(g); // I do not know the proper way to get a font set automatically // in a Graphics object. Calling JComponent.setFont has gotten // me nowhere. Setting it myself when I first get control // seems to work; but note that I have to do this *after* // calling super.paint(). g.setFont(this.dedWindow.diagramFont); // Filename label. if (this.diagram.drawFileName && !this.fileName.isEmpty()) { String name = new File(this.fileName).getName(); FontMetrics fm = g.getFontMetrics(); LineMetrics lm = fm.getLineMetrics(name, g); int x = fileNameLabelMargin; int y = fileNameLabelMargin + (int) lm.getAscent(); g.drawString(name, x, y); y += (int) lm.getUnderlineOffset() + 1 /*...*/; g.drawLine(x, y, x + fm.stringWidth(name), y); } // Controllers. for (Controller c : this.controllers) { if (c.isSelected()) { c.paintSelectionBackground(g); } c.paint(g); } // Lasso rectangle. if (this.mode == Mode.DCM_RECT_LASSO) { Rectangle r = this.getLassoRect(); g.drawRect(r.x, r.y, r.width, r.height); } // Current focused Component. if (debugFocus) { KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Component fo = kfm.getFocusOwner(); g.drawString("Focus: " + fo, 3, this.getHeight() - 22); } // Mode label. if (this.mode != Mode.DCM_SELECT) { g.drawString("Mode: " + this.mode.description, 3, this.getHeight() - 4); } else if (this.fpsMeasurementMode) { this.fpsFrameCount++; long current = System.currentTimeMillis(); long millis = current - this.fpsStartMillis; if (millis > 1000) { // Update the FPS measurement with the results for this // interval. this.fpsSampleCount++; this.fpsMeasurement = "FPS: " + this.fpsFrameCount + " (millis=" + millis + ", samples=" + this.fpsSampleCount + ")"; // Reset the counters. this.fpsStartMillis = current; this.fpsFrameCount = 0; } g.drawString(this.fpsMeasurement + " (Ctrl+G to stop)", 3, this.getHeight() - 4); } }