Revision 38320

View differences:

tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/src/org/gvsig/app/eventtheme/daltransform/EventThemeTransformGui.java
1
/* 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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.app.eventtheme.daltransform;
29

  
30
import java.awt.Dimension;
31
import java.util.ArrayList;
32
import java.util.List;
33

  
34
import org.gvsig.andami.PluginServices;
35
import org.gvsig.app.eventtheme.dal.feature.EventThemeTransform;
36
import org.gvsig.daltransform.swing.DataTransformGui;
37
import org.gvsig.daltransform.swing.DataTransformWizardPanel;
38
import org.gvsig.fmap.dal.exception.DataException;
39
import org.gvsig.fmap.dal.feature.FeatureStore;
40
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
41

  
42

  
43
/**
44
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
45
 */
46
public class EventThemeTransformGui implements DataTransformGui{
47
	private EventThemeTransformPanel panel = null;
48
	
49
	public EventThemeTransformGui() {
50
		super();		
51
	}	
52
	
53
	/* (non-Javadoc)
54
	 * @see org.gvsig.app.daltransform.gui.FeatureTransformGui#createPanels(org.gvsig.app.daltransform.gui.FeatureTransformWizardModel)
55
	 */
56
	public List<DataTransformWizardPanel> createPanels() {
57
		if (panel == null){
58
			panel = new EventThemeTransformPanel();
59
		}
60
		List<DataTransformWizardPanel> panels = new ArrayList<DataTransformWizardPanel>();
61
		panels.add(panel);
62
		return panels;
63
	}
64

  
65
	/* (non-Javadoc)
66
	 * @see org.gvsig.app.daltransform.gui.FeatureTransformGui#getDescription()
67
	 */
68
	public String getDescription() {
69
		return PluginServices.getText(this, "events_layer_description");
70
	}
71

  
72
	/* (non-Javadoc)
73
	 * @see java.awt.Component#toString()
74
	 */	
75
	public String toString() {
76
		return getName();
77
	}
78

  
79
	/* (non-Javadoc)
80
	 * @see org.gvsig.app.daltransform.gui.FeatureTransformGui#createFeatureStoreTransform(org.gvsig.fmap.dal.feature.FeatureStore)
81
	 */
82
	public FeatureStoreTransform createFeatureStoreTransform(
83
			FeatureStore featureStore) throws DataException {
84
		EventThemeTransform transform = new EventThemeTransform();
85
		transform.initialize(featureStore,
86
				panel.getGeometryName(),
87
				panel.getXName(),
88
				panel.getYName(),
89
				panel.getProjection());
90
		return transform;
91
	}
92

  
93
	/* (non-Javadoc)
94
	 * @see org.gvsig.app.daltransform.gui.FeatureTransformGui#getName()
95
	 */
96
	public String getName() {
97
		return PluginServices.getText(this, "events_layer");
98
	}
99

  
100
	/* (non-Javadoc)
101
	 * @see org.gvsig.app.daltransform.gui.DataTransformGui#getMinDimension()
102
	 */
103
	public Dimension getMinDimension() {
104
		// TODO Auto-generated method stub
105
		return null;
106
	}
107

  
108
    public boolean accept(FeatureStore featureStore) {
109
        try {
110
            return featureStore.getDefaultFeatureType().getDefaultGeometryAttribute() == null;
111
        } catch (DataException e) {
112
           return false;
113
        }        
114
    }
115
}
116

  
0 117

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/src/org/gvsig/app/eventtheme/daltransform/EventThemeTransformPanel.java
1
/* 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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.app.eventtheme.daltransform;
29

  
30
import java.awt.BorderLayout;
31
import java.awt.Insets;
32
import java.awt.event.ActionEvent;
33
import java.awt.event.ActionListener;
34

  
35
import javax.swing.JButton;
36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
38
import javax.swing.JTextField;
39

  
40
import org.cresques.cts.IProjection;
41

  
42
import org.gvsig.andami.PluginServices;
43
import org.gvsig.app.gui.panels.CRSSelectPanel;
44
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel;
45
import org.gvsig.daltransform.swing.impl.AbstractDataTransformWizardPanel;
46
import org.gvsig.daltransform.swing.impl.components.FeatureTypeCombo;
47
import org.gvsig.daltransform.swing.impl.components.NumericFeatureTypeAttributesCombo;
48
import org.gvsig.fmap.crs.CRSFactory;
49

  
50

  
51
/**
52
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
53
 */
