use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class BasicToolTipUI method paint.
public void paint(Graphics g, JComponent c) {
Font font = c.getFont();
FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g, font);
Dimension size = c.getSize();
g.setColor(c.getForeground());
// fix for bug 4153892
String tipText = ((JToolTip) c).getTipText();
if (tipText == null) {
tipText = "";
}
Insets insets = c.getInsets();
Rectangle paintTextR = new Rectangle(insets.left + 3, insets.top, size.width - (insets.left + insets.right) - 6, size.height - (insets.top + insets.bottom));
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
v.paint(g, paintTextR);
} else {
g.setFont(font);
SwingUtilities2.drawString(c, g, tipText, paintTextR.x, paintTextR.y + metrics.getAscent());
}
}
use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class SynthToolTipUI method getPreferredSize.
/**
* {@inheritDoc}
*/
@Override
public Dimension getPreferredSize(JComponent c) {
SynthContext context = getContext(c);
Insets insets = c.getInsets();
Dimension prefSize = new Dimension(insets.left + insets.right, insets.top + insets.bottom);
String text = ((JToolTip) c).getTipText();
if (text != null) {
View v = (c != null) ? (View) c.getClientProperty("html") : null;
if (v != null) {
prefSize.width += (int) v.getPreferredSpan(View.X_AXIS);
prefSize.height += (int) v.getPreferredSpan(View.Y_AXIS);
} else {
Font font = context.getStyle().getFont(context);
FontMetrics fm = c.getFontMetrics(font);
prefSize.width += context.getStyle().getGraphicsUtils(context).computeStringWidth(context, font, fm, text);
prefSize.height += fm.getHeight();
}
}
context.dispose();
return prefSize;
}
use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class SynthToolTipUI method paint.
/**
* 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);
}
}
use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class SynthTabbedPaneUI method paintText.
private void paintText(SynthContext ss, Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) {
g.setFont(font);
View v = getTextViewForTab(tabIndex);
if (v != null) {
// html
v.paint(g, textRect);
} else {
// plain text
int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
g.setColor(ss.getStyle().getColor(ss, ColorType.TEXT_FOREGROUND));
ss.getStyle().getGraphicsUtils(ss).paintText(ss, g, title, textRect, mnemIndex);
}
}
use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class SynthTabbedPaneUI method calculateTabWidth.
/**
* {@inheritDoc}
*/
@Override
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
Icon icon = getIconForTab(tabIndex);
Insets tabInsets = getTabInsets(tabPlacement, tabIndex);
int width = tabInsets.left + tabInsets.right;
Component tabComponent = tabPane.getTabComponentAt(tabIndex);
if (tabComponent != null) {
width += tabComponent.getPreferredSize().width;
} else {
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 += tabContext.getStyle().getGraphicsUtils(tabContext).computeStringWidth(tabContext, metrics.getFont(), metrics, title);
}
}
return width;
}
Aggregations