当前位置: 首页>>代码示例>>Java>>正文


Java SynthContext类代码示例

本文整理汇总了Java中javax.swing.plaf.synth.SynthContext的典型用法代码示例。如果您正苦于以下问题:Java SynthContext类的具体用法?Java SynthContext怎么用?Java SynthContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SynthContext类属于javax.swing.plaf.synth包,在下文中一共展示了SynthContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintAndCheckIcon

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
private static void paintAndCheckIcon(Icon icon, SynthContext synthContext,
        int width, int height) {

    BufferedImage buffImage = new BufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB);
    Graphics g = buffImage.createGraphics();
    g.setColor(Color.RED);
    g.fillRect(0, 0, width, height);
    SynthGraphicsUtils.paintIcon(icon, synthContext, g, 0, 0, width, height);
    g.dispose();

    Color iconCenterColor = new Color(buffImage.getRGB(width / 2, height / 2));

    if (!TEST_COLOR.equals(iconCenterColor)) {
        throw new RuntimeException("Icon is painted incorrectly!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:bug8081411.java

示例2: paintSliderThumbBackground

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * Paints the background of the thumb of a slider.
 *
 * @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>
 */
public void paintSliderThumbBackground(SynthContext context,
                                 Graphics g, int x, int y,
                                 int w, int h, int orientation) {
    if (context.getComponent().getClientProperty(
            "Slider.paintThumbArrowShape") == Boolean.TRUE){
        if (orientation == JSlider.HORIZONTAL){
            orientation = JSlider.VERTICAL;
        } else {
            orientation = JSlider.HORIZONTAL;
        }
        paintBackground(context, g, x, y, w, h, orientation);
    } else {
        paintBackground(context, g, x, y, w, h, orientation);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:SynthPainterImpl.java

示例3: getIconWidth

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:NimbusIcon.java

示例4: getFontForState

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * Overridden to cause this style to populate itself with data from
 * UIDefaults, if necessary. If a value named "font" is not found in
 * UIDefaults, then the "defaultFont" font in UIDefaults will be returned
 * instead.
 */
@Override protected Font getFontForState(SynthContext ctx) {
    Font f = (Font)get(ctx, "font");
    if (f == null) f = UIManager.getFont("defaultFont");

    // Account for scale
    // The key "JComponent.sizeVariant" is used to match Apple's LAF
    String scaleKey = (String)ctx.getComponent().getClientProperty(
            "JComponent.sizeVariant");
    if (scaleKey != null){
        if (LARGE_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*LARGE_SCALE));
        } else if (SMALL_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*SMALL_SCALE));
        } else if (MINI_KEY.equals(scaleKey)){
            f = f.deriveFont(Math.round(f.getSize2D()*MINI_SCALE));
        }
    }
    return f;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:NimbusStyle.java

示例5: scale

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:NimbusIcon.java

示例6: paintBackground

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
private void paintBackground(SynthContext ctx, Graphics g, int x, int y,
                             int w, int h, AffineTransform transform) {
    // if the background color of the component is 100% transparent
    // then we should not paint any background graphics. This is a solution
    // for there being no way of turning off Nimbus background painting as
    // basic components are all non-opaque by default.
    Component c = ctx.getComponent();
    Color bg = (c != null) ? c.getBackground() : null;
    if (bg == null || bg.getAlpha() > 0){

        Painter<Object> backgroundPainter = style.getBackgroundPainter(ctx);
        if (backgroundPainter != null) {
            paint(backgroundPainter, ctx, g, x, y, w, h,transform);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:SynthPainterImpl.java

示例7: getColorForState

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * {@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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:NimbusStyle.java

示例8: paintArrowButtonBackground

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SynthPainterImpl.java

示例9: paintFormattedTextFieldBorder

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:SynthPainterImpl.java

示例10: paintFormattedTextFieldBackground

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:SynthPainterImpl.java

示例11: paintTextFieldBorder

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:SynthPainterImpl.java

示例12: paintBackground

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
private void paintBackground(SynthContext ctx, Graphics g, int x, int y,
                             int w, int h, AffineTransform transform) {
    // if the background color of the component is 100% transparent
    // then we should not paint any background graphics. This is a solution
    // for there being no way of turning off Nimbus background painting as
    // basic components are all non-opaque by default.
    Component c = ctx.getComponent();
    Color bg = (c != null) ? c.getBackground() : null;
    if (bg == null || bg.getAlpha() > 0){
        Painter backgroundPainter = style.getBackgroundPainter(ctx);
        if (backgroundPainter != null) {
            paint(backgroundPainter, ctx, g, x, y, w, h,transform);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:SynthPainterImpl.java

示例13: get

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * {@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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:74,代码来源:NimbusStyle.java

示例14: getIconWidth

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
@Override
public int getIconWidth(SynthContext sc) {
    return width;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:bug8081411.java

示例15: paintSliderTrackBorder

import javax.swing.plaf.synth.SynthContext; //导入依赖的package包/类
/**
 * Paints the border of the track 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 paintSliderTrackBorder(SynthContext context,
                             Graphics g, int x, int y,
                             int w, int h, int orientation) {
    paintBorder(context, g, x, y, w, h, orientation);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:SynthPainterImpl.java


注:本文中的javax.swing.plaf.synth.SynthContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。