Commit 0e2c6211 authored by Jean-Marc Ronck's avatar Jean-Marc Ronck
Browse files

Bug Fixes

parent c77bf77e
......@@ -6,7 +6,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>math-pretty-printer</artifactId>
<version>0.3.0-SNAPSHOT</version>
<version>0.3.1-SNAPSHOT</version>
<properties>
......@@ -149,6 +149,31 @@
<version>2.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>de.monticore.lang.monticar.mpp.core.application.Application</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Other Configuration -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
......
......@@ -50,7 +50,7 @@ public class SVGGenerator {
icon.setInsets(new Insets(0,0,0,0));
graphics.setSVGCanvasSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));
graphics.setColor(new Color(37,37,37));
graphics.setColor(new Color(37,37,37, 0));
graphics.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight());
icon.paintIcon(null, graphics, 0, 0);
......
package de.monticore.lang.monticar.mpp.montimath;
import de.monticore.assignmentexpressions._ast.ASTMinusPrefixExpression;
import de.monticore.ast.Comment;
import de.monticore.commonexpressions._ast.*;
import de.monticore.lang.math._ast.*;
......@@ -10,6 +11,7 @@ import de.monticore.lang.matrixexpressions._ast.*;
import de.monticore.lang.monticar.ranges._ast.ASTRange;
import de.monticore.lang.monticar.types2._ast.ASTDimension;
import de.monticore.lang.monticar.types2._ast.ASTElementType;
import de.monticore.literals.literals._ast.ASTDoubleLiteral;
import de.monticore.literals.literals._ast.ASTIntLiteral;
import de.monticore.literals.literals._ast.ASTSignedIntLiteral;
import de.monticore.numberunit._ast.ASTNumberWithInf;
......@@ -272,7 +274,8 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
@Override
public void visit(ASTMathAssignmentStatement node) {
this.printComments(node.get_PreCommentList());
this.printer.print(node.getName());
if (node.isPresentName()) this.printer.print(node.getName());
}
@Override
......@@ -348,7 +351,7 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
}
@Override
public void visit(ASTLessThanExpression node) {
public void revisit(ASTLessThanExpression node) {
this.printSpace();
this.printer.print(node.getOperator());
this.printSpace();
......@@ -367,14 +370,14 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
}*/
@Override
public void visit(ASTLessEqualExpression node) {
public void revisit(ASTLessEqualExpression node) {
this.printSpace();
this.printer.print(node.getOperator());
this.printSpace();
}
@Override
public void visit(ASTGreaterThanExpression node) {
public void revisit(ASTGreaterThanExpression node) {
this.printSpace();
this.printer.print(node.getOperator());
this.printSpace();
......@@ -555,6 +558,13 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
this.printSpace();
}
@Override
public void revisit(ASTNotEqualsExpression node) {
this.printSpace();
this.printer.print(node.getOperator());
this.printSpace();
}
@Override
public void revisit(ASTGreaterEqualExpression node) {
this.printSpace();
......@@ -576,6 +586,13 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
this.printSpace();
}
@Override
public void revisit(ASTBooleanAndOpExpression node) {
this.printSpace();
this.printer.print(node.getOperator());
this.printSpace();
}
@Override
public void revisit(ASTMathArithmeticPowerOfExpression node) {
this.printCircumFlex();
......@@ -632,4 +649,14 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
this.printer.print(".\\");
this.printSpace();
}
@Override
public void visit(ASTDoubleLiteral node) {
this.printer.print(node.getValue());
}
@Override
public void visit(ASTMinusPrefixExpression node) {
this.printer.print("-");
}
}
......@@ -99,12 +99,15 @@ public interface MathStructuredVisitor extends MathVisitor {
@Override
default void handle(ASTLessThanExpression node) {
this.getRealThis().traversePartOne(node);
this.getRealThis().visit(node);
this.getRealThis().traversePartOne(node);
this.getRealThis().revisit(node);
this.getRealThis().traversePartTwo(node);
this.getRealThis().endVisit(node);
}
default void revisit(ASTLessThanExpression node) {}
default void traversePartOne(ASTLessThanExpression node) {
if (null != node.getLeftExpression()) {
node.getLeftExpression().accept(this.getRealThis());
......@@ -119,12 +122,15 @@ public interface MathStructuredVisitor extends MathVisitor {
@Override
default void handle(ASTLessEqualExpression node) {
this.getRealThis().traversePartOne(node);
this.getRealThis().visit(node);
this.getRealThis().traversePartOne(node);
this.getRealThis().revisit(node);
this.getRealThis().traversePartTwo(node);
this.getRealThis().endVisit(node);
}
default void revisit(ASTLessEqualExpression node) {}
default void traversePartOne(ASTLessEqualExpression node) {
if (null != node.getLeftExpression()) {
node.getLeftExpression().accept(this.getRealThis());
......
......@@ -10,6 +10,7 @@ import de.monticore.lang.monticar.types2._ast.ASTDimension;
import de.monticore.lang.monticar.types2._ast.ASTElementType;
import de.monticore.lang.matrixexpressions._ast.*;
import de.monticore.numberunit._ast.ASTTimeDiv;
import de.monticore.numberunit._ast.ASTUnitBaseDimWithPrefix;
public class TeXMathPrettyPrinter extends MathPrettyPrinter implements TeXMathStructuredVisitor {
protected boolean needsParenthesis;
......@@ -27,6 +28,11 @@ public class TeXMathPrettyPrinter extends MathPrettyPrinter implements TeXMathSt
this.printer.print(printedNode);
}
@Override
public void endVisit(ASTElementType node) {
this.printer.print("\\;");
}
@Override
public void revisit(ASTDimension ast) {
this.printSpace();
......@@ -65,15 +71,22 @@ public class TeXMathPrettyPrinter extends MathPrettyPrinter implements TeXMathSt
@Override
public void revisit(ASTMathAssignmentDeclarationStatement node) {
this.printer.print("~");
this.printer.print(node.getName());
this.printer.print("~");
String printedNode = String.format("\\text{%s}", node.getName());
//this.printer.print("~");
this.printer.print(printedNode);
//this.printer.print("~");
}
@Override
public void visit(ASTMathAssignmentStatement node) {
this.printer.print(node.getName());
this.printer.print("~");
if (node.isPresentName()) {
String printedNode = String.format("\\text{%s}", node.getName());
this.printer.print(printedNode);
}
//this.printer.print("~");
}
@Override
......@@ -83,7 +96,7 @@ public class TeXMathPrettyPrinter extends MathPrettyPrinter implements TeXMathSt
@Override
public void endVisit(ASTMathDeclarationStatement node) {
this.printer.print("~");
//this.printer.print("~");
this.printer.print(node.getName());
this.printSemicolon();
this.printer.println();
......@@ -93,10 +106,12 @@ public class TeXMathPrettyPrinter extends MathPrettyPrinter implements TeXMathSt
public void visit(ASTTimeDiv node) {
//TODO: Create LaTeX
if (node.isPresentIsDiv()) {
this.printer.print("\\;");
this.printer.print(node.getIsDiv());
}
if (node.isPresentIsTime()) {
this.printer.print("\\;");
this.printer.print("\\cdot");
}
}
......@@ -187,14 +202,14 @@ public class TeXMathPrettyPrinter extends MathPrettyPrinter implements TeXMathSt
}
@Override
public void visit(ASTLessThanExpression node) {
public void revisit(ASTLessThanExpression node) {
this.printSpace();
this.printer.print("<");
this.printSpace();
}
@Override
public void visit(ASTLessEqualExpression node) {
public void revisit(ASTLessEqualExpression node) {
this.printSpace();
this.printer.print("\\leqslant");
this.printSpace();
......@@ -228,6 +243,13 @@ public class TeXMathPrettyPrinter extends MathPrettyPrinter implements TeXMathSt
this.printSpace();
}
@Override
public void revisit(ASTNotEqualsExpression node) {
this.printSpace();
this.printer.print("\\neq");
this.printSpace();
}
@Override
public void visit(ASTMathIfExpression node) { /* NOOP */ }
......@@ -257,4 +279,23 @@ public class TeXMathPrettyPrinter extends MathPrettyPrinter implements TeXMathSt
public void endVisit(ASTMathArithmeticMatrixEERightDivideExpression node) {
this.printer.print("^{\\circ(-1)}");
}
@Override
public void visit(ASTNameExpression node) {
String printedNode = String.format("\\text{%s}", node.getName());
this.printer.print(printedNode);
}
@Override
public void visit(ASTUnitBaseDimWithPrefix node) {
this.printer.print("\\;");
this.printer.print(node.getName());
}
@Override
public void endVisit(ASTDimension node) {
this.printRightCurlyBracket();
this.printer.print("\\;");
}
}
......@@ -96,6 +96,7 @@
position:fixed;
top:0;
right:0;
z-index:2;
}
input {
......@@ -122,6 +123,16 @@
input.latex {
background-image: url("data:image/svg+xml;charset=UTF-8,%3c?xml version='1.0' encoding='UTF-8' standalone='no'?%3e%3csvg xmlns='http://www.w3.org/2000/svg' version='1.1' height='568.88px' width='588.42px'%3e%3cpath style='fill:black; stroke:none' d='M 10.499686,177.03840 L 31.174931,178.56990 C 52.615925,154.32116 61.039171,82.595924 187.38789,96.634671 C 182.79339,403.95560 48.021426,436.37234 56.444675,499.41907 C 59.507674,535.15406 87.840417,557.10556 118.47041,558.38181 C 215.21014,555.06356 210.87089,424.63084 240.99038,95.868921 L 365.80760,95.868921 C 359.17110,211.75239 341.04836,327.63586 339.00636,441.22208 C 340.53786,516.77606 386.48285,557.10556 446.97708,557.61606 C 546.52456,560.93431 577.92030,444.79558 577.92030,395.27709 L 556.47931,395.27710 C 554.43731,436.11709 534.78306,465.47083 492.92207,467.25758 C 378.82535,468.78908 441.61683,266.63113 442.38258,97.400421 L 577.92030,98.166171 L 577.15455,11.636437 C 13.807491,8.9075799 85.312284,-2.1366151 10.499686,177.03840 z' /%3e%3c/svg%3e ");
}
tr.marked {
transition-duration:2s;
background-color:#FFA500;
color:#000;
}
tr.marked img {
filter:invert(100%);
}
-->
</style>
<noscript>
......@@ -179,11 +190,52 @@
<script>
var radios = document.querySelectorAll("input[name='View']");
var card = document.querySelector(".card");
var front = document.querySelectorAll(".card-face-front tr");
var back = document.querySelectorAll(".card-face-back tr");
function clickButton(index) {
radios[index].click();
}
function selectRange(start, end) {
for(var i = start - 1; i < (end || start); i++) {
front[i].classList.add("marked");
back[i].classList.add("marked");
}
}
function scroll(index, start) {
start = start - 1;
window.scrollTo(0, index === 0 ? front[start].offsetTop : back[start].offsetTop);
}
function onChange(event) {
card.classList.toggle("flipped");
}
function onHashChange() {
window.setTimeout(function() {
var hash = window.location.hash;
var parts = hash.substring(1).split(':');
var index = parts[0];
var start = parts[1];
var end = parts[2];
if(index) {
clickButton(index);
if(start) {
scroll(index, start);
selectRange(start, end);
}
}
}, 0);
}
radios.forEach(function(element) { element.addEventListener("change", onChange) });
onHashChange();
window.addEventListener("hashchange", onHashChange);
</script>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment