use of javafx.scene.shape.Line in project JFoenix by jfoenixadmin.
the class JFXSliderSkinOLD method initialize.
private void initialize() {
isHorizontal = getSkinnable().getOrientation() == Orientation.HORIZONTAL;
thumb = new Circle();
thumb.setStrokeWidth(2);
thumb.setRadius(7);
thumb.setFill(thumbColor);
thumb.setStroke(thumbColor);
thumb.getStyleClass().setAll("thumb");
track = new Line();
track.setStroke(trackColor);
track.setStrokeWidth(3);
track.getStyleClass().setAll("track");
coloredTrack = new Line();
coloredTrack.strokeProperty().bind(thumb.strokeProperty());
coloredTrack.strokeWidthProperty().bind(track.strokeWidthProperty());
sliderValue = new Text();
sliderValue.setStroke(Color.WHITE);
sliderValue.setFont(new Font(10));
sliderValue.getStyleClass().setAll("sliderValue");
animatedThumb = new StackPane();
animatedThumb.getChildren().add(sliderValue);
getChildren().clear();
getChildren().addAll(track, coloredTrack, animatedThumb, thumb);
}
use of javafx.scene.shape.Line in project JFoenix by jfoenixadmin.
the class JFXTimePickerContent method createHoursContent.
private StackPane createHoursContent(LocalTime time) {
// create hours content
StackPane hoursPointer = new StackPane();
Circle selectionCircle = new Circle(contentCircleRadius / 6);
selectionCircle.fillProperty().bind(timePicker.defaultColorProperty());
double shift = 9;
Line line = new Line(shift, 0, contentCircleRadius, 0);
line.fillProperty().bind(timePicker.defaultColorProperty());
line.strokeProperty().bind(line.fillProperty());
line.setStrokeWidth(1.5);
hoursPointer.getChildren().addAll(line, selectionCircle);
StackPane.setAlignment(selectionCircle, Pos.CENTER_LEFT);
Group pointerGroup = new Group();
pointerGroup.getChildren().add(hoursPointer);
pointerGroup.setTranslateX((-contentCircleRadius + shift) / 2);
hoursPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius());
pointerRotate.set(hoursPointerRotate);
pointerGroup.getTransforms().add(hoursPointerRotate);
Pane clockLabelsContainer = new Pane();
// inner circle radius
double radius = contentCircleRadius - shift - selectionCircle.getRadius();
for (int i = 0; i < 12; i++) {
// create the label and its container
int val = (i + 3) % 12 == 0 ? 12 : (i + 3) % 12;
Label label = new Label(val + "");
label.setFont(Font.font("Roboto", FontWeight.BOLD, 12));
// init color
if (val == time.getHour() % 12 || (val == 12 && time.getHour() % 12 == 0))
label.setTextFill(Color.rgb(255, 255, 255, 0.87));
else
label.setTextFill(Color.rgb(0, 0, 0, 0.87));
selectedHourLabel.textProperty().addListener((o, oldVal, newVal) -> {
if (Integer.parseInt(newVal) == Integer.parseInt(label.getText())) {
label.setTextFill(Color.rgb(255, 255, 255, 0.87));
} else {
label.setTextFill(Color.rgb(0, 0, 0, 0.87));
}
});
// create label container
StackPane labelContainer = new StackPane();
labelContainer.getChildren().add(label);
double labelSize = (selectionCircle.getRadius() / Math.sqrt(2)) * 2;
labelContainer.setMinSize(labelSize, labelSize);
// position the label on the circle
double angle = 2 * i * Math.PI / 12;
double xOffset = radius * Math.cos(angle);
double yOffset = radius * Math.sin(angle);
final double startx = contentCircleRadius + xOffset;
final double starty = contentCircleRadius + yOffset;
labelContainer.setLayoutX(startx - labelContainer.getMinWidth() / 2);
labelContainer.setLayoutY(starty - labelContainer.getMinHeight() / 2);
// add label to the parent node
clockLabelsContainer.getChildren().add(labelContainer);
// init pointer angle
if (val == time.getHour() % 12 || (val == 12 && time.getHour() % 12 == 0))
hoursPointerRotate.setAngle(180 + Math.toDegrees(angle));
}
return new StackPane(pointerGroup, clockLabelsContainer);
}
use of javafx.scene.shape.Line in project aima-java by aimacode.
the class CspViewCtrl method visualize.
protected void visualize(Constraint<VAR, VAL> constraint) {
List<VAR> scope = constraint.getScope();
if (scope.size() == 2) {
// we show only binary constraints...
Point2D pos0 = getPosition(scope.get(0));
Point2D pos1 = getPosition(scope.get(1));
Line line = new Line(pos0.getX(), pos0.getY(), pos1.getX(), pos1.getY());
pane.getChildren().add(line);
//g2.drawLine(pos0[0] + 20, pos0[1] + 20, pos1[0] + 20, pos1[1] + 20);
}
}
use of javafx.scene.shape.Line in project aima-java by aimacode.
the class MapEnvironmentViewCtrl method update.
protected void update() {
envStateView.getChildren().clear();
if (env != null) {
double scale = adjustTransform();
Map map = env.getMap();
// print connections
for (String loc1 : map.getLocations()) {
Point2D pt1 = map.getPosition(loc1);
for (String loc2 : map.getPossibleNextLocations(loc1)) {
Point2D pt2 = map.getPosition(loc2);
Shape line = new Line(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY());
line.setStroke(Color.LIGHTGRAY);
envStateView.getChildren().add(line);
}
}
// print track of first agent
if (!env.getAgents().isEmpty()) {
String aLoc = env.getAgentLocation(env.getAgents().get(0));
if (track.isEmpty() || !Objects.equals(track.get(track.size() - 1), aLoc))
track.add(aLoc);
for (int i = 1; i < track.size(); i++) {
Point2D pt1 = map.getPosition(track.get(i - 1));
Point2D pt2 = map.getPosition(track.get(i));
Shape line = new Line(pt1.getX(), pt1.getY(), pt2.getX(), pt2.getY());
line.setStroke(Color.RED);
line.setStrokeWidth(2);
envStateView.getChildren().add(line);
}
}
// print locations
for (String loc : map.getLocations()) {
Point2D point = map.getPosition(loc);
Text text = new Text(point.getX() + 10 / scale, point.getY(), loc);
text.setFont(new Font(12.0 / scale));
envStateView.getChildren().add(text);
envStateView.getChildren().add(new Circle(point.getX(), point.getY(), 2 / scale));
}
// print agent locations
for (Agent agent : env.getAgents()) {
String loc = env.getAgentLocation(agent);
if (loc != null) {
Point2D pt = map.getPosition(loc);
envStateView.getChildren().add(new Circle(pt.getX(), pt.getY(), 8 / scale, Color.RED));
}
}
// print goal
if (goal != null) {
Point2D pt = map.getPosition(goal);
envStateView.getChildren().add(new Circle(pt.getX(), pt.getY(), 6 / scale, Color.GREEN));
}
}
}
use of javafx.scene.shape.Line in project JFoenix by jfoenixadmin.
the class JFXTimePickerContent method createMinutesContent.
private StackPane createMinutesContent(LocalTime time) {
// create minutes content
StackPane minsPointer = new StackPane();
Circle selectionCircle = new Circle(contentCircleRadius / 6);
selectionCircle.fillProperty().bind(timePicker.defaultColorProperty());
Circle minCircle = new Circle(selectionCircle.getRadius() / 8);
minCircle.setFill(Color.rgb(255, 255, 255, 0.87));
minCircle.setTranslateX(selectionCircle.getRadius() - minCircle.getRadius());
minCircle.setVisible(time.getMinute() % 5 != 0);
selectedMinLabel.textProperty().addListener((o, oldVal, newVal) -> {
if (Integer.parseInt(newVal) % 5 == 0)
minCircle.setVisible(false);
else
minCircle.setVisible(true);
});
double shift = 9;
Line line = new Line(shift, 0, contentCircleRadius, 0);
line.fillProperty().bind(timePicker.defaultColorProperty());
line.strokeProperty().bind(line.fillProperty());
line.setStrokeWidth(1.5);
minsPointer.getChildren().addAll(line, selectionCircle, minCircle);
StackPane.setAlignment(selectionCircle, Pos.CENTER_LEFT);
StackPane.setAlignment(minCircle, Pos.CENTER_LEFT);
Group pointerGroup = new Group();
pointerGroup.getChildren().add(minsPointer);
pointerGroup.setTranslateX((-contentCircleRadius + shift) / 2);
minsPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius());
pointerGroup.getTransforms().add(minsPointerRotate);
Pane clockLabelsContainer = new Pane();
// inner circle radius
double radius = contentCircleRadius - shift - selectionCircle.getRadius();
for (int i = 0; i < 12; i++) {
StackPane labelContainer = new StackPane();
int val = ((i + 3) * 5) % 60 == 0 ? 0 : ((i + 3) * 5) % 60;
Label label = new Label(unitConverter.toString(val) + "");
label.setFont(Font.font("Roboto", FontWeight.BOLD, 12));
// init label color
if (val == time.getMinute())
label.setTextFill(Color.rgb(255, 255, 255, 0.87));
else
label.setTextFill(Color.rgb(0, 0, 0, 0.87));
selectedMinLabel.textProperty().addListener((o, oldVal, newVal) -> {
if (Integer.parseInt(newVal) == Integer.parseInt(label.getText())) {
label.setTextFill(Color.rgb(255, 255, 255, 0.87));
} else {
label.setTextFill(Color.rgb(0, 0, 0, 0.87));
}
});
labelContainer.getChildren().add(label);
double labelSize = (selectionCircle.getRadius() / Math.sqrt(2)) * 2;
labelContainer.setMinSize(labelSize, labelSize);
double angle = 2 * i * Math.PI / 12;
double xOffset = radius * Math.cos(angle);
double yOffset = radius * Math.sin(angle);
final double startx = contentCircleRadius + xOffset;
final double starty = contentCircleRadius + yOffset;
labelContainer.setLayoutX(startx - labelContainer.getMinWidth() / 2);
labelContainer.setLayoutY(starty - labelContainer.getMinHeight() / 2);
// add label to the parent node
clockLabelsContainer.getChildren().add(labelContainer);
}
minsPointerRotate.setAngle(180 + (time.getMinute() + 45) % 60 * Math.toDegrees(2 * Math.PI / 60));
return new StackPane(pointerGroup, clockLabelsContainer);
}
Aggregations