本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}