• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Painter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: paintComponent

import javax.swing.Painter; //导入依赖的package包/类
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:TableScrollPaneCorner.java


示例2: paintBackground

import javax.swing.Painter; //导入依赖的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


示例3: paintComponent

import javax.swing.Painter; //导入依赖的package包/类
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    @SuppressWarnings("unchecked")
    Painter<JComponent> painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:TableScrollPaneCorner.java


示例4: getBackgroundPainter

import javax.swing.Painter; //导入依赖的package包/类
/**
 * Gets the appropriate background Painter, if there is one, for the state
 * specified in the given SynthContext. This method does appropriate
 * fallback searching, as described in #get.
 *
 * @param ctx The SynthContext. Must not be null.
 * @return The background painter associated for the given state, or null if
 * none could be found.
 */
public Painter<Object> getBackgroundPainter(SynthContext ctx) {
    Values v = getValues(ctx);
    int xstate = getExtendedState(ctx, v);
    Painter<Object> p = null;

    // check the cache
    tmpKey.init("backgroundPainter$$instance", xstate);
    p = paintFilter((Painter)v.cache.get(tmpKey));
    if (p != null) return p;

    // not in cache, so lookup and store in cache
    RuntimeState s = null;
    int[] lastIndex = new int[] {-1};
    while ((s = getNextState(v.states, lastIndex, xstate)) != null) {
        if (s.backgroundPainter != null) {
            p = paintFilter(s.backgroundPainter);
            break;
        }
    }
    if (p == null) p = paintFilter((Painter)get(ctx, "backgroundPainter"));
    if (p != null) {
        v.cache.put(new CacheKey("backgroundPainter$$instance", xstate), p);
    }
    return p;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:NimbusStyle.java


示例5: getForegroundPainter

import javax.swing.Painter; //导入依赖的package包/类
/**
 * Gets the appropriate foreground Painter, if there is one, for the state
 * specified in the given SynthContext. This method does appropriate
 * fallback searching, as described in #get.
 *
 * @param ctx The SynthContext. Must not be null.
 * @return The foreground painter associated for the given state, or null if
 * none could be found.
 */
public Painter<Object> getForegroundPainter(SynthContext ctx) {
    Values v = getValues(ctx);
    int xstate = getExtendedState(ctx, v);
    Painter<Object> p = null;

    // check the cache
    tmpKey.init("foregroundPainter$$instance", xstate);
    p = paintFilter((Painter)v.cache.get(tmpKey));
    if (p != null) return p;

    // not in cache, so lookup and store in cache
    RuntimeState s = null;
    int[] lastIndex = new int[] {-1};
    while ((s = getNextState(v.states, lastIndex, xstate)) != null) {
        if (s.foregroundPainter != null) {
            p = paintFilter(s.foregroundPainter);
            break;
        }
    }
    if (p == null) p = paintFilter((Painter)get(ctx, "foregroundPainter"));
    if (p != null) {
        v.cache.put(new CacheKey("foregroundPainter$$instance", xstate), p);
    }
    return p;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:NimbusStyle.java


示例6: getBorderPainter

import javax.swing.Painter; //导入依赖的package包/类
/**
 * Gets the appropriate border Painter, if there is one, for the state
 * specified in the given SynthContext. This method does appropriate
 * fallback searching, as described in #get.
 *
 * @param ctx The SynthContext. Must not be null.
 * @return The border painter associated for the given state, or null if
 * none could be found.
 */
public Painter<Object> getBorderPainter(SynthContext ctx) {
    Values v = getValues(ctx);
    int xstate = getExtendedState(ctx, v);
    Painter<Object> p = null;

    // check the cache
    tmpKey.init("borderPainter$$instance", xstate);
    p = paintFilter((Painter)v.cache.get(tmpKey));
    if (p != null) return p;

    // not in cache, so lookup and store in cache
    RuntimeState s = null;
    int[] lastIndex = new int[] {-1};
    while ((s = getNextState(v.states, lastIndex, xstate)) != null) {
        if (s.borderPainter != null) {
            p = paintFilter(s.borderPainter);
            break;
        }
    }
    if (p == null) p = paintFilter((Painter)get(ctx, "borderPainter"));
    if (p != null) {
        v.cache.put(new CacheKey("borderPainter$$instance", xstate), p);
    }
    return p;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:NimbusStyle.java


示例7: paintBackground

import javax.swing.Painter; //导入依赖的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


示例8: paintForeground

import javax.swing.Painter; //导入依赖的package包/类
private void paintForeground(SynthContext ctx, Graphics g, int x, int y,
                             int w, int h, AffineTransform transform) {
    Painter foregroundPainter = style.getForegroundPainter(ctx);
    if (foregroundPainter != null) {
        paint(foregroundPainter, ctx, g, x, y, w, h,transform);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:SynthPainterImpl.java


示例9: paintBorder

import javax.swing.Painter; //导入依赖的package包/类
private void paintBorder(SynthContext ctx, Graphics g, int x, int y, int w,
                         int h, AffineTransform transform) {
    Painter borderPainter = style.getBorderPainter(ctx);
    if (borderPainter != null) {
        paint(borderPainter, ctx, g, x, y, w, h,transform);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:SynthPainterImpl.java


示例10: getPainter

import javax.swing.Painter; //导入依赖的package包/类
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:NimbusStyle.java


示例11: paintIcon

import javax.swing.Painter; //导入依赖的package包/类
/**
 * Implements the standard Icon interface's paintIcon method as the standard
 * synth stub passes null for the context and this will cause us to not
 * paint any thing, so we override here so that we can paint the enabled
 * state if no synth context is available
 */
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    Painter painter = (Painter)UIManager.get(prefix + "[Enabled]." + key);
    if (painter != null){
        JComponent jc = (c instanceof JComponent) ? (JComponent)c : null;
        Graphics2D gfx = (Graphics2D)g;
        gfx.translate(x, y);
        painter.paint(gfx, jc , width, height);
        gfx.translate(-x, -y);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:NimbusIcon.java


示例12: paintForeground

import javax.swing.Painter; //导入依赖的package包/类
private void paintForeground(SynthContext ctx, Graphics g, int x, int y,
                             int w, int h, AffineTransform transform) {
    Painter<Object> foregroundPainter = style.getForegroundPainter(ctx);
    if (foregroundPainter != null) {
        paint(foregroundPainter, ctx, g, x, y, w, h,transform);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:SynthPainterImpl.java


示例13: paintBorder

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


示例14: getPainter

import javax.swing.Painter; //导入依赖的package包/类
private Painter<Object> getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    @SuppressWarnings("unchecked")
    Painter<Object> tmp = (p instanceof Painter ? (Painter)p : null);
    return tmp;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:NimbusStyle.java


示例15: paintIcon

import javax.swing.Painter; //导入依赖的package包/类
/**
 * Implements the standard Icon interface's paintIcon method as the standard
 * synth stub passes null for the context and this will cause us to not
 * paint any thing, so we override here so that we can paint the enabled
 * state if no synth context is available
 */
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    Painter<JComponent> painter =
        paintFilter((Painter)UIManager.get(prefix + "[Enabled]." + key));
    if (painter != null){
        JComponent jc = (c instanceof JComponent) ? (JComponent)c : null;
        Graphics2D gfx = (Graphics2D)g;
        gfx.translate(x, y);
        painter.paint(gfx, jc , width, height);
        gfx.translate(-x, -y);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:NimbusIcon.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FromItemVisitor类代码示例发布时间:2022-05-21
下一篇:
Java SocketConnector类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap