Revision 40899

View differences:

tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.geom.GeometryLibrary
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/handler/CenterHandler.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.handler;
25

  
26

  
27

  
28
/**
29
 * Center handlers.
30
 *
31
 * @author Vicente Caballero Navarro
32
 */
33
public interface CenterHandler extends Handler {
34
}
0 35

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/handler/CuadrantHandler.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.handler;
25

  
26
/**
27
 * Cuadrant handlers.
28
 *
29
 * @author Vicente Caballero Navarro
30
 */
31
public interface CuadrantHandler extends Handler {
32
}
0 33

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/handler/AbstractHandler.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.handler;
25

  
26
import java.awt.geom.Point2D;
27

  
28

  
29

  
30
/**
31
 * This class expands the <code>Handler</code> interface adding support for selection, and
32
 *  identifying a handler of a geometry.
33
 * 
34
 * @see Handler
35
 *
36
 * @author Vicente Caballero Navarro
37
 */
38
public abstract class AbstractHandler implements Handler {
39
	/**
40
	 * Identifies each handler of a geometry.
41
	 */
42
	protected int index;
43
	/**
44
	 * Position of this handler.
45
	 * 
46
	 * @see #getPoint()
47
	 * @see Handler#set(double, double)
48
	 * @see Handler#move(double, double)
49
	 */
50
	protected Point2D point;
51
	/**
52
	 * True when the handler is selected.
53
	 * 
54
	 * @see #select
55
	 * @see #isSelected()
56
	 */
57
	private boolean select=false;
58
	/*
59
	 * (non-Javadoc)
60
	 * @see com.iver.cit.gvsig.fmap.core.Handler#getPoint()
61
	 */
62
	public Point2D getPoint() {
63
		return point;
64
	}
65
	/**
66
	 * Sets the state of the handler. <code>True</code> if is selected, <code>false</code> if it's not.
67
	 * 
68
	 * @param b <code>true</code> if the handler is selected, <code>false</code>  otherwise
69
	 * 
70
	 * @see #isSelected()
71
	 */
72
	public void select(boolean b) {
73
		select=b;
74
	}
75
	/**
76
	 * Returns the state of the handler. <code>True</code> if is selected, <code>false</code> if it's not.
77
	 * 
78
	 * @return <code>true</code> if the handler is selected,<code>false</code> otherwise 
79
	 * 
80
	 * @see #select(boolean)
81
	 */
82
	public boolean isSelected(){
83
		return select;
84
	}
85
	/*
86
	 * (non-Javadoc)
87
	 * @see com.iver.cit.gvsig.fmap.core.Handler#equalsPoint(java.lang.Object)
88
	 */
89
	public boolean equalsPoint(Object obj) {
90
		Point2D p1=this.getPoint();
91
		Point2D p2=((Handler)obj).getPoint();
92
		if (p1.getX()==p2.getX() && p1.getY()==p2.getY()) {
93
			return true;
94
		}
95
		return false;
96
	}
97
}
0 98

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/handler/FinalHandler.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.handler;
25

  
26
/**
27
 * Final handlers.
28
 *
29
 * @author Vicente Caballero Navarro
30
 */
31
public interface FinalHandler extends Handler {
32
}
0 33

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/handler/Handler.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.handler;
25

  
26
import java.awt.geom.Point2D;
27

  
28

  
29
/**
30
* <p>In a <i>FMap</i> graphic layer, each geometry drawn has control points named <i>handlers</i>
31
* that allow user to move, modify, set, ... that geometry.</p>
32
*  
33
* <p>Each geometry will have its own handlers, and each one can have different behavior 
34
* according its nature.</p>
35
* 
36
* <p>The <code>Handler</code> interface defines the least set of common methods for all
37
* geometry handlers.</p>
38
*/
39
public interface Handler {
40
	/**
41
	 * <p>Generic method of moving in 2D a handler of a geometry using two numbers that
42
	 * represent the 2D coordinates.</p>
43
	 * 
44
	 * <p>Each handler of each geometry adapts this method to its own behavior in that 
45
	 * geometry, that implies that could not be implemented.</p>
46
	 *
47
	 * @param x first dimension coordinate
48
	 * @param y second dimension coordinate
49
	 * 
50
	 * @see #set(double, double)
51
	 */
52
	public void move(double x, double y);
53
	/**
54
 	 * <p>Generic method of situating in 2D a handler of a geometry using two numbers
55
 	 * that represent the 2D coordinates.</p>
56
	 * 
57
	 * <p>Each handler of each geometry adapts this method to its own behavior in that 
58
	 * geometry, that implies that could not be implemented.</p>
59
	 *
60
	 * @param x first dimension coordinate
61
	 * @param y second dimension coordinate
62
	 * 
63
	 * @see #move(double, double)
64
	 * @see #getPoint()
65
	 */
66
	public void set(double x, double y);
67

  
68
	/**
69
 	 * <p>Generic method of getting the 2D point that represents a handler of a geometry.</p>
70
	 * 
71
	 * <p>Each handler of each geometry adapts this method to its own behavior in that
72
	 * geometry, that implies that could not be implemented.</p>
73
	 *
74
	 * @return point 2D that represents this handler of geometry
75
	 * 
76
	 * @see #set(double, double)
77
	 * @see #move(double, double)
78
	 */
79
	public Point2D getPoint();
80
	/**
81
	 * <p>Returns <code>true</code> if the object is a <code>Handler</code> and has the
82
	 *  same coordinates as this one.</p>
83
	 * 
84
	 * @param obj the reference object with which to compare 
85
	 * @return <code>true</code> if this object is the same as the <code>obj</code> 
86
	 * argument; <code>false</code> otherwise
87
	 * 
88
	 * @see #getPoint()
89
	 */
90
	public boolean equalsPoint(Object obj);
91
}
0 92

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/DataTypes.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom;
25

  
26
/**
27
 * This interface defines a set of constants for all data types supported by the
28
 * DAL.
29
 * 
30
 * @author gvSIG Team
31
 * @version $Id$
32
 * 
33
 */
34
public interface DataTypes extends org.gvsig.tools.dataTypes.DataTypes {
35

  
36
    /*
37
	 * 
38
	 */
39
    public static final int GEOMETRY = OBJECT + 2;
40
    public static final int ENVELOPE = OBJECT + 3;
41
}
0 42

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/exception/CreateGeometryException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
 
25
package org.gvsig.fmap.geom.exception;
26

  
27
import org.gvsig.fmap.geom.Geometry;
28
import org.gvsig.fmap.geom.GeometryException;
29

  
30
/**
31
 * Exception thrown when there is an error creating a new {@link Geometry}.
32
 * 
33
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
34
 */
35
public class CreateGeometryException extends GeometryException {
36
	private static final long serialVersionUID = -9092927920296656571L;
37
	private final static String MESSAGE_FORMAT = "Exception creating the geometry with " +
38
			"type '%(type)' and subType '%(subType)'.";
39
	private final static String MESSAGE_KEY = "_CreateGeometryException";
40
	
41
	public CreateGeometryException(int type, int subType, Throwable cause){
42
		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
43
		setValue("type", new Integer(type));
44
		setValue("subType", new Integer(subType));
45
	}
46
	
47
}
0 48

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/exception/CreateEnvelopeException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
 
25
package org.gvsig.fmap.geom.exception;
26

  
27
import org.gvsig.tools.exception.BaseException;
28

  
29
/**
30
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
31
 */
32
public class CreateEnvelopeException extends BaseException{
33
	private static final long serialVersionUID = -8080549653325427654L;
34
	private final static String MESSAGE_FORMAT = "Exception creating the envelope with " +
35
			"subType '%(subType)'.";
36
	private final static String MESSAGE_KEY = "_CreateEnvelopeException";
37
	
38
	public CreateEnvelopeException(int subType, Throwable cause){
39
		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
40
		setValue("subType", new Integer(subType));
41
	}
42
}
43

  
0 44

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/exception/ReprojectionRuntimeException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.exception;
25

  
26
import java.awt.geom.Point2D;
27

  
28
import org.cresques.cts.IProjection;
29

  
30

  
31
/**
32
 * 
33
 * This exception is thrown when the reprojection library is unable to
34
 * reproject and we need to notify that there was a problem
35
 * (so far, the reproject method in Geometry API does not
36
 * throw a standard exception)
37
 * 
38
 * @author jldominguez
39
 *
40
 */
