Skip to content
This repository has been archived by the owner on May 22, 2022. It is now read-only.

Commit

Permalink
Fixed pref size calculation and will not throw exceptions on parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
bitstormFA committed Nov 11, 2017
1 parent 40b51f4 commit e4e498b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ uploadArchives {
}

task wrapper(type: Wrapper) {
gradleVersion = '2.8'
gradleVersion = '4.3.1'
}


2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.3.2
version=0.3.3
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javafx.geometry.VPos;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.SkinBase;
import org.scilab.forge.jlatexmath.ParseException;
import org.scilab.forge.jlatexmath.TeXConstants;
import org.scilab.forge.jlatexmath.TeXFormula;
import org.scilab.forge.jlatexmath.TeXIcon;
Expand Down Expand Up @@ -42,9 +43,18 @@ public LateXMathSkin(LateXMathControl control) {
}

protected void updateTeXIcon() {
TeXFormula teXFormula = new TeXFormula(getSkinnable().getFormula());
teXIcon= teXFormula.createTeXIcon(TeXConstants.STYLE_DISPLAY, getSkinnable().getSize()/11);
teXIcon.setInsets(new Insets(1, 1, 1, 1));
try {

TeXFormula teXFormula = new TeXFormula(getSkinnable().getFormula());
teXIcon = teXFormula.createTeXIcon(TeXConstants.STYLE_DISPLAY, getSkinnable().getSize() / 11);
teXIcon.setInsets(new Insets(1, 1, 1, 1));
}
catch (ParseException p) {
getSkinnable().setFormula("\\text{Invalid Formula}");
TeXFormula teXFormula = new TeXFormula(getSkinnable().getFormula());
teXIcon = teXFormula.createTeXIcon(TeXConstants.STYLE_DISPLAY, getSkinnable().getSize() / 11);
teXIcon.setInsets(new Insets(1, 1, 1, 1));
}

getSkinnable().requestLayout();
}
Expand Down Expand Up @@ -75,7 +85,7 @@ protected void layoutChildren(double contentX, double contentY, double contentWi

@Override
protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
return computePrefHeight(height, topInset, rightInset, bottomInset, leftInset);
return computePrefWidth(height, topInset, rightInset, bottomInset, leftInset);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.proudapes.jlatexmathfx.test;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import com.proudapes.jlatexmathfx.Control.LateXMathControl;

public class NoExceptionOnWrongFormula extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
String latex = "\\beginError{array}{l}";
VBox pane=new VBox();
LateXMathControl lc=new LateXMathControl(latex);
lc.setSize(24);
pane.getChildren().addAll(lc);

Scene scene=new Scene(pane);
primaryStage.setScene(scene);
primaryStage.setWidth(800);
primaryStage.setHeight(600);

primaryStage.show();


}

public static void main(String[] args) {
launch(args);
}

}

0 comments on commit e4e498b

Please sign in to comment.