Statistics
| Revision:

root / trunk / extensions / extAnimationGUI / src / com / iver / ai2 / animationgui / gui / document / ProjectAnimationDocumentFactory.java @ 20095

History | View | Annotate | Download (3.23 KB)

1
package com.iver.ai2.animationgui.gui.document;
2

    
3
import java.text.DateFormat;
4
import java.util.Date;
5
import java.util.Hashtable;
6

    
7
import javax.swing.ImageIcon;
8

    
9
import com.iver.ai2.animationgui.gui.AnimationDocumentRegister;
10
import com.iver.ai2.gvsig3dgui.ProjectView3D;
11
import com.iver.ai2.gvsig3dgui.ProjectView3DFactory;
12
import com.iver.andami.PluginServices;
13
import com.iver.cit.gvsig.project.Project;
14
import com.iver.cit.gvsig.project.documents.ProjectDocument;
15
import com.iver.cit.gvsig.project.documents.ProjectDocumentFactory;
16
import com.iver.utiles.XMLEntity;
17

    
18
public class ProjectAnimationDocumentFactory extends ProjectDocumentFactory {
19

    
20
        public static String registerName = "ProjectAnimationDocument";
21
        private int numViews = 0;
22
        private boolean createFromGUI;
23
        
24
        public ProjectDocument createFromGUI(Project project) {
25
                createFromGUI = true;
26
                ProjectDocument doc = create(project);
27
                createFromGUI = false;
28
                return doc;
29
        }
30

    
31
        @Override
32
        public ProjectDocument create(Project project) {
33
                String viewName = "";
34
        String aux = PluginServices.getText(this, "untitled");
35
               viewName = aux + " - " + numViews ++;
36

    
37
        if (project != null) {
38
            while (existName(project, viewName)) {
39
                viewName = aux + " - " + numViews++;
40
            }
41
        }
42
//       ProjectDocument.NUMS.put(registerName,new Integer(numViews));
43
       ProjectAnimationDocument Animation = createAnimation(viewName);
44
                
45
                if (Animation != null)
46
                        Animation.setProject(project, 0);
47

    
48
                return Animation;
49
        }
50
        
51

    
52
        /**
53
         * This method creates a new instance of animation
54
         * @param animationName
55
         * @return
56
         */
57
        private ProjectAnimationDocument createAnimation(String animationName) {
58
                 ProjectAnimationDocument animation = new ProjectAnimationDocument();
59
                 animation.setName(animationName);
60
                 animation.setCreationDate(DateFormat.getInstance().format(new Date()));
61
                return animation;
62
        }
63

    
64
        @Override
65
        public ImageIcon getButtonIcon() {
66
                return new ImageIcon(this.getClass().getClassLoader().getResource(
67
                "images/camera_add.png"));
68
        }
69

    
70
        @Override
71
        public String getRegisterName() {
72
                // TODO Auto-generated method stub
73
                return this.registerName;
74
        }
75

    
76
        @Override
77
        public ImageIcon getSelectedButtonIcon() {
78
                return new ImageIcon(this.getClass().getClassLoader().getResource(
79
                "images/camera_add.png"));
80
        }
81

    
82
        @Override
83
        public boolean resolveImportXMLConflicts(XMLEntity root, Project project,
84
                        Hashtable conflicts) {
85
                // TODO Auto-generated method stub
86
                return false;
87
        }
88
        
89
        /**
90
         * Registers in the points of extension the Factory with alias.
91
         * 
92
         */
93
        public static void register() {
94
                register(registerName , new ProjectAnimationDocumentFactory());
95
        }
96
        
97
        /**
98
         * Returns the priority of de ProjectDocument.
99
         * 
100
         * @return Priority.
101
         */
102
        public int getPriority() {
103
                return 40;
104
        }
105

    
106
        /**
107
         * Returns the priority of the Document in the ProjectWindow list.
108
         * 
109
         * @return Priority.
110
         */
111
        public int getListPriority() {
112
                return 40; // so the 3D View appears before other document types
113
        }
114
        
115

    
116
        /**
117
         * Returns the name of ProjectDocument.
118
         * 
119
         * @return Name of ProjectDocument.
120
         */
121
        public String getNameType() {
122
                return "Animation";
123
        }
124

    
125
}