41
public class ReprojectionRuntimeException extends RuntimeException {
42
    
43
    public ReprojectionRuntimeException(
44
        IProjection from_p, IProjection to_p,
45
        Point2D from_point, Throwable cause) {
46
        
47
        super("Error while reprojecting point " + from_point.toString()
48
            + " (" + from_p.getAbrev() + " to " + to_p.getAbrev() + ")",
49
            cause);
50
    }
51

  
52
}
0 53

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/DirectPosition.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom;
25

  
26
/**
27
 * <p>
28
 * DirectPosition object data types hold the coordinates for 
29
 * a position within some coordinate reference system. 
30
 * The coordinate reference system is described in 
31
 * <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=41126">ISO 19111</a>.
32
 * </p>
33
 * @see <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=26012">ISO 19107</a>
34
 * @see <a http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=41126">ISO 19111</a>
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
36
 */
37
public interface DirectPosition {
38
	
39
	/**
40
	 * Returns the length of coordinate. This is determined by 
41
	 * the reference system.
42
	 * @return
43
	 * The dimension
44
	 */
45
	public int getDimension();
46
	
47
	/**
48
	 * Returns the ordinate of the given dimension.
49
	 * @param dimension
50
	 * The dimension to retrieve
51
	 * @return
52
	 * The value of the ordinate
53
	 */
54
	public double getOrdinate(int dimension);
55

  
56
}
0 57

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/GeometryLocator.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
 
25
package org.gvsig.fmap.geom;
26

  
27
import org.gvsig.tools.locator.AbstractLocator;
28
import org.gvsig.tools.locator.Locator;
29
import org.gvsig.tools.locator.LocatorException;
30

  
31
/**
32
 * This Locator provides the entry point for the gvSIG 
33
 * {@link GeometryManager}. 
34
 * @see {@link Locator}
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
36
 */
37
public class GeometryLocator extends AbstractLocator {
38

  
39
	private static final String LOCATOR_NAME = "GeometryLocator";
40
	
41
	/**
42
	 * GeometryManager name used by the locator to access the instance
43
	 */
44
	public static final String GEOMETRY_MANAGER_NAME = "GeometryManager";
45
	
46
	private static final String GEOMETRY_MANAGER_DESCRIPTION = "GeometryManager of gvSIG";
47
	
48
	/**
49
	 * Unique instance.
50
	 */
51
	private static final GeometryLocator instance = new GeometryLocator();
52

  
53
	/**
54
	 * Return the singleton instance.
55
	 *
56
	 * @return the singleton instance
57
	 */
58
	public static GeometryLocator getInstance() {
59
		return instance;
60
	}
61
	
62
	/* (non-Javadoc)
63
	 * @see org.gvsig.tools.locator.Locator#getLocatorName()
64
	 */
65
	public String getLocatorName() {
66
		return LOCATOR_NAME;
67
	}
68
	
69
	/**
70
	 * Return a reference to {@link GeometryManager}.
71
	 *
72
	 * @return a reference to GeometryManager
73
	 * @throws LocatorException
74
	 *             if there is no access to the class or the class cannot be
75
	 *             instantiated
76
	 * @see Locator#get(String)
77
	 */
78
	public static GeometryManager getGeometryManager() throws LocatorException {
79
		return (GeometryManager) getInstance().get(GEOMETRY_MANAGER_NAME);
80
	}
81
	
82
	/**
83
	 * Registers the Class implementing the {@link GeometryManager} interface.
84
	 *
85
	 * @param clazz
86
	 *            implementing the GeometryManager interface
87
	 */
88
	public static void registerGeometryManager(Class clazz) {
89
		getInstance().register(GEOMETRY_MANAGER_NAME, GEOMETRY_MANAGER_DESCRIPTION,
90
				clazz);
91
	}
92
}
93

  
0 94

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/GeometryLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.fmap.geom;
26

  
27
import org.cresques.ProjectionLibrary;
28

  
29
import org.gvsig.fmap.geom.primitive.Envelope;
30
import org.gvsig.tools.ToolsLibrary;
31
import org.gvsig.tools.ToolsLocator;
32
import org.gvsig.tools.dataTypes.DataTypesManager;
33
import org.gvsig.tools.library.AbstractLibrary;
34
import org.gvsig.tools.library.LibraryException;
35
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
36

  
37
/**
38
 * Registers the default implementation for {@link GeometryManager}.
39
 * 
40
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
41
 */
