Search in sources :

Example 11 with UIResource

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());
}
Also used : Color(java.awt.Color) View(javax.swing.text.View) UIResource(javax.swing.plaf.UIResource)

Example 12 with UIResource

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);
}
Also used : Border(javax.swing.border.Border) UIResource(javax.swing.plaf.UIResource)

Example 13 with UIResource

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();
}
Also used : Dimension(java.awt.Dimension) DimensionUIResource(javax.swing.plaf.DimensionUIResource) UIResource(javax.swing.plaf.UIResource) DimensionUIResource(javax.swing.plaf.DimensionUIResource)

Example 14 with UIResource

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);
}
Also used : JTree(javax.swing.JTree) JComponent(javax.swing.JComponent) Component(java.awt.Component) UIResource(javax.swing.plaf.UIResource)

Example 15 with UIResource

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));
        }
    }
}
Also used : TreeCellRenderer(javax.swing.tree.TreeCellRenderer) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Color(java.awt.Color) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) UIResource(javax.swing.plaf.UIResource)

Aggregations

UIResource (javax.swing.plaf.UIResource)33 Border (javax.swing.border.Border)16 FocusEvent (java.awt.event.FocusEvent)6 FocusListener (java.awt.event.FocusListener)6 EmptyBorder (javax.swing.border.EmptyBorder)4 View (javax.swing.text.View)4 JBColor (com.intellij.ui.JBColor)3 Color (java.awt.Color)3 ColorUIResource (javax.swing.plaf.ColorUIResource)3 Area (java.awt.geom.Area)2 FontUIResource (javax.swing.plaf.FontUIResource)2 JTextComponent (javax.swing.text.JTextComponent)2 JRSUIState (apple.laf.JRSUIState)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1 GraphicsConfig (com.intellij.openapi.ui.GraphicsConfig)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 Insets (java.awt.Insets)1 StringSelection (java.awt.datatransfer.StringSelection)1