use of java.awt.Font 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.Font 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.Font 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.Font in project Fling by entertailion.
the class DragHereIcon method makeUI.
/**
* Display a custom icon with file drag-and-drop support
*
* @param flingFrame
* the parent frame
* @return
*/
public static JComponent makeUI(final FlingFrame flingFrame) {
JLabel label = new JLabel(new DragHereIcon());
label.setText("<html>Drag <b>Media</b> Here");
label.setVerticalTextPosition(SwingConstants.BOTTOM);
label.setHorizontalTextPosition(SwingConstants.CENTER);
label.setForeground(Color.GRAY);
label.setFont(new Font("Monospace", Font.PLAIN, 24));
JPanel p = new JPanel();
p.add(label);
p.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
new FileDrop(p, new FileDrop.Listener() {
public void filesDropped(java.io.File[] files) {
if (files != null && files.length > 0) {
try {
String file = files[0].getCanonicalPath();
Log.d(LOG_TAG, file);
Properties systemProperties = System.getProperties();
// EmbeddedServer.serveFile
systemProperties.setProperty(EmbeddedServer.CURRENT_FILE, file);
flingFrame.sendMediaUrl(file);
} catch (IOException e) {
}
}
}
});
// end FileDrop.Listener
return p;
}
use of java.awt.Font in project android_frameworks_base by ParanoidAndroid.
the class Paint_Delegate method updateFontObject.
/**
* Update the {@link Font} object from the typeface, text size and scaling
*/
@SuppressWarnings("deprecation")
private void updateFontObject() {
if (mTypeface != null) {
// Get the fonts from the TypeFace object.
List<Font> fonts = mTypeface.getFonts();
// create new font objects as well as FontMetrics, based on the current text size
// and skew info.
ArrayList<FontInfo> infoList = new ArrayList<FontInfo>(fonts.size());
for (Font font : fonts) {
FontInfo info = new FontInfo();
info.mFont = font.deriveFont(mTextSize);
if (mTextScaleX != 1.0 || mTextSkewX != 0) {
// TODO: support skew
info.mFont = info.mFont.deriveFont(new AffineTransform(mTextScaleX, mTextSkewX, 0, 1, 0, 0));
}
info.mMetrics = Toolkit.getDefaultToolkit().getFontMetrics(info.mFont);
infoList.add(info);
}
mFonts = Collections.unmodifiableList(infoList);
}
}
Aggregations