Search in sources :

Example 26 with Text

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);
}
Also used : Circle(javafx.scene.shape.Circle) Point2D(aima.core.util.math.geom.shapes.Point2D) Color(javafx.scene.paint.Color) Text(javafx.scene.text.Text)

Example 27 with Text

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));
        }
    }
}
Also used : Line(javafx.scene.shape.Line) Circle(javafx.scene.shape.Circle) Agent(aima.core.agent.Agent) Shape(javafx.scene.shape.Shape) Point2D(aima.core.util.math.geom.shapes.Point2D) Text(javafx.scene.text.Text) Map(aima.core.environment.map.Map) Font(javafx.scene.text.Font)

Example 28 with Text

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);
}
Also used : Label(javafx.scene.control.Label) FlowPane(javafx.scene.layout.FlowPane) Text(javafx.scene.text.Text)

Example 29 with Text

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);
    }
}
Also used : Text(javafx.scene.text.Text) VBox(javafx.scene.layout.VBox)

Example 30 with 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();
}
Also used : Text(javafx.scene.text.Text)

Aggregations

Text (javafx.scene.text.Text)313 VBox (javafx.scene.layout.VBox)55 TextFlow (javafx.scene.text.TextFlow)55 Label (javafx.scene.control.Label)51 Pane (javafx.scene.layout.Pane)34 Font (javafx.scene.text.Font)30 Button (javafx.scene.control.Button)25 Region (javafx.scene.layout.Region)25 Group (javafx.scene.Group)23 GridPane (javafx.scene.layout.GridPane)23 List (java.util.List)22 Rectangle (javafx.scene.shape.Rectangle)22 HBox (javafx.scene.layout.HBox)21 StackPane (javafx.scene.layout.StackPane)20 Color (javafx.scene.paint.Color)20 Insets (javafx.geometry.Insets)17 Canvas (javafx.scene.canvas.Canvas)17 Circle (javafx.scene.shape.Circle)17 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)17 ScrollPane (javafx.scene.control.ScrollPane)16