Example usage for javafx.scene.canvas GraphicsContext clearRect

List of usage examples for javafx.scene.canvas GraphicsContext clearRect

Introduction

In this page you can find the example usage for javafx.scene.canvas GraphicsContext clearRect.

Prototype

public void clearRect(double x, double y, double w, double h) 

Source Link

Document

Clears a portion of the canvas with a transparent color value.

Usage

From source file:de.hs.mannheim.modUro.controller.diagram.fx.ChartCanvas.java

/**
 * Draws the content of the canvas and updates the 
 * {@code renderingInfo} attribute with the latest rendering 
 * information.//from  ww w.  ja va 2 s.c  om
 */
public final void draw() {
    GraphicsContext ctx = getGraphicsContext2D();
    ctx.save();
    double width = getWidth();
    double height = getHeight();
    if (width > 0 && height > 0) {
        ctx.clearRect(0, 0, width, height);
        this.info = new ChartRenderingInfo();
        this.chart.draw(this.g2, new Rectangle((int) width, (int) height), this.anchor, this.info);
    }
    ctx.restore();
    this.anchor = null;
}