54
public class EventThemeTransformPanel extends AbstractDataTransformWizardPanel implements ActionListener {
55
	private JLabel nameLabel;
56
	private JTextField nameText;
57
	private NumericFeatureTypeAttributesCombo xCombo;
58
	private JLabel xLabel;
59
	private NumericFeatureTypeAttributesCombo yCombo;
60
	private JLabel yLabel;
61
	private FeatureTypeCombo featureTypeCombo;
62
	private JLabel featureTypeLabel;
63
	private JPanel northPanel = null;
64
	private JTextField projectionText;
65
	private JLabel projectionLabel;
66
	private JButton projectionButton = null;
67

  
68
	public EventThemeTransformPanel() {
69
		super();
70
		initComponents();
71
		initLabels();
72
		initProjection();
73
		featureTypeCombo.addActionListener(this);
74
		projectionButton.addActionListener(this);
75
	}
76

  
77
	private void initProjection() {
78
		projectionText.setText("EPSG:23030");
79
	}
80

  
81
	private void initLabels() {
82
		featureTypeLabel.setText(PluginServices.getText(this, "events_feature_type_field") + ":");
83
		xLabel.setText(PluginServices.getText(this, "events_x_field") + ":");
84
		yLabel.setText(PluginServices.getText(this, "events_y_field") + ":");
85
		nameLabel.setText(PluginServices.getText(this, "events_geom_field") + ":");
86
		projectionLabel.setText(PluginServices.getText(this, "projection") + ":");
87
		projectionButton.setText("...");
88
	}
89

  
90
	private void initComponents() {
91
		java.awt.GridBagConstraints gridBagConstraints;
92

  
93
		featureTypeCombo = new FeatureTypeCombo();
94
		featureTypeLabel = new javax.swing.JLabel();
95
		xLabel = new javax.swing.JLabel();
96
		xCombo = new NumericFeatureTypeAttributesCombo();
97
		yLabel = new javax.swing.JLabel();
98
		yCombo = new NumericFeatureTypeAttributesCombo();
99
		nameLabel = new javax.swing.JLabel();
100
		nameText = new javax.swing.JTextField();
101
		northPanel= new JPanel();
102
		projectionText = new JTextField();
103
		projectionLabel = new JLabel();
104
		projectionButton = new JButton();
105
		projectionButton.setSize(25, 25);
106
		projectionText.setEnabled(false);
107

  
108
		setLayout(new BorderLayout());
109
		northPanel.setLayout(new java.awt.GridBagLayout());
110

  
111
		//		gridBagConstraints = new java.awt.GridBagConstraints();
112
		//		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
113
		//		gridBagConstraints.insets = new Insets(5,2,2,2);
114
		//		northPanel.add(featureTypeLabel, gridBagConstraints);
115
		//
116
		//		featureTypeCombo.setModel(new javax.swing.DefaultComboBoxModel());
117
		//		gridBagConstraints = new java.awt.GridBagConstraints();
118
		//		gridBagConstraints.gridx = 0;
119
		//		gridBagConstraints.gridy = 1;
120
		//		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
121
		//		gridBagConstraints.weightx = 1.0;
122
		//		gridBagConstraints.insets = new Insets(2,2,5,2);
123
		//		northPanel.add(featureTypeCombo, gridBagConstraints);
124

  
125
		gridBagConstraints = new java.awt.GridBagConstraints();
126
		gridBagConstraints.gridx = 0;
127
		gridBagConstraints.gridy = 0;
128
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
129
		gridBagConstraints.gridwidth = 2;
130
		gridBagConstraints.insets = new Insets(5,2,2,2);
131
		northPanel.add(xLabel, gridBagConstraints);
132

  
133
		xCombo.setModel(new javax.swing.DefaultComboBoxModel());
134
		gridBagConstraints = new java.awt.GridBagConstraints();
135
		gridBagConstraints.gridx = 0;
136
		gridBagConstraints.gridy = 1;
137
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
138
		gridBagConstraints.gridwidth = 2;
139
		gridBagConstraints.insets = new Insets(2,2,5,2);
140
		gridBagConstraints.weightx = 1.0;
141
		northPanel.add(xCombo, gridBagConstraints);
142

  
143
		gridBagConstraints = new java.awt.GridBagConstraints();
144
		gridBagConstraints.gridx = 0;
145
		gridBagConstraints.gridy = 2;
146
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
147
		gridBagConstraints.insets = new Insets(5,2,2,2);
148
		gridBagConstraints.gridwidth = 2;
149
		northPanel.add(yLabel, gridBagConstraints);
150

  
151
		yCombo.setModel(new javax.swing.DefaultComboBoxModel());
152
		gridBagConstraints = new java.awt.GridBagConstraints();
153
		gridBagConstraints.gridx = 0;
154
		gridBagConstraints.gridy = 3;
155
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
156
		gridBagConstraints.weightx = 1.0;
157
		gridBagConstraints.insets = new Insets(2,2,5,2);
158
		gridBagConstraints.gridwidth = 2;
159
		northPanel.add(yCombo, gridBagConstraints);
160

  
161
		gridBagConstraints = new java.awt.GridBagConstraints();
162
		gridBagConstraints.gridx = 0;
163
		gridBagConstraints.gridy = 4;
164
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
165
		gridBagConstraints.insets = new Insets(5,2,2,2);
166
		gridBagConstraints.gridwidth = 2;
167
		northPanel.add(nameLabel, gridBagConstraints);
168

  
169
		gridBagConstraints = new java.awt.GridBagConstraints();
170
		gridBagConstraints.gridx = 0;
171
		gridBagConstraints.gridy = 5;
172
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
173
		gridBagConstraints.weightx = 1.0;
174
		gridBagConstraints.insets = new Insets(2,2,5,2);
175
		gridBagConstraints.gridwidth = 2;
176
		northPanel.add(nameText, gridBagConstraints);
177

  
178
		gridBagConstraints = new java.awt.GridBagConstraints();
179
		gridBagConstraints.gridx = 0;
180
		gridBagConstraints.gridy = 6;
181
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
182
		gridBagConstraints.gridwidth = 2;
183
		gridBagConstraints.insets = new Insets(5,2,2,2);
184
		northPanel.add(projectionLabel, gridBagConstraints);
185

  
186
		gridBagConstraints = new java.awt.GridBagConstraints();
187
		gridBagConstraints.gridx = 0;
188
		gridBagConstraints.gridy = 7;
189
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
190
		gridBagConstraints.weightx = 1.0;
191
		gridBagConstraints.gridwidth = 1;
192
		gridBagConstraints.insets = new Insets(2,2,5,2);
193
		northPanel.add(projectionText, gridBagConstraints);
194

  
195
		gridBagConstraints = new java.awt.GridBagConstraints();
196
		gridBagConstraints.gridx = 1;
197
		gridBagConstraints.gridy = 7;
198
		gridBagConstraints.gridwidth = 1;
199
		gridBagConstraints.insets = new Insets(2,2,5,2);
200
		northPanel.add(projectionButton, gridBagConstraints);
201

  
202
		add(northPanel, BorderLayout.NORTH);
203
	}	
204

  
205
	/* (non-Javadoc)
206
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
207
	 */
208
	public void actionPerformed(ActionEvent event) {
209
		if (event == null){
210
			return;
211
		}
212
		if (event.getSource() == featureTypeCombo){
213
			Object obj = featureTypeCombo.getSelectedItem();
214
			if (obj != null){
215
				xCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType());
216
				yCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType());			
217
			}
218
		}else if (event.getSource() == projectionButton){
219
			ISelectCrsPanel panel = CRSSelectPanel.getUIFactory().getSelectCrsPanel(
220
					CRSFactory.getCRS(projectionText.getText()), false);
221
			PluginServices.getMDIManager().addWindow(panel);
222
			if (panel.isOkPressed()) {
223
				IProjection proj = panel.getProjection();
224
				projectionText.setText(proj.getAbrev());
225
			}
226
		}
