use of java.awt.FontMetrics in project checkstyle by checkstyle.
the class TreeTable method setColumnsInitialWidth.
/**
* Set initial value of width for columns in table.
*/
private void setColumnsInitialWidth() {
final FontMetrics fontMetrics = getFontMetrics(getFont());
// Six character string to contain "Column" column.
final int widthOfSixCharacterString = fontMetrics.stringWidth("XXXXXX");
// Padding must be added to width for columns to make them fully
// visible in table header.
final int padding = 10;
final int widthOfColumnContainingSixCharacterString = widthOfSixCharacterString + padding;
getColumn("Line").setMaxWidth(widthOfColumnContainingSixCharacterString);
getColumn("Column").setMaxWidth(widthOfColumnContainingSixCharacterString);
final int preferredTreeColumnWidth = Math.toIntExact(Math.round(getPreferredSize().getWidth() * 0.6));
getColumn("Tree").setPreferredWidth(preferredTreeColumnWidth);
// Twenty eight character string to contain "Type" column
final int widthOfTwentyEightCharacterString = fontMetrics.stringWidth("XXXXXXXXXXXXXXXXXXXXXXXXXXXX");
final int preferredTypeColumnWidth = widthOfTwentyEightCharacterString + padding;
getColumn("Type").setPreferredWidth(preferredTypeColumnWidth);
}
use of java.awt.FontMetrics in project hackpad by dropbox.
the class RunProxy method mousePressed.
/**
* Called when a mouse button is pressed.
*/
public void mousePressed(MouseEvent e) {
Font font = fileWindow.textArea.getFont();
FontMetrics metrics = getFontMetrics(font);
int h = metrics.getHeight();
pressLine = e.getY() / h;
}
use of java.awt.FontMetrics in project hackpad by dropbox.
the class RunProxy method update.
/**
* Updates the gutter.
*/
public void update() {
FileTextArea textArea = fileWindow.textArea;
Font font = textArea.getFont();
setFont(font);
FontMetrics metrics = getFontMetrics(font);
int h = metrics.getHeight();
int lineCount = textArea.getLineCount() + 1;
String dummy = Integer.toString(lineCount);
if (dummy.length() < 2) {
dummy = "99";
}
Dimension d = new Dimension();
d.width = metrics.stringWidth(dummy) + 16;
d.height = lineCount * h + 100;
setPreferredSize(d);
setSize(d);
}
use of java.awt.FontMetrics in project hackpad by dropbox.
the class RunProxy method mouseReleased.
/**
* Called when a mouse button is released.
*/
public void mouseReleased(MouseEvent e) {
if (e.getComponent() == this && (e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
int y = e.getY();
Font font = fileWindow.textArea.getFont();
FontMetrics metrics = getFontMetrics(font);
int h = metrics.getHeight();
int line = y / h;
if (line == pressLine) {
fileWindow.toggleBreakPoint(line + 1);
} else {
pressLine = -1;
}
}
}
use of java.awt.FontMetrics in project qi4j-sdk by Qi4j.
the class StackedLayout method getItemMinSize.
private Dimension getItemMinSize(NodeItem node, Dimension minSize) {
if (minSize == null) {
minSize = new Dimension(0, 0);
}
String label = node.getString("name");
FontMetrics fm = Renderer.DEFAULT_GRAPHICS.getFontMetrics(StackedGraphDisplay.FONT);
int width = fm.stringWidth(label);
int height = fm.getHeight();
minSize.setSize(width + INSET + INSET, height + INSET + INSET);
//System.out.println(fm.getAscent());
return minSize;
}
Aggregations