42
public class GeometryLibrary extends AbstractLibrary {
43

  
44
    public void doRegistration() {
45
        registerAsAPI(GeometryLibrary.class);
46
        require(ToolsLibrary.class);
47
        require(ProjectionLibrary.class);
48
    }
49

  
50
    protected void doInitialize() throws LibraryException {
51
    }
52

  
53
    protected void doPostInitialize() throws LibraryException {
54
        // Validate there is any implementation registered.
55
        if(! GeometryLocator.getInstance().exists(GeometryLocator.GEOMETRY_MANAGER_NAME)) {
56
            throw new ReferenceNotRegisteredException(
57
                GeometryLocator.GEOMETRY_MANAGER_NAME,
58
                GeometryLocator.getInstance());
59
        }
60
        DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager();
61
        dataTypesManager.addtype(DataTypes.GEOMETRY, "Geometry", "Geometry",
62
            Geometry.class, null);
63
        dataTypesManager.addtype(DataTypes.ENVELOPE, "Envelope", "Envelope",
64
            Envelope.class, null);
65

  
66
    }
67
}
0 68

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/operation/GeometryOperationException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import java.util.HashMap;
27
import java.util.Map;
28

  
29
import org.gvsig.tools.exception.BaseException;
30

  
31
/**
32
 * @author Jorge Piera Llodr? (jorge.piera@iver.es)
33
 */
34
public class GeometryOperationException extends BaseException {
35

  
36
	/**
37
	 * Generated serial version UID
38
	 */
39
	private static final long serialVersionUID = 8230919748601156772L;
40
	private static final String MESSAGE_KEY = "geometry_operation_exception";
41
	private static final String FORMAT_STRING =
42
		"Exception executing the operation with code %(operationCode) for the geometry with type %(geometryType).";
43

  
44
	private int geometryType = -1;
45
	private int operationCode = -1;
46

  
47
	/**
48
	 * Constructor with some context data for cases in which the root cause of
49
	 * <code>this</code> is internal (usually an unsatisfied logic rule).
50
	 * @param geometryType
51
	 * @param operationCode
52
	 */
53
	public GeometryOperationException(int geometryType, int operationCode){
54
		this(geometryType, operationCode, null);
55
	}
56

  
57
	/**
58
	 * Constructor to use when <code>this</code> is caused by another Exception
59
	 * but there is not further context data available.
60
	 * @param e
61
	 */
62
	public GeometryOperationException(Exception e) {
63
		this(-1, -1, e);
64
	}
65

  
66
	/**
67
	 * Main constructor that provides both context data and a cause Exception
68
	 * @param geometryType
69
	 * @param operationCode
70
	 * @param exp
71
	 */
72
	public GeometryOperationException(int geometryType, int operationCode, Exception e) {
73
		super(FORMAT_STRING, e, MESSAGE_KEY, serialVersionUID);
74

  
75
		this.geometryType = geometryType;
76
		this.operationCode = operationCode;
77
	}
78

  
79
	protected Map values() {
80
		HashMap map = new HashMap();
81
		map.put("geometryType", String.valueOf(geometryType));
82
		map.put("operationCode", String.valueOf(operationCode));
83
		return map;
84
	}
85
}
86

  
0 87

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/operation/GeometryOperation.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.fmap.geom.GeometryLocator;
28

  
29
/**
30
 * Every geometry operation that is registered dynamically must extend this class.<br>
31
 *
32
 * The following example shows how to implement and register a custom operation:
33
 *  
34
 * <pre>
35
 * public class MyOperation extends GeometryOperation {
36
 * 
37
 *   // Check GeometryManager for alternative methods to register an operation  
38
 *   public static final int CODE = 
39
 *     GeometryManager.getInstance()
40
 *        .registerGeometryOperation("MyOperation", new MyOperation(), geomType);
41
 *   
42
 *   public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
43
 *        // Operation logic goes here
44
 *   }     
45
 *   
46
 *   public int getOperationIndex() {
47
 *      return CODE;
48
 *   }
49
 *   
50
 * }
51
 * </pre>
52
 *
53
 * @author jiyarza
54
 *
55
 */
