use of org.graphstream.ui.view.util.GraphMetrics in project gs-ui-javafx by graphstream.
the class GraphBackgroundRenderer method strokeGraph.
private void strokeGraph(Backend bck, DefaultCamera2D camera) {
GraphMetrics metrics = camera.getMetrics();
GraphicsContext g = bck.graphics2D();
if (style.getStrokeMode() != StyleConstants.StrokeMode.NONE && style.getStrokeWidth().value > 0) {
g.setStroke(ColorManager.getStrokeColor(style, 0));
g.setFill(ColorManager.getStrokeColor(style, 0));
g.setLineWidth(metrics.lengthToGu(style.getStrokeWidth()));
int padx = (int) metrics.lengthToPx(style.getPadding(), 0);
int pady = padx;
if (style.getPadding().size() > 1)
pady = (int) metrics.lengthToPx(style.getPadding(), 1);
g.fillRect(padx, pady, (int) metrics.viewport[2] - padx * 2, (int) metrics.viewport[3] - pady * 2);
}
}
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);
}
}
Aggregations