Revision 25

View differences:

trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfText.java
7 7

  
8 8
import java.awt.Font;
9 9
import java.awt.Graphics2D;
10
import java.awt.geom.AffineTransform;
11 10
import java.awt.geom.Point2D;
12 11

  
13 12
import org.cresques.geo.Projection;
......
70 69
	}
71 70

  
72 71
	public void draw(Graphics2D g, ViewPort vp) {
73
		AffineTransform msave=g.getTransform();
74
		g.setTransform(vp.mat);
72
		//AffineTransform msave=g.getTransform();
73
		//g.setTransform(vp.mat);
75 74
		if (dxfColor == AcadColor.BYLAYER)
76 75
			g.setColor(layer.getColor());
77 76
		else
78 77
			g.setColor(AcadColor.getColor(dxfColor));
79 78
		Font fnt = g.getFont();
80
		fnt = new Font(fnt.getName(), fnt.getStyle(), (int) h);
79
		Point2D ptT0 = new Point2D.Double(0, 0);
80
		Point2D ptT1 = new Point2D.Double(h, h);
81
		vp.mat.transform(ptT0, ptT0);
82
		vp.mat.transform(ptT1, ptT1);
83
		fnt = new Font(fnt.getName(), fnt.getStyle(), (int) (ptT1.getX()-ptT0.getX()));
81 84
		g.setFont(fnt);
82
		g.drawString(text, (int) pts[0].getX(), (int)pts[0].getY());
83
		g.setTransform(msave);
85
		ptT0.setLocation(pts[0].getX(), pts[0].getY());
86
		vp.mat.transform(ptT0, ptT0);
87
		g.drawString(text, (int) ptT0.getX(), (int)ptT0.getY());
88
		//g.setTransform(msave);
84 89
	}
85 90

  
86 91
	/* (non-Javadoc)
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java
124 124
		
125 125
		double scalex = vp.mat.getScaleX()	/* g.getTransform().getScaleX()*/ ,
126 126
			scaley = vp.mat.getScaleY()		/* g.getTransform().getScaleY() */;
127
		System.out.println("Sz=("+(int) (w*scalex)+","+(int) (h*scaley)+"); scale=("+scalex+","+scaley+")");
128 127
		int wImg = (int) Math.abs(w*scalex), hImg = (int) Math.abs(h*scaley);
128
		System.out.println("Sz=("+wImg+","+hImg+"); scale=("+scalex+","+scaley+")");
129 129
		if (wImg <= 0 || hImg <= 0) return;
130 130
		Image geoImage = geoFile.updateImage(wImg, hImg);
131 131
		
