aboutsummaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2001-02-27 00:05:52 +0000
committerKeiron Liddle <keiron@apache.org>2001-02-27 00:05:52 +0000
commit3964637dabc1882e8e71036a05a4153820189bcf (patch)
treea7c94541a4b0b2017a504363c92d54ac166a8d03 /src/org
parent954452418f9686b7405cf0eb563438bbf15f767d (diff)
downloadxmlgraphics-fop-3964637dabc1882e8e71036a05a4153820189bcf.tar.gz
xmlgraphics-fop-3964637dabc1882e8e71036a05a4153820189bcf.zip
compiles with jdk1.1, uses local methods to convert degrees <-> radians
Submitted by: Art Welch git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194093 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org')
-rw-r--r--src/org/apache/fop/render/pdf/SVGRenderer.java44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/org/apache/fop/render/pdf/SVGRenderer.java b/src/org/apache/fop/render/pdf/SVGRenderer.java
index 0a4dee52d..d79013287 100644
--- a/src/org/apache/fop/render/pdf/SVGRenderer.java
+++ b/src/org/apache/fop/render/pdf/SVGRenderer.java
@@ -114,6 +114,32 @@ public class SVGRenderer {
/** the current colour for use in svg */
private PDFColor currentColour = new PDFColor(0, 0, 0);
+ // The toRadians() and toDegrees() methods of the Math class are not available in JDK 1.1, so reproduce here
+ /**
+ * Converts an angle measured in degrees to the equivalent angle
+ * measured in radians.
+ *
+ * @param angdeg an angle, in degrees
+ * @return the measurement of the angle <code>angdeg</code>
+ * in radians.
+ * @since JDK1.2
+ */
+ public static double toRadians(double angdeg) {
+ return angdeg / 180.0 * Math.PI;
+ }
+ /**
+ * Converts an angle measured in radians to the equivalent angle
+ * measured in degrees.
+ *
+ * @param angrad an angle, in radians
+ * @return the measurement of the angle <code>angrad</code>
+ * in degrees.
+ * @since JDK1.2
+ */
+ public static double toDegrees(double angrad) {
+ return angrad * 180.0 / Math.PI;
+ }
+
/**
* create the SVG renderer
*/
@@ -672,7 +698,7 @@ public class SVGRenderer {
if(ry < 0)
ry = -ry;
// Convert angle from degrees to radians
- angle = Math.toRadians(angle % 360.0);
+ angle = toRadians(angle % 360.0);
double x0 = startx;
double y0 = starty;
@@ -724,13 +750,13 @@ public class SVGRenderer {
n = Math.sqrt((ux * ux) + (uy * uy));
p = ux; // (1 * ux) + (0 * uy)
sign = (uy < 0) ? -1d : 1d;
- double angleStart = Math.toDegrees(sign * Math.acos(p / n));
+ double angleStart = toDegrees(sign * Math.acos(p / n));
// Compute the angle extent
n = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy));
p = ux * vx + uy * vy;
sign = (ux * vy - uy * vx < 0) ? -1d : 1d;
- double angleExtent = Math.toDegrees(sign * Math.acos(p / n));
+ double angleExtent = toDegrees(sign * Math.acos(p / n));
if(!sweepFlag && angleExtent > 0) {
angleExtent -= 360f;
} else if (sweepFlag && angleExtent < 0) {
@@ -747,16 +773,16 @@ public class SVGRenderer {
boolean wrap = (sweepFlag ? angleStart > angleExtent : angleStart < angleExtent);
boolean wrapped = false;
-/* newx = Math.cos(Math.toRadians(angle)) * rx * Math.cos(Math.toRadians(currentAngle)) - Math.sin(Math.toRadians(angle)) * ry * Math.sin(Math.toRadians(currentAngle)) + cx;
- newy = Math.sin(Math.toRadians(angle)) * rx * Math.cos(Math.toRadians(currentAngle)) + Math.cos(Math.toRadians(angle)) * ry * Math.sin(Math.toRadians(currentAngle)) + cy;
+/* newx = Math.cos(toRadians(angle)) * rx * Math.cos(toRadians(currentAngle)) - Math.sin(toRadians(angle)) * ry * Math.sin(toRadians(currentAngle)) + cx;
+ newy = Math.sin(toRadians(angle)) * rx * Math.cos(toRadians(currentAngle)) + Math.cos(toRadians(angle)) * ry * Math.sin(toRadians(currentAngle)) + cy;
System.out.println("ox:" + startx + " oy: " + starty + " nx:" + newx + " ny:" + newy);
- newx = Math.cos(Math.toRadians(angle)) * rx * Math.cos(Math.toRadians(angleStart + angleExtent)) - Math.sin(Math.toRadians(angle)) * ry * Math.sin(Math.toRadians(angleStart + angleExtent)) + cx;
- newy = Math.sin(Math.toRadians(angle)) * rx * Math.cos(Math.toRadians(angleStart + angleExtent)) + Math.cos(Math.toRadians(angle)) * ry * Math.sin(Math.toRadians(angleStart + angleExtent)) + cy;
+ newx = Math.cos(toRadians(angle)) * rx * Math.cos(toRadians(angleStart + angleExtent)) - Math.sin(toRadians(angle)) * ry * Math.sin(toRadians(angleStart + angleExtent)) + cx;
+ newy = Math.sin(toRadians(angle)) * rx * Math.cos(toRadians(angleStart + angleExtent)) + Math.cos(toRadians(angle)) * ry * Math.sin(toRadians(angleStart + angleExtent)) + cy;
System.out.println("ox:" + x + " oy: " + y + " nx:" + newx + " ny:" + newy);*/
while(true) {
- newx = Math.cos(Math.toRadians(angle)) * rx * Math.cos(Math.toRadians(currentAngle)) - Math.sin(Math.toRadians(angle)) * ry * Math.sin(Math.toRadians(currentAngle)) + cx;
- newy = Math.sin(Math.toRadians(angle)) * rx * Math.cos(Math.toRadians(currentAngle)) + Math.cos(Math.toRadians(angle)) * ry * Math.sin(Math.toRadians(currentAngle)) + cy;
+ newx = Math.cos(toRadians(angle)) * rx * Math.cos(toRadians(currentAngle)) - Math.sin(toRadians(angle)) * ry * Math.sin(toRadians(currentAngle)) + cx;
+ newy = Math.sin(toRadians(angle)) * rx * Math.cos(toRadians(currentAngle)) + Math.cos(toRadians(angle)) * ry * Math.sin(toRadians(currentAngle)) + cy;
currentStream.write(pdfNumber.doubleOut(newx) + " " + pdfNumber.doubleOut(newy) + " l\n");
currentAngle = (currentAngle + (sweepFlag ? 1 : -1) * 5.0);
if((sweepFlag && currentAngle > (angleStart + angleExtent)) || (!sweepFlag && currentAngle < (angleStart + angleExtent))) {