227
	}
228

  
229
	public String getGeometryName(){
230
		return nameText.getText();
231
	}
232

  
233
	public String getXName(){
234
		return xCombo.getSelectedFeatureAttributeDescriptor().getName();
235
	}
236

  
237
	public String getYName(){
238
		return yCombo.getSelectedFeatureAttributeDescriptor().getName();
239
	}
240

  
241
	/*
242
	 * (non-Javadoc)
243
	 * @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#updatePanel()
244
	 */
245
	public void updatePanel() {
246
		featureTypeCombo.addFeatureStore(getFeatureStore());
247
		actionPerformed(null);			
248
	}
249

  
250
	public IProjection getProjection() {
251
		return CRSFactory.getCRS(projectionText.getText());
252
	}
253
}
0 254

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/src/org/gvsig/app/eventtheme/dal/feature/EventThemeTransform.java
1
/* 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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.app.eventtheme.dal.feature;
29

  
30
import java.util.Arrays;
31

  
32
import org.cresques.cts.IProjection;
33

  
34
import org.gvsig.fmap.dal.DataStore;
35
import org.gvsig.fmap.dal.DataTypes;
36
import org.gvsig.fmap.dal.exception.DataException;
37
import org.gvsig.fmap.dal.exception.InitializeException;
38
import org.gvsig.fmap.dal.feature.AbstractFeatureStoreTransform;
39
import org.gvsig.fmap.dal.feature.EditableFeature;
40
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
41
import org.gvsig.fmap.dal.feature.EditableFeatureType;
42
import org.gvsig.fmap.dal.feature.Feature;
43
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
44
import org.gvsig.fmap.dal.feature.FeatureStore;
45
import org.gvsig.fmap.dal.feature.FeatureType;
46
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
47
import org.gvsig.fmap.geom.Geometry.TYPES;
48
import org.gvsig.fmap.geom.GeometryLocator;
49
import org.gvsig.fmap.geom.GeometryManager;
50
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
51
import org.gvsig.fmap.geom.exception.CreateGeometryException;
52
import org.gvsig.fmap.geom.primitive.Envelope;
53
import org.gvsig.fmap.geom.primitive.Point;
54
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException;
55
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException;
56
import org.gvsig.tools.ToolsLocator;
57
import org.gvsig.tools.dynobject.DynStruct;
58
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
59
import org.gvsig.tools.persistence.PersistenceManager;
60
import org.gvsig.tools.persistence.PersistentState;
61
import org.gvsig.tools.persistence.exception.PersistenceException;
62

  
63
/**
64
 * This class implements a transformation for a events theme. The original 
65
 * {@link DataStore} have to have a couple of attributes, one with the X 
66
 * coordinate and the second one with the Y coordinate. The result of 
67
 * the transformation is a {@link DataStore} that has a new geometric 
68
 * attribute and its value is a point with the coordinates specified in 
69
 * the original {@link DataStore}. 
70
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
71
 */
