<commit_before>package afester.javafx.examples.svg;

import afester.javafx.components.SnapSlider;
import afester.javafx.examples.Example;
import afester.javafx.svg.GradientPolicy;
import afester.javafx.svg.SvgLoader;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.StringConverter;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

@Example("Using SvgLoader to render an SVG file")
public class SvgLoaderResultViewer extends Application {

    // The SVG image's top node, as returned from the SvgLoader
    private Group svgImage = new Group();

    /* in order to properly scale the svgImage node, we need an additional
     * intermediate node 
     */
    private Group imageLayout = new Group();

    private final HBox mainLayout = new HBox();
    private SvgLoader loader = new SvgLoader();
    private String currentFile;

    public static void main(String[] args) {
        launch(args);
    }

    public void run()  {
        start(new Stage());
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("SVGLoader result viewer");

        ListView<String> listPanel = createListPanel();
        Pane optionsPanel = createOptionsPanel();

        VBox leftPanel = new VBox();
        leftPanel.getChildren().add(listPanel);
        leftPanel.getChildren().add(optionsPanel);

        mainLayout.getChildren().add(leftPanel);
        mainLayout.getChildren().add(imageLayout);

        listPanel.getSelectionModel().select(0);

        // show the generated scene graph
        Scene scene = new Scene(mainLayout, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }


    private ListView<String> createListPanel() {

        ObservableList<String> ol = FXCollections.observableList(getTestFiles());
        ListView<String> listView = new ListView<String>(ol);
        listView.getSelectionModel().getSelectedItems().addListener(
            new ListChangeListener<String>() {

                @Override
                public void onChanged(
                        javafx.collections.ListChangeListener.Change<? extends String> change) {
                    selectFile(change.getList().get(0));
                }
            }
        );
        
        return listView;
    }

    private Pane createOptionsPanel() {
        // gradient policy
        HBox gradientPolicy = new HBox();
        gradientPolicy.setSpacing(10);
        gradientPolicy.getChildren().add(new Label("Gradient Transformation Policy:"));

        ComboBox<GradientPolicy> comboBox = new ComboBox<>();
        comboBox.getItems().addAll(GradientPolicy.values());
        comboBox.setOnAction(e -> {
            loader.setGradientTransformPolicy(comboBox.getSelectionModel().getSelectedItem());
            selectFile(currentFile);
        }); 
        gradientPolicy.getChildren().add(comboBox);
        comboBox.getSelectionModel().select(GradientPolicy.USE_SUPPORTED);

        // show/hide viewport rectangle
        CheckBox showViewport = new CheckBox("Show Viewport");<commit_msg>Set the initial value for the gradient policy combobox before adding the change listener<commit_after>package afester.javafx.examples.svg;

import afester.javafx.components.SnapSlider;
import afester.javafx.examples.Example;
import afester.javafx.svg.GradientPolicy;
import afester.javafx.svg.SvgLoader;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.StringConverter;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

@Example("Using SvgLoader to render an SVG file")
public class SvgLoaderResultViewer extends Application {

    // The SVG image's top node, as returned from the SvgLoader
    private Group svgImage = new Group();

    /* in order to properly scale the svgImage node, we need an additional
     * intermediate node 
     */
    private Group imageLayout = new Group();

    private final HBox mainLayout = new HBox();
    private SvgLoader loader = new SvgLoader();
    private String currentFile;

    public static void main(String[] args) {
        launch(args);
    }

    public void run()  {
        start(new Stage());
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("SVGLoader result viewer");

        ListView<String> listPanel = createListPanel();
        Pane optionsPanel = createOptionsPanel();

        VBox leftPanel = new VBox();
        leftPanel.getChildren().add(listPanel);
        leftPanel.getChildren().add(optionsPanel);

        mainLayout.getChildren().add(leftPanel);
        mainLayout.getChildren().add(imageLayout);

        listPanel.getSelectionModel().select(0);

        // show the generated scene graph
        Scene scene = new Scene(mainLayout, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }


    private ListView<String> createListPanel() {

        ObservableList<String> ol = FXCollections.observableList(getTestFiles());
        ListView<String> listView = new ListView<String>(ol);
        listView.getSelectionModel().getSelectedItems().addListener(
            new ListChangeListener<String>() {

                @Override
                public void onChanged(
                        javafx.collections.ListChangeListener.Change<? extends String> change) {
                    selectFile(change.getList().get(0));
                }
            }
        );
        
        return listView;
    }

    private Pane createOptionsPanel() {
        // gradient policy
        HBox gradientPolicy = new HBox();
        gradientPolicy.setSpacing(10);
        gradientPolicy.getChildren().add(new Label("Gradient Transformation Policy:"));

        ComboBox<GradientPolicy> comboBox = new ComboBox<>();
        comboBox.getItems().addAll(GradientPolicy.values());
        comboBox.getSelectionModel().select(GradientPolicy.USE_SUPPORTED);
        comboBox.setOnAction(e -> {
            loader.setGradientTransformPolicy(comboBox.getSelectionModel().getSelectedItem());
            selectFile(currentFile);
        }); 
        gradientPolicy.getChildren().add(comboBox);

        // show/hide viewport rectangle
        CheckBox showViewport = new CheckBox("Show Viewport");
{'fraction_non_alphanumeric': 0.10022718161165307, 'fraction_numerical': 0.0026727248429774153, 'mean_word_length': 3.213963963963964, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '536152', 'n_tokens_mistral': 2074, 'n_tokens_neox': 1964, 'n_words': 450}