56
public abstract class GeometryOperation {
57
	
58
	
59
	// Constants for well-known operations to avoid dependency between geometry model and
60
	// operations.
61
	public static final String OPERATION_INTERSECTS_NAME = "intersects";
62
	public static final String OPERATION_CONTAINS_NAME = "contains";
63
	
64
	public static int OPERATION_INTERSECTS_CODE = Integer.MIN_VALUE;
65
	public static int OPERATION_CONTAINS_CODE = Integer.MIN_VALUE;
66

  
67
	
68
	
69
	
70
	/**
71
	 * Invokes this operation given the geometry and context 
72
	 * @param geom Geometry to which apply this operation
73
	 * @param ctx Parameter container
74
	 * @return Place-holder object that may contain any specific return value. 
75
	 * @throws GeometryOperationException The implementation is responsible to throw this exception when needed.
76
	 */
77
	public abstract Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException;
78

  
79
	/**
80
	 * Returns the constant value that identifies this operation and that was obtained upon registering it. 
81
	 * @return operation unique index 
82
	 */
83
	public abstract int getOperationIndex();
84
}
0 85

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/operation/GeometryOperationContext.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import java.util.HashMap;
27
import java.util.Map;
28

  
29
/**
30
 * This class is a default parameter container for geometry operation.<br>
31
 * 
32
 * Normally every GeometryOperation will extend this class and identify
33
 * its parameters publicly with getters/setters
34
 *
35
 * For those operations that need high performance, parameters should be declared as class 
36
 * members instead of using the setAttribute/getAttribute mechanism. This way you avoid a hash
37
 * and a cast operation.
38
 * 
39
 * @author jyarza
40
 *
41
 */
