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


Java Line.getEndX方法代碼示例

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


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

示例1: distanceToLine

import javafx.scene.shape.Line; //導入方法依賴的package包/類
private double distanceToLine(Line l, double pointX, double pointY){
    double y1 = l.getStartY();
    double y2 = l.getEndY();
    double x1 = l.getStartX();
    double x2 = l.getEndX();

    double px = x2-x1;
    double py = y2-y1;

    double something = px*px + py*py;

    double u =  ((pointX - x1) * px + (pointY - y1) * py) / something;

    if (u > 1){
        u = 1;
    }
    else if (u < 0){
        u = 0;
    }

    double x = x1 + u * px;
    double y = y1 + u * py;

    double dx = x - pointX;
    double dy = y - pointY;

    double dist = Math.sqrt(dx*dx + dy*dy);

    return dist;

}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:32,代碼來源:SelectController.java

示例2: scale

import javafx.scene.shape.Line; //導入方法依賴的package包/類
public void scale(int buttonWidth, Font font) {
	for (Node cell : getChildren()) {
		if (cell instanceof Button) {
			((Button) cell).setMinSize(buttonWidth, buttonWidth);
			((Button) cell).setMaxSize(buttonWidth, buttonWidth);
			((Button) cell).setFont(font);
		} else if (cell instanceof Line) {
			Line line = ((Line) cell);
			if (line.getEndX() > 1) {
				line.setEndX(buttonWidth);
			} else if (line.getEndY() > 1) {
				line.setEndY(buttonWidth);
			}
		}
	}
}
 
開發者ID:Henney,項目名稱:sudokusolver,代碼行數:17,代碼來源:SudokuGridPane.java

示例3: insertRectangles

import javafx.scene.shape.Line; //導入方法依賴的package包/類
protected void insertRectangles() {
    if(list.size() > 0){
        showArea.getChildren().clear();


        //根據添加
        for (int i = 0; i < list.size(); i++) {
            Rectangle rectangle = new Rectangle(START_X, START_Y + i * HEIGHT, WIDTH, HEIGHT);
            rectangle.setFill(Color.WHITE);
            rectangle.setStroke(Color.BLACK);
            rectangle.setOpacity(0.5);
            Text text = new Text(rectangle.getX() + rectangle.getWidth()/2, rectangle.getY() + rectangle.getHeight()/2, list.get(i));

            if(i == list.size() - 1){
                top = new Text(START_X - WIDTH, START_Y + HEIGHT/2, TOP);

                //畫箭頭
                top_mid = new Line(START_X - WIDTH/5*3, START_Y + HEIGHT/2,
                        START_X, START_Y + HEIGHT/2);
                top_left = new Line(top_mid.getEndX(), top_mid.getEndY(),
                        top_mid.getEndX() - HEIGHT/3, top_mid.getEndY() - HEIGHT/2);
                top_right = new Line(top_mid.getEndX(), top_mid.getEndY(),
                        top_mid.getEndX() - HEIGHT/3, top_mid.getEndY() + HEIGHT/2);

                        showArea.getChildren().addAll(top, top_mid, top_left, top_right);
            }


            showArea.getChildren().addAll(rectangle, text);
        }
    }else {
        initialInsert();
    }
}
 
開發者ID:fankaljead,項目名稱:Curriculum-design-of-data-structure,代碼行數:35,代碼來源:ShowStackController.java

示例4: create

import javafx.scene.shape.Line; //導入方法依賴的package包/類
private Transition create(Line line, double startX, double startY, double endX, double endY) {
    double currentStartX = line.getStartX();
    double currentStartY = line.getStartY();
    double currentEndX = line.getEndX();
    double currentEndY = line.getEndY();

    return createAnimation(frac -> {
        line.setStartX(currentStartX + (startX - currentStartX) * frac);
        line.setStartY(currentStartY + (startY - currentStartY) * frac);
        line.setEndX(currentEndX + (endX - currentEndX) * frac);
        line.setEndY(currentEndY + (endY - currentEndY) * frac);
    });
}
 
開發者ID:hendrikebbers,項目名稱:ExtremeGuiMakeover,代碼行數:14,代碼來源:AnimatedIcon.java

示例5: minDistance

