use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class AquaTabbedPaneContrastUI method paintTitle.
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
final View v = getTextViewForTab(tabIndex);
if (v != null) {
v.paint(g2d, textRect);
return;
}
if (title == null)
return;
final Color color = tabPane.getForegroundAt(tabIndex);
if (color instanceof UIResource) {
g2d.setColor(getNonSelectedTabTitleColor());
if (tabPane.getSelectedIndex() == tabIndex) {
boolean pressed = isPressedAt(tabIndex);
boolean enabled = tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex);
Color textColor = getSelectedTabTitleColor(enabled, pressed);
Color shadowColor = getSelectedTabTitleShadowColor(enabled);
AquaUtils.paintDropShadowText(g2d, tabPane, font, metrics, textRect.x, textRect.y, 0, 1, textColor, shadowColor, title);
return;
}
} else {
g2d.setColor(color);
}
g2d.setFont(font);
SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class BasicSplitPaneUI method installDefaults.
/**
* Installs the UI defaults.
*/
protected void installDefaults() {
LookAndFeel.installBorder(splitPane, "SplitPane.border");
LookAndFeel.installColors(splitPane, "SplitPane.background", "SplitPane.foreground");
LookAndFeel.installProperty(splitPane, "opaque", Boolean.TRUE);
if (divider == null)
divider = createDefaultDivider();
divider.setBasicSplitPaneUI(this);
Border b = divider.getBorder();
if (b == null || !(b instanceof UIResource)) {
divider.setBorder(UIManager.getBorder("SplitPaneDivider.border"));
}
dividerDraggingColor = UIManager.getColor("SplitPaneDivider.draggingColor");
setOrientation(splitPane.getOrientation());
// note: don't rename this temp variable to dividerSize
// since it will conflict with "this.dividerSize" field
Integer temp = (Integer) UIManager.get("SplitPane.dividerSize");
LookAndFeel.installProperty(splitPane, "dividerSize", temp == null ? 10 : temp);
divider.setDividerSize(splitPane.getDividerSize());
dividerSize = divider.getDividerSize();
splitPane.add(divider, JSplitPane.DIVIDER);
setContinuousLayout(splitPane.isContinuousLayout());
resetLayoutManager();
/* Install the nonContinuousLayoutDivider here to avoid having to
add/remove everything later. */
if (nonContinuousLayoutDivider == null) {
setNonContinuousLayoutDivider(createDefaultNonContinuousLayoutDivider(), true);
} else {
setNonContinuousLayoutDivider(nonContinuousLayoutDivider, true);
}
// focus forward traversal key
if (managingFocusForwardTraversalKeys == null) {
managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
}
splitPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys);
// focus backward traversal key
if (managingFocusBackwardTraversalKeys == null) {
managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusBackwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
}
splitPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys);
}
use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class SynthSeparatorUI method updateStyle.
private void updateStyle(JSeparator sep) {
SynthContext context = getContext(sep, ENABLED);
SynthStyle oldStyle = style;
style = SynthLookAndFeel.updateStyle(context, this);
if (style != oldStyle) {
if (sep instanceof JToolBar.Separator) {
Dimension size = ((JToolBar.Separator) sep).getSeparatorSize();
if (size == null || size instanceof UIResource) {
size = (DimensionUIResource) style.get(context, "ToolBar.separatorSize");
if (size == null) {
size = new DimensionUIResource(10, 10);
}
((JToolBar.Separator) sep).setSeparatorSize(size);
}
}
}
context.dispose();
}
use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class SynthTreeUI method paintRow.
private void paintRow(TreeCellRenderer renderer, DefaultTreeCellRenderer dtcr, SynthContext treeContext, SynthContext cellContext, Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, Rectangle rowBounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
// Don't paint the renderer if editing this row.
boolean selected = tree.isRowSelected(row);
JTree.DropLocation dropLocation = tree.getDropLocation();
boolean isDrop = dropLocation != null && dropLocation.getChildIndex() == -1 && path == dropLocation.getPath();
int state = ENABLED;
if (selected || isDrop) {
state |= SELECTED;
}
if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
state |= FOCUSED;
}
cellContext.setComponentState(state);
if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof UIResource)) {
dtcr.setBorderSelectionColor(style.getColor(cellContext, ColorType.FOCUS));
}
SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
cellContext.getPainter().paintTreeCellBackground(cellContext, g, rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height);
cellContext.getPainter().paintTreeCellBorder(cellContext, g, rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height);
if (editingComponent != null && editingRow == row) {
return;
}
int leadIndex;
if (tree.hasFocus()) {
leadIndex = getLeadSelectionRow();
} else {
leadIndex = -1;
}
Component component = renderer.getTreeCellRendererComponent(tree, path.getLastPathComponent(), selected, isExpanded, isLeaf, row, (leadIndex == row));
rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y, bounds.width, bounds.height, true);
}
use of javax.swing.plaf.UIResource in project jdk8u_jdk by JetBrains.
the class SynthTreeUI method configureRenderer.
private void configureRenderer(SynthContext context) {
TreeCellRenderer renderer = tree.getCellRenderer();
if (renderer instanceof DefaultTreeCellRenderer) {
DefaultTreeCellRenderer r = (DefaultTreeCellRenderer) renderer;
SynthStyle style = context.getStyle();
context.setComponentState(ENABLED | SELECTED);
Color color = r.getTextSelectionColor();
if (color == null || (color instanceof UIResource)) {
r.setTextSelectionColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
}
color = r.getBackgroundSelectionColor();
if (color == null || (color instanceof UIResource)) {
r.setBackgroundSelectionColor(style.getColor(context, ColorType.TEXT_BACKGROUND));
}
context.setComponentState(ENABLED);
color = r.getTextNonSelectionColor();
if (color == null || color instanceof UIResource) {
r.setTextNonSelectionColor(style.getColorForState(context, ColorType.TEXT_FOREGROUND));
}
color = r.getBackgroundNonSelectionColor();
if (color == null || color instanceof UIResource) {
r.setBackgroundNonSelectionColor(style.getColorForState(context, ColorType.TEXT_BACKGROUND));
}
}
}
Aggregations