72
public class EventThemeTransform extends AbstractFeatureStoreTransform {
73

  
74
    public static final String PERSISTENCE_DEFINITION_NAME = "EventThemeTransform";
75

  
76
    private String xFieldName = null;
77
    private String yFieldName = null;
78
    private String geometryFieldName = null;
79
    private IProjection projection = null;
80
    private FeatureType originalFeatureType;
81
    private GeometryManager geometryManager = GeometryLocator.getGeometryManager();    
82
    private Envelope envelope;
83

  
84
    public EventThemeTransform() {
85
        super();
86
        geometryManager = GeometryLocator.getGeometryManager();
87
    }
88

  
89
    /**
90
     * This method initializes the transformation, sets the name of the parameters and 
91
     * sets the value of the {@link FeatureType} returned by the transformation. 
92
     * @param store
93
     * The original store. 
94
     * @param geometryFieldName
95
     * The field that contains the geometric attribute.
96
     * @param xFieldName
97
     * The field that contains the X coordinate.
98
     * @param yFieldName
99
     * The field that contains the Y coordinate.
100
     * @throws DataException
101
     */
102
    public void initialize(FeatureStore store, String geometryFieldName, String xFieldName, String yFieldName,
103
        IProjection projection) throws DataException{
104
        setFeatureStore(store);
105
        this.xFieldName = xFieldName;
106
        this.yFieldName = yFieldName;
107
        this.projection = projection;
108
        if ((geometryFieldName == null) || (geometryFieldName.equals(""))){
109
            this.geometryFieldName = "the_geom";
110
        }else{
111
            this.geometryFieldName = geometryFieldName;
112
        }
113
        this.originalFeatureType = this.getFeatureStore()
114
        .getDefaultFeatureType();
115

  
116
        EditableFeatureType type = originalFeatureType.getEditable();
117
        if (type.get(this.geometryFieldName) == null){
118
            EditableFeatureAttributeDescriptor attributeDescriptor = type.add(this.geometryFieldName,  DataTypes.GEOMETRY);
119
            try {
120
                attributeDescriptor.setGeometryType(geometryManager.getGeometryType(TYPES.POINT, SUBTYPES.GEOM2D));
121
            } catch (GeometryTypeNotSupportedException e) {
122
                throw new InitializeException(e);
123
            } catch (GeometryTypeNotValidException e) {
124
                throw new InitializeException(e);
125
            }           
126
            attributeDescriptor.setSRS(projection);
127
        }
128

  
129
        try {
130
            envelope = geometryManager.createEnvelope(SUBTYPES.GEOM2D);
131
        } catch (CreateEnvelopeException e) {
132
            throw new org.gvsig.fmap.dal.feature.exception.CreateGeometryException(e);
133
        }
134

  
135
        type.setDefaultGeometryAttributeName(this.geometryFieldName);
136
        FeatureType[] types = new FeatureType[] { type.getNotEditableCopy() };
137
        setFeatureTypes(Arrays.asList(types), types[0]);
138
    }
139

  
140
    /* (non-Javadoc)
141
     * @see org.gvsig.fmap.dal.feature.FeatureStoreTransform#applyTransform(org.gvsig.fmap.dal.feature.Feature, org.gvsig.fmap.dal.feature.EditableFeature)
142
     */
143
    public void applyTransform(Feature source, EditableFeature target)
144
    throws DataException {
145
        this.copySourceToTarget(source, target);
146

  
147
        try {			
148
            Point point = geometryManager.createPoint(
149
                new Double(source.get(xFieldName).toString()),
150
                new Double(source.get(yFieldName).toString()),
151
                SUBTYPES.GEOM2D);
152
            target.set(geometryFieldName, point);
153
            target.setDefaultGeometry(point);	
154
            envelope.add(point.getEnvelope());
155
        } catch (CreateGeometryException e) {
156
            throw new org.gvsig.fmap.dal.feature.exception.CreateGeometryException(TYPES.POINT, SUBTYPES.GEOM2D, e);
157
        }		
158
    }
159

  
160
    /**
161
     * @param source
162
     * @param target
163
     */
164
    private void copySourceToTarget(Feature source, EditableFeature target) {
165
        FeatureAttributeDescriptor attr, attrTrg;
166
        FeatureType ftSrc = source.getType();
167
        FeatureType ftTrg = target.getType();
168

  
169

  
170
        for (int i = 0; i < source.getType().size(); i++) {
171
            attr = ftSrc.getAttributeDescriptor(i);
172
            if (ftTrg.getIndex(attr.getName()) > -1) {
173
                try {
174
                    target.set(attr.getName(), source.get(i));
175
                } catch (IllegalArgumentException e) {
176
                    attrTrg = ftTrg.getAttributeDescriptor(attr.getName());
177
                    target.set(attrTrg.getIndex(), attrTrg.getDefaultValue());
178
                }
179

  
180
            }
181
        }
182

  
183
    }
184

  
185
    /* (non-Javadoc)
186
     * @see org.gvsig.fmap.dal.feature.FeatureStoreTransform#getSourceFeatureTypeFrom(org.gvsig.fmap.dal.feature.FeatureType)
187
     */
188
    public FeatureType getSourceFeatureTypeFrom(FeatureType targetFeatureType) {
189
        return this.originalFeatureType;
190
    }
191

  
192
    /* (non-Javadoc)
193
     * @see org.gvsig.fmap.dal.feature.FeatureStoreTransform#isTransformsOriginalValues()
194
     */
195
    public boolean isTransformsOriginalValues() {
196
        return true;
197
    }
198

  
199
    public static void registerPersistent() {
200
        PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager();
201

  
202
        if( persistenceManager.getDefinition(AbstractFeatureStoreTransform.class) == null ) {
203
            AbstractFeatureStoreTransform.registerPersistent();
204
        }
205

  
206
        DynStruct definition = persistenceManager.getDefinition(PERSISTENCE_DEFINITION_NAME);
207

  
208
        if (definition == null){           
209
            definition = persistenceManager.addDefinition(
210
                EventThemeTransform.class,
211
                PERSISTENCE_DEFINITION_NAME,
212
                "EventThemeTransform Persistence definition",
213
                null, 
214
                null
215
            );
216
            definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE,
217
                ABSTRACT_FEATURESTORE_DYNCLASS_NAME);
218

  
219
            definition.addDynFieldString("geometryFieldName").setMandatory(true);
220
            definition.addDynFieldString("xFieldName").setMandatory(true);
221
            definition.addDynFieldString("yFieldName").setMandatory(true);
222
            definition.addDynFieldObject("projection").setType(DataTypes.CRS);
223
        }
224
    }
225

  
226
    /* (non-Javadoc)
227
     * @see org.gvsig.tools.persistence.Persistent#saveToState(org.gvsig.tools.persistence.PersistentState)
228
     */
229
    public void saveToState(PersistentState state) throws PersistenceException {
230
        super.saveToState(state);
231
        state.set("geometryFieldName", this.geometryFieldName);
232
        state.set("xFieldName", this.xFieldName);
233
        state.set("yFieldName", this.yFieldName);
234
        state.set("projection", this.projection);		
235
    }
236

  
237
    /* (non-Javadoc)
238
     * @see org.gvsig.tools.persistence.Persistent#loadFromState(org.gvsig.tools.persistence.PersistentState)
239
     */
240
    public void loadFromState(PersistentState state)
241
    throws PersistenceException {
242
        super.loadFromState(state);		
243
        String geometryFieldName = state.getString("geometryFieldName");
244
        String xFieldName = state.getString("xFieldName");
245
        String yFieldName = state.getString("yFieldName");
246
        IProjection projection =  (IProjection)state.get("projection");	
247
        try {
248
            initialize(getFeatureStore(), geometryFieldName, xFieldName, yFieldName, projection);
249
        } catch (DataException e) {
250
            throw new PersistenceException("Impossible to create the transform", e);
251
        }
252
    }
253

  
254
    public Object getDynValue(String name) throws DynFieldNotFoundException {
255
        if (DataStore.METADATA_CRS.equals(name)){
256
            return projection;
257
        }else if(DataStore.METADATA_ENVELOPE.equals(name)){
258
            return envelope;
259
        }
260
        return null;
261
    }
262

  
263
    public boolean hasDynValue(String name) {
264
        return ((DataStore.METADATA_CRS.equals(name)) || 
265
            (DataStore.METADATA_ENVELOPE.equals(name)));
266
    }    
