상향선과 화살표가 함께있는 그룹을 만든 다음이 그룹을 가운데로 회전하는 것이 더 쉽다고 생각합니다.
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
Pane root = createPane();
root.setTranslateX(200);
root.setTranslateY(200);
Scene scene = new Scene(root,400,400);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
private Pane createPane() {
BorderPane root = new BorderPane();
ArrowFactory arrowfactory = new ArrowFactory();
double lineLength = 100;
double centerX = 0;
double centerY = 0;
root.getChildren().addAll(
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 0),
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 30),
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 45),
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 60),
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 90),
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 135),
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 180),
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 225),
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 270),
arrowfactory.createLineAndArrow(centerX, centerY, lineLength, 315)
);
return root;
}
public static void main(String[] args) {
launch(args);
}
}
ArrayFactory.java
: 당신이 사용할 수있는 입력으로 원 센터를 사용
public class ArrowFactory {
private final int arrowWidth = 10;
private final int arrowHeight = 10;
public Group createLineAndArrow(double centerX, double centerY, double lineLength, double rotation) {
Group group = new Group();
Line line = new Line(centerX, centerY, centerX, centerY - lineLength);
Polygon upwardArrow = createUpwardArrow(centerX, centerY - lineLength/2);
group.getChildren().addAll(line, upwardArrow);
group.getTransforms().add(new Rotate(rotation, centerX, centerY));
return group;
}
private Polygon createUpwardArrow(double centerX, double centerY) {
Polygon arrow = new Polygon(
createUpwardArrowPoints(centerX, centerY + arrowHeight/2));
arrow.setFill(Color.TRANSPARENT);
arrow.setStroke(Color.BLACK);
return arrow;
}
private double[] createUpwardArrowPoints(double centerX, double centerY) {
return new double[] {
centerX - arrowWidth/2, centerY, // left
centerX + arrowWidth/2, centerY, // right
centerX, centerY - arrowHeight, // top
};
}
}

:
private Group createLineAndArrow(double x1, double y1, double x2, double y2) {
double distance = Math.hypot(x1-x2, y1-y2);
double angle = Math.toDegrees(Math.atan2(x2 - x1, y2 - y1));
return arrowfactory.createLineAndArrow(x1, y1, distance, angle);
}
혼란 스럽 습니다만, 결국 번역은 무엇입니까? 화살표가 끝에서 시작을 가리키고 있지 않습니까? 변화에 관해서는 layoutBounds를 보셨습니까? 회전의 피벗은 layoutBounds의 중심이므로 삼각형의 중심이 아닌 경우 교대를 설명 할 수 있습니다. – Lidae
@Lidae 화살표가 회전 된 다음 올바른 위치 (선의 중간)로 이동합니다. 그러므로 번역. – alex
하지만 화살표가 안쪽으로 향하지 않는 한 그들은 번역하기 전에 이미 올바른 위치에 있지만 화살표 머리가 잘못된 방향으로 향하고 있습니다. – Lidae