trunk/libraries/libCq CMS for java.old/src/org/cresques/geo/EquidistantCilindrical.java
1
1   /*
2
2    * EquidistantCylindricalMapProjection.java
3
3    *
4
4     * Copyright (c) 2002, 2003, Raben Systems, Inc.
5
5    * All rights reserved.
6
6    *
7
7    * Redistribution and use in source and binary forms, with or without
8
8    * modification, are permitted provided that the following conditions are met:
9
9    *
10
10   *    Redistributions of source code must retain the above copyright notice,
11
11   *    this list of conditions and the following disclaimer.
12
12   *
13
13   *    Redistributions in binary form must reproduce the above copyright notice,
14
14   *    this list of conditions and the following disclaimer in the documentation
15
15   *    and/or other materials provided with the distribution.
16
16   *
17
17   *    Neither the name of Raben Systems, Inc. nor the names of its contributors
18
18   *    may be used to endorse or promote products derived from this software
19
19   *    without specific prior written permission.
20
20   *
21
21   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
22   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
24   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25
25   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
28   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
29   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
30   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
31   * POSSIBILITY OF SUCH DAMAGE.
32
32   *
33
33   * Created on July 2, 2002, 3:45 PM
34
34   */
35
35  
36
package org.cresques.geo;
37

  
38
36  package com.raben.projection.map;
39
37      import java.awt.geom.Point2D;  
40
38      import java.awt.geom.GeneralPath;
41
39      
42
40  /***
43
41   * Implementation ProjectionInterface for Equidistant Cylindrical map projection
44
42   * @author  Vern Raben
45
43   * @version $Revision$ $Date$
46
44   */
47
45      public class EquidistantCylindricalMapProjection 
48
46          extends AbstractMapProjection {
49
47  
50
48      /*** Creates new CylindricalEquidistantMapProjection */
51
49      public EquidistantCylindricalMapProjection() {
52
50          setCenterCoordinate(new Point2D.Double(Math.PI, 0.0));
53
51      }
54
52  
55
53      /***
56
54       * Get coordinate for a given location in radians
57
55       * @param loc Point2D Screen location
58
56       * @return Point2D Coordinate of the point in radians
59
57       */
60
58      public Point2D getCoordinateForLocation(Point2D loc) {
61
59          Point2D.Double coordinate = new Point2D.Double(Double.NaN,
62
60              Double.NaN);
63
61          Point2D centerCoordinate = getCenterCoordinate();
64
62          Point2D centerPoint = getCenterPoint();
65
63          double radius = getRadius();
66
64          
67
65          if (!Double.isNaN(loc.getX())) {
68
66              double x = loc.getX() - centerPoint.getX();
69
67              double y = loc.getY() - centerPoint.getY();
70
68              double latitude = y / radius;
71
69              double longitude = centerCoordinate.getX() + (x / radius);
72
70              coordinate.setLocation(longitude, latitude);
73
71              normalizeCoordinate(coordinate);
74
72          }
75
73          
76
74          return coordinate;        
77
75      }
78
76      
79
77      /***
80
78       * Get location for specified coordinate in radians
81
79       * @param coordinate Point2D longitude and latitude of coordinate in radians
82
80       * @return Point2D Screen location of the coordinate
83
81       */
84
82      public Point2D getLocationForCoordinate(Point2D coordinate) {
85
83          Point2D.Double location = new Point2D.Double(Double.NaN, Double.NaN);
86
84          Point2D centerPoint = getCenterPoint();
87
85          Point2D centerCoordinate = getCenterCoordinate();     
88
86          double radius = getRadius();
89
87          
90
88          if (!Double.isNaN(coordinate.getX())) {
91
89              double lonDiff = normalizeLongitude(coordinate.getX() 
92
90                  - centerCoordinate.getX());
93
91              double x = centerPoint.getX() + (radius * lonDiff);
94
92              double y = radius * coordinate.getY();
95
93              location.setLocation(x, y);
96
94          }
97
95          
98
96          return location;        
99
97      }
100
98      
101
99      /***
102
100      * Get overlay grid for map
103
101      * @return mapOverlay GeneneralPath
104
102      */
105
103     public GeneralPath getOverlayGridPath() {
106
104         GeneralPath overlayGridPath = new GeneralPath();
107
105         double radius = getRadius();
108
106         Point2D centerCoordinate = getCenterCoordinate();
109
107         Point2D centerPoint = getCenterPoint();
110
108         float mark = (float) (radius / 360.0);
111
109         double latLim = getLatitudeRange() / 2.0;
112
110         double overlayGridLatitudeIncrement = getOverlayGridLatitudeIncrement();
113
111         double overlayGridIncrement = getOverlayGridIncrement();
114
112         double overlayGridLongitudeIncrement 
115
113             = getOverlayGridLongitudeIncrement();
116
114  
117
115         // Create latitude lines
118
116         for (double lat = -latLim; lat <= latLim; 
119
117                 lat += overlayGridLatitudeIncrement) {
120
118             float y = (float) (radius * lat);
121
119             
122
120             for (double lon = -Math.PI; lon <= Math.PI;
123
121                     lon += overlayGridIncrement) {
124
122                 double lonDiff = normalizeLongitude(lon
125
123                     - centerCoordinate.getX()); 
126
124                 float x = (float) (centerPoint.getX() + (radius * lonDiff));
127
125                 overlayGridPath.moveTo(x - mark, y);
128
126                 overlayGridPath.lineTo(x + mark, y);
129
127                 overlayGridPath.moveTo(x, y - mark);
130
128                 overlayGridPath.lineTo(x, y + mark);
131
129             }
132
130         }        
133
131   
134
132         // Create longitude lines
135
133         for (double lon = -Math.PI; lon <= Math.PI;
136
134                 lon += overlayGridLongitudeIncrement) {
137
135             double lonDiff = normalizeLongitude(lon - centerCoordinate.getX()); 
138
136             float x = (float) (centerPoint.getX() + (radius * lonDiff)); 
139
137             
140
138             for (double lat = -latLim; lat <= latLim; 
141
139                     lat += overlayGridIncrement) {
142
140                 float y = (float) (radius * lat);
143
141                 overlayGridPath.moveTo(x - mark, y);
144
142                 overlayGridPath.lineTo(x + mark, y);
145
143                 overlayGridPath.moveTo(x, y - mark);
146
144                 overlayGridPath.lineTo(x, y + mark);
147
145             }
148
146         }
149
147         
150
148         return overlayGridPath;        
151
149     }
152
150     
153
151     /***
154
152      * Get name of the projection
155
153      * @return ProjectionName
156
154      */
157
155     public ProjectionName getProjectionName() {
158
156         return ProjectionName.EQUIDISTANT_CYLINDRICAL;
159
157     }
160
158     
161
159 }
trunk/libraries/libCq CMS for java.old/src/org/cresques/geo/EquidistantCylindrical.java
1
/*
2
 * EquidistantCylindricalMapProjection.java
3
 *
4
 * Copyright (c) 2002, 2003, Raben Systems, Inc.
5
 * All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions are met:
9
 *
10
 *    Redistributions of source code must retain the above copyright notice,
11
 *    this list of conditions and the following disclaimer.
12
 *
13
 *    Redistributions in binary form must reproduce the above copyright notice,
14
 *    this list of conditions and the following disclaimer in the documentation
15
 *    and/or other materials provided with the distribution.
16
 *
17
 *    Neither the name of Raben Systems, Inc. nor the names of its contributors
18
 *    may be used to endorse or promote products derived from this software
19
 *    without specific prior written permission.
20
 *
21
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
 * POSSIBILITY OF SUCH DAMAGE.
32
 *
33
 * Created on July 2, 2002, 3:45 PM
34
 */
