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


Java SynthContext.getComponent方法代码示例

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


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

示例1: 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:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:NimbusIcon.java

示例2: getIconHeight

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

示例3: 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:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:NimbusIcon.java

示例4: 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

示例5: 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:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:SynthPainterImpl.java


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