javax.swing.plaf.synth.SynthContext Java Examples
The following examples show how to use
javax.swing.plaf.synth.SynthContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NimbusStyle.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * <p>Overridden to cause this style to populate itself with data from * UIDefaults, if necessary.</p> * * <p>In addition, NimbusStyle handles ColorTypes slightly differently from * Synth.</p> * <ul> * <li>ColorType.BACKGROUND will equate to the color stored in UIDefaults * named "background".</li> * <li>ColorType.TEXT_BACKGROUND will equate to the color stored in * UIDefaults named "textBackground".</li> * <li>ColorType.FOREGROUND will equate to the color stored in UIDefaults * named "textForeground".</li> * <li>ColorType.TEXT_FOREGROUND will equate to the color stored in * UIDefaults named "textForeground".</li> * </ul> */ @Override protected Color getColorForState(SynthContext ctx, ColorType type) { String key = null; if (type == ColorType.BACKGROUND) { key = "background"; } else if (type == ColorType.FOREGROUND) { //map FOREGROUND as TEXT_FOREGROUND key = "textForeground"; } else if (type == ColorType.TEXT_BACKGROUND) { key = "textBackground"; } else if (type == ColorType.TEXT_FOREGROUND) { key = "textForeground"; } else if (type == ColorType.FOCUS) { key = "focus"; } else if (type != null) { key = type.toString(); } else { return DEFAULT_COLOR; } Color c = (Color) get(ctx, key); //if all else fails, return a default color (which is a ColorUIResource) if (c == null) c = DEFAULT_COLOR; return c; }
Example #2
Source File: NimbusIcon.java From JDKSourceCode1.8 with MIT License | 6 votes |
@Override public int getIconWidth(SynthContext context) { if (context == null) { return width; } JComponent c = context.getComponent(); if (c instanceof JToolBar && ((JToolBar)c).getOrientation() == JToolBar.VERTICAL) { //we only do the -1 hack for UIResource borders, assuming //that the border is probably going to be our border if (c.getBorder() instanceof UIResource) { return c.getWidth() - 1; } else { return c.getWidth(); } } else { return scale(context, width); } }
Example #3
Source File: NimbusIcon.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
@Override public int getIconWidth(SynthContext context) { if (context == null) { return width; } JComponent c = context.getComponent(); if (c instanceof JToolBar && ((JToolBar)c).getOrientation() == JToolBar.VERTICAL) { //we only do the -1 hack for UIResource borders, assuming //that the border is probably going to be our border if (c.getBorder() instanceof UIResource) { return c.getWidth() - 1; } else { return c.getWidth(); } } else { return scale(context, width); } }
Example #4
Source File: NimbusIcon.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Scale a size based on the "JComponent.sizeVariant" client property of the * component that is using this icon * * @param context The synthContext to get the component from * @param size The size to scale * @return The scaled size or original if "JComponent.sizeVariant" is not * set */ private int scale(SynthContext context, int size) { if (context == null || context.getComponent() == null){ return size; } // The key "JComponent.sizeVariant" is used to match Apple's LAF String scaleKey = (String) context.getComponent().getClientProperty( "JComponent.sizeVariant"); if (scaleKey != null) { if (NimbusStyle.LARGE_KEY.equals(scaleKey)) { size *= NimbusStyle.LARGE_SCALE; } else if (NimbusStyle.SMALL_KEY.equals(scaleKey)) { size *= NimbusStyle.SMALL_SCALE; } else if (NimbusStyle.MINI_KEY.equals(scaleKey)) { // mini is not quite as small for icons as full mini is // just too tiny size *= NimbusStyle.MINI_SCALE + 0.07; } } return size; }
Example #5
Source File: NimbusStyle.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} * * <p>Overridden to cause this style to populate itself with data from * UIDefaults, if necessary.</p> * * <p>In addition, NimbusStyle handles ColorTypes slightly differently from * Synth.</p> * <ul> * <li>ColorType.BACKGROUND will equate to the color stored in UIDefaults * named "background".</li> * <li>ColorType.TEXT_BACKGROUND will equate to the color stored in * UIDefaults named "textBackground".</li> * <li>ColorType.FOREGROUND will equate to the color stored in UIDefaults * named "textForeground".</li> * <li>ColorType.TEXT_FOREGROUND will equate to the color stored in * UIDefaults named "textForeground".</li> * </ul> */ @Override protected Color getColorForState(SynthContext ctx, ColorType type) { String key = null; if (type == ColorType.BACKGROUND) { key = "background"; } else if (type == ColorType.FOREGROUND) { //map FOREGROUND as TEXT_FOREGROUND key = "textForeground"; } else if (type == ColorType.TEXT_BACKGROUND) { key = "textBackground"; } else if (type == ColorType.TEXT_FOREGROUND) { key = "textForeground"; } else if (type == ColorType.FOCUS) { key = "focus"; } else if (type != null) { key = type.toString(); } else { return DEFAULT_COLOR; } Color c = (Color) get(ctx, key); //if all else fails, return a default color (which is a ColorUIResource) if (c == null) c = DEFAULT_COLOR; return c; }
Example #6
Source File: ThemeValue.java From netbeans with Apache License 2.0 | 6 votes |
private static SynthContext getSynthContext () { try { JButton dummyButton = getDummyButton(); ButtonUI bui = dummyButton.getUI(); if (bui instanceof SynthUI) { return ((SynthUI) bui).getContext(dummyButton); } else { throw new IllegalStateException ("I don't have a SynthButtonUI to play with"); //NOI18N } } catch (Exception e) { functioning = Boolean.FALSE; if (log) { e.printStackTrace(); } return null; } }
Example #7
Source File: SynthPainterImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Paints the border of a formatted text field. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintFormattedTextFieldBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { if (context.getComponent().getComponentOrientation().isLeftToRight()){ paintBorder(context, g, x, y, w, h, null); } else { AffineTransform transform = new AffineTransform(); transform.translate(x,y); transform.scale(-1, 1); transform.translate(-w,0); paintBorder(context, g, 0, 0, w, h, transform); } }
Example #8
Source File: SynthPainterImpl.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Paints the border of a text field. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintTextFieldBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { if (context.getComponent().getComponentOrientation().isLeftToRight()){ paintBorder(context, g, x, y, w, h, null); } else { AffineTransform transform = new AffineTransform(); transform.translate(x,y); transform.scale(-1, 1); transform.translate(-w,0); paintBorder(context, g, 0, 0, w, h, transform); } }
Example #9
Source File: MSynthPainter.java From swift-k with Apache License 2.0 | 5 votes |
@Override public void paintTabbedPaneContentBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(BG); g.drawRoundRect(x, y, w, h, 6, 6); }
Example #10
Source File: NimbusStyle.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} * * Overridden to cause this style to populate itself with data from * UIDefaults, if necessary. */ @Override public void installDefaults(SynthContext ctx) { validate(); //delegate to the superclass to install defaults such as background, //foreground, font, and opaque onto the swing component. super.installDefaults(ctx); }
Example #11
Source File: SynthPainterImpl.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Paints the background of a formatted text field. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintFormattedTextFieldBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { if (context.getComponent().getComponentOrientation().isLeftToRight()){ paintBackground(context, g, x, y, w, h, null); } else { AffineTransform transform = new AffineTransform(); transform.translate(x,y); transform.scale(-1, 1); transform.translate(-w,0); paintBackground(context, g, 0, 0, w, h, transform); } }
Example #12
Source File: SynthPainterImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Paints the background of an arrow button. Arrow buttons are created by * some components, such as <code>JScrollBar</code>. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintArrowButtonBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { if (context.getComponent().getComponentOrientation().isLeftToRight()){ paintBackground(context, g, x, y, w, h, null); } else { AffineTransform transform = new AffineTransform(); transform.translate(x,y); transform.scale(-1, 1); transform.translate(-w,0); paintBackground(context, g, 0, 0, w, h, transform); } }
Example #13
Source File: NimbusStyle.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} * * Overridden to cause this style to populate itself with data from * UIDefaults, if necessary. If opacity is not specified in UI defaults, * then it defaults to being non-opaque. */ @Override public boolean isOpaque(SynthContext ctx) { // Force Table CellRenderers to be opaque if ("Table.cellRenderer".equals(ctx.getComponent().getName())) { return true; } Boolean opaque = (Boolean)get(ctx, "opaque"); return opaque == null ? false : opaque; }
Example #14
Source File: SynthPainterImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Paints the background of a combo box. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintComboBoxBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { if (context.getComponent().getComponentOrientation().isLeftToRight()){ paintBackground(context, g, x, y, w, h, null); } else { AffineTransform transform = new AffineTransform(); transform.translate(x,y); transform.scale(-1, 1); transform.translate(-w,0); paintBackground(context, g, 0, 0, w, h, transform); } }
Example #15
Source File: SynthPainterImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void paintBorder(SynthContext ctx, Graphics g, int x, int y, int w, int h, AffineTransform transform) { Painter<Object> borderPainter = style.getBorderPainter(ctx); if (borderPainter != null) { paint(borderPainter, ctx, g, x, y, w, h,transform); } }
Example #16
Source File: SeaGlassIcon.java From seaglass with Apache License 2.0 | 5 votes |
/** * Returns the icon's height. This is a cover method for <code> * getIconHeight(null)</code>. * * @param context the SynthContext describing the component/region, the * style, and the state. * * @return an int specifying the fixed height of the icon. */ @Override public int getIconHeight(SynthContext context) { if (context == null) { return height; } JComponent c = context.getComponent(); if (c instanceof JToolBar) { JToolBar toolbar = (JToolBar) c; if (toolbar.getOrientation() == JToolBar.HORIZONTAL) { // we only do the -1 hack for UIResource borders, assuming // that the border is probably going to be our border if (toolbar.getBorder() instanceof UIResource) { return c.getHeight() - 1; } else { return c.getHeight(); } } else { return scale(context, width); } } else { return scale(context, height); } }
Example #17
Source File: SeaGlassToolBarUI.java From seaglass with Apache License 2.0 | 4 votes |
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { ((SeaGlassContext) context).getPainter().paintToolBarBorder(context, g, x, y, w, h, toolBar.getOrientation()); }
Example #18
Source File: NimbusStyle.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * {@inheritDoc} * * <p>Overridden to cause this style to populate itself with data from * UIDefaults, if necessary.</p> * * <p>Properties in UIDefaults may be specified in a chained manner. For * example: * <pre> * background * Button.opacity * Button.Enabled.foreground * Button.Enabled+Selected.background * </pre> * * <p>In this example, suppose you were in the Enabled+Selected state and * searched for "foreground". In this case, we first check for * Button.Enabled+Selected.foreground, but no such color exists. We then * fall back to the next valid state, in this case, * Button.Enabled.foreground, and have a match. So we return it.</p> * * <p>Again, if we were in the state Enabled and looked for "background", we * wouldn't find it in Button.Enabled, or in Button, but would at the top * level in UIManager. So we return that value.</p> * * <p>One special note: the "key" passed to this method could be of the form * "background" or "Button.background" where "Button" equals the prefix * passed to the NimbusStyle constructor. In either case, it looks for * "background".</p> * * @param ctx * @param key must not be null */ @Override public Object get(SynthContext ctx, Object key) { Values v = getValues(ctx); // strip off the prefix, if there is one. String fullKey = key.toString(); String partialKey = fullKey.substring(fullKey.indexOf(".") + 1); Object obj = null; int xstate = getExtendedState(ctx, v); // check the cache tmpKey.init(partialKey, xstate); obj = v.cache.get(tmpKey); boolean wasInCache = obj != null; if (!wasInCache){ // Search exact matching states and then lesser matching states RuntimeState s = null; int[] lastIndex = new int[] {-1}; while (obj == null && (s = getNextState(v.states, lastIndex, xstate)) != null) { obj = s.defaults.get(partialKey); } // Search Region Defaults if (obj == null && v.defaults != null) { obj = v.defaults.get(partialKey); } // return found object // Search UIManager Defaults if (obj == null) obj = UIManager.get(fullKey); // Search Synth Defaults for InputMaps if (obj == null && partialKey.equals("focusInputMap")) { obj = super.get(ctx, fullKey); } // if all we got was a null, store this fact for later use v.cache.put(new CacheKey(partialKey, xstate), obj == null ? NULL : obj); } // return found object return obj == NULL ? null : obj; }
Example #19
Source File: SynthPainterImpl.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Paints the background of a radio button. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintRadioButtonBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { paintBackground(context, g, x, y, w, h, null); }
Example #20
Source File: SynthPainterImpl.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Paints the border of an editor pane. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintEditorPaneBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { paintBorder(context, g, x, y, w, h, null); }
Example #21
Source File: SynthPainterImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 2 votes |
/** * Paints the border of an editor pane. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintEditorPaneBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { paintBorder(context, g, x, y, w, h, null); }
Example #22
Source File: SynthPainterImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 2 votes |
/** * Paints the border of a toggle button. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintToggleButtonBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { paintBorder(context, g, x, y, w, h, null); }
Example #23
Source File: SynthPainterImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 2 votes |
/** * Paints the border of a popup menu. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintPopupMenuBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { paintBorder(context, g, x, y, w, h, null); }
Example #24
Source File: SynthPainterImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Paints the border of the header of a table. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintTableHeaderBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { paintBorder(context, g, x, y, w, h, null); }
Example #25
Source File: SynthPainterImpl.java From hottub with GNU General Public License v2.0 | 2 votes |
/** * Paints the border of a scrollbar. This implementation invokes the * method of the same name without the orientation. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to * @param orientation Orientation of the JScrollBar, one of * <code>JScrollBar.HORIZONTAL</code> or * <code>JScrollBar.VERTICAL</code> * @since 1.6 */ public void paintScrollBarBorder(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) { paintBorder(context, g, x, y, w, h, orientation); }
Example #26
Source File: SeaGlassFormattedTextFieldUI.java From seaglass with Apache License 2.0 | 2 votes |
/** * @see com.seaglasslookandfeel.ui.SeaGlassTextFieldUI#paintBorder(javax.swing.plaf.synth.SynthContext, * java.awt.Graphics, int, int, int, int) */ public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h) { ((SeaGlassContext) context).getPainter().paintFormattedTextFieldBorder(context, g, x, y, w, h); }
Example #27
Source File: SynthPainterImpl.java From JDKSourceCode1.8 with MIT License | 2 votes |
/** * Paints the border of a progress bar. This implementation invokes the * method of the same name without the orientation. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to * @param orientation one of <code>JProgressBar.HORIZONTAL</code> or * <code>JProgressBar.VERTICAL</code> * @since 1.6 */ public void paintProgressBarBorder(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) { paintBorder(context, g, x, y, w, h, orientation); }
Example #28
Source File: SynthPainterImpl.java From hottub with GNU General Public License v2.0 | 2 votes |
/** * Paints the border of a tab of a tabbed pane. This implementation invokes * the method of the same name without the orientation. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to * @param tabIndex Index of tab being painted. * @param orientation One of <code>JTabbedPane.TOP</code>, * <code>JTabbedPane.LEFT</code>, * <code>JTabbedPane.BOTTOM</code>, or * <code>JTabbedPane.RIGHT</code> * @since 1.6 */ public void paintTabbedPaneTabBorder(SynthContext context, Graphics g, int x, int y, int w, int h, int tabIndex, int orientation) { paintBorder(context, g, x, y, w, h, null); }
Example #29
Source File: SynthPainterImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Paints the background of the viewport. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to */ public void paintViewportBackground(SynthContext context, Graphics g, int x, int y, int w, int h) { paintBackground(context, g, x, y, w, h, null); }
Example #30
Source File: SynthPainterImpl.java From hottub with GNU General Public License v2.0 | 2 votes |
/** * Paints the border of a slider. This implementation invokes the * method of the same name without the orientation. * * @param context SynthContext identifying the <code>JComponent</code> and * <code>Region</code> to paint to * @param g <code>Graphics</code> to paint to * @param x X coordinate of the area to paint to * @param y Y coordinate of the area to paint to * @param w Width of the area to paint to * @param h Height of the area to paint to * @param orientation One of <code>JSlider.HORIZONTAL</code> or * <code>JSlider.VERTICAL</code> * @since 1.6 */ public void paintSliderBorder(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) { paintBorder(context, g, x, y, w, h, orientation); }