35

  
36
package org.cresques.geo;
37

  
38
//package com.raben.projection.map;
39
//import java.awt.geom.Point2D;  
40
//import java.awt.geom.GeneralPath;
41
  
42
/***
43
 * Implementation ProjectionInterface for Equidistant Cylindrical map projection
44
 * @author  Vern Raben
45
 * @version $Revision$ $Date$
46
 */
47
public class EquidistantCylindrical { //extends AbstractMapProjection {
48
/*47  
49
48      /*** Creates new CylindricalEquidistantMapProjection * /
50
49      public EquidistantCylindricalMapProjection() {
51
50          setCenterCoordinate(new Point2D.Double(Math.PI, 0.0));
52
51      }
53
52  
54
53      /***
55
54       * Get coordinate for a given location in radians
56
55       * @param loc Point2D Screen location
57
56       * @return Point2D Coordinate of the point in radians
58
57       * /
59
58      public Point2D getCoordinateForLocation(Point2D loc) {
60
59          Point2D.Double coordinate = new Point2D.Double(Double.NaN,
61
60              Double.NaN);
62
61          Point2D centerCoordinate = getCenterCoordinate();
63
62          Point2D centerPoint = getCenterPoint();
64
63          double radius = getRadius();
65
64          
66
65          if (!Double.isNaN(loc.getX())) {
67
66              double x = loc.getX() - centerPoint.getX();
68
67              double y = loc.getY() - centerPoint.getY();
69
68              double latitude = y / radius;
70
69              double longitude = centerCoordinate.getX() + (x / radius);
71
70              coordinate.setLocation(longitude, latitude);
72
71              normalizeCoordinate(coordinate);
73
72          }
74
73          
75
74          return coordinate;        
76
75      }
77
76      
78
77      /***
79
78       * Get location for specified coordinate in radians
80
79       * @param coordinate Point2D longitude and latitude of coordinate in radians
81
80       * @return Point2D Screen location of the coordinate
82
81       * /
83
82      public Point2D getLocationForCoordinate(Point2D coordinate) {
84
83          Point2D.Double location = new Point2D.Double(Double.NaN, Double.NaN);
85
84          Point2D centerPoint = getCenterPoint();
86
85          Point2D centerCoordinate = getCenterCoordinate();     
87
86          double radius = getRadius();
88
87          
89
88          if (!Double.isNaN(coordinate.getX())) {
90
89              double lonDiff = normalizeLongitude(coordinate.getX() 
91
90                  - centerCoordinate.getX());
92
91              double x = centerPoint.getX() + (radius * lonDiff);
93
92              double y = radius * coordinate.getY();
94
93              location.setLocation(x, y);
95
94          }
96
95          
97
96          return location;        
98
97      }
99
98      
100
99      /***
101
100      * Get overlay grid for map
102
101      * @return mapOverlay GeneneralPath
103
102      * /
104
103     public GeneralPath getOverlayGridPath() {
105
104         GeneralPath overlayGridPath = new GeneralPath();
106
105         double radius = getRadius();
107
106         Point2D centerCoordinate = getCenterCoordinate();
108
107         Point2D centerPoint = getCenterPoint();
109
108         float mark = (float) (radius / 360.0);
110
109         double latLim = getLatitudeRange() / 2.0;
111
110         double overlayGridLatitudeIncrement = getOverlayGridLatitudeIncrement();
112
111         double overlayGridIncrement = getOverlayGridIncrement();
113
112         double overlayGridLongitudeIncrement 
114
113             = getOverlayGridLongitudeIncrement();
115
114  
116
115         // Create latitude lines
117
116         for (double lat = -latLim; lat <= latLim; 
118
117                 lat += overlayGridLatitudeIncrement) {
119
118             float y = (float) (radius * lat);
120
119             
121
120             for (double lon = -Math.PI; lon <= Math.PI;
122
121                     lon += overlayGridIncrement) {
123
122                 double lonDiff = normalizeLongitude(lon
124
123                     - centerCoordinate.getX()); 
125
124                 float x = (float) (centerPoint.getX() + (radius * lonDiff));
126
125                 overlayGridPath.moveTo(x - mark, y);
127
126                 overlayGridPath.lineTo(x + mark, y);
128
127                 overlayGridPath.moveTo(x, y - mark);
129
128                 overlayGridPath.lineTo(x, y + mark);
130
129             }
131
130         }        
132
131   
133
132         // Create longitude lines
134
133         for (double lon = -Math.PI; lon <= Math.PI;
135
134                 lon += overlayGridLongitudeIncrement) {
136
135             double lonDiff = normalizeLongitude(lon - centerCoordinate.getX()); 
137
136             float x = (float) (centerPoint.getX() + (radius * lonDiff)); 
138
137             
139
138             for (double lat = -latLim; lat <= latLim; 
140
139                     lat += overlayGridIncrement) {
141
140                 float y = (float) (radius * lat);
142
141                 overlayGridPath.moveTo(x - mark, y);
143
142                 overlayGridPath.lineTo(x + mark, y);
144
143                 overlayGridPath.moveTo(x, y - mark);
145
144                 overlayGridPath.lineTo(x, y + mark);
146
145             }
147
146         }
148
147         
149
148         return overlayGridPath;        
150
149     }
151
150     
152
151     /***
153
152      * Get name of the projection
154
153      * @return ProjectionName
155
154      * /
156
155     public ProjectionName getProjectionName() {
157
156         return ProjectionName.EQUIDISTANT_CYLINDRICAL;
158
157     }
159
*/     
160
}
0 161

  
trunk/libraries/libCq CMS for java.old/src/org/cresques/geo/Orthographic.java
44 44
 * Copyright (c) Raben Systems, Inc., 2002
