Changeset 839


Ignore:
Timestamp:
02/05/14 14:16:00 (10 years ago)
Author:
ngw8
Message:

Changes to web parser so that the converted pages are displayed in a grid on the index page, plus the converted pages are set to be 90% of the frame size, rather than just using the displayed size of the webview.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/io/WebParser.java

    r832 r839  
    3939import org.expeditee.gui.DisplayIO;
    4040import org.expeditee.gui.Frame;
     41import org.expeditee.gui.FrameGraphics;
    4142import org.expeditee.gui.FrameIO;
    4243import org.expeditee.gui.FrameMouseActions;
     
    282283         *            The Expeditee frame to output the converted page to
    283284         */
    284         public static void parsePageSimple(JfxBrowser browserWidget, final WebEngine webEngine, final WebView webView, final Frame frame) {
     285        public static void parsePageSimple(final JfxBrowser browserWidget, final WebEngine webEngine, final WebView webView, final Frame frame) {
    285286                try {
    286                         browserWidget.setOverlayVisible(true);
     287                        Platform.runLater(new Runnable() {
     288
     289                                @Override
     290                                public void run() {
     291                                        browserWidget.setOverlayVisible(true);
     292                                        browserWidget.setWebViewSize(FrameGraphics.getMaxFrameSize().getWidth() * 0.9, FrameGraphics.getMaxFrameSize().getHeight() * 0.9);
     293                                }
     294                        });
    287295
    288296                        final Object notifier = new Object();
     
    291299                        final MutableBool rightReached = new MutableBool(false);
    292300                       
    293                         final MutableInt pageCount = new MutableInt(0);
     301                        final MutableInt verticalCount = new MutableInt(0);
     302                        final MutableInt horizontalCount = new MutableInt(0);
    294303
    295304                        final String pageTitle = webEngine.getTitle();
     
    323332                                                this.stop();
    324333                                               
    325                                                 pageCount.setValue(pageCount.getValue() + 1);
    326 
    327                                                 frameToAddTo = FrameIO.CreateFrame(frameToAddTo.getFramesetName(), pageTitle + " " + pageCount.getValue(), null);
     334                                                verticalCount.setValue(verticalCount.getValue() + 1);
     335
     336                                                frameToAddTo = FrameIO.CreateFrame(frameToAddTo.getFramesetName(), pageTitle, null);
    328337
    329338                                                try {
     
    369378                                                       
    370379                                                        // Adding thumbnail to the overview page
    371                                                         Text thumb = frameset.addText(100, (int) (((((float) thumbWidth / image.getWidth()) * image.getHeight()) + 10) * pageCount.getValue()), "@i: " + out.getName() + " " + thumbWidth, null);
     380                                                        Text thumb = frameset.addText((int) (thumbWidth * 1.1 * horizontalCount.getValue()) + 10,
     381                                                                        (int) ((((float) thumbWidth / image.getWidth()) * image.getHeight()) * 1.1 * verticalCount.getValue()),
     382                                                                        "@i: " + out.getName() + " " + thumbWidth,
     383                                                                        null);
     384                                                       
    372385                                                        thumb.setLink(frameToAddTo.getName());
    373386                                                        thumb.setBorderColor(Color.lightGray);
     
    392405
    393406                                                        // Button to go to the previous frame/page
    394                                                         if (pageCount.getValue() > 1) {
     407                                                        if (verticalCount.getValue() > 1) {
    395408                                                                Text previousButton = nextButton.copy();
    396409                                                                previousButton.setText("Previous");
     
    642655       
    643656                                }
     657
     658                                horizontalCount.setValue(horizontalCount.getValue() + 1);
     659                                verticalCount.setValue(0);
    644660                        }
    645661
     
    659675                }
    660676
    661                 browserWidget.setOverlayVisible(false);
    662 
     677                Platform.runLater(new Runnable() {
     678
     679                        @Override
     680                        public void run() {             
     681                                browserWidget.setOverlayVisible(false);
     682                                browserWidget.rebindWebViewSize();
     683                        }
     684                });
    663685        }
    664686
  • trunk/src/org/expeditee/items/widgets/JfxBrowser.java

    r837 r839  
    3333import javafx.scene.control.ProgressIndicator;
    3434import javafx.scene.control.TextField;
    35 import javafx.scene.effect.BlendMode;
    3635import javafx.scene.input.KeyEvent;
    3736import javafx.scene.input.MouseButton;
    3837import javafx.scene.input.MouseEvent;
    3938import javafx.scene.layout.HBox;
     39import javafx.scene.layout.Pane;
    4040import javafx.scene.layout.Priority;
    4141import javafx.scene.layout.StackPane;
     
    4646
    4747import org.expeditee.gui.DisplayIO;
     48import org.expeditee.gui.FrameGraphics;
    4849import org.expeditee.gui.FrameMouseActions;
    4950import org.expeditee.gui.FreeItems;
     
    6364 * @author ngw8
    6465 * @author jts21
     66 */
     67/**
     68 * @author ngw8
     69 *
    6570 */
    6671public class JfxBrowser extends DataFrameWidget {
     
    212217                        this._webView.setMaxWidth(Double.MAX_VALUE);
    213218                        this._webView.setMaxHeight(Double.MAX_VALUE);
    214                         HBox.setHgrow(this._webView, Priority.ALWAYS);
    215                         VBox.setVgrow(this._webView, Priority.ALWAYS);
    216219                        this._webEngine = this._webView.getEngine();
    217220                       
    218221                        this._urlProgressBar.progressProperty().bind(_webEngine.getLoadWorker().progressProperty());
    219222
    220                         vertical.getChildren().addAll(horizontal, this._webView);
     223
     224                        // Pane to hold just the webview. This seems to be the only way to allow the webview to be resized to greater than its parent's
     225                        // size. This also means that the webview's prefSize must be manually set when the Pane resizes, using the event handlers below
     226                        Pane browserPane = new Pane();
     227                        browserPane.getChildren().add(_webView);
     228                       
     229                        HBox.setHgrow(browserPane, Priority.ALWAYS);
     230                        VBox.setVgrow(browserPane, Priority.ALWAYS);
     231
     232                        browserPane.widthProperty().addListener(new ChangeListener<Object>() {
     233
     234                                @Override
     235                                public void changed(ObservableValue<?> observable, Object oldValue, Object newValue) {
     236                                        JfxBrowser.this._webView.setPrefWidth((Double) newValue);
     237                                }
     238                        });
     239
     240                        browserPane.heightProperty().addListener(new ChangeListener<Object>() {
     241
     242                                @Override
     243                                public void changed(ObservableValue<?> observable, Object oldValue, Object newValue) {
     244                                        JfxBrowser.this._webView.setPrefHeight((Double) newValue);
     245                                }
     246                        });
     247
     248                        vertical.getChildren().addAll(horizontal, browserPane);
    221249
    222250                        this._overlay = new StackPane();
     
    291319                                @Override
    292320                public void handle(ActionEvent e) {
    293                     getFrameNew();
     321                                        getFrameNew();
    294322                }
    295323                        });
     
    334362                public void handle(MouseEvent arg0) {
    335363                                        JfxBrowser.this._urlField.requestFocus();
    336                 }
     364                                }
    337365                        });
    338366                       
     
    774802        }
    775803       
     804        /**
     805         * Shows/hides a message reading 'Importing page' over the widget
     806         *
     807         * @param visible
     808         */
    776809        public void setOverlayVisible(final boolean visible) {
    777                 Platform.runLater(new Runnable() {
    778 
    779                         @Override
    780                         public void run() {
    781                                 JfxBrowser.this._overlay.setVisible(visible);
    782                         }
    783                 });
    784 
     810                this._overlay.setVisible(visible);
     811        }
     812
     813        /**
     814         * Sets the size of the webview element of the widget
     815         *
     816         * @param width
     817         * @param height
     818         */
     819        public void setWebViewSize(double width, double height) {
     820                this._webView.setPrefSize(width, height);
     821        }
     822
     823        /**
     824         * Resizes the webview back to the size of its parent element
     825         */
     826        public void rebindWebViewSize() {
     827                this._webView.getParent().resize(0, 0);
    785828        }
    786829
Note: See TracChangeset for help on using the changeset viewer.