267
}
268

  
0 269

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/src/org/gvsig/app/eventtheme/EventThemeTransformLibrary.java
1
/* 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

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.app.eventtheme;
29

  
30
import org.gvsig.app.eventtheme.dal.feature.EventThemeTransform;
31
import org.gvsig.app.eventtheme.daltransform.EventThemeTransformGui;
32
import org.gvsig.daltransform.DataTransformLibrary;
33
import org.gvsig.daltransform.DataTransformLocator;
34
import org.gvsig.daltransform.DataTransformManager;
35
import org.gvsig.tools.library.AbstractLibrary;
36
import org.gvsig.tools.library.LibraryException;
37
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
38

  
39
/**
40
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
41
 */
42
public class EventThemeTransformLibrary extends AbstractLibrary {
43

  
44
    @Override
45
    public void doRegistration() {
46
        this.registerAsImplementationOf(EventThemeTransformLibrary.class);
47
        this.require(DataTransformLibrary.class);
48
    }
49

  
50
	@Override
51
	protected void doInitialize() throws LibraryException {
52
				
53
	}
54

  
55
	@Override
56
	protected void doPostInitialize() throws LibraryException {
57
				
58
		// Validate there is any implementation registered.
59
		DataTransformManager dataTransformManager = DataTransformLocator.getDataTransformManager();
60
		if (dataTransformManager == null) {
61
			throw new ReferenceNotRegisteredException(
62
					DataTransformLocator.DATA_TRANSFORM_MANAGER_NAME, DataTransformLocator.getInstance());
63
		}	
64
		dataTransformManager.registerDataTransform("EventThemeTransform", EventThemeTransformGui.class);
65
		
66
		EventThemeTransform.registerPersistent();
67
	}
68

  
69
}
70

  
0 71

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5
                      http://maven.apache.org/maven-v4_0_0.xsd">
6

  
7
	<modelVersion>4.0.0</modelVersion>
8
	<artifactId>org.gvsig.app.eventtheme</artifactId>
9
	<packaging>jar</packaging>
10
	<version>2.0-SNAPSHOT</version>
11
	<name>Transformation: Event theme</name>
12
	<description>Add an event theme layer to the view by selecting 2 fields from a table.</description>
13
	<parent>
14
		<groupId>org.gvsig</groupId>
15
		<artifactId>gvsig-base-extension-pom</artifactId>
16
		<version>2.0-SNAPSHOT</version>
17
	</parent>	
18
	<dependencies>
19
		<dependency>
20
			<groupId>org.gvsig</groupId>
21
			<artifactId>org.gvsig.daltransform.app.mainplugin</artifactId>
22
			<version>2.0-SNAPSHOT</version>
23
            <scope>compile</scope>
24
		</dependency>
25
		<dependency>
26
			<groupId>org.gvsig</groupId>
27
			<artifactId>org.gvsig.app</artifactId>
28
			<version>2.0-SNAPSHOT</version>
29
            <scope>compile</scope>
30
		</dependency>
31
        <dependency>
32
            <groupId>org.gvsig</groupId>
33
            <artifactId>org.gvsig.fmap.dal</artifactId>
34
            <scope>compile</scope>
35
        </dependency>
36
        <dependency>
37
            <groupId>org.gvsig</groupId>
38
            <artifactId>org.gvsig.fmap.dal</artifactId>
39
            <classifier>impl</classifier>
40
            <scope>runtime</scope>
41
        </dependency>
42
        <dependency>
43
            <groupId>org.gvsig</groupId>
44
            <artifactId>org.gvsig.andami</artifactId>
45
            <scope>compile</scope>
46
        </dependency>
47
        <dependency>
48
            <groupId>org.gvsig</groupId>
49
            <artifactId>org.gvsig.tools.lib</artifactId>
50
            <scope>compile</scope>
51
        </dependency>
52
        <dependency>
53
            <groupId>org.gvsig</groupId>
54
            <artifactId>org.gvsig.fmap.mapcontext</artifactId>
55
            <scope>compile</scope>
56
        </dependency>
57
        <dependency>
58
            <groupId>org.gvsig</groupId>
59
            <artifactId>org.gvsig.projection</artifactId>
60
            <scope>compile</scope>
61
        </dependency>
62
        <dependency>
63
            <groupId>org.gvsig</groupId>
64
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
65
            <scope>compile</scope>
66
        </dependency>
67
        <dependency>
68
            <groupId>org.gvsig</groupId>
69
            <artifactId>org.gvsig.fmap.control</artifactId>
70
            <scope>compile</scope>
71
        </dependency>
72
        <dependency>
73
            <groupId>org.gvsig</groupId>
74
            <artifactId>org.gvsig.fmap.geometry</artifactId>
75
            <scope>compile</scope>
76
        </dependency>
77
        <dependency>
78
            <groupId>org.gvsig</groupId>
79
            <artifactId>org.gvsig.timesupport.lib.api</artifactId>
80
            <scope>compile</scope>
81
        </dependency>
82
		<!--TEST-->
83
        <dependency>
84
            <groupId>org.gvsig</groupId>
85
            <artifactId>org.gvsig.daltransform.app.mainplugin</artifactId>
86
            <version>2.0-SNAPSHOT</version>
87
            <type>test-jar</type>
88
            <scope>test</scope>
89
        </dependency>        
90
		<dependency>
91
			<groupId>org.gvsig</groupId>
92
			<artifactId>org.gvsig.fmap.dal</artifactId>
93
			<classifier>tests</classifier>
94
			<scope>test</scope>
95
		</dependency>
96
		<dependency>
97
			<groupId>org.gvsig</groupId>
98
			<artifactId>org.gvsig.tools.lib</artifactId>
99
			<type>test-jar</type>
100
			<scope>test</scope>
101
		</dependency>		
102
	</dependencies>
103
	<build>
104
		<sourceDirectory>src</sourceDirectory>
105
		<testSourceDirectory>src-test</testSourceDirectory>
106
		<resources>
107
			<resource>
108
				<directory>${basedir}/resources</directory>
109
			</resource>
110
		</resources>
111
		<plugins>			
112
			<!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
113
			<plugin>
