Revision 11170 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LinePlacementConstraints.java

View differences:

LinePlacementConstraints.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.5  2007-04-12 14:28:43  jaume
46
* Revision 1.6  2007-04-12 16:01:11  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.5  2007/04/12 14:28:43  jaume
47 50
* basic labeling support for lines
48 51
*
49 52
* Revision 1.4  2007/04/11 16:01:08  jaume
......
78 81
 *
79 82
 */
80 83
public class LinePlacementConstraints extends AbstractPlacementConstraints {
84
	private static final double HALF_PI = Math.PI * 0.5;
85

  
81 86
	public FShape[] getLocationsFor(IGeometry geom, FShape labelShape, MultiPolygon exclusionZone) {
82 87
		return new FShape[] { (FShape) geom.getInternalShape() };
83 88
	}
84 89
	public void placeLabel(Graphics2D g, IGeometry geom, LabelClass lc, MultiPolygon exclusionZone, AffineTransform at, String[] labelTexts) {
85
		Point2D startingPoint;
86
		double rot;
90
		Point2D startingPoint = null;
91
		double rot = 0;
87 92
		if (isFollowingLine()) {
88 93
			throw new Error("following line option not yet implemented");
89 94
			// 1. create text path
......
92 97
		} else {
93 98
			PathLength pathLen = new PathLength(geom.getInternalShape());
94 99
			float distance;
100

  
95 101
			if (isAtTheBeginingOfLine()) {
96 102
				distance = 0;
97 103
			} else if (isAtTheEndOfLine()) {
......
102 108
			}
103 109

  
104 110
			startingPoint = pathLen.pointAtLength(distance);
105
			rot = pathLen.angleAtLength(distance);
106 111

  
112
			if (isParallel()) {
113
				// get the line theta and apply it
114
				rot = pathLen.angleAtLength(distance);
115

  
116
			} else if (isPerpendicular()) {
117
				// get the line theta with 90 degrees
118
				rot = pathLen.angleAtLength(distance) + HALF_PI;
119
			}
107 120
		}
108 121

  
109 122
		/*
......
124 137
			}
125 138

  
126 139

  
127
			if (isParallel()) {
128
				// get the line theta and apply it
129
			} else if (isPerpendicular()) {
130
				// get the line theta with 90 degrees
131
			}
132 140

  
133 141
			/*
134 142
			 * Now, we'll need to see who is defining the orientation

Also available in: Unified diff