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]);
}
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]);
}
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);
}
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);
}
}
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]);
}
Aggregations