From ef71558d7834ee6f31bf0f488ed285a4df8c101a Mon Sep 17 00:00:00 2001 From: ucrhh Date: Sat, 30 Jan 2021 14:43:25 +0100 Subject: [PATCH] configure rough layout of TypeInferenceView --- .../typeinferencecontent/LatexCreator.java | 12 ++++---- .../TypeInferenceView.java | 28 +++++++++++++------ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/LatexCreator.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/LatexCreator.java index b6bd8ad..868ce38 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/LatexCreator.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/LatexCreator.java @@ -56,7 +56,7 @@ public class LatexCreator implements StepVisitor, TermVisitor, TypeVisitor { * Needed for typeVisitor methods */ private String visitorBuffer = ""; - private boolean needsParentheses; + private boolean needsParentheses = false; /** * Generate the pieces of LaTeX-code from the type inferer. @@ -71,28 +71,30 @@ public class LatexCreator implements StepVisitor, TermVisitor, TypeVisitor { this.tree = new StringBuilder(); this.stepLabels = stepLabels; - typeInferer.getFirstInferenceStep().accept(this); +// typeInferer.getFirstInferenceStep().accept(this); } /** * @return the LaTeX-code for the proof tree */ protected String getTree() { - return null; + return "the $\\LaTeX$ inference tree should be here "; } // todo implement /** * @return the LaTeX-code for constraints nad unification */ protected String[] getUnification() { - return null; + return new String[]{"$\\tau_0$", "$\\tau_1$", "$\\tau_2$", "$\\tau_3$", "$\\tau_4$", + "$\\tau_5$", "$\\tau_6$", "$\\tau_7$", "$\\tau_8$", "$\\tau_9$", "$\\tau_{10}$", "$\\tau_{11}$", + "$\\tau_{12}$", "$\\tau_{13}$", "$\\tau_{14}$"}; } // todo implement /** * @return the packages needed for the LaTeX-code from getTree() and getUnification()to work */ protected String getLatexPackages() { - return null; + return "the packages should be here"; } // todo implement private String conclusionToLatex(Conclusion conclusion) { diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java index ca72786..63fa3c2 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java @@ -2,8 +2,9 @@ package edu.kit.typicalc.view.content.typeinferencecontent; import com.vaadin.flow.component.ComponentUtil; import com.vaadin.flow.component.UI; -import com.vaadin.flow.component.orderedlayout.HorizontalLayout; +import com.vaadin.flow.component.html.Div; import com.vaadin.flow.component.orderedlayout.Scroller; +import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.Route; import edu.kit.typicalc.model.TypeInfererInterface; @@ -13,28 +14,37 @@ import edu.kit.typicalc.view.main.MainViewImpl; @Route(value = "visualize", layout = MainViewImpl.class) @PageTitle("TypeInferenceView") -public class TypeInferenceView extends HorizontalLayout +public class TypeInferenceView extends VerticalLayout implements ControlPanelView { - private int currentStep; + private int currentStep = 0; private MathjaxUnification unification; private MathjaxProofTree tree; private TypeInfererInterface typeInferer; + private Div content; + private ControlPanel controlPanel; public TypeInferenceView() { - setId("type-inference-view"); - add(new ControlPanel(this)); typeInferer = ComponentUtil.getData(UI.getCurrent(), TypeInfererInterface.class); + setId("type-inference-view"); + setSizeFull(); + content = new Div(); + controlPanel = new ControlPanel(this); + Scroller scroller = new Scroller(content); + scroller.setSizeFull(); + scroller.setScrollDirection(Scroller.ScrollDirection.BOTH); + setAlignItems(Alignment.CENTER); + add(scroller, controlPanel); + setContent(); } - private void buildView() { + private void setContent() { // todo implement correctly LatexCreator lc = new LatexCreator(typeInferer); unification = new MathjaxUnification(lc.getUnification()); tree = new MathjaxProofTree(lc.getTree()); - add(unification); - add(new Scroller(tree)); + content.add(unification, tree); } @Override @@ -49,7 +59,7 @@ public class TypeInferenceView extends HorizontalLayout @Override public void firstStepButton() { - currentStep = currentStep > tree.getStepCount() ? tree.getStepCount() - 1 : 0; + currentStep = currentStep > tree.getStepCount() && tree.getStepCount() > 0 ? tree.getStepCount() - 1 : 0; refreshElements(currentStep); }