Search in sources :

Example 1 with GraphMetrics

use of org.graphstream.ui.view.util.GraphMetrics in project gs-ui-javafx by graphstream.

the class GraphBackgroundRenderer method fillImageTiled.

private void fillImageTiled(GraphicsContext g, DefaultCamera2D camera) {
    GraphMetrics metrics = camera.getMetrics();
    double px2gu = metrics.ratioPx2Gu;
    Image img = null;
    img = ImageCache.loadImage(style.getFillImage());
    if (img == null) {
        img = ImageCache.dummyImage();
    }
    // + ( padx * 2 )	// consider the padding ???
    double gw = (metrics.graphWidthGU() * px2gu);
    // + ( pady * 2 )	// probably not.
    double gh = (metrics.graphHeightGU() * px2gu);
    double x = (metrics.viewport[2] / 2) - (gw / 2);
    double y = metrics.viewport[3] - (metrics.viewport[3] / 2) - (gh / 2);
    g.setFill(new ImagePattern(img));
    g.fillRect(0, 0, metrics.viewport[2], metrics.viewport[3]);
}
Also used : ImagePattern(javafx.scene.paint.ImagePattern) GraphMetrics(org.graphstream.ui.view.util.GraphMetrics) Image(javafx.scene.image.Image)

Example 2 with GraphMetrics

use of org.graphstream.ui.view.util.GraphMetrics in project gs-ui-javafx by graphstream.

the class GraphBackgroundRenderer method fillCanvasBackground.

private void fillCanvasBackground(GraphicsContext g, DefaultCamera2D camera) {
    GraphMetrics metrics = camera.getMetrics();
    g.setFill(ColorManager.getCanvasColor(style, 0));
    g.fillRect(0, 0, (int) metrics.viewport[2], (int) metrics.viewport[3]);
}
Also used : GraphMetrics(org.graphstream.ui.view.util.GraphMetrics)

Example 3 with GraphMetrics

use of org.graphstream.ui.view.util.GraphMetrics in project gs-ui-javafx by graphstream.

the class FxGraphRenderer method renderLayer.

/**
 * Render a back or from layer.
 */
protected void renderLayer(LayerRenderer<GraphicsContext> renderer) {
    GraphMetrics metrics = camera.getMetrics();
    renderer.render(backend.graphics2D(), graph, metrics.ratioPx2Gu, (int) metrics.viewport[2], (int) metrics.viewport[3], metrics.loVisible.x, metrics.loVisible.y, metrics.hiVisible.x, metrics.hiVisible.y);
}
Also used : GraphMetrics(org.graphstream.ui.view.util.GraphMetrics)

Example 4 with GraphMetrics

use of org.graphstream.ui.view.util.GraphMetrics in project gs-ui-javafx by graphstream.

the class GraphBackgroundRenderer method fillGradient.

protected void fillGradient(GraphicsContext g, DefaultCamera2D camera) {
    GraphMetrics metrics = camera.getMetrics();
    if (style.getFillColors().size() < 2) {
        fillBackground(g, camera);
    } else {
        int w = (int) metrics.viewport[2];
        int h = (int) metrics.viewport[3];
        g.setStroke(GradientFactory.gradientInArea(0, 0, w, h, style));
        g.setFill(GradientFactory.gradientInArea(0, 0, w, h, style));
        g.fillRect(0, 0, w, h);
    }
}
Also used : GraphMetrics(org.graphstream.ui.view.util.GraphMetrics)

Example 5 with GraphMetrics

use of org.graphstream.ui.view.util.GraphMetrics in project gs-ui-javafx by graphstream.

the class GraphBackgroundRenderer method fillBackground.

private void fillBackground(GraphicsContext g, DefaultCamera2D camera) {
    GraphMetrics metrics = camera.getMetrics();
    g.setFill(ColorManager.getFillColor(style, 0));
    g.fillRect(0, 0, (int) metrics.viewport[2], (int) metrics.viewport[3]);
}
Also used : GraphMetrics(org.graphstream.ui.view.util.GraphMetrics)

Aggregations

GraphMetrics (org.graphstream.ui.view.util.GraphMetrics)7 Image (javafx.scene.image.Image)2 GraphicsContext (javafx.scene.canvas.GraphicsContext)1 ImagePattern (javafx.scene.paint.ImagePattern)1