if (shouldDisplayOnTop()) { if (sortIcon instanceof SynthIcon) { SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, x, rect.y + V_GAP, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + rect.width - iconWidth - textWidth - H_GAP - ARROW_TEXT_GAP, rect.y + yOffset, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + textWidth + H_GAP + ARROW_TEXT_GAP, rect.y + yOffset, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); if (shouldDisplayOnTop()) { if (sortIcon instanceof SynthIcon) { SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + rect.width / 2 - iconWidth / 2, rect.y + V_GAP, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + rect.width - iconWidth - H_GAP, rect.y + yOffset, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context)); SynthContext context = new SynthContext(c, Region.TABLE_HEADER, SynthLookAndFeel.getStyle(c, Region.TABLE_HEADER), 0); ((SynthIcon) sortIcon).paintIcon(context, g, rect.x + H_GAP, rect.y + yOffset, ((SynthIcon) sortIcon).getIconWidth(context), ((SynthIcon) sortIcon).getIconHeight(context));
/** * A convience method that will reset the Style of StyleContext if * necessary. * * @param context the SynthContext corresponding to the current state. * @param ui the UI delegate. * * @return the new, updated style. */ public static SynthStyle updateStyle(SeaGlassContext context, SeaglassUI ui) { SynthStyle newStyle = SynthLookAndFeel.getStyle(context.getComponent(), context.getRegion()); SynthStyle oldStyle = context.getStyle(); if (newStyle != oldStyle) { if (oldStyle != null) { oldStyle.uninstallDefaults(context); } context.setStyle(newStyle); if (newStyle instanceof SeaGlassStyle) { ((SeaGlassStyle) newStyle).installDefaults(context, ui); } } return newStyle; }
private void updateStyle(JComponent c) { SeaGlassContext context = getContext(c, ENABLED); // Note: JViewport is special cased as it does not allow for // a border to be set. JViewport.setBorder is overriden to throw // an IllegalArgumentException. Refer to SynthScrollPaneUI for // details of this. SynthStyle newStyle = SynthLookAndFeel.getStyle(context.getComponent(), context.getRegion()); SynthStyle oldStyle = context.getStyle(); if (newStyle != oldStyle) { if (oldStyle != null) { oldStyle.uninstallDefaults(context); } context.setStyle(newStyle); newStyle.installDefaults(context); } this.style = newStyle; context.dispose(); }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { Icon icon = (Icon) _originalIcon.createValue(UIManager.getDefaults()); if (isSynthIcon(icon)) { int state = getComponentState((JComponent) c); if (c instanceof TristateCheckBox && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) state &= ~SynthConstants.SELECTED; SynthContext context = new SynthContext((JComponent) c, Region.CHECK_BOX, SynthLookAndFeel.getStyle((JComponent) c, Region.CHECK_BOX), state); final int w = ((SynthIcon) icon).getIconWidth(context); final int h = ((SynthIcon) icon).getIconHeight(context); ((SynthIcon) icon).paintIcon(context, g, x, y, w, h); } else { if (c instanceof TristateCheckBox && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) { ((TristateButtonModel) ((TristateCheckBox) c).getModel()).internalSetSelected(false); } icon.paintIcon(c, g, x, y); if (c instanceof TristateCheckBox && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) { ((TristateButtonModel) ((TristateCheckBox) c).getModel()).internalSetSelected(true); } } g.setColor(UIManager.getColor("CheckBox.foreground")); if (c instanceof TristateCheckBox && ((TristateCheckBox) c).getModel() instanceof TristateButtonModel && ((TristateButtonModel) ((TristateCheckBox) c).getModel()).isMixed()) drawSquare(c, g, x, y); }
protected void updateMargin(AbstractButton b) { String pp = getPropertyPrefix(); if (LookAndFeelFactory.isLnfInUse(LookAndFeelFactory.SYNTH_LNF)) { SynthStyle ss = SynthLookAndFeel.getStyle(b, Region.BUTTON); SynthContext sc = new SynthContext(b, Region.BUTTON, ss, 0); Insets insets = ss.getInsets(sc, new InsetsUIResource(0, 0, 0, 0)); if (insets != null) { b.setMargin(insets); } } else if (b.getMargin() == null || (b.getMargin() instanceof UIResource)) { if (shouldWrapText(b)) { b.setMargin(UIDefaultsLookup.getInsets(pp + "margin.vertical")); } else { b.setMargin(UIDefaultsLookup.getInsets(pp + "margin")); } } }