use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class BasicMenuItemUI method getMaximumSize.
public Dimension getMaximumSize(JComponent c) {
Dimension d = null;
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
d = getPreferredSize(c);
d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
}
return d;
}
use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class BasicMenuItemUI method getMinimumSize.
public Dimension getMinimumSize(JComponent c) {
Dimension d = null;
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
d = getPreferredSize(c);
d.width -= v.getPreferredSpan(View.X_AXIS) - v.getMinimumSpan(View.X_AXIS);
}
return d;
}
use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class BasicTabbedPaneUI method calculateTabHeight.
protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) {
int height = 0;
Component c = tabPane.getTabComponentAt(tabIndex);
if (c != null) {
height = c.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 tabInsets = getTabInsets(tabPlacement, tabIndex);
height += tabInsets.top + tabInsets.bottom + 2;
return height;
}
use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class BasicTabbedPaneUI method paintText.
protected void paintText(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);
if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
Color fg = tabPane.getForegroundAt(tabIndex);
if (isSelected && (fg instanceof UIResource)) {
Color selectedFG = UIManager.getColor("TabbedPane.selectedForeground");
if (selectedFG != null) {
fg = selectedFG;
}
}
g.setColor(fg);
SwingUtilities2.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
} else {
// tab disabled
g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
SwingUtilities2.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
SwingUtilities2.drawStringUnderlineCharAt(tabPane, g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1);
}
}
}
use of javax.swing.text.View in project jdk8u_jdk by JetBrains.
the class AquaButtonLabeledUI method paint.
public synchronized void paint(final Graphics g, final JComponent c) {
final AbstractButton b = (AbstractButton) c;
final ButtonModel model = b.getModel();
final Font f = c.getFont();
g.setFont(f);
final FontMetrics fm = g.getFontMetrics();
Dimension size = b.getSize();
final Insets i = c.getInsets();
Rectangle viewRect = new Rectangle(b.getWidth(), b.getHeight());
Rectangle iconRect = new Rectangle();
Rectangle textRect = new Rectangle();
Icon altIcon = b.getIcon();
final boolean isCellEditor = c.getParent() instanceof CellRendererPane;
// opaque. So we put this back in to fix [3179839] (radio buttons not being translucent)
if (b.isOpaque() || isCellEditor) {
g.setColor(b.getBackground());
g.fillRect(0, 0, size.width, size.height);
}
// only do this if borders are on!
if (((AbstractButton) c).isBorderPainted() && !isCellEditor) {
final Border border = c.getBorder();
if (border instanceof AquaButtonBorder) {
((AquaButtonBorder) border).paintButton(c, g, viewRect.x, viewRect.y, viewRect.width, viewRect.height);
}
}
viewRect.x = i.left;
viewRect.y = i.top;
viewRect.width = b.getWidth() - (i.right + viewRect.x);
viewRect.height = b.getHeight() - (i.bottom + viewRect.y);
// normal size ??
// at some point we substitute the small icon instead of the normal icon
// we should base this on height. Use normal unless we are under a certain size
// see our button code!
final String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), altIcon != null ? altIcon : getDefaultIcon(b), b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, b.getText() == null ? 0 : b.getIconTextGap());
// draw the native radio button stuff here.
if (altIcon == null) {
widgetBorder.paintButton(c, g, iconRect.x, iconRect.y, iconRect.width, iconRect.height);
} else {
// Paint the button
if (!model.isEnabled()) {
if (model.isSelected()) {
altIcon = b.getDisabledSelectedIcon();
} else {
altIcon = b.getDisabledIcon();
}
} else if (model.isPressed() && model.isArmed()) {
altIcon = b.getPressedIcon();
if (altIcon == null) {
// Use selected icon
altIcon = b.getSelectedIcon();
}
} else if (model.isSelected()) {
if (b.isRolloverEnabled() && model.isRollover()) {
altIcon = b.getRolloverSelectedIcon();
if (altIcon == null) {
altIcon = b.getSelectedIcon();
}
} else {
altIcon = b.getSelectedIcon();
}
} else if (b.isRolloverEnabled() && model.isRollover()) {
altIcon = b.getRolloverIcon();
}
if (altIcon == null) {
altIcon = b.getIcon();
}
altIcon.paintIcon(c, g, iconRect.x, iconRect.y);
}
// Draw the Text
if (text != null) {
final View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
v.paint(g, textRect);
} else {
paintText(g, b, textRect, text);
}
}
}
Aggregations