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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.