import javafx.scene.shape.Line; //導入方法依賴的package包/類
static double minDistance(Wrap relativeWrap, Line line, Wrap wrap) {
    Point p1 = new Point(line.getStartX(), line.getStartY());
    Point p2 = new Point(line.getEndX(), line.getEndY());
    Point p3 = getRectangleSideCenter(wrap.getScreenBounds(), Side.LEFT);
    p3.translate(-relativeWrap.getScreenBounds().x, -relativeWrap.getScreenBounds().y);
    Point p4 = getRectangleSideCenter(wrap.getScreenBounds(), Side.RIGHT);
    p4.translate(-relativeWrap.getScreenBounds().x, -relativeWrap.getScreenBounds().y);
    return Math.min(Math.min(distance(p1, p3), distance(p1, p4)), Math.min(distance(p2, p3), distance(p2, p4)));
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:10,代碼來源:Geometry.java

示例6: getLineDescription

import javafx.scene.shape.Line; //導入方法依賴的package包/類
static String getLineDescription(Line line) {
    if (line == null) {
        return "null";
    } else {
        return "Line : startX " + line.getStartX() + " startY " + line.getStartY() + " endX " + line.getEndX() + " endY " + line.getEndY();
    }
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:8,代碼來源:Geometry.java

示例7: start

import javafx.scene.shape.Line; //導入方法依賴的package包/類
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a pane
	Pane pane = new Pane();

	// Create two circles
	Circle circle1 = new Circle(Math.random() * 201, Math.random() * 201, 15);
	Circle circle2 = new Circle(Math.random() * 201, Math.random() * 201, 15);

	// Create a line
	Line line = new Line(circle1.getCenterX(), circle1.getCenterY(),
		circle2.getCenterX(), circle2.getCenterY());

	// Calculate distane between the two centers of the circles
	double distance = Math.sqrt(Math.pow(line.getEndX() - line.getStartX(), 2)
		+ Math.pow(line.getEndY() - line.getStartY(), 2));

	// Create a text
	double x = (line.getStartX() + line.getEndX()) / 2;
	double y = (line.getStartY() + line.getEndY()) / 2;
	Text text = new Text(x, y, String.valueOf(distance));
	
	// Add nodes to pane
	pane.getChildren().addAll(circle1, circle2, line, text);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_14_21"); // Set the stage title 
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
開發者ID:jsquared21,項目名稱:Intro-to-Java-Programming,代碼行數:32,代碼來源:Exercise_14_21.java

示例8: start

import javafx.scene.shape.Line; //導入方法依賴的package包/類
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create two panes
	Pane pane1 = new Pane();
	pane1.setRotate(180);
	pane1.setPadding(new Insets(72, 0, 0, 75));
	Pane pane2 = new Pane();

	// Create a polyline
	Polyline polyline1 = new Polyline();
	pane1.getChildren().add(polyline1);             
	ObservableList<Double> list = polyline1.getPoints();
	double scaleFactor = 0.0125;                       
	for (int x = -100; x <= 100; x++) {                
		list.add(x + 200.0);                            
		list.add(scaleFactor * x * x);                  
	}  

	// Create two lines
	Line lineX = new Line(10, 200, 350, 200);                                                
	//pane.getChildren().addAll(stackPane, lineX);

	Line lineY = new Line(lineX.getEndX() / 2, 250, lineX.getEndX() / 2, 30);                                                
	pane2.getChildren().addAll(pane1, lineX, lineY);

	// Create two polylines
	Polyline polyline2 = new Polyline();
	pane2.getChildren().add(polyline2);
	ObservableList<Double> list2 = polyline2.getPoints();
	list2.addAll(lineY.getEndX() - 10, lineY.getEndY() + 20, 
		lineY.getEndX(), lineY.getEndY(), lineY.getEndX() + 10, 
		lineY. getEndY() + 20);

	Polyline polyline3 = new Polyline();
	pane2.getChildren().add(polyline3);
	ObservableList<Double> list3 = polyline3.getPoints();
	list3.addAll(lineX.getEndX() - 20, lineX.getEndY() - 10, 
		lineX.getEndX(), lineX.getEndY(), lineX.getEndX() - 20, 
		lineX. getEndY() + 10);

	// Create two text objects
	Text textX = new Text(lineX.getEndX() - 10, lineX.getEndY() - 20, "X");
	Text textY = new Text(lineY.getEndX() + 20, lineY.getEndY() + 10, "Y");
	pane2.getChildren().addAll(textX, textY);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane2);
	primaryStage.setTitle("Exercise_14_18"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
開發者ID:jsquared21,項目名稱:Intro-to-Java-Programming,代碼行數:52,代碼來源:Exercise_14_18.java

示例9: getLineAngle

import javafx.scene.shape.Line; //導入方法依賴的package包/類
/**
 * Evaluated starting from Ox axis in clockwise direction.
 *
 * @param line
 * @return angle in grads
 */
static double getLineAngle(Line line) {
    double OY = line.getEndY() - line.getStartY();
    double OX = line.getEndX() - line.getStartX();
    return Math.atan(-OY / OX) / Math.PI * 180 + (OX < 0 ? 180 : 0);
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:12,代碼來源:Geometry.java


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