Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.fmap / src / main / java / org / gvsig / raster / fmap / layers / FLyrState.java @ 1738

History | View | Annotate | Download (4.12 KB)

1 103 nbrodin
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22
package org.gvsig.raster.fmap.layers;
23
24
25
/**
26
 * Estados de una capa. Cada capa tiene uno o varios estados activos en cada instante.
27
 * Hay estados no compatibles entre si, es decir, no pueden estar activos a la vez en cada
28
 * instante. Por ejemplo, una capa no puede estar cerrada y renderizando ya que sus datos no
29
 * est?n accesibles para esa operaci?n. Los estados de una capa sir
30
 * @version 13/09/2007
31
 * @author Nacho Brodin (nachobrodin@gmail.com)
32
 *
33
 */
34
public class FLyrState implements ILayerState {
35
        private boolean open                 = false;
36
        private boolean closed               = true;
37
        private boolean awake                = false;
38
        private boolean stopped              = false;
39
        //private boolean renderizing        = false;
40
41
        private int lastBeforeStop           = UNDEFINED;
42
43
44
        /*
45
         * (non-Javadoc)
46
         * @see org.gvsig.fmap.raster.layers.IState#isAwake()
47
         */
48
        public boolean isAwake() {
49
                return awake;
50
        }
51
52
        /*
53
         * (non-Javadoc)
54
         * @see org.gvsig.fmap.raster.layers.IState#enableAwake()
55
         */
56
        public void enableAwake() throws NotAvailableStateException {
57 163 nbrodin
                if(awake)
58
                        return;
59 103 nbrodin
                if(open == true || closed == true || stopped == true) {
60
                        this.awake = true;
61
                        stopped = closed = open = false;
62
                        lastBeforeStop = UNDEFINED;
63
                } else
64
                        throw new NotAvailableStateException("Awake state not available");
65
        }
66
67
        /*
68
         * (non-Javadoc)
69
         * @see org.gvsig.fmap.raster.layers.IState#isOpen()
70
         */
71
        public boolean isOpen() {
72
                return open;
73
        }
74
75
        /*
76
         * (non-Javadoc)
77
         * @see org.gvsig.fmap.raster.layers.IState#enableOpen()
78
         */
79
        public void enableOpen() throws NotAvailableStateException {
80
                if(stopped == true || awake == true) {
81
                        this.open = true;
82
                        stopped = closed = awake = false;
83
                        lastBeforeStop = UNDEFINED;
84
                } else
85
                        throw new NotAvailableStateException("Open state not available");
86
        }
87
88
89
        /*
90
         * (non-Javadoc)
91
         * @see org.gvsig.fmap.raster.layers.IState#isClosed()
92
         */
93
        public boolean isClosed() {
94
                return closed;
95
        }
96
97
        /*
98
         * (non-Javadoc)
99
         * @see org.gvsig.fmap.raster.layers.IState#enableClosed()
100
         */
101
        public void enableClosed() throws NotAvailableStateException {
102
                if(open == true || awake == true || stopped == true) {
103
                        this.closed = true;
104
                        stopped = open = awake = false;
105
                        lastBeforeStop = UNDEFINED;
106
                } else
107
                        throw new NotAvailableStateException("Closed state not available");
108
        }
109
110
        /*
111
         * (non-Javadoc)
112
         * @see org.gvsig.fmap.raster.layers.IState#isStopped()
113
         */
114
        public boolean isStopped() {
115
                return stopped;
116
        }
117
118
        /*
119
         * (non-Javadoc)
120
         * @see org.gvsig.fmap.raster.layers.IState#enableStopped()
121
         */
122
        public void enableStopped() {
123
                if(open == true || awake == true || closed == true) {
124
                        lastBeforeStop = (open == true) ? OPEN : ((closed == true) ? CLOSED : ((awake == true) ? AWAKE : UNDEFINED));
125
                        if(lastBeforeStop != UNDEFINED) {
126
                                stopped = true;
127
                                closed = open = awake = false;
128
                        }
129
                }
130
        }
131
132
        /*
133
         * (non-Javadoc)
134
         * @see org.gvsig.fmap.raster.layers.IState#disableStopped()
135
         */
136
        public void disableStopped() {
137
                if(stopped == true && lastBeforeStop != UNDEFINED) {
138
                        switch(lastBeforeStop) {
139
                        case OPEN: open = true; closed = awake = false; break;
140
                        case CLOSED: closed = true; awake = open = false; break;
141
                        case AWAKE: awake = true; closed = open = false; break;
142
                        }
143
                        stopped = false;
144
                        lastBeforeStop = UNDEFINED;
145
                }
146
        }
147
148
}