114
				<groupId>org.apache.maven.plugins</groupId>
115
				<artifactId>maven-surefire-plugin</artifactId>
116
				<configuration>
117
					<skipTests>true</skipTests>
118
				</configuration>
119
			</plugin>
120
		</plugins>
121
	</build>
122
	
123
	<properties>
124
		<build-dir>${basedir}/../build</build-dir>
125
        <eclipse.project.name>extDalTransformEventTheme</eclipse.project.name>
126
        <package.info.dependencies>required: org.gvsig.daltransform.app.mainplugin -ge 2</package.info.dependencies>
127
        <package.info.state>alpha5</package.info.state>
128
	</properties>
129
</project>
0 130

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.app.eventtheme.EventThemeTransformLibrary
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/.cvsignore
1
bin-test
0 2

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/distribution/distribution.xml
1
<assembly>
2
  <id>distribution</id>
3
  <formats>
4
    <format>dir</format>
5
  </formats>
6
  <fileSets>
7
    <fileSet>
8
      <directory>config</directory>
9
	  <outputDirectory>${extension.install.dir.name}</outputDirectory>
10
    </fileSet>    
11
	<fileSet>
12
      <directory>images</directory>
13
	  <outputDirectory>/${extension.install.dir.name}/images</outputDirectory>
14
    </fileSet>
15
  </fileSets>
16
    <files>
17
        <file>
18
            <source>package.info</source>
19
            <outputDirectory>${extension.install.dir.name}
20
            </outputDirectory>
21
        </file>
22
    </files>
23
  	<dependencySets>
24
  		<dependencySet>			
25
  			<outputDirectory>${extension.install.dir.name}/${library-dir}
26
        	</outputDirectory>
27
          	 <includes>
28
           		<include>org.gvsig:org.gvsig.app.eventtheme</include>        	 
29
        	</includes>
30
  		</dependencySet>  		
31
	</dependencySets>
32
</assembly>
33

  
0 34

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Tue May 29 16:39:59 CEST 2012
3
buildNumber=2039
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/src-test/org/gvsig/app/eventlayer/dal/feature/EventThemeTransformTest.java
1
/* 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

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.app.eventlayer.dal.feature;
29

  
30
import java.io.File;
31

  
32
import org.gvsig.app.eventtheme.dal.feature.EventThemeTransform;
33
import org.gvsig.daltransform.BaseFeatureStoreTransform;
34
import org.gvsig.fmap.crs.CRSFactory;
35
import org.gvsig.fmap.dal.DataStoreParameters;
36
import org.gvsig.fmap.dal.exception.DataException;
37
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
38
import org.gvsig.fmap.dal.feature.FeatureStore;
39
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
40
import org.gvsig.fmap.dal.store.dbf.DBFStoreProvider;
41

  
42
/**
43
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
44
 */
45
public class EventThemeTransformTest extends BaseFeatureStoreTransform {
46
	private final File dbf = new File("testdata/events.dbf");
47
	private final String xFieldName = "x";
48
	private final String yFieldName = "y";
49
	private final String geometryFieldName = "geom";
50
	private final String projection = "EPSG:23030";
51
	protected boolean testDBFInitialized = false;
52
	
53

  
54
	public DataStoreParameters getDefaultDataStoreParameters() throws DataException {
55
		DataStoreParameters dbfParameters = null;
56
		dbfParameters = dataManager.createStoreParameters(DBFStoreProvider.NAME);
57

  
58
		dbfParameters.setDynValue("dbfFile", dbf);
59

  
60
		return dbfParameters;
61
	}
62

  
63
	/* (non-Javadoc)
64
	 * @see org.gvsig.fmap.dal.feature.BaseFeatureStoreTransform#getFeatureStoreTransform()
65
	 */
66
	public FeatureStoreTransform getFeatureStoreTransform() throws DataException, ValidateDataParametersException {
67
		FeatureStore store = (FeatureStore) dataManager.openStore("DBF", 
68
		    this.getDefaultDataStoreParameters());
69
		EventThemeTransform transform = new EventThemeTransform();
70
		transform.initialize(store, geometryFieldName, xFieldName, yFieldName,
71
				CRSFactory.getCRS(projection));
72
		return transform;
73
	}
74

  
75
	/* (non-Javadoc)
76
	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
77
	 */
78
	public boolean hasExplorer() {
79
		// TODO Auto-generated method stub
80
		return false;
81
	}
82

  
83
	/* (non-Javadoc)
84
	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#usesResources()
85
	 */
86
	public boolean usesResources() {
87
		// TODO Auto-generated method stub
88
		return false;
89
	}
90

  
91
}
0 92

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_ca.properties
1
#Translations for language [ca]
2
#Mon Oct 30 09:38:21 CET 2006
3
Anadir_capa_de_eventos=Afegir capa d'esdeveniments
4
Tabla=Taula
5
Vista=Vista
0 6

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_pt.properties
1
#Translations for language [pt]
2
#Mon Oct 30 09:38:21 CET 2006
3
Anadir_capa_de_eventos=
4
Tabla=Tabela
5
Vista=Vista
0 6

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<libraries library-dir="lib/"/>
4
	<depends plugin-name="org.gvsig.app"/>
5
	<depends plugin-name="org.gvsig.daltransform.app.mainplugin"/>
6
	<resourceBundle name="text"/>
7
	<extensions><extension class-name="VOID" active="false"/></extensions>		
