KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > command > CreateShapeCommand


1 /**
2  * <p> Project: com.nightlabs.editor2d </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 29.12.2004 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.command;
9
10 import org.apache.log4j.Logger;
11
12 import com.nightlabs.editor2d.EditorPlugin;
13 import com.nightlabs.editor2d.LineDrawComponent;
14 import com.nightlabs.editor2d.ShapeDrawComponent;
15 import com.nightlabs.editor2d.j2d.GeneralShape;
16
17
18 public class CreateShapeCommand
19 //extends Command
20
extends CreateDrawComponentCommand
21 {
22   public static final Logger LOGGER = Logger.getLogger(CreateShapeCommand.class);
23     
24   protected GeneralShape generalShape;
25   public void setGeneralShape(GeneralShape generalShape) {
26     this.generalShape = generalShape;
27   }
28     
29     /**
30      * Create a command that will add a new DrawComponent to a MultiLayerDrawComponent.
31      * @param parent the MultiLayerDrawComponent that will hold the new element
32      * @param req a request to create a new DrawComponent
33      * @throws IllegalArgumentException if any parameter is null, or the request
34      * does not provide a new DrawComponent instance
35      */

36     public CreateShapeCommand()
37     {
38       super(EditorPlugin.getResourceString("command_create_shape"));
39     }
40         
41     /* (non-Javadoc)
42      * @see org.eclipse.gef.commands.Command#execute()
43      */

44     public void execute()
45     {
46       if (generalShape != null)
47       getShapeDrawComponent().setGeneralShape(generalShape);
48                 
49         if (drawComponent instanceof LineDrawComponent)
50       getShapeDrawComponent().setFill(false);
51     
52     super.execute();
53     }
54             
55   protected ShapeDrawComponent getShapeDrawComponent() {
56    return (ShapeDrawComponent) getChild();
57   }
58 }
59
Popular Tags