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

📄 insertimagecommand.java

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

package CH.ifa.draw.figures;

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

/**
 * Command to insert a named image.
 */
public class InsertImageCommand extends Command {

    private DrawingView  fView;
    private String       fImage;

   /**
    * Constructs an insert image command.
    * @param name the command name
    * @param image the pathname of the image
    * @param view the target view
    */
    public InsertImageCommand(String name, String image, DrawingView view) {
        super(name);
        fImage = image;
        fView = view;
    }

    public void execute() {
        // ugly cast to component, but AWT wants and Component instead of an ImageObserver...
        Image image = Iconkit.instance().registerAndLoadImage((Component)fView, fImage);
        ImageFigure figure = new ImageFigure(image, fImage, fView.lastClick());
        fView.add(figure);
        fView.clearSelection();
        fView.addToSelection(figure);
        fView.checkDamage();
    }
}



⌨️ 快捷键说明

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