use of javax.swing.text.View in project netbeans-mmd-plugin by raydac.
the class JHtmlLabel method cacheLinkElements.
private void cacheLinkElements() {
this.linkCache = new ArrayList<>();
// NOI18N
final View view = (View) this.getClientProperty("html");
if (view != null) {
final HTMLDocument doc = (HTMLDocument) view.getDocument();
final HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A);
while (it.isValid()) {
final SimpleAttributeSet s = (SimpleAttributeSet) it.getAttributes();
final String link = (String) s.getAttribute(HTML.Attribute.HREF);
if (link != null) {
this.linkCache.add(new HtmlLinkAddress(link, it.getStartOffset(), it.getEndOffset()));
}
it.next();
}
}
}
use of javax.swing.text.View in project Botnak by Gocnak.
the class BaseRadioButtonUI method paintText.
protected void paintText(Graphics g, JComponent c, String text, Rectangle textRect) {
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
Graphics2D g2D = (Graphics2D) g;
Object savedRenderingHint = null;
if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint());
}
v.paint(g, textRect);
if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
}
} else {
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
Font f = c.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics();
int mnemIndex = -1;
if (JTattooUtilities.getJavaVersion() >= 1.4) {
mnemIndex = b.getDisplayedMnemonicIndex();
} else {
mnemIndex = JTattooUtilities.findDisplayedMnemonicIndex(b.getText(), model.getMnemonic());
}
if (model.isEnabled()) {
g.setColor(b.getForeground());
JTattooUtilities.drawStringUnderlineCharAt(c, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
} else {
g.setColor(Color.white);
JTattooUtilities.drawStringUnderlineCharAt(c, g, text, mnemIndex, textRect.x + 1, textRect.y + 1 + fm.getAscent());
g.setColor(AbstractLookAndFeel.getDisabledForegroundColor());
JTattooUtilities.drawStringUnderlineCharAt(c, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
}
}
}
use of javax.swing.text.View in project Botnak by Gocnak.
the class BaseButtonUI method paint.
public void paint(Graphics g, JComponent c) {
Graphics2D g2D = (Graphics2D) g;
AbstractButton b = (AbstractButton) c;
Font f = c.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics();
Insets insets = c.getInsets();
viewRect.x = insets.left;
viewRect.y = insets.top;
viewRect.width = b.getWidth() - (insets.right + viewRect.x);
viewRect.height = b.getHeight() - (insets.bottom + viewRect.y);
textRect.x = textRect.y = textRect.width = textRect.height = 0;
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
int iconTextGap = defaultTextIconGap;
if (JTattooUtilities.getJavaVersion() >= 1.4) {
iconTextGap = b.getIconTextGap();
}
String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), b.getIcon(), b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, b.getText() == null ? 0 : iconTextGap);
paintBackground(g, b);
if (b.getIcon() != null) {
if (!b.isEnabled()) {
Composite savedComposite = g2D.getComposite();
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
g2D.setComposite(alpha);
paintIcon(g, c, iconRect);
g2D.setComposite(savedComposite);
} else {
if (b.getModel().isPressed() && b.getModel().isRollover()) {
iconRect.x++;
iconRect.y++;
}
paintIcon(g, c, iconRect);
}
}
if (text != null && !text.equals("")) {
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
Object savedRenderingHint = null;
if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
v.paint(g, textRect);
if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
}
} else {
paintText(g, b, textRect, text);
}
}
if (b.isFocusPainted() && b.hasFocus()) {
paintFocus(g, b, viewRect, textRect, iconRect);
}
}
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;
}
use of javax.swing.text.View in project Botnak by Gocnak.
the class BaseToggleButtonUI method paint.
public void paint(Graphics g, JComponent c) {
Graphics2D g2D = (Graphics2D) g;
AbstractButton b = (AbstractButton) c;
Font f = c.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics();
Insets insets = c.getInsets();
viewRect.x = insets.left;
viewRect.y = insets.top;
viewRect.width = b.getWidth() - (insets.right + viewRect.x);
viewRect.height = b.getHeight() - (insets.bottom + viewRect.y);
textRect.x = textRect.y = textRect.width = textRect.height = 0;
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), b.getIcon(), b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, b.getText() == null ? 0 : defaultTextIconGap);
paintBackground(g, b);
if (b.getIcon() != null) {
if (!b.isEnabled()) {
Composite savedComposite = g2D.getComposite();
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
g2D.setComposite(alpha);
paintIcon(g, c, iconRect);
g2D.setComposite(savedComposite);
} else {
paintIcon(g, c, iconRect);
}
}
if (text != null && !text.equals("") && textRect != null) {
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
Object savedRenderingHint = null;
if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
savedRenderingHint = g2D.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, AbstractLookAndFeel.getTheme().getTextAntiAliasingHint());
}
v.paint(g, textRect);
if (AbstractLookAndFeel.getTheme().isTextAntiAliasingOn()) {
g2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, savedRenderingHint);
}
} else {
paintText(g, b, textRect, text);
}
}
if (b.isFocusPainted() && b.hasFocus()) {
paintFocus(g, b, viewRect, textRect, iconRect);
}
}
Aggregations