/** * Returns the style for this component from the style factory. * @return */ private SynthStyle getStyle() { return SynthLookAndFeel.getStyleFactory().getStyle(list, getRegion()); }
return (laf instanceof SynthLookAndFeel && ((SynthLookAndFeel)laf). shouldUpdateStyleOnAncestorChanged());
/** * Get the region. * * @param c the component. * * @return the region. */ private Region getRegion(JComponent c) { return SynthLookAndFeel.getRegion(c); }
SynthLookAndFeel laf = new SynthLookAndFeel(); laf.load(LnFTest.class.getResourceAsStream("laf.xml"), LnFTest.class); UIManager.setLookAndFeel(laf); SynthLookAndFeel.setStyleFactory(new MyStyleFactory(SynthLookAndFeel.getStyleFactory()));
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));
SynthLookAndFeel.setStyleFactory(new MySynthStyleFactory( SynthLookAndFeel.getStyleFactory())); } catch (Exception e) { e.printStackTrace(System.err);
try { Class<?> c = SynthButtonTest.class; SynthLookAndFeel synth = new SynthLookAndFeel(); synth.load(c.getResourceAsStream("button.xml"), c); UIManager.setLookAndFeel(synth); } catch (Exception ex) {
public UIDefaults getDefaults() { if (uiDefaults == null) { uiDefaults = new UIWrapper(super.getDefaults());
/** * 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; }
SynthLookAndFeel laf = new SynthLookAndFeel(); laf.load(ButtonRollover.class.getResourceAsStream("menusynt.xml"), ButtonRollover.class); UIManager.setLookAndFeel(laf); } catch (Exception e) {
return (laf instanceof SynthLookAndFeel && ((SynthLookAndFeel)laf). shouldUpdateStyleOnAncestorChanged());
/** * Returns the style for this component from the style factory. * @return */ private SynthStyle getStyle() { return SynthLookAndFeel.getStyleFactory().getStyle(list, getRegion()); }
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(); }
SynthLookAndFeel laf = new SynthLookAndFeel(); laf.load(SynthSliderTest.class.getResourceAsStream("yourPathTo/demo.xml"), SynthSliderTest.class); UIManager.setLookAndFeel(laf); } catch (Exception e) {
private Region getRegion(JComponent c) { return SynthLookAndFeel.getRegion(c); }
return (laf instanceof SynthLookAndFeel && ((SynthLookAndFeel)laf). shouldUpdateStyleOnAncestorChanged());
/** * Returns the style for this component from the style factory. * @return */ private SynthStyle getStyle() { return SynthLookAndFeel.getStyleFactory().getStyle(list, getRegion()); }
@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); }
/** * DOCUMENT ME! * * @param c DOCUMENT ME! * @param state DOCUMENT ME! * * @return DOCUMENT ME! */ private SeaGlassContext getContext(JComponent c, int state) { return SeaGlassContext.getContext(SeaGlassContext.class, c, SynthLookAndFeel.getRegion(c), style, state); }
return (laf instanceof SynthLookAndFeel && ((SynthLookAndFeel)laf). shouldUpdateStyleOnAncestorChanged());