8
</plugin-config>
0 9

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_cs.properties
1
#Translations for language [cs]
2
#Mon Nov 06 09:04:31 CET 2006
3
Anadir_capa_de_eventos=P\u0159idej vrstvu ud\u00e1losti
4
Tabla=Tabulka
5
Vista=Pohled
0 6

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_fr.properties
1
#Translations for language [fr]
2
#Mon Oct 30 09:38:21 CET 2006
3
Anadir_capa_de_eventos=Ajouter une couche g\u00e9ographique de points
4
Tabla=Table
5
Vista=Vue
0 6

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_de.properties
1
#Translations for language [de]
2
#Wed Oct 08 17:44:19 CEST 2008
3
Anadir\ capa\ de\ eventos=
4
Anadir_capa_de_eventos=F\u00fcge Ereignislayer hinzu
5
Tabla=Tabelle
6
Vista=Ansicht
0 7

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_eu.properties
1
#Translations for language [eu]
2
#Mon Oct 30 09:38:21 CET 2006
3
Anadir_capa_de_eventos=Gehitu gertaeren geruza
4
Tabla=Taula
5
Vista=Bista
0 6

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_it.properties
1
#Translations for language [it]
2
#Tue Nov 07 12:30:01 CET 2006
3
Anadir_capa_de_eventos=Aggiungi layer eventi
4
Tabla=Tabella
5
Vista=Vista
0 6

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text.properties
1
#Translations for language [es]
2
#Mon Oct 30 09:38:21 CET 2006
3
Anadir_capa_de_eventos=A\u00f1adir capa de eventos
4
Tabla=Tabla
5
Vista=Vista
6
events_layer=Capa de Eventos
7
events_layer_description=Esta transformaci?n crea una capa de eventos, que no es m?s que una capa de puntos cuyas coordenadas X e Y sos dos atributos de un origen de datos vectorial.
8
events_x_field=Campo que cotiene la coordenada X
9
events_y_field=Campo que contiene la coordenada Y
10
events_geom_field=Nombre del campo que contiene la geometr?a
11
events_feature_type_field=Tipo de feature
0 12

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_zh.properties
1
#Translations for language [en]
2
#Fri Nov 03 13:14:56 CET 2006
3
Anadir_capa_de_eventos=\u6dfb\u52a0\u9879\u76ee\u56fe\u5c42
4
Tabla=\u8868\u683c
5
Vista=\u89c6\u56fe
0 6

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_en.properties
1
#Translations for language [en]
2
#Mon Oct 30 09:38:21 CET 2006
3
Anadir_capa_de_eventos=Add event layer
4
Tabla=Table
5
Vista=View
0 6

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/config/text_gl.properties
1
#Translations for language [gl]
2
#Mon Oct 30 09:38:21 CET 2006
3
Anadir_capa_de_eventos=Engadir capa de eventos
4
Tabla=T\u00e1boa
5
Vista=Vista
0 6

  
tags/v2_0_0_Build_2047/extensions/extDalTransformEventTheme/extDalTransformEventTheme/doc/gpl.txt
1
		    GNU GENERAL PUBLIC LICENSE
2
		       Version 2, June 1991
3

  
4
 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6
 Everyone is permitted to copy and distribute verbatim copies
7
 of this license document, but changing it is not allowed.
8

  
9
			    Preamble
10

  
11
  The licenses for most software are designed to take away your
12
freedom to share and change it.  By contrast, the GNU General Public
13
License is intended to guarantee your freedom to share and change free
14
software--to make sure the software is free for all its users.  This
15
General Public License applies to most of the Free Software
16
Foundation's software and to any other program whose authors commit to
17
using it.  (Some other Free Software Foundation software is covered by
18
the GNU Library General Public License instead.)  You can apply it to
19
your programs, too.
20

  
21
  When we speak of free software, we are referring to freedom, not
22
price.  Our General Public Licenses are designed to make sure that you
23
have the freedom to distribute copies of free software (and charge for
24
this service if you wish), that you receive source code or can get it
25
if you want it, that you can change the software or use pieces of it
26
in new free programs; and that you know you can do these things.
27

  
28
  To protect your rights, we need to make restrictions that forbid
29
anyone to deny you these rights or to ask you to surrender the rights.
30
These restrictions translate to certain responsibilities for you if you
31
distribute copies of the software, or if you modify it.
32

  
33
  For example, if you distribute copies of such a program, whether
34
gratis or for a fee, you must give the recipients all the rights that
35
you have.  You must make sure that they, too, receive or can get the
36
source code.  And you must show them these terms so they know their
37
rights.
38

  
39
  We protect your rights with two steps: (1) copyright the software, and
40
(2) offer you this license which gives you legal permission to copy,
41
distribute and/or modify the software.
42

  
43
  Also, for each author's protection and ours, we want to make certain
44
that everyone understands that there is no warranty for this free
45
software.  If the software is modified by someone else and passed on, we
46
want its recipients to know that what they have is not the original, so
47
that any problems introduced by others will not reflect on the original
48
authors' reputations.
49

  
50
  Finally, any free program is threatened constantly by software
51
patents.  We wish to avoid the danger that redistributors of a free
52
program will individually obtain patent licenses, in effect making the
53
program proprietary.  To prevent this, we have made it clear that any
54
patent must be licensed for everyone's free use or not licensed at all.
55

  
56
  The precise terms and conditions for copying, distribution and
57
modification follow.
58

59
		    GNU GENERAL PUBLIC LICENSE
60
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61

  
62
  0. This License applies to any program or other work which contains
63
a notice placed by the copyright holder saying it may be distributed
64
under the terms of this General Public License.  The "Program", below,
65
refers to any such program or work, and a "work based on the Program"
66
means either the Program or any derivative work under copyright law:
67
that is to say, a work containing the Program or a portion of it,
68
either verbatim or with modifications and/or translated into another
69
language.  (Hereinafter, translation is included without limitation in
70
the term "modification".)  Each licensee is addressed as "you".
71

  
72
Activities other than copying, distribution and modification are not
73
covered by this License; they are outside its scope.  The act of
74
running the Program is not restricted, and the output from the Program
75
is covered only if its contents constitute a work based on the
76
Program (independent of having been made by running the Program).
77
Whether that is true depends on what the Program does.
78

  
79
  1. You may copy and distribute verbatim copies of the Program's
80
source code as you receive it, in any medium, provided that you
81
conspicuously and appropriately publish on each copy an appropriate
82
copyright notice and disclaimer of warranty; keep intact all the
83
notices that refer to this License and to the absence of any warranty;
84
and give any other recipients of the Program a copy of this License
85
along with the Program.
86

  
87
You may charge a fee for the physical act of transferring a copy, and
88
you may at your option offer warranty protection in exchange for a fee.
89

  
90
  2. You may modify your copy or copies of the Program or any portion
