use of javafx.scene.text.Text in project aima-java by aimacode.
the class CspViewCtrl method visualize.
protected void visualize(VAR var) {
Point2D pos = getPosition(var);
String label = var.getName();
VAL value = null;
Color fillColor = null;
if (assignment != null)
value = assignment.getValue(var);
if (value != null) {
label += " = " + value;
fillColor = colorMapping.get(value);
}
Circle circle = new Circle(pos.getX(), pos.getY(), 20);
circle.setStroke(Color.BLACK);
circle.setFill(fillColor != null ? fillColor : Color.WHITE);
Text t1 = new Text(pos.getX() + 25, pos.getY(), label);
t1.setTextOrigin(VPos.CENTER);
Text t2 = new Text(pos.getX(), pos.getY() + 40, csp.getDomain(var).toString());
pane.getChildren().addAll(circle, t1, t2);
}
use of javafx.scene.text.Text 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.text.Text in project TeachingInSimulation by ScOrPiOzzy.
the class RecordQuestionItem method loadBlankQuestion.
private void loadBlankQuestion() {
String title = question.getTitle();
List<String> titles = StringUtil.split(title);
List<String> references = StringUtil.split(question.getReference());
FlowPane pane = new FlowPane();
pane.maxWidth(600);
this.getChildren().add(pane);
VBox.setVgrow(pane, Priority.ALWAYS);
pane.getChildren().add(new Label(index + ". "));
for (int i = 0; i < titles.size(); i++) {
Label label = new Label(titles.get(i));
pane.getChildren().add(label);
if (i < references.size()) {
Label reference = new Label(references.get(i));
reference.getStyleClass().add("green");
pane.getChildren().add(reference);
}
}
Label label = new Label(MsgUtil.getMessage("question.point", question.getPoint()));
pane.getChildren().add(label);
Text studentAnswer = new Text(MsgUtil.getMessage("question.answer", answer.getAnswer().replaceAll("\\|", ";")));
studentAnswer.setWrappingWidth(600);
if (AnswerState.ANSWER_STATE_RIGHT.getType() == answer.getCorrected()) {
studentAnswer.getStyleClass().add("green");
} else {
studentAnswer.getStyleClass().add("red");
}
this.getChildren().add(studentAnswer);
}
use of javafx.scene.text.Text in project TeachingInSimulation by ScOrPiOzzy.
the class PreviewQuestionItem method loadChoiceQuestion.
private void loadChoiceQuestion(Question question) {
Text title = new Text(index + ". " + question.getTitle() + MsgUtil.getMessage("question.point", question.getPoint()));
title.setWrappingWidth(600);
this.getChildren().add(title);
VBox.setVgrow(title, Priority.ALWAYS);
VBox box = new VBox(5);
this.getChildren().add(box);
List<String> options = StringUtil.split(question.getOptions());
String reference = question.getReference();
for (String option : options) {
Text text = new Text(option);
text.setWrappingWidth(600);
if (showReference && reference.indexOf(option.substring(0, 1)) > -1) {
text.getStyleClass().add("green");
}
VBox.setVgrow(text, Priority.ALWAYS);
box.getChildren().add(text);
}
}
use of javafx.scene.text.Text in project jphp by jphp-compiler.
the class UXFont method calculateTextWidth.
public static double calculateTextWidth(String atext, Font font) {
Text text = new Text(atext);
text.setFont(font);
return text.getLayoutBounds().getWidth();
}
Aggregations