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


Java Canvas.setWidth方法代碼示例

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


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

示例1: Framework

import javafx.scene.canvas.Canvas; //導入方法依賴的package包/類
public Framework(int width, int height) {

        this.setWidth(width);
        this.setHeight(height);
        random = new Random();
        bullets = new ArrayList<>();
        tanks = new ArrayList<>();
        mines = new ArrayList<>();
        pickUps = new ArrayList<>();
        hud = new HUD(this);

        canvas = new Canvas(width, height);
        gc = canvas.getGraphicsContext2D();
        canvas.setWidth(width);
        canvas.setHeight(height);
        this.getChildren().add(canvas);

        //Create Game Loop
        gameloop = new Timeline(new KeyFrame(
                Duration.millis(16.666666666667),
                ae -> update()));
        gameloop.setCycleCount(Timeline.INDEFINITE);

        //Set SCALE to current scale of Canvas
        SCALE = this.getScaleX();

        //Make the Canvas register keystrokes
        this.addEventFilter(MouseEvent.ANY, (e) -> this.requestFocus());

        //Set Inputs
        setKeyInput();
        setMouseInput();
    }
 
開發者ID:TheBromo,項目名稱:netTanks,代碼行數:34,代碼來源:Framework.java

示例2: layoutChildren

import javafx.scene.canvas.Canvas; //導入方法依賴的package包/類
@Override
protected void layoutChildren()
{
	super.layoutChildren();
	final double x = this.snappedLeftInset();
	final double y = this.snappedTopInset();
	final double w = this.snapSize(this.getWidth()) - x - this.snappedRightInset();
	final double h = this.snapSize(this.getHeight()) - y - this.snappedBottomInset();

	for(Canvas canvas : this.layers)
	{
		canvas.setLayoutX(x);
		canvas.setLayoutY(y);
		canvas.setWidth(w);
		canvas.setHeight(h);
	}
}
 
開發者ID:andykuo1,項目名稱:candlelight,代碼行數:18,代碼來源:ResizeableLayeredCanvasPane.java

示例3: CircularDirectionIndicator

import javafx.scene.canvas.Canvas; //導入方法依賴的package包/類
public CircularDirectionIndicator(String name, double radius){
	this.name = name;
	this.radius = radius;
	
	root = new VBox();
	
	StackPane graphicalData = new StackPane();
	graphicalData.setMaxSize(radius * 2, radius * 2);
	lineBox = new Canvas();
	
	outerCircle = new Circle(graphicalData.getWidth() * 0.5, graphicalData.getHeight() * 0.5, radius);
	outerCircle.setFill(Color.TRANSPARENT);
	outerCircle.setStroke(Color.BLACK);
	/*innerCircle = new Circle(graphicalData.getWidth() * 0.5, graphicalData.getHeight() * 0.5, radius * 0.5);
	innerCircle.setFill(Color.TRANSPARENT);
	innerCircle.setStroke(Color.BLACK);*/
	
	lineBox.setWidth(radius * 2);
	lineBox.setHeight(radius * 2);
	
	graphicalData.getChildren().addAll(outerCircle, lineBox);
	
	valLbl = new Label(name+": 0.0");
	valLbl.setMinWidth(radius * 2);
	valLbl.setTextAlignment(TextAlignment.CENTER);
	
	HBox labalBox = new HBox();
	labalBox.getChildren().add(valLbl);
	labalBox.setAlignment(Pos.CENTER);
	
	root.setAlignment(Pos.CENTER);
	root.setSpacing(2.0);
	root.getChildren().addAll(labalBox, graphicalData);
	
	setValue(0);
}
 
開發者ID:Flash3388,項目名稱:FlashLib,代碼行數:37,代碼來源:CircularDirectionIndicator.java


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