當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicHTML.getHTMLBaseline方法代碼示例

本文整理匯總了Java中javax.swing.plaf.basic.BasicHTML.getHTMLBaseline方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicHTML.getHTMLBaseline方法的具體用法?Java BasicHTML.getHTMLBaseline怎麽用?Java BasicHTML.getHTMLBaseline使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.plaf.basic.BasicHTML的用法示例。


在下文中一共展示了BasicHTML.getHTMLBaseline方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBaseline

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
public int getBaseline(JComponent c, int width, int height) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Width and height must be >= 0");
    }
    JLabel label = (JLabel) c;
    String text = label.getText();
    if (text == null || "".equals(text)) {
        return -1;
    }
    Insets i = label.getInsets();
    Rectangle viewRect = new Rectangle();
    Rectangle textRect = new Rectangle();
    Rectangle iconRect = new Rectangle();
    viewRect.x = i.left;
    viewRect.y = i.top;
    viewRect.width = width - (i.right + viewRect.x);
    viewRect.height = height - (i.bottom + viewRect.y);

    // layout the text and icon
    SeaGlassContext context = getContext(label);
    FontMetrics fm = context.getComponent().getFontMetrics(context.getStyle().getFont(context));
    context.getStyle().getGraphicsUtils(context).layoutText(context, fm, label.getText(), label.getIcon(),
        label.getHorizontalAlignment(), label.getVerticalAlignment(), label.getHorizontalTextPosition(),
        label.getVerticalTextPosition(), viewRect, iconRect, textRect, label.getIconTextGap());
    View view = (View) label.getClientProperty(BasicHTML.propertyKey);
    int baseline;
    if (view != null) {
        baseline = BasicHTML.getHTMLBaseline(view, textRect.width, textRect.height);
        if (baseline >= 0) {
            baseline += textRect.y;
        }
    } else {
        baseline = textRect.y + fm.getAscent();
    }
    context.dispose();
    return baseline;
}
 
開發者ID:khuxtable,項目名稱:seaglass,代碼行數:41,代碼來源:SeaGlassLabelUI.java

示例2: paint

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
public void paint(Graphics g, JComponent c) {
    JToolTip tip = (JToolTip)c;
    Font font = c.getFont();
    FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g, font);
    Dimension size = c.getSize();
    int accelBL;

    g.setColor(c.getForeground());
    // fix for bug 4153892
    String tipText = tip.getTipText();
    if (tipText == null) {
        tipText = "";
    }

    String accelString = getAcceleratorString(tip);
    FontMetrics accelMetrics = SwingUtilities2.getFontMetrics(c, g, smallFont);
    int accelSpacing = calcAccelSpacing(c, accelMetrics, accelString);

    Insets insets = tip.getInsets();
    Rectangle paintTextR = new Rectangle(
        insets.left + 3,
        insets.top,
        size.width - (insets.left + insets.right) - 6 - accelSpacing,
        size.height - (insets.top + insets.bottom));
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        v.paint(g, paintTextR);
        accelBL = BasicHTML.getHTMLBaseline(v, paintTextR.width,
                                              paintTextR.height);
    } else {
        g.setFont(font);
        SwingUtilities2.drawString(tip, g, tipText, paintTextR.x,
                              paintTextR.y + metrics.getAscent());
        accelBL = metrics.getAscent();
    }

    if (!accelString.equals("")) {
        g.setFont(smallFont);
        g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
        SwingUtilities2.drawString(tip, g, accelString,
                                   tip.getWidth() - 1 - insets.right
                                       - accelSpacing
                                       + padSpaceBetweenStrings
                                       - 3,
                                   paintTextR.y + accelBL);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:48,代碼來源:MetalToolTipUI.java

示例3: getBaseline

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public int getBaseline(JComponent c, int width, int height) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    if (width < 0 || height < 0) {
        throw new IllegalArgumentException(
                "Width and height must be >= 0");
    }
    AbstractButton b = (AbstractButton)c;
    String text = b.getText();
    if (text == null || "".equals(text)) {
        return -1;
    }
    Insets i = b.getInsets();
    Rectangle viewRect = new Rectangle();
    Rectangle textRect = new Rectangle();
    Rectangle iconRect = new Rectangle();
    viewRect.x = i.left;
    viewRect.y = i.top;
    viewRect.width = width - (i.right + viewRect.x);
    viewRect.height = height - (i.bottom + viewRect.y);

    // layout the text and icon
    SynthContext context = getContext(b);
    FontMetrics fm = context.getComponent().getFontMetrics(
        context.getStyle().getFont(context));
    context.getStyle().getGraphicsUtils(context).layoutText(
        context, fm, b.getText(), b.getIcon(),
        b.getHorizontalAlignment(), b.getVerticalAlignment(),
        b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
        viewRect, iconRect, textRect, b.getIconTextGap());
    View view = (View)b.getClientProperty(BasicHTML.propertyKey);
    int baseline;
    if (view != null) {
        baseline = BasicHTML.getHTMLBaseline(view, textRect.width,
                                             textRect.height);
        if (baseline >= 0) {
            baseline += textRect.y;
        }
    }
    else {
        baseline = textRect.y + fm.getAscent();
    }
    context.dispose();
    return baseline;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:51,代碼來源:SynthButtonUI.java

示例4: getBaseline

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public int getBaseline(JComponent c, int width, int height) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    if (width < 0 || height < 0) {
        throw new IllegalArgumentException(
                "Width and height must be >= 0");
    }
    AbstractButton b = (AbstractButton)c;
    String text = b.getText();
    if (text == null || "".equals(text)) {
        return -1;
    }
    Insets i = b.getInsets();
    Rectangle viewRect = new Rectangle();
    Rectangle textRect = new Rectangle();
    Rectangle iconRect = new Rectangle();
    viewRect.x = i.left;
    viewRect.y = i.top;
    viewRect.width = width - (i.right + viewRect.x);
    viewRect.height = height - (i.bottom + viewRect.y);

    // layout the text and icon
    SynthContext context = getContext(b);
    FontMetrics fm = context.getComponent().getFontMetrics(
        context.getStyle().getFont(context));
    context.getStyle().getGraphicsUtils(context).layoutText(
        context, fm, b.getText(), b.getIcon(),
        b.getHorizontalAlignment(), b.getVerticalAlignment(),
        b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
        viewRect, iconRect, textRect, b.getIconTextGap());
    View view = (View)b.getClientProperty(BasicHTML.propertyKey);
    int baseline;
    if (view != null) {
        baseline = BasicHTML.getHTMLBaseline(view, textRect.width,
                                             textRect.height);
        if (baseline >= 0) {
            baseline += textRect.y;
        }
    }
    else {
        baseline = textRect.y + fm.getAscent();
    }
    return baseline;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:50,代碼來源:SynthButtonUI.java

示例5: getBaseline

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
 * @see javax.swing.plaf.basic.BasicButtonUI#getBaseline(javax.swing.JComponent,
 *      int, int)
 */
public int getBaseline(JComponent c, int width, int height) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }

    if (width < 0 || height < 0) {
        throw new IllegalArgumentException("Width and height must be >= 0");
    }

    AbstractButton b    = (AbstractButton) c;
    String         text = b.getText();

    if (text == null || "".equals(text)) {
        return -1;
    }

    Insets    i        = b.getInsets();
    Rectangle viewRect = new Rectangle();
    Rectangle textRect = new Rectangle();
    Rectangle iconRect = new Rectangle();

    viewRect.x      = i.left;
    viewRect.y      = i.top;
    viewRect.width  = width - (i.right + viewRect.x);
    viewRect.height = height - (i.bottom + viewRect.y);

    // layout the text and icon
    SeaGlassContext context = getContext(b);
    FontMetrics     fm = context.getComponent().getFontMetrics(context.getStyle().getFont(context));

    context.getStyle().getGraphicsUtils(context).layoutText(context, fm, b.getText(), b.getIcon(), b.getHorizontalAlignment(),
                                                            b.getVerticalAlignment(), b.getHorizontalTextPosition(),
                                                            b.getVerticalTextPosition(), viewRect, iconRect, textRect,
                                                            b.getIconTextGap());
    View view     = (View) b.getClientProperty(BasicHTML.propertyKey);
    int  baseline;

    if (view != null) {
        baseline = BasicHTML.getHTMLBaseline(view, textRect.width, textRect.height);
        if (baseline >= 0) {
            baseline += textRect.y;
        }
    } else {
        baseline = textRect.y + fm.getAscent();
    }

    context.dispose();
    return baseline;
}
 
開發者ID:khuxtable,項目名稱:seaglass,代碼行數:54,代碼來源:SeaGlassButtonUI.java

示例6: getBaseline

import javax.swing.plaf.basic.BasicHTML; //導入方法依賴的package包/類
/**
 * @inheritDoc
 */
@Override
public int getBaseline(JComponent c, int width, int height) {
    if (c == null) {
        throw new NullPointerException("Component must be non-null");
    }
    if (width < 0 || height < 0) {
        throw new IllegalArgumentException(
                "Width and height must be >= 0");
    }
    AbstractButton b = (AbstractButton)c;
    String text = b.getText();
    if (text == null || "".equals(text)) {
        return -1;
    }
    Insets i = b.getInsets();
    Rectangle viewRect = new Rectangle();
    Rectangle textRect = new Rectangle();
    Rectangle iconRect = new Rectangle();
    viewRect.x = i.left;
    viewRect.y = i.top;
    viewRect.width = width - (i.right + viewRect.x);
    viewRect.height = height - (i.bottom + viewRect.y);

    // layout the text and icon
    SynthContext context = getContext(b);
    FontMetrics fm = context.getComponent().getFontMetrics(
        context.getStyle().getFont(context));
    context.getStyle().getGraphicsUtils(context).layoutText(
        context, fm, b.getText(), b.getIcon(),
        b.getHorizontalAlignment(), b.getVerticalAlignment(),
        b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
        viewRect, iconRect, textRect, b.getIconTextGap());
    View view = (View)b.getClientProperty(BasicHTML.propertyKey);
    int baseline;
    if (view != null) {
        baseline = BasicHTML.getHTMLBaseline(view, textRect.width,
                                             textRect.height);
        if (baseline >= 0) {
            baseline += textRect.y;
        }
    }
    else {
        baseline = textRect.y + fm.getAscent();
    }
    context.dispose();
    return baseline;
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:51,代碼來源:SynthButtonUI.java


注:本文中的javax.swing.plaf.basic.BasicHTML.getHTMLBaseline方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。