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

📄 swtpicture.java

📁 Java开发图文混排的编辑器
💻 JAVA
字号:
/*
 * Created on 2004-8-13
 * Author: Xuefeng, Copyright (C) 2004, Xuefeng.
 */
package jexi.ui.swt;

import java.io.*;

import jexi.core.Picture;
import jexi.ui.Graphics;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;

/**
 * SWTPicture is the implementation of jexi.core.Picture, 
 * it is a Glyph. 
 * 
 * @author Xuefeng
 */
public class SWTPicture extends Picture {

    private Image image;
    private int width;
    private int height;

    SWTPicture(String filename) throws IOException {
        try {
            image = new Image(Display.getCurrent(), filename);
            Rectangle r = image.getBounds();
            this.width = r.width;
            this.height = r.height;
        }
        catch(Exception e) {
            e.printStackTrace();
            throw new IOException();
        }
    }

    /* (non-Javadoc)
     * @see jexi.core.Glyph#draw(jexi.ui.Graphics)
     */
    public void draw(Graphics g) {
        SWTGraphics swtg = (SWTGraphics)g;
        swtg.gc.drawImage(image, g.getCurrentX(), g.getCurrentY());
    }

    /* (non-Javadoc)
     * @see jexi.core.Glyph#width()
     */
    public int width() {
        return this.width;
    }

    /* (non-Javadoc)
     * @see jexi.core.Glyph#height()
     */
    public int height() {
        return this.height;
    }
}

⌨️ 快捷键说明

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