Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / VectorialFileAdapter.java @ 229

History | View | Annotate | Download (3.78 KB)

1
/* Generated by Together */
2
package com.iver.cit.gvsig.fmap.layers;
3

    
4
import com.iver.cit.gvsig.fmap.core.FGeometry;
5
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
6
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
7
import com.iver.cit.gvsig.fmap.rendering.indexes.IndexNotExistsException;
8
import com.iver.cit.gvsig.fmap.write.FileWriterDriver;
9

    
10
import java.awt.geom.Rectangle2D;
11

    
12
import java.io.File;
13
import java.io.IOException;
14

    
15

    
16
/**
17
 * Adapta un driver de fichero vectorial a la interfaz vectorial, manteniendo
18
 * adem?s el estado necesario por una capa vectorial de fichero (el nombre del
19
 * fichero)
20
 */
21
public class VectorialFileAdapter extends VectorialAdapter {
22
    private boolean driverInitialized = false;
23
    private File file;
24
    private FileWriterDriver writeDriver;
25

    
26
    /**
27
     * Crea un nuevo VectorialFileAdapter.
28
     *
29
     * @param file DOCUMENT ME!
30
     */
31
    public VectorialFileAdapter(File file) {
32
        this.file = file;
33
    }
34

    
35
    /**
36
     * DOCUMENT ME!
37
     *
38
     * @return DOCUMENT ME!
39
     *
40
     * @throws IOException DOCUMENT ME!
41
     */
42
    private VectorialFileDriver getFileDriver() throws IOException {
43
        return (VectorialFileDriver) getDriver();
44
    }
45

    
46
    /**
47
     * incrementa el contador de las veces que se ha abierto el fichero.
48
     * Solamente cuando el contador est? a cero pide al driver que abra el
49
     * fichero
50
     *
51
     * @throws DriverIOException
52
     */
53
    public void start() throws DriverIOException {
54
        try {
55
            getFileDriver().open(file);
56

    
57
            if (!driverInitialized) {
58
                getFileDriver().initialize();
59
                driverInitialized = true;
60
            }
61
        } catch (IOException e) {
62
            throw new DriverIOException(e);
63
        }
64
    }
65

    
66
    /**
67
     * decrementa el contador de n?mero de aperturas y cuando llega a cero pide
68
     * al driver que cierre el fichero
69
     *
70
     * @throws DriverIOException
71
     */
72
    public void stop() throws DriverIOException {
73
        try {
74
            getFileDriver().close();
75
        } catch (IOException e) {
76
            throw new DriverIOException(e);
77
        }
78
    }
79

    
80
    /**
81
     * DOCUMENT ME!
82
     *
83
     * @param index DOCUMENT ME!
84
     *
85
     * @return DOCUMENT ME!
86
     *
87
     * @throws DriverIOException
88
     *
89
     * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int)
90
     */
91
    public FGeometry getShape(int index) throws DriverIOException {
92
        try {
93
            return getFileDriver().getShape(index);
94
        } catch (IOException e) {
95
            throw new DriverIOException(e);
96
        }
97
    }
98

    
99
    /**
100
     * DOCUMENT ME!
101
     *
102
     * @return DOCUMENT ME!
103
     *
104
     * @throws DriverIOException
105
     *
106
     * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeCount()
107
     */
108
    public int getShapeCount() throws DriverIOException {
109
        try {
110
            return getFileDriver().getShapeCount();
111
        } catch (IOException e) {
112
            throw new DriverIOException(e);
113
        }
114
    }
115

    
116
    /**
117
     * DOCUMENT ME!
118
     *
119
     * @return DOCUMENT ME!
120
     *
121
     * @throws DriverIOException
122
     *
123
     * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getFullExtent()
124
     */
125
    public Rectangle2D getFullExtent() throws DriverIOException {
126
        try {
127
            return getFileDriver().getFullExtent();
128
        } catch (IOException e) {
129
            throw new DriverIOException(e);
130
        }
131
    }
132

    
133
    /**
134
     * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#initialize()
135
     */
136
    public void initialize() {
137
    }
138

    
139
    /**
140
     * @see com.iver.cit.gvsig.fmap.rendering.indexes.Index#getRecordIndexes(java.awt.geom.Rectangle2D)
141
     */
142
    public int[] getRecordIndexes(Rectangle2D rect)
143
        throws DriverIOException, IndexNotExistsException {
144
        //TODO implementar bien
145
        return null;
146
    }
147
}