91
of it, thus forming a work based on the Program, and copy and
92
distribute such modifications or work under the terms of Section 1
93
above, provided that you also meet all of these conditions:
94

  
95
    a) You must cause the modified files to carry prominent notices
96
    stating that you changed the files and the date of any change.
97

  
98
    b) You must cause any work that you distribute or publish, that in
99
    whole or in part contains or is derived from the Program or any
100
    part thereof, to be licensed as a whole at no charge to all third
101
    parties under the terms of this License.
102

  
103
    c) If the modified program normally reads commands interactively
104
    when run, you must cause it, when started running for such
105
    interactive use in the most ordinary way, to print or display an
106
    announcement including an appropriate copyright notice and a
107
    notice that there is no warranty (or else, saying that you provide
108
    a warranty) and that users may redistribute the program under
109
    these conditions, and telling the user how to view a copy of this
110
    License.  (Exception: if the Program itself is interactive but
111
    does not normally print such an announcement, your work based on
112
    the Program is not required to print an announcement.)
113

114
These requirements apply to the modified work as a whole.  If
115
identifiable sections of that work are not derived from the Program,
116
and can be reasonably considered independent and separate works in
117
themselves, then this License, and its terms, do not apply to those
118
sections when you distribute them as separate works.  But when you
119
distribute the same sections as part of a whole which is a work based
120
on the Program, the distribution of the whole must be on the terms of
121
this License, whose permissions for other licensees extend to the
122
entire whole, and thus to each and every part regardless of who wrote it.
123

  
124
Thus, it is not the intent of this section to claim rights or contest
125
your rights to work written entirely by you; rather, the intent is to
126
exercise the right to control the distribution of derivative or
127
collective works based on the Program.
128

  
129
In addition, mere aggregation of another work not based on the Program
130
with the Program (or with a work based on the Program) on a volume of
131
a storage or distribution medium does not bring the other work under
132
the scope of this License.
133

  
134
  3. You may copy and distribute the Program (or a work based on it,
135
under Section 2) in object code or executable form under the terms of
136
Sections 1 and 2 above provided that you also do one of the following:
137

  
138
    a) Accompany it with the complete corresponding machine-readable
139
    source code, which must be distributed under the terms of Sections
140
    1 and 2 above on a medium customarily used for software interchange; or,
141

  
142
    b) Accompany it with a written offer, valid for at least three
143
    years, to give any third party, for a charge no more than your
144
    cost of physically performing source distribution, a complete
145
    machine-readable copy of the corresponding source code, to be
146
    distributed under the terms of Sections 1 and 2 above on a medium
147
    customarily used for software interchange; or,
148

  
149
    c) Accompany it with the information you received as to the offer
150
    to distribute corresponding source code.  (This alternative is
151
    allowed only for noncommercial distribution and only if you
152
    received the program in object code or executable form with such
153
    an offer, in accord with Subsection b above.)
154

  
155
The source code for a work means the preferred form of the work for
156
making modifications to it.  For an executable work, complete source
157
code means all the source code for all modules it contains, plus any
158
associated interface definition files, plus the scripts used to
159
control compilation and installation of the executable.  However, as a
160
special exception, the source code distributed need not include
161
anything that is normally distributed (in either source or binary
162
form) with the major components (compiler, kernel, and so on) of the
163
operating system on which the executable runs, unless that component
164
itself accompanies the executable.
165

  
166
If distribution of executable or object code is made by offering
167
access to copy from a designated place, then offering equivalent
168
access to copy the source code from the same place counts as
169
distribution of the source code, even though third parties are not
170
compelled to copy the source along with the object code.
171

172
  4. You may not copy, modify, sublicense, or distribute the Program
173
except as expressly provided under this License.  Any attempt
174
otherwise to copy, modify, sublicense or distribute the Program is
175
void, and will automatically terminate your rights under this License.
176
However, parties who have received copies, or rights, from you under
177
this License will not have their licenses terminated so long as such
178
parties remain in full compliance.
179

  
180
  5. You are not required to accept this License, since you have not
181
signed it.  However, nothing else grants you permission to modify or
182
distribute the Program or its derivative works.  These actions are
183
prohibited by law if you do not accept this License.  Therefore, by
184
modifying or distributing the Program (or any work based on the
185
Program), you indicate your acceptance of this License to do so, and
186
all its terms and conditions for copying, distributing or modifying
187
the Program or works based on it.
188

  
189
  6. Each time you redistribute the Program (or any work based on the
190
Program), the recipient automatically receives a license from the
191
original licensor to copy, distribute or modify the Program subject to
192
these terms and conditions.  You may not impose any further
193
restrictions on the recipients' exercise of the rights granted herein.
194
You are not responsible for enforcing compliance by third parties to
195
this License.
196

  
197
  7. If, as a consequence of a court judgment or allegation of patent
198
infringement or for any other reason (not limited to patent issues),
199
conditions are imposed on you (whether by court order, agreement or
200
otherwise) that contradict the conditions of this License, they do not
201
excuse you from the conditions of this License.  If you cannot
202
distribute so as to satisfy simultaneously your obligations under this
203
License and any other pertinent obligations, then as a consequence you
204
may not distribute the Program at all.  For example, if a patent
205
license would not permit royalty-free redistribution of the Program by
206
all those who receive copies directly or indirectly through you, then
207
the only way you could satisfy both it and this License would be to
208
refrain entirely from distribution of the Program.
209

  
210
If any portion of this section is held invalid or unenforceable under
211
any particular circumstance, the balance of the section is intended to
212
apply and the section as a whole is intended to apply in other
213
circumstances.
214

  
215
It is not the purpose of this section to induce you to infringe any
216
patents or other property right claims or to contest validity of any
217
such claims; this section has the sole purpose of protecting the
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff