Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / castor / ProjectView.java @ 652

History | View | Annotate | Download (3.24 KB)

1
package com.iver.cit.gvsig.project.castor;
2

    
3
import com.hardcode.driverManager.DriverLoadException;
4
import com.hardcode.gdbms.engine.data.DriverException;
5
import com.iver.cit.gvsig.fmap.FMap;
6
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
7
import com.iver.cit.gvsig.fmap.layers.CancelationException;
8
import com.iver.cit.gvsig.fmap.layers.DifferentVersionException;
9
import com.iver.cit.gvsig.fmap.layers.XMLException;
10

    
11
import com.iver.utiles.StringUtilities;
12
import com.iver.utiles.XMLEntity;
13

    
14
import java.awt.Color;
15

    
16
import java.text.DateFormat;
17

    
18
import java.util.Date;
19

    
20

    
21
/**
22
 * Clase que representa una vista del proyecto
23
 *
24
 * @author Fernando Gonz?lez Cort?s
25
 */
26
public class ProjectView extends ProjectElement {
27
    private static int numViews = 0;
28

    
29
    //public static int METROS = 0;
30
    //public static int KILOMETROS = 1;
31
    //public static int[] unidades = new int[] { METROS, KILOMETROS };
32
    private Color backgroundColor = new Color(255, 255, 255);
33
    private FMap mapContext = new FMap(null);
34

    
35
    /**
36
     * Obtiene el color de fondo del mapa
37
     *
38
     * @return
39
     */
40
    public Color getBackgroundColor() {
41
        return backgroundColor;
42
    }
43

    
44
    /**
45
     * Establece el color de fondo del mapa
46
     *
47
     * @param color
48
     */
49
    public void setBackgroundColor(Color color) {
50
        backgroundColor = color;
51
    }
52

    
53
    /**
54
     * DOCUMENT ME!
55
     *
56
     * @return
57
     */
58
    public FMap getMapContext() {
59
        return mapContext;
60
    }
61

    
62
    /**
63
     * DOCUMENT ME!
64
     *
65
     * @param baseName
66
     *
67
     * @return
68
     */
69
    public static ProjectView createView(String baseName) {
70
        ProjectView v = new ProjectView();
71
        v.setName(baseName + " - " + numViews);
72
        v.setCreationDate(DateFormat.getInstance().format(new Date()));
73
        numViews++;
74

    
75
        return v;
76
    }
77

    
78
    /**
79
     * @see com.iver.cit.gvsig.project.ProjectView#setMapContext(com.iver.cit.gvsig.fmap.FMap)
80
     */
81
    public void setMapContext(FMap fmap) {
82
        mapContext = fmap;
83
    }
84

    
85
    /**
86
     * DOCUMENT ME!
87
     *
88
     * @return DOCUMENT ME!
89
     * @throws DriverException
90
     */
91
    public XMLEntity getXMLEntity() {
92
        XMLEntity xml = super.getXMLEntity();
93
        xml.putProperty("nameClass",this.getClass().getName());
94
        xml.putProperty("numViews", numViews);
95
        xml.putProperty("backgroundColor",
96
            StringUtilities.color2String(backgroundColor));
97

    
98
        xml.addChild(mapContext.getXMLEntity());
99
        return xml;
100
    }
101

    
102
    /**
103
     * @throws XMLException
104
     * @throws com.iver.cit.gvsig.fmap.DriverException
105
     * @throws DifferentVersionException
106
     * @throws CancelationException
107
     * @throws ClassNotFoundException
108
     * @throws InstantiationException
109
     * @throws IllegalAccessException
110
     * @throws DriverIOException
111
     * @throws DriverLoadException
112
     * @see com.iver.cit.gvsig.project.castor.ProjectElement#setXMLEntity(com.iver.utiles.XMLEntity)
113
     */
114
    public void setXMLEntity(XMLEntity xml, Project p) throws XMLException, com.iver.cit.gvsig.fmap.DriverException{
115
        numViews = xml.getIntProperty("numViews");
116
        setBackgroundColor(StringUtilities.string2Color(xml.getStringProperty(
117
                    "backgroundColor")));
118

    
119
                setMapContext(FMap.createFromXML(xml.getChild(0)));
120
    }
121
}