Anonymous avatar Anonymous committed 1c97c1b Draft

finished rotation

Comments (0)

Files changed (1)

src/main/java/org/xmlcml/graphics/control/page/PageNormalizerAction.java

 import org.xmlcml.euclid.Angle.Units;
 import org.xmlcml.euclid.Real2;
 import org.xmlcml.euclid.Real2Range;
+import org.xmlcml.euclid.RealArray;
 import org.xmlcml.euclid.Transform2;
 import org.xmlcml.euclid.Vector2;
 import org.xmlcml.graphics.control.AbstractActionElement;
 		if (isTrue(PageActionElement.CAN_ROTATE_LANDSCAPE)) {
 			guessAndApplyConvertToLandscape();
 		}
-		debugFile("target/norm2.svg");
 		
 		Integer decimalPlaces = getDecimalPlaces();
 		if (decimalPlaces != null) {
 			getSVGPage().format(decimalPlaces);
 		}
+		debugFile("target/norm2.svg");
 	}
 
 	private void debugFile(String filename) {
 		}
 		storeRotationCounts(textsTransform);
 		guessRotationAndApply();
+		removeRedundantUnitMatrices();
+	}
+
+	private void removeRedundantUnitMatrices() {
+		Transform2 unit = new Transform2();
+		RealArray unitRa = new RealArray(unit.getMatrixAsArray());
+		List<SVGElement> elements = SVGUtil.getQuerySVGElements(getSVGPage(), ".//svg:*[@transform]");
+		for (SVGElement element : elements) {
+			Transform2 t2 = element.getTransform();
+			RealArray t2Ra = new RealArray(t2.getMatrixAsArray());
+			if (unitRa.equals(t2Ra, EPS)) {
+				Attribute t2Att = element.getAttribute(SVGElement.TRANSFORM);
+				t2Att.detach();
+			}
+		}
 	}
 
 	private void guessRotationAndApply() {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.