45 45
 * All rights reserved 
46 46
 */
47
public final class Orthographic extends AbstractMapProjection { 
47
public final class Orthographic { //extends AbstractMapProjection { 
48 48
	/*** Creates new OrthographicMapProjection */
49 49
	public Orthographic() { 
50 50
	}
......
56 56
	 */
57 57
	public Point2D getLocationForCoordinate(Point2D coordinate) {
58 58
		Point2D.Double loc = new Point2D.Double(Double.NaN, Double.NaN);
59
		Point2D centerPoint = getCenterPoint();
59
/*		Point2D centerPoint = getCenterPoint();
60 60
		Point2D centerCoordinate = getCenterCoordinate();        
61 61
		double radius = getRadius();
62 62
		double cosLatCenter = getCosLatCenter();
......
84 84
				loc.setLocation(x, y);
85 85
			}
86 86
		}
87

  
87
*/
88 88
		return loc;
89 89
	}
90 90

  
......
98 98
	public Point2D getCoordinateForLocation(Point2D loc) {
99 99
		Point2D.Double coordinate 
100 100
			= new Point2D.Double(Double.NaN, Double.NaN);
101
		Point2D centerPoint = getCenterPoint();
101
/*		Point2D centerPoint = getCenterPoint();
102 102
		Point2D centerCoordinate = getCenterCoordinate();
103 103
		double sinLatCenter = getSinLatCenter();
104 104
		double cosLatCenter = getCosLatCenter();
......
139 139
			}
140 140

  
141 141
		}
142
 
142
*/ 
143 143
		return coordinate;
144 144
	}
145 145

  
......
150 150
	 */
151 151
	public GeneralPath getOverlayGridPath() {
152 152
		GeneralPath overlayGridPath = new GeneralPath();
153
		double sinLat = 0.0;
153
/*		double sinLat = 0.0;
154 154
		double cosLat = 0.0;
155 155
		double cosLonDiff = 0.0;
156 156
		double sinLonDiff = 0.0;
......
226 226
				}
227 227
			}
228 228
		}        
229

  
229
*/
230 230
		return overlayGridPath;
231 231
	}
232 232

  
......
234 234
	 * Get projection name
235 235
	 * @return ProjectionName
236 236
	 */
237
	public ProjectionName getProjectionName() {
238
		return ProjectionName.ORTHOGRAPHIC;
239
	}
237
	//public ProjectionName getProjectionName() {
238
	//	return ProjectionName.ORTHOGRAPHIC;
239
	//}
240 240
}

Also available in: Unified diff