本文整理匯總了Java中javafx.scene.shape.Line.getStartY方法的典型用法代碼示例。如果您正苦於以下問題:Java Line.getStartY方法的具體用法?Java Line.getStartY怎麽用?Java Line.getStartY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.shape.Line
的用法示例。
在下文中一共展示了Line.getStartY方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例2: 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);
});
}
示例3: 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)));
}
示例4: 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();
}
}
示例5: handlePaddleHit
import javafx.scene.shape.Line; //導入方法依賴的package包/類
private void handlePaddleHit(Line leftPaddleLine, Line rightPaddleLine, boolean leftHit) {
Line paddleLine = rightPaddleLine;
int degreesToAdd = 0;
if (leftHit) {
paddleLine = leftPaddleLine;
degreesToAdd = 180;
}
double offsetY = paddleLine.getStartY();
double paddleBot = paddleLine.getEndY() - offsetY;
final double ballCoordWithinPaddle = ball.getCenterY() - offsetY;
//should be a float number between -1 - 1
double normalizedBallPosOnPaddle = (ballCoordWithinPaddle / paddleBot) * 2 - 1;
if (Math.abs(normalizedBallPosOnPaddle) > 1) {
// Print error if not between -1 and 1
//System.err.println("should be between -1 and 1: " + normalizedBallPosOnPaddle);
}
double degreeOnUnitCircle = normalizedBallPosOnPaddle * 70 + degreesToAdd;
Vector2D vectorToAdd = new Vector2D(Math.cos(degreeOnUnitCircle),Math.sin(degreeOnUnitCircle));
ball.setDirection(new Vector2D(-ball.getDirection().getX(), ball.getDirection().getY()));
//ball.getDirection().add(vectorToAdd).normalize();
ball.setSpeed(ball.getSpeed() + 0.01);
}
示例6: 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
}
示例7: getPositionInYAxis
import javafx.scene.shape.Line; //導入方法依賴的package包/類
private double getPositionInYAxis(CustomAxis axis, Line axisLine, double value) {
double yAxisMin = axis.getMinValue();
double yAxisMax = axis.getMaxValue();
double maxValue = yAxisMax - yAxisMin;
value = value - yAxisMin;
double percentage = value / maxValue;
double width = axisLine.getEndY() - axisLine.getStartY();
return axisLine.getStartY() + width * percentage;
}
示例8: 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);
}