当前位置: 首页>>代码示例>>Java>>正文


Java GraphicsContext.setFill方法代码示例

本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.setFill方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.setFill方法的具体用法?Java GraphicsContext.setFill怎么用?Java GraphicsContext.setFill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.canvas.GraphicsContext的用法示例。


在下文中一共展示了GraphicsContext.setFill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawYValueBox

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawYValueBox() {
    if (showMouseHoverIndicator.getValue()){
        double y = mouseY.getValue();
        y = y - 10;
        double x = 0;
        double wd = 150;
        double ht = 18;
        if (mouseY == null) {
            return;
        }
        int yIntPos = (int)Math.round(mouseY.getValue());
        Float yValue = this.getValueByYPos(yIntPos);
        if ( yValue != null && yValue != 0){
            String strVolume = String.format("%.2f", yValue);
            GraphicsContext gc = getGraphicsContext2D();
            gc.setFill(Color.web("#010a23"));
            gc.fillRect(x, y, wd, ht);
            gc.setFill(Color.web("#4bf221"));
            gc.fillText(strVolume, x + 13, y+13);
        }
    }
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:24,代码来源:RSMYCanvas.java

示例2: paintStone

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Paint a black/white stone onto a graphics context with a grid
 * @param gc Graphics context
 * @param startX Start (top left) x coordinate of the grid
 * @param startY Start (top left) y coordinate of the grid
 * @param cellSize Size of the grid cells
 * @param row Row position of the stone
 * @param col Column position of the stone
 * @param index Index of the stone (1 = black, 2 = white)
 * @param transparent Transparency value, 0.5 alpha if true
 */
private static void paintStone(GraphicsContext gc, double startX, double
        startY, double cellSize, int row, int col, int index,
                               boolean transparent) {
    double x = startX + col*cellSize;
    double y = startY + row*cellSize;
    double offset = (cellSize * 0.7) / 2;
    gc.save();
    if(transparent) {
        gc.setGlobalAlpha(0.5);
    }
    switch(index) {
        case 1:
            gc.setFill(blackGradient);
            gc.fillOval(x - offset, y - offset, cellSize * 0.7,
                    cellSize * 0.7);
            break;
        case 2:
            gc.setFill(whiteGradient);
            gc.fillOval(x - offset, y - offset, cellSize * 0.7,
                    cellSize * 0.7);
            break;
    }
    gc.restore();
}
 
开发者ID:haslam22,项目名称:gomoku,代码行数:36,代码来源:BoardPane.java

示例3: 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

示例4: setCanvasSize

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * 设置canvas大小
 */
private void setCanvasSize() {
    try {
        FXMLLoader fxmlLoader = new FXMLLoader((getClass().getResource("size_chooser.fxml")));
        Parent root1 = fxmlLoader.load();
        Stage stage = new Stage(DECORATED);
        stage.setTitle("选择画布");
        Scene scene = new Scene(root1);
        sizeChooser = fxmlLoader.getController();
        stage.setScene(scene);
        stage.showAndWait();
        if (sizeChooser.getCanvas() != null) {
            canvas.setHeight(sizeChooser.getCanvas().getHeight());
            canvas.setWidth(sizeChooser.getCanvas().getWidth());
            canvas.setLayoutX(450 - canvas.getWidth() / 2);
            canvas.setLayoutY(300 - canvas.getHeight() / 2);
            Rectangle rectangle = new Rectangle(canvas.getWidth(), canvas.getHeight());
            rectangle.setLayoutX(canvas.getLayoutX());
            rectangle.setLayoutY(canvas.getLayoutY());
            mainPane.setClip(rectangle);
            GraphicsContext gc = canvas.getGraphicsContext2D();
            gc.setFill(Color.WHITE);
            gc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
        } else {
            //不选择就退出程序
            System.exit(0);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:34,代码来源:Controller.java

示例5: initialize

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
	LOG.info("Loading map data.");
	
	worldMapCanvas.setOnDragDetected(new EventHandler<MouseEvent>() {

		@Override
		public void handle(MouseEvent event) {
			LOG.info("Drag detected.");
		}
	});
	
	worldMapCanvas.setOnMouseClicked(event -> {
		LOG.info("Click detected.");
	});
	
	// Testing
	final GraphicsContext gc = worldMapCanvas.getGraphicsContext2D();
	
	gc.setFill(Color.AZURE);
	gc.fillRect(0, 0, worldMapCanvas.getWidth(), worldMapCanvas.getHeight());
	
	gc.setFill(Color.GREEN);
	gc.strokeLine(40, 10, 10, 40);
	
}
 
开发者ID:tfelix,项目名称:bestia-palantir,代码行数:27,代码来源:MapController.java

示例6: draw

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void draw(DungeonTileRenderer renderer, GraphicsContext g)
{
	g.setFill(this.stairPaint);
	g.fillRect(0, 0, 1, 1);

	g.setFill(this.stairPaint);
	g.setEffect(new ColorAdjust(0, 0, -0.3, 0));
	g.fillRect(0, SIZE_STEP, 1, SIZE_STEP);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:11,代码来源:TileItemStairs.java

示例7: drawStone

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawStone(DrawCoords position, StoneColour colour, double radius) {
	GraphicsContext context = getGraphicsContext();

	if ( colour == BLACK )
		context.setFill(javafx.scene.paint.Paint.valueOf("#000000"));
	else
		context.setFill(Paint.valueOf("#FFFFFF"));

	drawCircle(position, radius);
}
 
开发者ID:GoSuji,项目名称:Suji,代码行数:11,代码来源:SimpleStoneDrawer.java

示例8: drawLetters

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draw letters along the Y axis for a previously drawn grid. Each letter
 * aligns with the corresponding intersection on the grid.
 * @param gc Graphics context
 * @param startX Start point on x axis
 * @param startY Start point on y axis
 * @param rows Number of rows
 * @param columns Number of columns
 * @param cellSize Size of each cell in the grid
 * @param distance Draw distance away from the bottom of the grid
 */
private void drawLetters(GraphicsContext gc, double startX, double
        startY, int rows, int columns, double cellSize, double distance) {
    gc.save();
    gc.setFont(BOARD_FONT);
    gc.setFill(Color.rgb(0,0,0, 0.75));
    for(int i = 0; i < size; i++) {
        double offset = i*cellSize;
        gc.setTextAlign(TextAlignment.CENTER);
        gc.setTextBaseline(VPos.CENTER);
        gc.fillText(Character.toString((char)('A' + i)), startX + offset,
                startY + cellSize*(rows) + distance);
    }
    gc.restore();
}
 
开发者ID:haslam22,项目名称:gomoku,代码行数:26,代码来源:BoardPane.java

示例9: drawTextWithBackground

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public static final void drawTextWithBackground(final GraphicsContext CTX, final String TEXT, final Font FONT, final Color TEXT_BACKGROUND, final Color TEXT_FILL, final double X, final double Y) {
    CtxDimension dim = getTextDimension(TEXT, FONT);
    double textWidth  = dim.getWidth() * 1.2;
    double textHeight = dim.getHeight();
    CTX.save();
    CTX.setFont(FONT);
    CTX.setTextBaseline(VPos.CENTER);
    CTX.setTextAlign(TextAlignment.CENTER);
    CTX.setFill(TEXT_BACKGROUND);
    CTX.fillRect(X - textWidth * 0.5, Y - textHeight * 0.5, textWidth, textHeight);
    CTX.setFill(TEXT_FILL);
    CTX.fillText(TEXT, X, Y);
    CTX.restore();
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:15,代码来源:Helper.java

示例10: drawTextTick

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawTextTick(double x, double y, double value) {
    GraphicsContext gc = getGraphicsContext2D();
    double bigTickLength = 10; //Big Tick
    //Draw ticks and draw texts
    gc.setLineWidth(0.1);
    gc.setStroke(ChartTickColorProperty.getValue());
    gc.strokeLine(x, y, x + bigTickLength, y);
    String strValue = "";
    
    if (value >= 0 && value <= 0.01) {
        strValue = String.format("%.4f", value);
    }
    else if (value > 0.01 && value <= 0.1) {
        strValue = String.format("%.3f", value);
    }
    else if (value > 0.1 && value <= 1.0) {
        strValue = String.format("%.3f", value);
    }
    else if (value > 1.0 && value <= 10.0) {
        strValue = String.format("%.2f", value);
    }
    else {
        strValue = String.format("%.2f", value);
    }
    
    gc.setFill(ChartTickColorProperty.getValue());
    gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:30,代码来源:RSMYCanvas.java

示例11: update

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void update(GraphicsContext gc) {
    gc.setFill(Color.LIGHTBLUE);
    gc.fillOval(x - radius, y - radius, radius * 2, radius * 2);

    if (time > 0) {
        time--;
    }
    if (time <= 0) {
        expired = true;
    }
}
 
开发者ID:TheBromo,项目名称:netTanks,代码行数:12,代码来源:PickUp.java

示例12: drawTextTick

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draw text tick
 * @param x POS
 * @param y POS
 * @param value - the text to be drawn
 */
@Override
public void drawTextTick(double x, double y, double value) {
    GraphicsContext gc = getGraphicsContext2D();
    double bigTickLength = 10; //Big Tick
    //Draw ticks and draw texts
    gc.setLineWidth(0.1);
    gc.setStroke(ChartTickColorProperty.getValue());
    gc.strokeLine(x, y, x + bigTickLength, y);
    String strValue = "";
    
    if (value >= 0 && value <= 0.01) {
        strValue = String.format("%.4f", value);
    }
    else if (value > 0.01 && value <= 0.1) {
        strValue = String.format("%.3f", value);
    }
    else if (value > 0.1 && value <= 1.0) {
        strValue = String.format("%.3f", value);
    }
    else if (value > 1.0 && value <= 10.0) {
        strValue = String.format("%.2f", value);
    }
    else {
        strValue = String.format("%.2f", value);
    }
    
    gc.setFill(ChartTickColorProperty.getValue());
    gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:36,代码来源:PriceYCanvas.java

示例13: 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

示例14: showPlayerInfo

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void showPlayerInfo(GraphicsContext gc) {
    for (Tank tank : framework.getTanks()) {
        int width = tank.getId().name().length() * 7 + 10;
        gc.setFill(Color.LIGHTGRAY);
        gc.fillRoundRect(tank.getX() - width / 2, tank.getY() - 65, width, 25, 4, 4);

        gc.setFill(Color.WHITESMOKE);
        gc.fillText(tank.getId().name(), tank.getX() - width / 2 + 5, tank.getY() - 50);
    }
}
 
开发者ID:TheBromo,项目名称:netTanks,代码行数:11,代码来源:HUD.java

示例15: 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


注:本文中的javafx.scene.canvas.GraphicsContext.setFill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。