1. shemnon
  2. FlowDown

Commits

shemnon  committed 475db96

move minheight hack to TextFlow

  • Participants
  • Parent commits f9a2bc2
  • Branches master

Comments (0)

Files changed (1)

File src/main/java/com/bitbucket/shemnon/flowdown/MarkdownToNodeGenerator.java

View file
         PegDownProcessor processor = new PegDownProcessor(parserFlags);
 
         FlowDownVisitor ourVisitor = new FlowDownVisitor();
-        VBox result = createVBox();
+        VBox result = new VBox();
         ourVisitor.pushNode(result);
 
         RootNode root = processor.parseMarkdown(markdown.toCharArray());
         @Override
         public void visit(CodeNode node) {
             cssClasses.add(STYLE_CLASS_CODE);
-            TextFlow tf = new TextFlow();
+            TextFlow tf = createTextFlow();
             tf.getStyleClass().setAll(cssClasses);
             currentCollector.getChildren().add(tf);
             pushNode(tf);
 
                 case Linebreak:
                     popNode();
-                    TextFlow tf = new TextFlow();
+                    TextFlow tf = createTextFlow();
                     tf.getStyleClass().setAll(cssClasses);
                     currentCollector.getChildren().add(tf);
                     pushNode(tf);
 
         @Override
         public void visit(ParaNode node) {
-            VBox vbox = createVBox();
+            VBox vbox = new VBox();
             vbox.getStyleClass().setAll(cssClasses);
             vbox.getStyleClass().add(STYLE_CLASS_PARA);
             currentCollector.getChildren().add(vbox);
             pushNode(vbox);
-            TextFlow tf = new TextFlow();
+            TextFlow tf = createTextFlow();
             currentCollector.getChildren().add(tf);
             pushNode(tf);
             visitChildren(node);
 
         @Override
         public void visit(BlockQuoteNode node) {
-            VBox vBox = createVBox();
+            VBox vBox = new VBox();
             vBox.getStyleClass().setAll(cssClasses);
             vBox.getStyleClass().add(STYLE_CLASS_BLOCKQUOTE);
             currentCollector.getChildren().add(vBox);
         public void visit(VerbatimNode node) {
             cssClasses.add(STYLE_CLASS_VERBATIM);
             cssClasses.add(STYLE_CLASS_VERBATIM + "-" + node.getType());
-            TextFlow tf = new TextFlow();
+            TextFlow tf = createTextFlow();
             tf.getStyleClass().setAll(cssClasses);
             pushNode(tf);
             addTextNode(node.getText());
         }
 
         void startListBox(String cssClass) {
-            VBox vbox = createVBox();
+            VBox vbox = new VBox();
             vbox.getStyleClass().setAll(cssClasses);
             vbox.getStyleClass().add(cssClass);
 
             bt.getStyleClass().setAll(cssClasses);
             bt.getStyleClass().add(STYLE_CLASS_BULLET);
 
-            VBox bulletContent = createVBox();
+            VBox bulletContent = new VBox();
             bulletContent.setAlignment(Pos.BASELINE_LEFT);
             bulletContent.getStyleClass().setAll(cssClasses);
             bulletContent.getStyleClass().add(STYLE_CLASS_LIST_CONTENT);
         public void visit(HeaderNode node) {
             cssClasses.add(STYLE_CLASS_HEADER_BASE + node.getLevel());
             cssClasses.add(STYLE_CLASS_HEADER);
-            TextFlow fp = new TextFlow();
+            TextFlow fp = createTextFlow();
             fp.getStyleClass().setAll(cssClasses);
             currentCollector.getChildren().add(fp);
             pushNode(fp);
         }
     }
 
-    VBox createVBox() {
+    TextFlow createTextFlow() {
         if (preferredHeight) {
-            return new PVBox();
+            return new TextFlow() {
+                @Override
+                protected double computeMinHeight(double v) {
+                    return computePrefHeight(v);
+                }
+            };
         } else {
-            return new VBox();
+          return new TextFlow();
         }
-    }
 
-    class PVBox extends VBox {
-        @Override
-        protected double computeMinHeight(double v) {
-            return super.computePrefHeight(v);
-        }
     }
-    
+
 }