本文整理汇总了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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
示例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();
}
示例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());
}
示例9: paintInit
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
*
* @param g2d
*/
protected void paintInit(GraphicsContext g2d) {
relocate(x, y);
g2d.clearRect(0, 0, width, height);
}
示例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;
}
}
示例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;
}
}
}
}
}
示例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());
}