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


Java GraphicsContext.fillRect方法代码示例

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


在下文中一共展示了GraphicsContext.fillRect方法的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,代码来源:RSDYCanvas.java

示例2: drawTimeBox

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draw little time box to indicate exactly the date time when
 * showMouseHoverIndicator is on
 */
public void drawTimeBox() {
    if (showMouseHoverIndicator.getValue()){
        double x = mouseX.getValue();
        double w = 45;
        x = x - w;
        double wd = 2 * w;
        double hi = 20;
        Calendar curDate = getDayByXPos(mouseX.getValue());
        if (curDate != null) {
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
            String strDateLabel = sf.format(curDate.getTime());
            GraphicsContext gc = getGraphicsContext2D();
            gc.setFill(Color.web("#010a23"));
            gc.fillRect(x, 0, wd, hi);
            gc.setFill(Color.web("#4bf221"));
            gc.fillText(strDateLabel, x+14, 14);
        }
    }
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:24,代码来源:BaseTimeCanvas.java

示例3: 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("%.4f", 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,代码来源:VolumeYCanvas.java

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

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

示例6: render

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void render(GraphicsContext g)
{
	g.setFill(COLOR_BACKGROUND);
	g.fillRect(this.x, this.y, this.width, this.height);

	g.setLineWidth(this.enabled ? OUTLINE_LINE_WIDTH : INACTIVE_LINE_WIDTH);
	g.setStroke(this.outline);
	g.strokeRoundRect(this.x, this.y, this.width, this.height,
			OUTLINE_ROUND_RADIUS, OUTLINE_ROUND_RADIUS);

	this.onRender(g);

	if (!this.enabled)
	{
		g.setFill(COLOR_DISABLED_OVERLAY);
		g.fillRoundRect(this.x, this.y, this.width, this.height,
				OUTLINE_ROUND_RADIUS, OUTLINE_ROUND_RADIUS);
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:20,代码来源:DungeonSlot.java

示例7: drawShapes

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawShapes() {
    GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
    gc.setStroke(Color.RED);
    gc.setFill(Color.YELLOW);
    gc.setLineWidth(5);
    double w = 100;
    double h = 100;
    double width = drawingCanvas.getWidth();
    double height = drawingCanvas.getHeight();

    gc.fillRect(width / 2 - w / 2, height / 2 - h / 2, w, h);
    gc.strokeRect(width / 2 - w / 2, height / 2 - h / 2, w, h);

    double initialX = 100;
    double initialY = 200;
    double dr = -20;
    for (double radius = 100; radius >= 20; radius += dr, initialX -= dr, initialY -= dr) {
        gc.strokeOval(initialX, initialY, 2 * radius, 2 * radius);
    }

    // Hometasks:
    // 1. draw a sun!
    // 2. draw regular ngons (fix the function that I wrote)
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:25,代码来源:FXMLDocumentController.java

示例8: draw

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw() {
    drawGrid();

    GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
    gc.setStroke(Color.BLACK);
    gc.setLineWidth(5);
    gc.setFill(Color.YELLOW);
    gc.fillRect(300 - 50, 200 - 50, 100, 100);
    gc.strokeRect(300 - 50, 200 - 50, 100, 100);
    gc.setFill(Color.GREEN);
    gc.fillOval(100, 100, 200, 100);
    gc.strokeOval(100, 100, 200, 100);

    // Hometasks:
    // 1. Draw a circle right at the center with radius of 150 pixels
    // 2. Draw 20 concentric circles in the top left box
    // 3. Draw a sun (circle + rays)
    // 4. Draw a regular n-gon (like pentagon)
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:20,代码来源:FXMLDocumentController.java

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

示例10: drawBackground

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawBackground() {
	DrawCoords topLeft = getTopLeftCorner();
	GraphicsContext context = getGraphicsContext();
	double length = getBoardLength();

	context.setFill(Color.web("0xB78600"));
	context.fillRect(topLeft.getX(), topLeft.getY(), length, length);
}
 
开发者ID:GoSuji,项目名称:Suji,代码行数:10,代码来源:SimpleBoardDrawer.java

示例11: update

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void update(GraphicsContext gc) {

        angle += rotation;
        x += Math.sin(Math.toRadians(-angle)) * velocity;
        y += Math.cos(Math.toRadians(-angle)) * velocity;

        bounds.setLocation(x, y, 64, 64, angle);

        //RENDER
        gc.save();

        Affine transform = new Affine(new Rotate(angle, x, y));
        gc.transform(transform);
        gc.setFill(Color.GREY);
        gc.fillRoundRect(x - 32, y - 32, 64, 64, 3, 3);
        gc.setFill(color);
        gc.fillRect(x - 32 + 12, y - 32, 64 - 24, 64);

        gc.restore();

        //Update turret
        turret.update(gc);

        if (currentPickUp != null && currentPickUp.getTime() == 0) {
            currentPickUp = null;
            bulletType = BulletType.STANDARD;
        }
    }
 
开发者ID:TheBromo,项目名称:netTanks,代码行数:29,代码来源:Tank.java

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

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

示例14: drawBlock

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
protected static void drawBlock(DungeonTileRenderer renderer, GraphicsContext g, Paint p, double offsetX, double offsetY, double width, double height)
{
	if (p == null) p = getRegionalPaint(renderer.region);

	g.setFill(p);
	g.fillRect(offsetX, offsetY, width, height);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:8,代码来源:DungeonTile.java

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


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