Search in sources :

Example 31 with View

use of javax.swing.text.View in project jdk8u_jdk by JetBrains.

the class AquaTabbedPaneCopyFromBasicUI method layoutLabel.

protected void layoutLabel(final int tabPlacement, final FontMetrics metrics, final int tabIndex, final String title, final Icon icon, final Rectangle tabRect, final Rectangle iconRect, final Rectangle textRect, final boolean isSelected) {
    textRect.x = textRect.y = iconRect.x = iconRect.y = 0;
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        tabPane.putClientProperty("html", v);
    }
    SwingUtilities.layoutCompoundLabel(tabPane, metrics, title, icon, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.CENTER, SwingConstants.TRAILING, tabRect, iconRect, textRect, textIconGap);
    tabPane.putClientProperty("html", null);
    final int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);
    final int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);
    iconRect.x += xNudge;
    iconRect.y += yNudge;
    textRect.x += xNudge;
    textRect.y += yNudge;
}
Also used : View(javax.swing.text.View)

Example 32 with View

use of javax.swing.text.View in project jdk8u_jdk by JetBrains.

the class AquaTabbedPaneUI method paintTitle.

protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }
    if (title == null)
        return;
    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        // sja fix getTheme().setThemeTextColor(g, isSelected, isPressed && tracking, tabPane.isEnabledAt(tabIndex));
        if (tabPane.isEnabledAt(tabIndex)) {
            g2d.setColor(Color.black);
        } else {
            g2d.setColor(Color.gray);
        }
    } else {
        g2d.setColor(color);
    }
    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
Also used : View(javax.swing.text.View)

Example 33 with View

use of javax.swing.text.View in project GCViewer by chewiebug.

the class AboutDialog method calculatePreferredSize.

/**
     * Returns the preferred size to set a component at in order to render
     * an html string.  You can specify the size of one dimension.
     *
     * @see <a href="http://blog.nobel-joergensen.com/2009/01/18/changing-preferred-size-of-a-html-jlabel/">reference for this implementation</a>
     */
private Dimension calculatePreferredSize(JLabel labelWithHtmlText, boolean width, int preferredSize) {
    View view = (View) labelWithHtmlText.getClientProperty(BasicHTML.propertyKey);
    view.setSize(width ? preferredSize : 0, width ? 0 : preferredSize);
    float w = view.getPreferredSpan(View.X_AXIS);
    float h = view.getPreferredSpan(View.Y_AXIS);
    return new Dimension((int) Math.ceil(w), (int) Math.ceil(h));
}
Also used : Dimension(java.awt.Dimension) View(javax.swing.text.View)

Example 34 with View

use of javax.swing.text.View in project Botnak by Gocnak.

the class BaseTabbedPaneUI method calculateTabWidth.

protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
    Insets insets = getTabInsets(tabPlacement, tabIndex);
    int width = insets.left + insets.right + 3;
    Component tabComponent = getTabComponentAt(tabIndex);
    if (tabComponent != null) {
        width += tabComponent.getPreferredSize().width;
    } else {
        Icon icon = getIconForTab(tabIndex);
        if (icon != null) {
            width += icon.getIconWidth() + textIconGap;
        }
        View v = getTextViewForTab(tabIndex);
        if (v != null) {
            // html
            width += (int) v.getPreferredSpan(View.X_AXIS);
        } else {
            // plain text
            String title = tabPane.getTitleAt(tabIndex);
            width += SwingUtilities.computeStringWidth(metrics, title);
        }
    }
    return width;
}
Also used : View(javax.swing.text.View)

Example 35 with View

use of javax.swing.text.View in project Botnak by Gocnak.

the class BaseTabbedPaneUI method calculateTabHeight.

protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) {
    int height = 0;
    Component tabComponent = getTabComponentAt(tabIndex);
    if (tabComponent != null) {
        height = tabComponent.getPreferredSize().height;
    } else {
        View v = getTextViewForTab(tabIndex);
        if (v != null) {
            // html
            height += (int) v.getPreferredSpan(View.Y_AXIS);
        } else {
            // plain text
            height += fontHeight;
        }
        Icon icon = getIconForTab(tabIndex);
        if (icon != null) {
            height = Math.max(height, icon.getIconHeight());
        }
    }
    Insets ti = getTabInsets(tabPlacement, tabIndex);
    height += ti.top + ti.bottom + 2;
    return height;
}
Also used : View(javax.swing.text.View)

Aggregations

View (javax.swing.text.View)66 Dimension (java.awt.Dimension)4 Rectangle (java.awt.Rectangle)4 UIResource (javax.swing.plaf.UIResource)4 FontMetrics (java.awt.FontMetrics)3 Insets (java.awt.Insets)3 Color (java.awt.Color)2 Border (javax.swing.border.Border)2 JBColor (com.intellij.ui.JBColor)1 JBGradientPaint (com.intellij.ui.JBGradientPaint)1 Container (java.awt.Container)1 Font (java.awt.Font)1 Graphics2D (java.awt.Graphics2D)1 Point (java.awt.Point)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 PrinterException (java.awt.print.PrinterException)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 ColorUIResource (javax.swing.plaf.ColorUIResource)1