root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / styling / AbstractPlacementConstraints.java @ 10671
History | View | Annotate | Download (3.83 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: AbstractPlacementConstraints.java 10671 2007-03-09 08:33:43Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.2 2007-03-09 08:33:43 jaume
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.1.2.2 2007/02/15 16:23:44 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.1.2.1 2007/02/09 07:47:05 jaume
|
53 |
* Isymbol moved
|
54 |
*
|
55 |
* Revision 1.1.2.3 2007/02/02 16:21:24 jaume
|
56 |
* start commiting labeling stuff
|
57 |
*
|
58 |
* Revision 1.1.2.2 2007/02/01 11:42:47 jaume
|
59 |
* *** empty log message ***
|
60 |
*
|
61 |
* Revision 1.1.2.1 2007/01/30 18:10:45 jaume
|
62 |
* start commiting labeling stuff
|
63 |
*
|
64 |
* Revision 1.1.2.1 2007/01/26 13:49:03 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
*
|
68 |
*/
|
69 |
|
70 |
|
71 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
72 |
import com.iver.cit.gvsig.fmap.core.FShape; |
73 |
|
74 |
/**
|
75 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
76 |
*/
|
77 |
public abstract class AbstractPlacementConstraints implements Cloneable, IPlacementConstraints { |
78 |
private int shapeType; |
79 |
|
80 |
private int duplicateLabelsMode = ONE_LABEL_PER_FEATURE_PART; // default duplicate treatment |
81 |
private int placementMode; |
82 |
|
83 |
public void setDuplicateLabelsMode(int mode) { |
84 |
if (mode != REMOVE_DUPLICATE_LABELS &&
|
85 |
mode != ONE_LABEL_PER_FEATURE && |
86 |
mode != ONE_LABEL_PER_FEATURE_PART) |
87 |
throw new IllegalArgumentException( |
88 |
"Only REMOVE_DUPLICATE_LABELS, " +
|
89 |
"ONE_LABEL_PER_FEATURE " +
|
90 |
"or ONE_LABEL_PER_FEATURE_PARTS allowed");
|
91 |
this.duplicateLabelsMode = mode;
|
92 |
} |
93 |
|
94 |
public void setPlacementMode(int mode) { |
95 |
switch (shapeType) {
|
96 |
case FShape.POINT:
|
97 |
if (mode != OFFSET_HORIZONTALY_AROUND_THE_POINT &&
|
98 |
mode != ON_TOP_OF_THE_POINT && |
99 |
mode != AT_SPECIFIED_ANGLE && |
100 |
mode != AT_ANGLE_SPECIFIED_BY_A_FIELD) |
101 |
throw new IllegalArgumentException( |
102 |
"Only OFFSET_HORIZONTALY_AROUND_THE_POINT, " +
|
103 |
"ON_TOP_OF_THE_POINT, " +
|
104 |
"AT_SPECIFIED_ANGLE " +
|
105 |
"or AT_ANGLE_SPECIFIED_BY_A_FIELD allowed for points");
|
106 |
break;
|
107 |
case FShape.POLYGON:
|
108 |
if (mode != HORIZONTAL &&
|
109 |
mode != PARALLEL ) |
110 |
throw new IllegalArgumentException( |
111 |
"Only HORIZONTAL, " +
|
112 |
"or PARALEL allowed for polygons");
|
113 |
break;
|
114 |
case FShape.LINE:
|
115 |
if (mode != HORIZONTAL &&
|
116 |
mode != PARALLEL && |
117 |
mode != FOLLOWING_LINE && |
118 |
mode != PERPENDICULAR) |
119 |
throw new IllegalArgumentException( |
120 |
"Only HORIZONTAL, " +
|
121 |
"or PARALEL allowed for lines");
|
122 |
break;
|
123 |
} |
124 |
this.placementMode = mode;
|
125 |
} |
126 |
|
127 |
public boolean isHorizontal() { |
128 |
return placementMode%100 == HORIZONTAL; |
129 |
} |
130 |
|
131 |
public boolean isPerpendicular() { |
132 |
return placementMode%100 == PERPENDICULAR; |
133 |
} |
134 |
|
135 |
public boolean isFollowingLine() { |
136 |
return placementMode%100 == FOLLOWING_LINE; |
137 |
} |
138 |
|
139 |
public boolean isParallel() { |
140 |
return placementMode%100 == PARALLEL; |
141 |
} |
142 |
|
143 |
public int getDuplicateLabelsMode() { |
144 |
return duplicateLabelsMode;
|
145 |
} |
146 |
} |