Back to index

moin  1.9.0~rc2
InsertImageCommand.java
Go to the documentation of this file.
00001 /*
00002  * @(#)InsertImageCommand.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.figures;
00007 
00008 import java.util.*;
00009 import java.awt.*;
00010 import CH.ifa.draw.util.*;
00011 import CH.ifa.draw.framework.*;
00012 import CH.ifa.draw.standard.*;
00013 
00017 public class InsertImageCommand extends Command {
00018 
00019     private DrawingView  fView;
00020     private String       fImage;
00021 
00028     public InsertImageCommand(String name, String image, DrawingView view) {
00029         super(name);
00030         fImage = image;
00031         fView = view;
00032     }
00033 
00034     public void execute() {
00035         // ugly cast to component, but AWT wants and Component instead of an ImageObserver...
00036         Image image = Iconkit.instance().registerAndLoadImage((Component)fView, fImage);
00037         ImageFigure figure = new ImageFigure(image, fImage, fView.lastClick());
00038         fView.add(figure);
00039         fView.clearSelection();
00040         fView.addToSelection(figure);
00041         fView.checkDamage();
00042     }
00043 }
00044 
00045 
00046