Commits

shemnon committed fbdf7f9

tweaks for new Stylesheet Locations

Comments (0)

Files changed (5)

flowdown-app/build.gradle

-apply from: 'https://repository-javafx-gradle-plugin.forge.cloudbees.com/snapshot/javafx.plugin'
+apply from: 'http://dl.bintray.com/content/shemnon/javafx-gradle/0.3.0/javafx.plugin'
 apply plugin: 'idea'
 
 version = 'prerelase'
 repositories {
     mavenLocal()
     mavenCentral()
+    ivy {
+        url 'http://jcenter.bintray.com'
+    }
 }
 
 dependencies {
     compile project(':markdown-node')
+    compile 'org.bitbucket.shemnon.deckcontrol:deckcontrol:0.1.0-SNAPSHOT'
+
 }
 
 cssToBin {
     appName = "FlowDown"
     appID = "com.bitbucket.shemnon.FlowDown"
 
-}
+}

flowdown-app/src/main/java/FlowDown/FlowDownView.java

 
         sourceTextArea.textProperty().addListener((observableValue, oldString, newString) -> updateMarkdown(newString));
 
-        styleCombo.getItems().setAll(MarkdownToNodeGenerator.STYLESHEET_FLOWDOWN, MarkdownToNodeGenerator.STYLESHEET_GITHUB, "Test.css");
-        styleCombo.setValue(MarkdownToNodeGenerator.STYLESHEET_DEFAULT);
+        styleCombo.getItems().setAll(MarkdownNode.STYLESHEET_FLOWDOWN, MarkdownNode.STYLESHEET_GITHUB, "Test.css");
+        styleCombo.setValue(MarkdownNode.STYLESHEET_DEFAULT);
 
         mdNode = new MarkdownNode();
         mdNode.setValue(sourceTextArea.getText());
 
 
     public void setMarkDownStylesheets(String... stylesheets) {
-       contentScrollPane.getStylesheets().clear();
-       contentScrollPane.getStylesheets().setAll(stylesheets);
+       mdNode.getStylesheets().clear();
+       mdNode.getStylesheets().setAll(stylesheets);
     }
 }
 

flowdown-app/src/main/java/SlideDown/MarkdownToSlideGenerator.java

+package SlideDown;
+
+import com.github.shemnon.deckcontrol.Deck;
+import javafx.application.Platform;
+import javafx.collections.FXCollections;
+import javafx.event.EventHandler;
+import javafx.geometry.Pos;
+import javafx.scene.Node;
+import javafx.scene.control.Button;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.VBox;
+import org.bitbucket.shemnon.mdnode.MarkdownNode;
+import org.bitbucket.shemnon.mdnode.MarkdownToNodeGenerator;
+import org.bitbucket.shemnon.mdnode.MarkdownVisitor;
+import org.pegdown.PegDownProcessor;
+import org.pegdown.ast.RootNode;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: shemnon
+ * Date: 6 Jun 2013
+ * Time: 7:50 PM
+ */
+public class MarkdownToSlideGenerator extends MarkdownToNodeGenerator {
+
+    private final HBox buttons;
+    Deck deck;
+    VBox box;
+
+    public MarkdownToSlideGenerator() {
+        super();
+        deck = new Deck();
+        deck.getStylesheets().setAll(MarkdownNode.class.getResource(MarkdownNode.STYLESHEET_DEFAULT).toExternalForm());
+        deck.setStyle("-fx-skin: 'com.github.shemnon.deckcontrol.skin.ShelfDeckSkin'");
+        deck.setAlignment(Pos.CENTER);
+        deck.setPrefHeight(400);
+
+        Button prevButton = new Button("Prev");
+        prevButton.setOnAction(evt -> {deck.previousNode();});
+        Button nextButton = new Button("Next");
+        nextButton.setOnAction(evt -> {deck.nextNode();});
+
+        buttons = new HBox(
+                prevButton, nextButton
+        );
+
+        box = new VBox(deck, buttons);
+    }
+
+    public javafx.scene.Node createMarkdownNode(String markdown) {
+        if (markdown == null) {
+            return null;
+        }
+
+        PegDownProcessor processor = new PegDownProcessor(parserFlags);
+
+        final SlideDownVisitor ourVisitor = new SlideDownVisitor();
+
+        ourVisitor.slidePages.clear();
+        ourVisitor.nextSlide();
+
+        RootNode root = processor.parseMarkdown(markdown.toCharArray());
+
+        root.accept(ourVisitor);
+
+        Platform.runLater(()-> {
+            try {
+                int pos = deck.getPrimaryNodeIndex();
+                if (pos < 0) pos = 0;
+
+
+                deck.setNodes(FXCollections.<Node>observableList(ourVisitor.slidePages));
+                deck.setPrimaryNodeIndex(pos);
+                deck.layout(); // this is needed to get the list box bullets to align properly
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        });
+
+        return box;
+
+    }
+
+}

flowdown-app/src/main/java/SlideDown/SlideDownNode.java

+package SlideDown;
+
+import org.bitbucket.shemnon.OffThreadTransformingPane;
+import org.bitbucket.shemnon.mdnode.MarkdownNode;
+import org.bitbucket.shemnon.mdnode.MarkdownToNodeGenerator;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: shemnon
+ * Date: 2 Feb 2013
+ * Time: 1:57 PM
+ */
+
+public class SlideDownNode extends MarkdownNode {
+
+    public SlideDownNode() {
+        this(new MarkdownToSlideGenerator());
+    }
+
+    public SlideDownNode(MarkdownToNodeGenerator generator) {
+        this.generator = generator;
+        setTransformation(this.generator::createMarkdownNode);
+        generator.setMarkdownVisitor(new SlideDownVisitor());
+
+    }
+}

flowdown-app/src/main/java/SlideDown/SlideDownVisitor.java

+package SlideDown;
+
+import javafx.scene.Node;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.VBox;
+import org.bitbucket.shemnon.mdnode.MarkdownVisitor;
+import org.pegdown.ast.SimpleNode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: shemnon
+ * Date: 6 Jun 2013
+ * Time: 7:53 PM
+ */
+public class SlideDownVisitor extends MarkdownVisitor {
+
+    double prefWidth = 600;
+    double prefHeight = 400;
+
+    List<Node> slidePages = new ArrayList<>();
+
+    public void nextSlide() {
+        popNode();
+        VBox slide = new VBox();
+        slide.setPrefWidth(prefWidth);
+        slide.setPrefHeight(prefHeight);
+        slidePages.add(slide);
+        slide.getStyleClass().setAll(MarkdownToSlideGenerator.STYLE_CLASS_BODY);
+        pushNode(slide);
+    }
+
+    @Override
+    public void popNode() {
+        if (nodeStack.size() == 1) {
+            nodeStack.peek().layout();
+        }
+        super.popNode();    //To change body of overridden methods use File | Settings | File Templates.
+    }
+
+    @Override
+    public void visit(SimpleNode node) {
+        if (node.getType() == SimpleNode.Type.HRule) {
+            nextSlide();
+        } else {
+            super.visit(node);
+        }
+    }
+}
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.