Search in sources :

Example 1 with HTTPUtils

use of com.cas.sim.tis.util.HTTPUtils in project TeachingInSimulation by ScOrPiOzzy.

the class ClientConfig method buildHttpUtil.

@Bean
public HTTPUtils buildHttpUtil() {
    HTTPUtils util = new HTTPUtils();
    util.setHost(httpdAddress);
    util.setPort(httpdPort);
    try {
        SocketTest.test(httpdAddress, httpdPort);
    } catch (RuntimeException e) {
        throw e;
    }
    return util;
}
Also used : HTTPUtils(com.cas.sim.tis.util.HTTPUtils) Bean(org.springframework.context.annotation.Bean)

Example 2 with HTTPUtils

use of com.cas.sim.tis.util.HTTPUtils in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceViewer method createImageViewer.

/**
 * 创建图片浏览
 */
public void createImageViewer() {
    HTTPUtils utils = SpringUtil.getBean(HTTPUtils.class);
    // Image image = new Image("http://192.168.1.19:8082/Test/1516772514400.png");
    String url = utils.getFullPath(ResourceConsts.FTP_RES_PATH + resource.getPath());
    if (url == null) {
        return;
    }
    Image image = new Image(url);
    ImageView imageView = new ImageView(image);
    HBox box = new HBox(imageView);
    box.setAlignment(Pos.CENTER);
    ScrollPane scrollPane = new ScrollPane(box);
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
    scrollPane.setPannable(true);
    double width = image.getWidth();
    double height = image.getHeight();
    DoubleProperty zoomProperty = new SimpleDoubleProperty(1);
    zoomProperty.addListener(observable -> {
        if (height * zoomProperty.get() > viewer.getHeight()) {
            return;
        }
        imageView.setFitWidth(width * zoomProperty.get());
        imageView.setFitHeight(height * zoomProperty.get());
    });
    scrollPane.addEventFilter(ScrollEvent.ANY, new EventHandler<ScrollEvent>() {

        @Override
        public void handle(ScrollEvent event) {
            double delta = event.getDeltaY() / 100;
            double zoom = zoomProperty.get();
            double zoomDelta = zoom + delta;
            if (zoomDelta < 0.5) {
                zoomProperty.set(0.5);
            } else if (zoomDelta > 2) {
                zoomProperty.set(2);
            } else {
                zoomProperty.set(zoomDelta);
            }
        }
    });
    viewer.getChildren().add(scrollPane);
}
Also used : HBox(javafx.scene.layout.HBox) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ScrollEvent(javafx.scene.input.ScrollEvent) ScrollPane(javafx.scene.control.ScrollPane) ImageView(javafx.scene.image.ImageView) HTTPUtils(com.cas.sim.tis.util.HTTPUtils) Image(javafx.scene.image.Image) DoubleProperty(javafx.beans.property.DoubleProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty)

Example 3 with HTTPUtils

use of com.cas.sim.tis.util.HTTPUtils in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceViewer method createVLCViewer.

/**
 * 创建视频查看器
 */
private void createVLCViewer() {
    HTTPUtils utils = SpringUtil.getBean(HTTPUtils.class);
    String url = utils.getFullPath(ResourceConsts.FTP_RES_PATH + resource.getPath());
    if (url == null) {
        return;
    }
    VLCPlayer player = new VLCPlayer();
    player.loadVideo(url);
    viewer.getChildren().add(player);
// player.loadVideo("http://192.168.1.19:8082/Test/Mux140928003405.avi");
// player.loadVideo("http://192.168.1.19:8082/resources/4dae3b67-1d55-4125-a577-4086585464c1.mp4");
}
Also used : VLCPlayer(com.cas.sim.tis.view.control.imp.vlc.VLCPlayer) HTTPUtils(com.cas.sim.tis.util.HTTPUtils)

Example 4 with HTTPUtils

use of com.cas.sim.tis.util.HTTPUtils in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceViewer method createPDFViewer.

/**
 * 创建PDF查看器
 */
private void createPDFViewer() {
    HTTPUtils utils = SpringUtil.getBean(HTTPUtils.class);
    String url = utils.getFullPath(ResourceConsts.FTP_RES_PATH + resource.getPath());
    if (url == null) {
        return;
    }
    Browser browser = new Browser(BrowserType.LIGHTWEIGHT);
    browser.loadURL(url);
    BrowserView view = new BrowserView(browser);
    viewer.getChildren().add(view);
}
Also used : BrowserView(com.teamdev.jxbrowser.chromium.javafx.BrowserView) HTTPUtils(com.cas.sim.tis.util.HTTPUtils) Browser(com.teamdev.jxbrowser.chromium.Browser)

Example 5 with HTTPUtils

use of com.cas.sim.tis.util.HTTPUtils in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceViewer method createSWFViewer.

/**
 * 创建FLASH查看器
 */
private void createSWFViewer() {
    HTTPUtils utils = SpringUtil.getBean(HTTPUtils.class);
    String url = utils.getFullPath(ResourceConsts.FTP_RES_PATH + resource.getPath());
    if (url == null) {
        return;
    }
    SWFBrowser browser = new SWFBrowser(BrowserType.LIGHTWEIGHT);
    browser.loadHTML(url);
    BrowserView view = new BrowserView(browser);
    viewer.getChildren().add(view);
}
Also used : BrowserView(com.teamdev.jxbrowser.chromium.javafx.BrowserView) HTTPUtils(com.cas.sim.tis.util.HTTPUtils)

Aggregations

HTTPUtils (com.cas.sim.tis.util.HTTPUtils)5 BrowserView (com.teamdev.jxbrowser.chromium.javafx.BrowserView)2 VLCPlayer (com.cas.sim.tis.view.control.imp.vlc.VLCPlayer)1 Browser (com.teamdev.jxbrowser.chromium.Browser)1 DoubleProperty (javafx.beans.property.DoubleProperty)1 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)1 ScrollPane (javafx.scene.control.ScrollPane)1 Image (javafx.scene.image.Image)1 ImageView (javafx.scene.image.ImageView)1 ScrollEvent (javafx.scene.input.ScrollEvent)1 HBox (javafx.scene.layout.HBox)1 Bean (org.springframework.context.annotation.Bean)1