/** * Returns a SynthContext with the specified values. * * @param component JComponent * @param region Identifies the portion of the JComponent * @param style Style associated with the component * @param state State of the component as defined in SynthConstants. * @return a SynthContext with the specified values. * * @throws NullPointerException if component, region of style is null. * */ public static SynthContext getContext(JComponent c, Region region, SynthStyle style, int state) { return new SynthContext(c, region, style, state); }
/** * Returns a SynthContext with the specified values. * * @param component JComponent * @param region Identifies the portion of the JComponent * @param style Style associated with the component * @param state State of the component as defined in SynthConstants. * @return a SynthContext with the specified values. * * @throws NullPointerException if component, region of style is null. * */ public static SynthContext getContext(JComponent c, Region region, SynthStyle style, int state) { return new SynthContext(c, region, style, state); }
/** * Returns a SynthContext with the specified values. * * @param component JComponent * @param region Identifies the portion of the JComponent * @param style Style associated with the component * @param state State of the component as defined in SynthConstants. * @return a SynthContext with the specified values. * * @throws NullPointerException if component, region of style is null. * */ public static SynthContext getContext(JComponent c, Region region, SynthStyle style, int state) { return new SynthContext(c, region, style, state); }
/** * Returns a SynthContext with the specified values. * * @param component JComponent * @param region Identifies the portion of the JComponent * @param style Style associated with the component * @param state State of the component as defined in SynthConstants. * @return a SynthContext with the specified values. * * @throws NullPointerException if component, region of style is null. * */ public static SynthContext getContext(JComponent c, Region region, SynthStyle style, int state) { return new SynthContext(c, region, style, state); }
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));
@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")); } } }