Search in sources :

Example 1 with Font

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;
}
Also used : FontMetrics(java.awt.FontMetrics) Font(java.awt.Font) Point(java.awt.Point)

Example 2 with Font

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);
}
Also used : FontMetrics(java.awt.FontMetrics) Dimension(java.awt.Dimension) Font(java.awt.Font) Point(java.awt.Point)

Example 3 with Font

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;
        }
    }
}
Also used : FontMetrics(java.awt.FontMetrics) Point(java.awt.Point) Font(java.awt.Font)

Example 4 with Font

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;
}
Also used : JPanel(javax.swing.JPanel) JLabel(javax.swing.JLabel) IOException(java.io.IOException) Properties(java.util.Properties) Font(java.awt.Font)

Example 5 with Font

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);
    }
}
Also used : ArrayList(java.util.ArrayList) AffineTransform(java.awt.geom.AffineTransform) Font(java.awt.Font)

Aggregations

Font (java.awt.Font)413 Color (java.awt.Color)63 JLabel (javax.swing.JLabel)59 Graphics2D (java.awt.Graphics2D)58 Dimension (java.awt.Dimension)50 FontMetrics (java.awt.FontMetrics)43 JPanel (javax.swing.JPanel)38 JScrollPane (javax.swing.JScrollPane)34 JButton (javax.swing.JButton)30 Insets (java.awt.Insets)29 ArrayList (java.util.ArrayList)28 BufferedImage (java.awt.image.BufferedImage)27 Point (java.awt.Point)26 FontRenderContext (java.awt.font.FontRenderContext)25 AffineTransform (java.awt.geom.AffineTransform)21 IOException (java.io.IOException)21 BorderLayout (java.awt.BorderLayout)20 JTextArea (javax.swing.JTextArea)19 TextLayout (java.awt.font.TextLayout)18 BoxLayout (javax.swing.BoxLayout)18