42
public class GeometryOperationContext {
43
	
44
	private Map ctx = new HashMap();
45
	
46
	/**
47
	 * Returns an attribute given its name.
48
	 * If it does not exist returns <code>null</code>
49
	 * @param name
50
	 * @return attribute
51
	 */
52
	public Object getAttribute(String name) {
53
		return ctx.get(name.toLowerCase());
54
	}
55
	
56
	/**
57
	 * Sets an attribute
58
	 * @param name
59
	 * @param value
60
	 */
61
	public GeometryOperationContext setAttribute(String name, Object value) {
62
		ctx.put(name.toLowerCase(), value);
63
		return this;
64
	}
65

  
66
}
0 67

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/operation/GeometryOperationNotSupportedException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import java.util.HashMap;
27
import java.util.Map;
28

  
29
import org.gvsig.fmap.geom.type.GeometryType;
30
import org.gvsig.tools.exception.BaseException;
31

  
32
public class GeometryOperationNotSupportedException extends BaseException {
33

  
34
	/**
35
	 * Generated UID
36
	 */
37
	private static final long serialVersionUID = -8394502194572892834L;
38

  
39
	/**
40
	 * Constants specific to this BaseException subclass
41
	 */
42
	private static final String MESSAGE_KEY = "Operation_opCode_is_not_registered_for_geomTypeName_type";
43
	private static final String FORMAT_STRING = "Operation %(opCode)s is not registered for '%(geomTypeName)s' type.";
44
	
45
	private String geomTypeName = null;
46
	private int opCode = -1;
47
	
48
	/**
49
	 * Constructor with the operation code of a common operation.
50
	 * @param opCode
51
	 */	
52
	public GeometryOperationNotSupportedException(int opCode) {
53
		this(opCode, null);
54
	}
55
	
56
	/**
57
	 * Constructor with the operation code related to a geometry type
58
	 * @param opCode
59
	 * @param geomType
60
	 */
61
	public GeometryOperationNotSupportedException(int opCode, GeometryType geomType) {
62
		this(opCode, geomType, null);
63
	}
64

  
65
	/**
66
	 * Constructor to use when <code>this</code> is caused by another Exception 
67
	 * but there is not further context data available.
68
	 * @param e
69
	 */
70
	public GeometryOperationNotSupportedException(Exception e) {
71
		this(-1, null, e);
72
	}
73
	
74
	/**
75
	 * Main constructor
76
	 * @param opCode
77
	 * @param geomType
78
	 * @param e
79
	 */
80
	public GeometryOperationNotSupportedException(int opCode, GeometryType geomType, Exception e) {
81
		messageKey = MESSAGE_KEY;
82
		formatString = FORMAT_STRING;
83
		code = serialVersionUID;
84

  
85
		if (e != null) {
86
			initCause(e);
87
		}
88
		if (geomType != null) {
89
			geomTypeName = geomType.getName();
90
		} else {
91
			geomTypeName = "ANY";
92
		}
93
		this.opCode = opCode;
94
	}
95
		
96
	protected Map values() {
97
		HashMap map = new HashMap();
98
		map.put("opCode", Integer.toString(opCode));
99
		map.put("geomTypeName", geomTypeName);
100
		return map;
101
	}
102
	
103
}
0 104

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/type/GeometryType.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.type;
25

  
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.fmap.geom.exception.CreateGeometryException;
28
import org.gvsig.fmap.geom.operation.GeometryOperation;
29

  
30
/**
31
 * This class represents the type of a geometry. All the geometries
32
 * has to have a type that can be retrieved using the 
33
 * {@link Geometry}{@link #getGeometryType()} method.
34
 * 
35
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
36
 */
37
public interface GeometryType {
38
	
39
	/**
40
	 * @return the name of the geometry type.
41
	 */
42
	public String getName();
43
	
44
	/**
45
	 * @return the type of the geometry. It is a constant value
46
	 * that has to be one of the values in {@link Geometry.TYPES}
47
	 * The type is an abstract representation of the object (Point, Curve...) 
48
	 * but it is not a concrete representation (Point2D, Point3D...). 
49
	 */
50
	public int getType();	
51
	
52
	/**
53
	 * @return the subtype of the geometry. It is a constant value
54
	 * that has to be one of the values in {@link Geometry.SUBTYPES}.
55
	 * The subtype represents a set of geometries with a 
56
	 * dimensional relationship (2D, 3D, 2DM...)
57
	 */
58
	public int getSubType();
59
	
60
	/**
61
	 * Check if a geometry type inherits of other type. E.g:
62
	 * the super type of an arc could be a a curve, the super 
63
	 * type of a circle could be a surface...
64
	 * @param geometryType
65
	 * the value of the {@link Geometry.TYPES} to check if is 
66
	 * it super type
67
	 * @return
68
	 * <true> if the the parameter is a super type of this
69
	 * geometry type
70
	 */
71
	public boolean isTypeOf(int geometryType);
72
	   
73
	/**
74
     * Check if a geometry subType inherits of other subType. E.g:
75
     * the super Subtype of a geometry 3D could be a geometry 2D, 
76
     * because the 3D extends the behavior of a geometry 2D.
77
     * @param geometrySubType
78
     * the value of the {@link Geometry.SUBTYPES} to check if is 
79
     * it super subType
80
     * @return
81
     * <true> if the the parameter is a super subType of this
82
     * geometry type
83
     */
84
	public boolean isSubTypeOf(int geometrySubType);
85

  
86
    /**
87
     * Check if a geometry type inherits of other type. E.g:
88
     * the super type of an arc could be a a curve, the super
89
     * type of a circle could be a surface...
90
     * 
91
     * @param geometryType
92
     *            the geometry type to check if is it super type
93
     * @return
94
     *         if the the parameter is a super type of this
95
     *         geometry type
96
     */
97
    public boolean isTypeOf(GeometryType geometryType);
98

  
99
    /**
100
     * Check if a geometry subType inherits of other subType. E.g:
101
     * the super Subtype of a geometry 3D could be a geometry 2D,
102
     * because the 3D extends the behavior of a geometry 2D.
103
     * 
104
     * @param geometryType
105
     *            the geometry type to check if is it super subtype
106
     * @return
107
     *         if the the parameter is a super subType of this
108
     *         geometry type
109
     */
110
    public boolean isSubTypeOf(GeometryType geometryType);
111
	
112
	/**
113
	 * This method creates a {@link Geometry} with the type specified 
114
	 * by this class. The geometry is empty, and all the internal 
115
	 * attributes must be assigned to a value when the geometry has  
116
	 * been created.
117
	 * 
118
	 * @return
119
	 * A empty geometry 
120
	 * @throws InstantiationException
121
	 * This exception is maybe thrown when  the application is  trying 
122
	 * to instantiate the geometry
123
	 * @throws IllegalAccessException
124
	 * This exception is maybe thrown when  the application is  trying 
125
	 * to instantiate the geometry
126
	 */
127
	public Geometry create() throws CreateGeometryException;
128
		
129
	/**
130
	 * Registers an operation for this geometry type. 
131
	 * @param index
132
	 * @param geomOp
133
	 */
134
	public void setGeometryOperation(int index, GeometryOperation geomOp);
135
	
136
	/**
137
	 * Get the operation for this geometry at a concrete position
138
	 * @param index
139
	 * The position of the operation
140
	 * @return
141
	 * A geometry operation
142
	 */
143
	public GeometryOperation getGeometryOperation(int index);
144
		
145
	/**
146
	 * @return the geometry as a String
147
	 */
148
	public String toString();
149
	
150
}
0 151

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/type/GeometryTypeNotValidException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
 
25
package org.gvsig.fmap.geom.type;
26

  
27
import java.util.HashMap;
28
import java.util.Map;
29

  
30
import org.gvsig.fmap.geom.GeometryException;
31

  
32
/**
33
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
34
 */
35
public class GeometryTypeNotValidException extends GeometryException {
36
	private static final long serialVersionUID = 2588983103873322295L;
37

  
38
	/**
39
	 * Key to retrieve this exception's message
40
	 */
41
	private static final String MESSAGE_KEY = "geometry_type_not_valid_exception";
42
	/**
43
	 * This exception's message. Substitution fields follow the format %(fieldName) and 
44
	 * must be stored in the Map returned by the values() method. 
45
	 */
46
	private static final String FORMAT_STRING = 
47
		"The geometry with type %(type) and subType %(subType) is not supported.";
48
	
49
	/**
50
	 * Class name of the geometry type. Should never be null in this exception
51
	 */
52
	private int type;
53
	private int subType;
54
		
55
	/**
56
	 * Main constructor that provides both context data and a cause Exception
57
	 * @param geomClass geometry class 
58
	 * @param e cause exception
59
	 */
60
	public GeometryTypeNotValidException(int type, int subType, Exception e) {
61
		super(FORMAT_STRING, e, MESSAGE_KEY, serialVersionUID);
62
		// messageKey = MESSAGE_KEY;
63
		// formatString = FORMAT_STRING;
64
		// code = serialVersionUID;
65
		//		
66
		// if (e != null) {
67
		// initCause(e);
68
		// }
69
		
70
		this.type = type;
71
		this.subType = subType;
72
	}
73
	
74
	/**
75
	 * Main constructor that provides both context data and a cause Exception
76
	 * @param geomClass geometry class 
77
	 * @param e cause exception
78
	 */
79
	public GeometryTypeNotValidException(int type, int subType) {
80
		this(type, subType, null);
81
	}	
82
	
83
	protected Map values() {
84
		HashMap map = new HashMap();
85
		map.put("type", new Integer(type));
86
		map.put("subType", new Integer(subType));
87
		return map;
88
	}
89
}
90

  
91

  
0 92

  
tags/org.gvsig.desktop-2.0.20/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/type/AbstractGeometryType.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff