⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 patternpainter.java

📁 开源(Open Source)项目JHotDraw的文档和源程序
💻 JAVA
字号:
/*
 * @(#)PatternPainter.java 5.2
 *
 */

package CH.ifa.draw.samples.javadraw;

import java.awt.*;
import CH.ifa.draw.framework.*;

/**
 * PatternDrawer a background that can be added to a
 * drawing.
 * @see DrawingView
 * @see Painter
 */

public  class PatternPainter
        implements Painter {

    private Image   fImage;

    public PatternPainter(Image image) {
        fImage = image;
    }

    public void draw(Graphics g, DrawingView view) {
        drawPattern(g, fImage, view);
    }

    /**
     * Draws a pattern background pattern by replicating an image.
     */
    private void drawPattern(Graphics g, Image image, DrawingView view) {
        int iwidth = image.getWidth(view);
        int iheight = image.getHeight(view);
        Dimension d = view.getSize();
        int x = 0; int y = 0;

        while (y < d.height) {
            while (x < d.width) {
                g.drawImage(image, x, y, view);
                x += iwidth;
            }
            y += iheight;
            x = 0;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -