FOP-3135: Allow source resolution configuration by João André Gonçalves
diff --git a/batik-bridge/src/main/java/org/apache/batik/bridge/UserAgent.java b/batik-bridge/src/main/java/org/apache/batik/bridge/UserAgent.java
index 6ab6bbd..89ed989 100644
--- a/batik-bridge/src/main/java/org/apache/batik/bridge/UserAgent.java
+++ b/batik-bridge/src/main/java/org/apache/batik/bridge/UserAgent.java
@@ -310,11 +310,7 @@
/** Returns the Font Family Resolver */
FontFamilyResolver getFontFamilyResolver();
- float getTargetResolution();
-
float getSourceResolution();
- void setTargetResolution(float targetResolution);
-
void setSourceResolution(float sourceResolution);
}
diff --git a/batik-bridge/src/main/java/org/apache/batik/bridge/UserAgentAdapter.java b/batik-bridge/src/main/java/org/apache/batik/bridge/UserAgentAdapter.java
index 720de3a..eb9023f 100644
--- a/batik-bridge/src/main/java/org/apache/batik/bridge/UserAgentAdapter.java
+++ b/batik-bridge/src/main/java/org/apache/batik/bridge/UserAgentAdapter.java
@@ -55,8 +55,6 @@
private float sourceResolution = 96;
- private float targetResolution = UnitConv.IN2PT;
-
/**
* Sets the BridgeContext to be used for error information.
*/
@@ -154,7 +152,7 @@
* Returns the medium font size.
*/
public float getMediumFontSize() {
- return 9f * UnitConv.IN2MM / (getTargetResolution() * getPixelUnitToMillimeter());
+ return 9f * UnitConv.IN2MM / (UnitConv.IN2PT * getPixelUnitToMillimeter());
}
/**
@@ -471,13 +469,7 @@
public float getSourceResolution() { return sourceResolution; }
- public float getTargetResolution() { return targetResolution; }
-
public void setSourceResolution(float sourceResolution) {
this.sourceResolution = sourceResolution;
}
-
- public void setTargetResolution(float targetResolution) {
- this.targetResolution = targetResolution;
- }
}
diff --git a/batik-bridge/src/test/java/org/apache/batik/bridge/UserAgentAdapterTestCase.java b/batik-bridge/src/test/java/org/apache/batik/bridge/UserAgentAdapterTestCase.java
index 6434cc7..6e2b568 100644
--- a/batik-bridge/src/test/java/org/apache/batik/bridge/UserAgentAdapterTestCase.java
+++ b/batik-bridge/src/test/java/org/apache/batik/bridge/UserAgentAdapterTestCase.java
@@ -26,54 +26,34 @@
public class UserAgentAdapterTestCase {
@Test
- public void testEqualResolution_72() {
- checkGetMediumFontSize(72f, 72f, 9f);
+ public void testMediumFontResolution_72() {
+ checkGetMediumFontSize(72f, 9f);
}
@Test
- public void testEqualResolution_96() {
- checkGetMediumFontSize(96f, 96f, 9f);
- }
-
- @Test
- public void testDiffResolution_72_96() {
- checkGetMediumFontSize(72f, 96f, 6.74f);
- }
-
- @Test
- public void testDiffResolution_96_72() {
- checkGetMediumFontSize(96f, 72f, 12f);
+ public void testMediumFontResolution_96() {
+ checkGetMediumFontSize(96f, 12f);
}
@Test
public void testPixelMM_72() {
- checkGetPixelUnitToMillimeter(72f, 72f);
+ checkGetPixelUnitToMillimeter(72f);
}
@Test
- public void testPixelMM_96() { checkGetPixelUnitToMillimeter(96f, 96f); }
+ public void testPixelMM_96() { checkGetPixelUnitToMillimeter(96f); }
- @Test
- public void testPixelMM_72_96() { checkGetPixelUnitToMillimeter(72f, 96f); }
-
- @Test
- public void testPixelMM_96_72() {
- checkGetPixelUnitToMillimeter(96f, 72f);
- }
-
- private void checkGetMediumFontSize(float sourceRes, float targetRes, float expectedSize) {
+ private void checkGetMediumFontSize(float sourceRes, float expectedSize) {
UserAgentAdapter adapter = new UserAgentAdapter();
adapter.setSourceResolution(sourceRes);
- adapter.setTargetResolution(targetRes);
// Size must be calculated based on the dpi settings
assertEquals(expectedSize, adapter.getMediumFontSize(), 0.01);
}
- private void checkGetPixelUnitToMillimeter(float sourceRes, float targetRes) {
+ private void checkGetPixelUnitToMillimeter(float sourceRes) {
UserAgentAdapter adapter = new UserAgentAdapter();
adapter.setSourceResolution(sourceRes);
- adapter.setTargetResolution(targetRes);
// Pixel unit to mm must be calculated using the resolution set in the conf
// instead of assuming what the resolution is
diff --git a/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java b/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
index 585e384..4d92d7a 100644
--- a/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
+++ b/batik-svgbrowser/src/main/java/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
@@ -2747,8 +2747,6 @@
private float sourceResolution = 96;
- private float targetResolution = UnitConv.IN2PT;
-
/**
* Creates a new SVGUserAgent.
*/
@@ -2847,7 +2845,7 @@
*/
public float getMediumFontSize() {
// 9pt (72pt == 1in)
- return 9f * UnitConv.IN2MM / (getTargetResolution() * getPixelUnitToMillimeter());
+ return 9f * UnitConv.IN2MM / (UnitConv.IN2PT * getPixelUnitToMillimeter());
}
/**
@@ -3085,21 +3083,11 @@
}
@Override
- public float getTargetResolution() {
- return targetResolution;
- }
-
- @Override
public float getSourceResolution() {
return sourceResolution;
}
@Override
- public void setTargetResolution(float targetResolution) {
- this.targetResolution = targetResolution;
- }
-
- @Override
public void setSourceResolution(float sourceResolution) {
this.sourceResolution = sourceResolution;
}
diff --git a/batik-swing/src/main/java/org/apache/batik/swing/svg/JSVGComponent.java b/batik-swing/src/main/java/org/apache/batik/swing/svg/JSVGComponent.java
index aed8f52..d5812de 100644
--- a/batik-swing/src/main/java/org/apache/batik/swing/svg/JSVGComponent.java
+++ b/batik-swing/src/main/java/org/apache/batik/swing/svg/JSVGComponent.java
@@ -3102,17 +3102,10 @@
return userAgent.getSourceResolution();
}
- public float getTargetResolution() {
- return userAgent.getTargetResolution();
- }
-
public void setSourceResolution(float sourceResolution) {
userAgent.setSourceResolution(sourceResolution);
}
- public void setTargetResolution(float targetResolution) {
- userAgent.setTargetResolution(targetResolution);
- }
}
/**
@@ -3726,17 +3719,9 @@
return svgUserAgent.getSourceResolution();
}
- public float getTargetResolution() {
- return svgUserAgent.getTargetResolution();
- }
-
public void setSourceResolution(float sourceResolution) {
svgUserAgent.setSourceResolution(sourceResolution);
}
-
- public void setTargetResolution(float targetResolution) {
- svgUserAgent.setTargetResolution(targetResolution);
- }
}
protected static final Set FEATURES = new HashSet();
diff --git a/batik-swing/src/main/java/org/apache/batik/swing/svg/SVGUserAgent.java b/batik-swing/src/main/java/org/apache/batik/swing/svg/SVGUserAgent.java
index 1bfd186..760c64c 100644
--- a/batik-swing/src/main/java/org/apache/batik/swing/svg/SVGUserAgent.java
+++ b/batik-swing/src/main/java/org/apache/batik/swing/svg/SVGUserAgent.java
@@ -228,11 +228,7 @@
void checkLoadExternalResource(ParsedURL resourceURL,
ParsedURL docURL) throws SecurityException;
- float getTargetResolution();
-
float getSourceResolution();
- void setTargetResolution(float targetResolution);
-
void setSourceResolution(float sourceResolution);
}
diff --git a/batik-swing/src/main/java/org/apache/batik/swing/svg/SVGUserAgentAdapter.java b/batik-swing/src/main/java/org/apache/batik/swing/svg/SVGUserAgentAdapter.java
index a27ecba..855ecae 100644
--- a/batik-swing/src/main/java/org/apache/batik/swing/svg/SVGUserAgentAdapter.java
+++ b/batik-swing/src/main/java/org/apache/batik/swing/svg/SVGUserAgentAdapter.java
@@ -54,8 +54,6 @@
private float sourceResolution = 96;
- private float targetResolution = UnitConv.IN2PT;
-
public SVGUserAgentAdapter() { }
/**
@@ -136,7 +134,7 @@
* Returns the medium font size.
*/
public float getMediumFontSize() {
- return 9f * UnitConv.IN2MM / (getTargetResolution() * getPixelUnitToMillimeter());
+ return 9f * UnitConv.IN2MM / (UnitConv.IN2PT * getPixelUnitToMillimeter());
}
/**
@@ -360,15 +358,7 @@
return sourceResolution;
}
- public float getTargetResolution() {
- return targetResolution;
- }
-
public void setSourceResolution(float sourceResolution) {
this.sourceResolution = sourceResolution;
}
-
- public void setTargetResolution(float targetResolution) {
- this.targetResolution = targetResolution;
- }
}
diff --git a/batik-swing/src/test/java/org/apache/batik/swing/svg/SVGUserAgentAdapterTestCase.java b/batik-swing/src/test/java/org/apache/batik/swing/svg/SVGUserAgentAdapterTestCase.java
index 1d6f05f..1259f14 100644
--- a/batik-swing/src/test/java/org/apache/batik/swing/svg/SVGUserAgentAdapterTestCase.java
+++ b/batik-swing/src/test/java/org/apache/batik/swing/svg/SVGUserAgentAdapterTestCase.java
@@ -26,54 +26,34 @@
public class SVGUserAgentAdapterTestCase {
@Test
- public void testEqualResolution_72() {
- checkGetMediumFontSize(72f, 72f, 9f);
+ public void testMediumFontResolution_72() {
+ checkGetMediumFontSize(72f, 9f);
}
@Test
- public void testEqualResolution_96() {
- checkGetMediumFontSize(96f, 96f, 9f);
+ public void testMediumFontResolution_96() {
+ checkGetMediumFontSize(96f, 12f);
}
@Test
- public void testDiffResolution_72_96() {
- checkGetMediumFontSize(72f, 96f, 6.74f);
+ public void testPixelMM_72() { checkGetPixelUnitToMillimeter(72f); }
+
+ @Test
+ public void testPixelMM_96() {
+ checkGetPixelUnitToMillimeter(96f);
}
- @Test
- public void testDiffResolution_96_72() {
- checkGetMediumFontSize(96f, 72f, 12f);
- }
-
- @Test
- public void testPixelMM_72() {
- checkGetPixelUnitToMillimeter(72f, 72f);
- }
-
- @Test
- public void testPixelMM_96() { checkGetPixelUnitToMillimeter(96f, 96f); }
-
- @Test
- public void testPixelMM_72_96() { checkGetPixelUnitToMillimeter(72f, 96f); }
-
- @Test
- public void testPixelMM_96_72() {
- checkGetPixelUnitToMillimeter(96f, 72f);
- }
-
- private void checkGetMediumFontSize(float sourceRes, float targetRes, float expectedSize) {
+ private void checkGetMediumFontSize(float sourceRes, float expectedSize) {
SVGUserAgentAdapter adapter = new SVGUserAgentAdapter();
adapter.setSourceResolution(sourceRes);
- adapter.setTargetResolution(targetRes);
// Size must be calculated based on the dpi settings
assertEquals(expectedSize, adapter.getMediumFontSize(), 0.01);
}
- private void checkGetPixelUnitToMillimeter(float sourceRes, float targetRes) {
+ private void checkGetPixelUnitToMillimeter(float sourceRes) {
SVGUserAgentAdapter adapter = new SVGUserAgentAdapter();
adapter.setSourceResolution(sourceRes);
- adapter.setTargetResolution(targetRes);
// Pixel unit to mm must be calculated using the resolution set in the conf
// instead of assuming what the resolution is