當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphicsContext.clearRect方法代碼示例

本文整理匯總了Java中javafx.scene.canvas.GraphicsContext.clearRect方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphicsContext.clearRect方法的具體用法?Java GraphicsContext.clearRect怎麽用?Java GraphicsContext.clearRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.canvas.GraphicsContext的用法示例。


在下文中一共展示了GraphicsContext.clearRect方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: draw

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
/**
 * Draws the content of the canvas and updates the 
 * {@code renderingInfo} attribute with the latest rendering 
 * information.
 */
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();
        if (this.chart != null) {
            this.chart.draw(this.g2, new Rectangle((int) width, 
                    (int) height), this.anchor, this.info);
        }
    }
    ctx.restore();
    for (OverlayFX overlay : this.overlays) {
        overlay.paintOverlay(g2, this);
    }
    this.anchor = null;
}
 
開發者ID:jfree,項目名稱:jfreechart-fx,代碼行數:25,代碼來源:ChartCanvas.java

示例2: initDraw

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
private void initDraw(GraphicsContext gc) {
    double canvasWidth = gc.getCanvas().getWidth();
    double canvasHeight = gc.getCanvas().getHeight();

    log.info("canvasWidth = {}, canvasHeight = {}", canvasWidth, canvasHeight);

    gc.clearRect(0, 0, canvasWidth, canvasHeight);

    gc.setStroke(borderRectangleColor);
    gc.setLineWidth(5);
    gc.strokeRect(0, // x of the upper left corner
            0, // y of the upper left corner
            canvasWidth, // width of the rectangle
            canvasHeight); // height of the rectangle

    gc.setFill(Color.RED);
    gc.setStroke(Color.BLUE);
    gc.setLineWidth(drawLineWidth);
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:20,代碼來源:DrawBuilder.java

示例3: drawConnectedBlock

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
protected static void drawConnectedBlock(DungeonTileRenderer renderer, GraphicsContext g, Paint p, double border)
{
	if (p == null) p = getRegionalPaint(renderer.region);

	g.setFill(p);
	g.fillRect(0, 0, 1, 1);

	byte direction = renderer.direction;

	if (border > 0 && direction != 15)
	{
		boolean east = (direction & 1) != 0;
		boolean north = (direction & 2) != 0;
		boolean west = (direction & 4) != 0;
		boolean south = (direction & 8) != 0;

		if (!east) g.clearRect(1 - border, 0, border, 1);
		if (!north) g.clearRect(0, 0, 1, border);
		if (!west) g.clearRect(0, 0, border, 1);
		if (!south) g.clearRect(0, 1 - border, 1, border);
	}
}
 
開發者ID:andykuo1,項目名稱:candlelight,代碼行數:23,代碼來源:DungeonTile.java

示例4: draw

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
private void draw() {
    int n = 0;
    try {
        n = Integer.parseInt(nField.getText());
    } catch (NumberFormatException nfe) {
        // show an alert here
    }
    
    GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
    gc.clearRect(0, 0, drawingCanvas.getWidth(), drawingCanvas.getHeight());
    if (gridToggle.isSelected())
        drawGrid();
    if (filledPolygonToggle.isSelected())
        drawRegularNGons(n, true);
    else drawRegularNGons(n, false);        
}
 
開發者ID:kmhasan-class,項目名稱:spring2017java,代碼行數:17,代碼來源:FXMLDocumentController.java

示例5: draw

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
public void draw() {
    final double width = getWidth();
    final double height = getHeight();

    GraphicsContext gc = getGraphicsContext2D();
    gc.clearRect(0, 0, width, height);

    if (entries != null && !entries.isEmpty()) {
        for (Entry<?> entry : entries) {
            com.calendarfx.model.Calendar calendar = entry.getCalendar();
            if (calendar == null) {
                continue;
            }

            Color color = getCalendarColor(calendar.getStyle());
            gc.setFill(color);

            if (entry.isFullDay()) {
                gc.fillRect(0, 0, width, height);
            } else {
                LocalTime startTime = entry.getStartTime();
                LocalTime endTime = entry.getEndTime();

                if (entry.getStartDate().isBefore(getDate())) {
                    startTime = LocalTime.MIN;
                }

                if (entry.getEndDate().isAfter(getDate())) {
                    endTime = LocalTime.MAX;
                }

                double y = height * (startTime.toSecondOfDay() / (double) LocalTime.MAX.toSecondOfDay());
                double h = height * (endTime.toSecondOfDay() / (double) LocalTime.MAX.toSecondOfDay());
                gc.fillRect(0, y, width, h - y);
            }
        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:39,代碼來源:MonthSheetView.java

示例6: clearConner

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
/**
 * 設置圖形節點為未選中樣式
 */
public void clearConner() {
    canvas.setMouseTransparent(true);
    if (node != null) {
        node.setMouseTransparent(false);
    }
    isConnerShow = false;
    double height = getPrefHeight();
    double width = getPrefWidth();
    GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.clearRect(0, 0, width, height);
}
 
開發者ID:xfangfang,項目名稱:PhotoScript,代碼行數:15,代碼來源:DragBox.java

示例7: showPaint

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
public void showPaint(Paint paint) {
  GraphicsContext graphics = canvas.getGraphicsContext2D();
  graphics.clearRect(0, 0, width, height);

  // graphics.setStroke(Color.BLACK);
  // graphics.setLineWidth(line);
  // graphics.strokeRect(line / 2, line / 2, width + line, height + line);

  graphics.setFill(paint);
  graphics.fillRect(0, 0, width, height);

  contentPane.getChildren().setAll(canvas);
  showPopup();
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:15,代碼來源:PreviewCodeAreaBind.java

示例8: eraseAll

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
/**
 * It does a canvas clean up
 */
public void eraseAll() {
    GraphicsContext gc = getGraphicsContext2D();
    gc.clearRect(0,0, widthProperty().doubleValue(), heightProperty().doubleValue());
    gc.setFill(Color.WHITESMOKE);
    gc.fillRect(0,0, widthProperty().doubleValue(), heightProperty().doubleValue());
}
 
開發者ID:ztan5,項目名稱:TechnicalAnalysisTool,代碼行數:10,代碼來源:BaseTimeCanvas.java

示例9: paintInit

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
/**
 *
 * @param g2d
 */
protected void paintInit(GraphicsContext g2d) {
    relocate(x, y);
    g2d.clearRect(0, 0, width, height);
}
 
開發者ID:CIRDLES,項目名稱:Squid,代碼行數:9,代碼來源:AbstractDataView.java

示例10: drawStrokes

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
/**
 * Draws out the all of the phonemes in stroke form on the canvas of the Application.
 *
 * @param s The string that is to be split up and put into phonemes, and then drawn out.
 */
private void drawStrokes(String s, GraphicsContext gc){

    Canvas canvas = gc.getCanvas();

    // Clears all of the previous drawings
    gc.clearRect(0,0, canvas.getWidth(), canvas.getHeight());


    Character[][] phones = TextProc.phones(s);
    int x = 90;
    int y = 100;
    int line = 1;
    Stroke current;

    //Iterates through the sentence
    for (Character[] word : phones) {

        // Checks to see if it is necessary to wrap at the word. The on the end is for padding
        if((canvas.getWidth() - 90)  - x < GraphicsCalculations.wordLength(word)){
            line++;
            x = 80;
            y = line * 80;
        }

        y -= GraphicsCalculations.wordHeight(word);
        // Iterates through the word
        for (Character c : word) {

            // Don't bother with the vowels yet, only draw outlines.
            if (TextProc.isVowel(c)){
                continue;
            }

            current = TextProc.strokeMap.get(c);

            // The starting and ending points of the current stroke
            Point start = current.getStart();
            Point end = current.getEnd();

            // Draw the image
            gc.drawImage(current.getImage(), x - start.x, y - start.y);

            // Moves the pointer to the end of the stroke
            x += end.x - start.x;
            y += end.y - start.y;

        }

        // Puts 80 pixels in between words to fo indicate a space until joining is funtioning
        x += 80;
        y = line * 100;
    }

}
 
開發者ID:squablyScientist,項目名稱:Pitman-Translator,代碼行數:60,代碼來源:Scratchpad.java

示例11: layoutChildren

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
@Override
protected void layoutChildren() {
    GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.clearRect(0, 0, getWidth(), getHeight());

    // Fit the grid into the available space, which may be limited by
    // either the height or the width of the pane
    double smallestAxis = Math.min(getHeight(), getWidth());
    this.cellSize = smallestAxis / (size - 1);

    // Add some padding around the grid, so we can display numbers/letters
    cellSize = (smallestAxis - (cellSize * 2)) / (size - 1);

    // Center the grid by accounting for any extra space around it
    double remainingSpaceX = getWidth() - (cellSize * (size - 1));
    double remainingSpaceY = getHeight() - (cellSize * (size - 1));

    // Spread the remaining space around the board
    this.paddingX = remainingSpaceX / 2;
    this.paddingY = remainingSpaceY / 2;

    // Draw the grid
    drawGrid(gc, paddingX, paddingY, size - 1, size - 1,
            cellSize);

    // Draw the numbers/letters
    drawNumbers(gc, paddingX, paddingY, size - 1, size - 1,
            cellSize, 0.7 * cellSize);
    drawLetters(gc, paddingX, paddingY, size - 1, size - 1,
            cellSize, 0.7 * cellSize);

    // Paint the stones
    for(int i = 0; i < board.length; i++) {
        for(int j = 0; j < board[0].length; j++) {
            if(board[i][j] != null) {
                paintStone(gc, paddingX, paddingY, cellSize, i, j,
                        board[i][j].index, board[i][j].transparent);
                if(board[i][j].transparent) {
                    board[i][j] = null;
                }
            }
        }
    }
}
 
開發者ID:haslam22,項目名稱:gomoku,代碼行數:45,代碼來源:BoardPane.java

示例12: eraseAll

import javafx.scene.canvas.GraphicsContext; //導入方法依賴的package包/類
/**
 * It does a canvas clean up
 */
public void eraseAll() {
    GraphicsContext gc = getGraphicsContext2D();
    gc.clearRect(0,0, widthProperty().doubleValue(), heightProperty().doubleValue());
}
 
開發者ID:ztan5,項目名稱:TechnicalAnalysisTool,代碼行數:8,代碼來源:BaseCanvas.java


注:本文中的javafx.scene.canvas.GraphicsContext.clearRect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。