Changeset 690


Ignore:
Timestamp:
01/14/14 10:09:38 (10 years ago)
Author:
ngw8
Message:

Modified message bay progress bar unicode characters to work properly. Added progress bar to web page parser

Location:
trunk/src/org/expeditee
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/MessageBay.java

    r689 r690  
    446446        public static final class Progress {
    447447               
    448                 private static final String t = "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓";
    449                 private static final String f = "░░░░░░░░░░░░░░░░░░░░";
     448                private static final String filled = "\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592";
     449                private static final String unfilled = "\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591";
    450450               
    451451                String message;
     
    456456                        //this.text.setFont(Font.decode(Text.MONOSPACED_FONT + "-16"));
    457457                        this.message = this.text.getText();
    458                         this.text.setText(this.message + " [" + f + "] 0%");
     458                        this.text.setText(this.message + " [" + unfilled + "] 0%");
    459459                        refresh(false, FrameGraphics.createGraphics(), Item.DEFAULT_BACKGROUND);
    460460                }
     
    470470                        int p = progress / 5;
    471471                        if(isMessageItem(this.text)) {
    472                                 this.text.setText(this.message + " [" + t.substring(0, p) + f.substring(p) + "] " + progress + "%");
     472                                this.text.setText(this.message + " [" + filled.substring(0, p) + unfilled.substring(p) + "] " + progress + "%");
    473473                                refresh(false, FrameGraphics.createGraphics(), Item.DEFAULT_BACKGROUND);
    474474                                return true;
  • trunk/src/org/expeditee/io/WebParser.java

    r688 r690  
    2020import org.expeditee.gui.FrameUtils;
    2121import org.expeditee.gui.MessageBay;
     22import org.expeditee.gui.MessageBay.Progress;
    2223import org.expeditee.items.ItemUtils;
    2324import org.expeditee.items.Justification;
     
    131132                                public void run() {
    132133                                        try {
     134                                                Progress progressBar = MessageBay.displayProgress("Converting web page");
     135
    133136                                                HTMLBodyElement doc = (HTMLBodyElement) JavaFX.WebEngineExecuteScript.invoke(webEngine, "document.body");
    134137
    135138                                                Object window = JavaFX.WebEngineExecuteScript.invoke(webEngine, "window");
     139                                               
     140                                                JavaFX.WebEngineExecuteScript.invoke(webEngine, ""
     141                                                                + "var css = 'h1 { background: red; }';" // TODO
     142                                                                + "var head = document.head;"
     143                                                                + "style = document.createElement('style');"
     144                                                                + "style.type = 'text/css';"
     145                                                                + "if (style.styleSheet){"
     146                                                                + "             style.styleSheet.cssText = css;"
     147                                                                + "} "
     148                                                                + "else {"
     149                                                                + "             style.appendChild(document.createTextNode(css));"
     150                                                                + "}"
     151                                                                + "head.appendChild(style);"
     152                                                                );
    136153
    137154                                                frame.setBackgroundColor(rgbStringToColor((String) JavaFX.JSObjectCall.invoke(JavaFX.JSObjectCall.invoke(window, "getComputedStyle", new Object[] { doc }), "getPropertyValue",
     
    168185
    169186                                                for (int i = 0; i < contentElementsLength; i++) {
    170                                                         System.out.println(i + "/" + contentElementsLength);
    171187                                                        // Getting the current HTML element, then making it accessible in JavaScript
    172188                                                        Element currentElement = (Element) JavaFX.JSObjectGetSlot.invoke(contentElements, i);
     
    224240                                                        }
    225241
     242                                                        progressBar.set((100 * (i + 1)) / contentElementsLength);
    226243                                                }
    227244                                               
     
    252269                                                               
    253270                                                                // Bounding rectangle position is relative to the current view, so scroll position must be added to x/y
     271                                                                // TODO: This doesn't check if an element or any of its parent elements have position:fixed set - the only
     272                                                                // way to check seems to be to walking through the element's parents until the document root is reached
    254273                                                                float x = Float.valueOf(JavaFX.JSObjectGetMember.invoke(bounds, "left").toString())
    255274                                                                                + Float.valueOf(JavaFX.WebEngineExecuteScript.invoke(webEngine, "window.pageXOffset").toString());
Note: See TracChangeset for help on using the changeset viewer.