Java 类javax.swing.plaf.basic.BasicHTML 实例源码

项目:incubator-netbeans    文件:TopComponent.java   
/** Sets localized display name of this <code>TopComponent</code>.
 * @param displayName localized display name which is set
 * @since 4.13 */
public void setDisplayName(String displayName) {
    String old = this.displayName;

    if ((displayName == old) || ((displayName != null) && displayName.equals(old))) {
        return;
    }

    // warning if display name contains html tags
    if (BasicHTML.isHTMLString(displayName)) {
        Logger.getAnonymousLogger().warning(
            "Call of " + getClass().getName() + ".setDisplayName(\"" + displayName + "\")" +
            " shouldn't contain any HTML tags. Please use " + getClass().getName() + ".setHtmlDisplayName(String)" +
            "for such purpose. For details please see http://www.netbeans.org/issues/show_bug.cgi?id=66777.");
    }

    this.displayName = displayName;
    firePropertyChange("displayName", old, displayName); // NOI18N

    WindowManager.getDefault().topComponentDisplayNameChanged(this, displayName);
}
项目:OpenJSharp    文件:TitledBorder.java   
/**
 * Creates a TitledBorder instance with the specified border,
 * title, title-justification, title-position, title-font, and
 * title-color.
 *
 * @param border  the border
 * @param title  the title the border should display
 * @param titleJustification the justification for the title
 * @param titlePosition the position for the title
 * @param titleFont the font of the title
 * @param titleColor the color of the title
 */
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor) {
    this.title = title;
    this.border = border;
    this.titleFont = titleFont;
    this.titleColor = titleColor;

    setTitleJustification(titleJustification);
    setTitlePosition(titlePosition);

    this.label = new JLabel();
    this.label.setOpaque(false);
    this.label.putClientProperty(BasicHTML.propertyKey, null);
}
项目:OpenJSharp    文件:SynthGraphicsUtils.java   
/**
 * Returns the minimum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMinimumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width -= v.getPreferredSpan(View.X_AXIS) -
                      v.getMinimumSpan(View.X_AXIS);
    }
    return size;
}
项目:OpenJSharp    文件:SynthGraphicsUtils.java   
/**
 * Returns the maximum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMaximumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width += v.getMaximumSpan(View.X_AXIS) -
                      v.getPreferredSpan(View.X_AXIS);
    }
    return size;
}
项目:OpenJSharp    文件:SynthToolTipUI.java   
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    JToolTip tip = (JToolTip)context.getComponent();

    Insets insets = tip.getInsets();
    View v = (View)tip.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        Rectangle paintTextR = new Rectangle(insets.left, insets.top,
              tip.getWidth() - (insets.left + insets.right),
              tip.getHeight() - (insets.top + insets.bottom));
        v.paint(g, paintTextR);
    } else {
        g.setColor(context.getStyle().getColor(context,
                                               ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(
            context, g, tip.getTipText(), insets.left, insets.top, -1);
    }
}
项目:OpenJSharp    文件:SynthToolTipUI.java   
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JToolTip)e.getSource());
    }
    String name = e.getPropertyName();
    if (name.equals("tiptext") || "font".equals(name) ||
            "foreground".equals(name)) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JToolTip tip = ((JToolTip) e.getSource());
        String text = tip.getTipText();
        BasicHTML.updateRenderer(tip, text);
    }
}
项目:jdk8u-jdk    文件:TitledBorder.java   
/**
 * Creates a TitledBorder instance with the specified border,
 * title, title-justification, title-position, title-font, and
 * title-color.
 *
 * @param border  the border
 * @param title  the title the border should display
 * @param titleJustification the justification for the title
 * @param titlePosition the position for the title
 * @param titleFont the font of the title
 * @param titleColor the color of the title
 */
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor) {
    this.title = title;
    this.border = border;
    this.titleFont = titleFont;
    this.titleColor = titleColor;

    setTitleJustification(titleJustification);
    setTitlePosition(titlePosition);

    this.label = new JLabel();
    this.label.setOpaque(false);
    this.label.putClientProperty(BasicHTML.propertyKey, null);
}
项目:jdk8u-jdk    文件:SynthGraphicsUtils.java   
/**
 * Returns the minimum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMinimumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width -= v.getPreferredSpan(View.X_AXIS) -
                      v.getMinimumSpan(View.X_AXIS);
    }
    return size;
}
项目:jdk8u-jdk    文件:SynthGraphicsUtils.java   
/**
 * Returns the maximum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMaximumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width += v.getMaximumSpan(View.X_AXIS) -
                      v.getPreferredSpan(View.X_AXIS);
    }
    return size;
}
项目:jdk8u-jdk    文件:SynthToolTipUI.java   
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    JToolTip tip = (JToolTip)context.getComponent();

    Insets insets = tip.getInsets();
    View v = (View)tip.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        Rectangle paintTextR = new Rectangle(insets.left, insets.top,
              tip.getWidth() - (insets.left + insets.right),
              tip.getHeight() - (insets.top + insets.bottom));
        v.paint(g, paintTextR);
    } else {
        g.setColor(context.getStyle().getColor(context,
                                               ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(
            context, g, tip.getTipText(), insets.left, insets.top, -1);
    }
}
项目:jdk8u-jdk    文件:SynthToolTipUI.java   
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JToolTip)e.getSource());
    }
    String name = e.getPropertyName();
    if (name.equals("tiptext") || "font".equals(name) ||
            "foreground".equals(name)) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JToolTip tip = ((JToolTip) e.getSource());
        String text = tip.getTipText();
        BasicHTML.updateRenderer(tip, text);
    }
}
项目:openjdk-jdk10    文件:TitledBorder.java   
/**
 * Creates a TitledBorder instance with the specified border,
 * title, title-justification, title-position, title-font, and
 * title-color.
 *
 * @param border  the border
 * @param title  the title the border should display
 * @param titleJustification the justification for the title
 * @param titlePosition the position for the title
 * @param titleFont the font of the title
 * @param titleColor the color of the title
 */
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor) {
    this.title = title;
    this.border = border;
    this.titleFont = titleFont;
    this.titleColor = titleColor;

    setTitleJustification(titleJustification);
    setTitlePosition(titlePosition);

    this.label = new JLabel();
    this.label.setOpaque(false);
    this.label.putClientProperty(BasicHTML.propertyKey, null);
    installPropertyChangeListeners();
}
项目:openjdk-jdk10    文件:SynthToolTipUI.java   
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    JToolTip tip = (JToolTip)context.getComponent();

    Insets insets = tip.getInsets();
    View v = (View)tip.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        Rectangle paintTextR = new Rectangle(insets.left, insets.top,
              tip.getWidth() - (insets.left + insets.right),
              tip.getHeight() - (insets.top + insets.bottom));
        v.paint(g, paintTextR);
    } else {
        g.setColor(context.getStyle().getColor(context,
                                               ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(
            context, g, tip.getTipText(), insets.left, insets.top, -1);
    }
}
项目:openjdk-jdk10    文件:SynthToolTipUI.java   
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JToolTip)e.getSource());
    }
    String name = e.getPropertyName();
    if (name.equals("tiptext") || "font".equals(name) ||
            "foreground".equals(name)) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JToolTip tip = ((JToolTip) e.getSource());
        String text = tip.getTipText();
        BasicHTML.updateRenderer(tip, text);
    }
}
项目:openjdk9    文件:TitledBorder.java   
/**
 * Creates a TitledBorder instance with the specified border,
 * title, title-justification, title-position, title-font, and
 * title-color.
 *
 * @param border  the border
 * @param title  the title the border should display
 * @param titleJustification the justification for the title
 * @param titlePosition the position for the title
 * @param titleFont the font of the title
 * @param titleColor the color of the title
 */
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor) {
    this.title = title;
    this.border = border;
    this.titleFont = titleFont;
    this.titleColor = titleColor;

    setTitleJustification(titleJustification);
    setTitlePosition(titlePosition);

    this.label = new JLabel();
    this.label.setOpaque(false);
    this.label.putClientProperty(BasicHTML.propertyKey, null);
    installPropertyChangeListeners();
}
项目:openjdk9    文件:SynthToolTipUI.java   
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    JToolTip tip = (JToolTip)context.getComponent();

    Insets insets = tip.getInsets();
    View v = (View)tip.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        Rectangle paintTextR = new Rectangle(insets.left, insets.top,
              tip.getWidth() - (insets.left + insets.right),
              tip.getHeight() - (insets.top + insets.bottom));
        v.paint(g, paintTextR);
    } else {
        g.setColor(context.getStyle().getColor(context,
                                               ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(
            context, g, tip.getTipText(), insets.left, insets.top, -1);
    }
}
项目:openjdk9    文件:SynthToolTipUI.java   
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JToolTip)e.getSource());
    }
    String name = e.getPropertyName();
    if (name.equals("tiptext") || "font".equals(name) ||
            "foreground".equals(name)) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JToolTip tip = ((JToolTip) e.getSource());
        String text = tip.getTipText();
        BasicHTML.updateRenderer(tip, text);
    }
}
项目:Java8CN    文件:TitledBorder.java   
/**
 * Creates a TitledBorder instance with the specified border,
 * title, title-justification, title-position, title-font, and
 * title-color.
 *
 * @param border  the border
 * @param title  the title the border should display
 * @param titleJustification the justification for the title
 * @param titlePosition the position for the title
 * @param titleFont the font of the title
 * @param titleColor the color of the title
 */
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor) {
    this.title = title;
    this.border = border;
    this.titleFont = titleFont;
    this.titleColor = titleColor;

    setTitleJustification(titleJustification);
    setTitlePosition(titlePosition);

    this.label = new JLabel();
    this.label.setOpaque(false);
    this.label.putClientProperty(BasicHTML.propertyKey, null);
}
项目:Java8CN    文件:SynthGraphicsUtils.java   
/**
 * Returns the minimum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMinimumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width -= v.getPreferredSpan(View.X_AXIS) -
                      v.getMinimumSpan(View.X_AXIS);
    }
    return size;
}
项目:Java8CN    文件:SynthGraphicsUtils.java   
/**
 * Returns the maximum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMaximumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width += v.getMaximumSpan(View.X_AXIS) -
                      v.getPreferredSpan(View.X_AXIS);
    }
    return size;
}
项目:Java8CN    文件:SynthToolTipUI.java   
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    JToolTip tip = (JToolTip)context.getComponent();

    Insets insets = tip.getInsets();
    View v = (View)tip.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        Rectangle paintTextR = new Rectangle(insets.left, insets.top,
              tip.getWidth() - (insets.left + insets.right),
              tip.getHeight() - (insets.top + insets.bottom));
        v.paint(g, paintTextR);
    } else {
        g.setColor(context.getStyle().getColor(context,
                                               ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(
            context, g, tip.getTipText(), insets.left, insets.top, -1);
    }
}
项目:Java8CN    文件:SynthToolTipUI.java   
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JToolTip)e.getSource());
    }
    String name = e.getPropertyName();
    if (name.equals("tiptext") || "font".equals(name) ||
            "foreground".equals(name)) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JToolTip tip = ((JToolTip) e.getSource());
        String text = tip.getTipText();
        BasicHTML.updateRenderer(tip, text);
    }
}
项目:jdk8u_jdk    文件:TitledBorder.java   
/**
 * Creates a TitledBorder instance with the specified border,
 * title, title-justification, title-position, title-font, and
 * title-color.
 *
 * @param border  the border
 * @param title  the title the border should display
 * @param titleJustification the justification for the title
 * @param titlePosition the position for the title
 * @param titleFont the font of the title
 * @param titleColor the color of the title
 */
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor) {
    this.title = title;
    this.border = border;
    this.titleFont = titleFont;
    this.titleColor = titleColor;

    setTitleJustification(titleJustification);
    setTitlePosition(titlePosition);

    this.label = new JLabel();
    this.label.setOpaque(false);
    this.label.putClientProperty(BasicHTML.propertyKey, null);
}
项目:jdk8u_jdk    文件:SynthGraphicsUtils.java   
/**
 * Returns the minimum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMinimumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width -= v.getPreferredSpan(View.X_AXIS) -
                      v.getMinimumSpan(View.X_AXIS);
    }
    return size;
}
项目:jdk8u_jdk    文件:SynthGraphicsUtils.java   
/**
 * Returns the maximum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMaximumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width += v.getMaximumSpan(View.X_AXIS) -
                      v.getPreferredSpan(View.X_AXIS);
    }
    return size;
}
项目:jdk8u_jdk    文件:SynthToolTipUI.java   
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    JToolTip tip = (JToolTip)context.getComponent();

    Insets insets = tip.getInsets();
    View v = (View)tip.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        Rectangle paintTextR = new Rectangle(insets.left, insets.top,
              tip.getWidth() - (insets.left + insets.right),
              tip.getHeight() - (insets.top + insets.bottom));
        v.paint(g, paintTextR);
    } else {
        g.setColor(context.getStyle().getColor(context,
                                               ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(
            context, g, tip.getTipText(), insets.left, insets.top, -1);
    }
}
项目:jdk8u_jdk    文件:SynthToolTipUI.java   
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JToolTip)e.getSource());
    }
    String name = e.getPropertyName();
    if (name.equals("tiptext") || "font".equals(name) ||
            "foreground".equals(name)) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JToolTip tip = ((JToolTip) e.getSource());
        String text = tip.getTipText();
        BasicHTML.updateRenderer(tip, text);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:TitledBorder.java   
/**
 * Creates a TitledBorder instance with the specified border,
 * title, title-justification, title-position, title-font, and
 * title-color.
 *
 * @param border  the border
 * @param title  the title the border should display
 * @param titleJustification the justification for the title
 * @param titlePosition the position for the title
 * @param titleFont the font of the title
 * @param titleColor the color of the title
 */
@ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
public TitledBorder(Border border,
                    String title,
                    int titleJustification,
                    int titlePosition,
                    Font titleFont,
                    Color titleColor) {
    this.title = title;
    this.border = border;
    this.titleFont = titleFont;
    this.titleColor = titleColor;

    setTitleJustification(titleJustification);
    setTitlePosition(titlePosition);

    this.label = new JLabel();
    this.label.setOpaque(false);
    this.label.putClientProperty(BasicHTML.propertyKey, null);
}
项目:lookaside_java-1.8.0-openjdk    文件:SynthGraphicsUtils.java   
/**
 * Returns the minimum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMinimumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width -= v.getPreferredSpan(View.X_AXIS) -
                      v.getMinimumSpan(View.X_AXIS);
    }
    return size;
}
项目:lookaside_java-1.8.0-openjdk    文件:SynthGraphicsUtils.java   
/**
 * Returns the maximum size needed to properly render an icon and text.
 *
 * @param ss SynthContext
 * @param font Font to use
 * @param text Text to layout
 * @param icon Icon to layout
 * @param hAlign horizontal alignment
 * @param vAlign vertical alignment
 * @param hTextPosition horizontal text position
 * @param vTextPosition vertical text position
 * @param iconTextGap gap between icon and text
 * @param mnemonicIndex Index into text to render the mnemonic at, -1
 *        indicates no mnemonic.
 */
public Dimension getMaximumSize(SynthContext ss, Font font, String text,
                  Icon icon, int hAlign, int vAlign, int hTextPosition,
                  int vTextPosition, int iconTextGap, int mnemonicIndex) {
    JComponent c = ss.getComponent();
    Dimension size = getPreferredSize(ss, font, text, icon, hAlign,
                                      vAlign, hTextPosition, vTextPosition,
                                      iconTextGap, mnemonicIndex);
    View v = (View) c.getClientProperty(BasicHTML.propertyKey);

    if (v != null) {
        size.width += v.getMaximumSpan(View.X_AXIS) -
                      v.getPreferredSpan(View.X_AXIS);
    }
    return size;
}
项目:lookaside_java-1.8.0-openjdk    文件:SynthToolTipUI.java   
/**
 * Paints the specified component.
 *
 * @param context context for the component being painted
 * @param g the {@code Graphics} object used for painting
 * @see #update(Graphics,JComponent)
 */
protected void paint(SynthContext context, Graphics g) {
    JToolTip tip = (JToolTip)context.getComponent();

    Insets insets = tip.getInsets();
    View v = (View)tip.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
        Rectangle paintTextR = new Rectangle(insets.left, insets.top,
              tip.getWidth() - (insets.left + insets.right),
              tip.getHeight() - (insets.top + insets.bottom));
        v.paint(g, paintTextR);
    } else {
        g.setColor(context.getStyle().getColor(context,
                                               ColorType.TEXT_FOREGROUND));
        g.setFont(style.getFont(context));
        context.getStyle().getGraphicsUtils(context).paintText(
            context, g, tip.getTipText(), insets.left, insets.top, -1);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SynthToolTipUI.java   
/**
 * {@inheritDoc}
 */
@Override
public void propertyChange(PropertyChangeEvent e) {
    if (SynthLookAndFeel.shouldUpdateStyle(e)) {
        updateStyle((JToolTip)e.getSource());
    }
    String name = e.getPropertyName();
    if (name.equals("tiptext") || "font".equals(name) ||
            "foreground".equals(name)) {
        // remove the old html view client property if one
        // existed, and install a new one if the text installed
        // into the JLabel is html source.
        JToolTip tip = ((JToolTip) e.getSource());
        String text = tip.getTipText();
        BasicHTML.updateRenderer(tip, text);
    }
}
项目:iBioSim    文件:CloseTabPaneUI.java   
@Override
public void componentAdded(ContainerEvent e) {
    JTabbedPane tp = (JTabbedPane) e.getContainer();
    Component child = e.getChild();
    if (child instanceof UIResource) {
        return;
    }
    int index = tp.indexOfComponent(child);
    String title = tp.getTitleAt(index);
    boolean isHTML = BasicHTML.isHTMLString(title);
    if (isHTML) {
        if (htmlViews == null) { // Initialize vector
            htmlViews = createHTMLVector();
        }
        else { // Vector already exists
            View v = BasicHTML.createHTMLView(tp, title);
            htmlViews.insertElementAt(v, index);
        }
    }
    else { // Not HTML
        if (htmlViews != null) { // Add placeholder
            htmlViews.insertElementAt(null, index);
        } // else nada!
    }
}
项目:iBioSim    文件:CloseTabPaneUI.java   
private Vector<View> createHTMLVector() {
    Vector<View> htmlViews = new Vector<View>();
    int count = tabPane.getTabCount();
    if (count > 0) {
        for (int i = 0; i < count; i++) {
            String title = tabPane.getTitleAt(i);
            if (BasicHTML.isHTMLString(title)) {
                htmlViews.addElement(BasicHTML.createHTMLView(tabPane, title));
            }
            else {
                htmlViews.addElement(null);
            }
        }
    }
    return htmlViews;
}
项目:javify    文件:JLabel.java   
/**
 * Returns the bounding box of the character at the specified index.
 *
 * @param index the index of the character that we return the
 *        bounds for
 *
 * @return the bounding box of the character at the specified index
 */
public Rectangle getCharacterBounds(int index)
{
  Rectangle bounds = null;
  View view = (View) getClientProperty(BasicHTML.propertyKey);
  if (view != null)
    {
      Rectangle textR = getTextRectangle();
      try
        {
          Shape s = view.modelToView(index, textR, Position.Bias.Forward);
          bounds = s.getBounds();
        }
      catch (BadLocationException ex)
        {
          // Can't return something reasonable in this case.
        }
    }
  return bounds;
}
项目:javify    文件:AbstractButton.java   
/**
 * Returns the bounds of the character at the specified index of the
 * button's label. This will only work for HTML labels.
 *
 * @param i the index of the character of the label
 *
 * @return the bounds of the character at the specified index of the
 *         button's label
 */
public Rectangle getCharacterBounds(int i)
{
  Rectangle rect = null;
  View view = (View) getClientProperty(BasicHTML.propertyKey);
  if (view != null)
    {
      Rectangle shape = new Rectangle(0, 0, getWidth(), getHeight());
      try
        {
          Shape s = view.modelToView(i, shape, Position.Bias.Forward);
          rect = s.getBounds();
        }
      catch (BadLocationException ex)
        {
          rect = null;
        }
    }
  return rect;
}
项目:javify    文件:AbstractButton.java   
/**
 * Returns the text attribute for the character at the specified character
 * index.
 *
 * @param i the character index
 *
 * @return the character attributes for the specified character or
 *         <code>null</code> if the character has no attributes
 */
public AttributeSet getCharacterAttribute(int i)
{
  AttributeSet atts = null;
  View view = (View) getClientProperty(BasicHTML.propertyKey);
  if (view != null)
    {
      Document doc = view.getDocument();
      if (doc instanceof StyledDocument)
        {
          StyledDocument sDoc = (StyledDocument) doc;
          Element charEl = sDoc.getCharacterElement(i);
          if (charEl != null)
            atts = charEl.getAttributes();
        }
    }
  return atts;
}
项目:intellij-ce-playground    文件:DarculaRadioButtonUI.java   
protected void drawText(AbstractButton b, Graphics2D g, String text, Rectangle textRect, FontMetrics fm) {
  // Draw the Text
  if(text != null) {
    View v = (View) b.getClientProperty(BasicHTML.propertyKey);
    if (v != null) {
      v.paint(g, textRect);
    } else {
      int mnemIndex = b.getDisplayedMnemonicIndex();
      if(b.isEnabled()) {
        // *** paint the text normally
        g.setColor(b.getForeground());
      } else {
        // *** paint the text disabled
        g.setColor(getDisabledTextColor());
      }
      SwingUtilities2.drawStringUnderlineCharAt(b, g, text,
                                                mnemIndex, textRect.x, textRect.y + fm.getAscent());
    }
  }
}
项目:jvm-stm    文件:JLabel.java   
/**
 * Returns the bounding box of the character at the specified index.
 *
 * @param index the index of the character that we return the
 *        bounds for
 *
 * @return the bounding box of the character at the specified index
 */
public Rectangle getCharacterBounds(int index)
{
  Rectangle bounds = null;
  View view = (View) getClientProperty(BasicHTML.propertyKey);
  if (view != null)
    {
      Rectangle textR = getTextRectangle();
      try
        {
          Shape s = view.modelToView(index, textR, Position.Bias.Forward);
          bounds = s.getBounds();
        }
      catch (BadLocationException ex)
        {
          // Can't return something reasonable in this case.
        }
    }
  return bounds;
}
项目:jvm-stm    文件:AbstractButton.java   
/**
 * Returns the bounds of the character at the specified index of the
 * button's label. This will only work for HTML labels.
 *
 * @param i the index of the character of the label
 *
 * @return the bounds of the character at the specified index of the
 *         button's label
 */
public Rectangle getCharacterBounds(int i)
{
  Rectangle rect = null;
  View view = (View) getClientProperty(BasicHTML.propertyKey);
  if (view != null)
    {
      Rectangle shape = new Rectangle(0, 0, getWidth(), getHeight());
      try
        {
          Shape s = view.modelToView(i, shape, Position.Bias.Forward);
          rect = s.getBounds();
        }
      catch (BadLocationException ex)
        {
          rect = null;
        }
    }
  return rect;
}