|
1 | 1 | package github.weichware10.toolbox.codecharts;
|
2 | 2 |
|
| 3 | +import github.weichware10.toolbox.Util; |
| 4 | +import github.weichware10.util.config.CodeChartsConfiguration; |
3 | 5 | import github.weichware10.util.config.ConfigClient;
|
4 | 6 | import github.weichware10.util.data.TrialData;
|
| 7 | +import github.weichware10.util.db.DataBaseClient; |
| 8 | +import java.io.FileNotFoundException; |
| 9 | +import java.io.IOException; |
| 10 | +import java.net.MalformedURLException; |
| 11 | +import java.util.ArrayList; |
| 12 | +import java.util.List; |
| 13 | +import javafx.scene.image.Image; |
| 14 | +import javafx.scene.image.ImageView; |
| 15 | +import javafx.scene.layout.StackPane; |
5 | 16 |
|
6 | 17 | /**
|
7 |
| - * Steuert den Datenverkehr und gibt die BEfehle zum anzeigen. |
| 18 | + * Steuert den Datenverkehr und gibt die Befehle zum anzeigen. |
8 | 19 | * von Bild Raster und Eingabefenster.
|
9 | 20 | */
|
10 | 21 | public class CodeChartsCoordinator {
|
11 |
| - ConfigClient configClient; |
12 |
| - protected TrialData trialData; |
13 |
| - // private long[] speed = new long[2]; |
14 |
| - private static boolean isRelative; |
15 |
| - private int[] dimensions = new int[2]; |
16 |
| - private static String[] strings; |
17 |
| - private boolean configData; |
| 22 | + private final TrialData trialData; |
| 23 | + private final ImageView imageView; |
| 24 | + private final CodeChartsPane rootPane; |
| 25 | + |
| 26 | + private final List<String> usableStrings; |
| 27 | + private final List<String> currentStrings; |
| 28 | + |
| 29 | + private final long[] timings; |
| 30 | + private final boolean relativeSize; |
| 31 | + private final boolean randomized; |
| 32 | + private final int maxDepth; |
| 33 | + private final int iterations; |
18 | 34 |
|
19 | 35 | /**
|
20 | 36 | * Konstruktor für den CodeChartsCoordinator.
|
21 | 37 | *
|
22 | 38 | * @param configClient - aus dem die Configuration geladen wird
|
| 39 | + * @param dataBaseClient - |
| 40 | + * @throws IOException |
| 41 | + * @throws FileNotFoundException |
| 42 | + * @throws IllegalArgumentException |
| 43 | + * @throws MalformedURLException |
23 | 44 | */
|
24 |
| - public CodeChartsCoordinator(ConfigClient configClient, TrialData trialData) { |
25 |
| - this.configClient = configClient; |
| 45 | + public CodeChartsCoordinator(ConfigClient configClient, DataBaseClient dataBaseClient, |
| 46 | + TrialData trialData, ImageView imageView, StackPane stackPane) |
| 47 | + throws MalformedURLException, IllegalArgumentException, |
| 48 | + FileNotFoundException, IOException { |
26 | 49 | this.trialData = trialData;
|
27 |
| - this.dimensions = configClient.getConfig().getCodeChartsConfiguration().getInitialSize(); |
28 |
| - } |
| 50 | + this.imageView = imageView; |
29 | 51 |
|
30 |
| - public CodeChartsCoordinator() { |
| 52 | + // BILD SETZEN |
| 53 | + String imageUrl = Util.saveImage(configClient.getConfig().getImageUrl()); |
| 54 | + imageView.setImage(new Image(imageUrl)); |
| 55 | + imageView.setVisible(false); |
31 | 56 |
|
32 |
| - } |
| 57 | + // Konfiguration abspeichern |
| 58 | + CodeChartsConfiguration ccConfig = configClient.getConfig().getCodeChartsConfiguration(); |
| 59 | + iterations = ccConfig.getInterations(); |
| 60 | + maxDepth = ccConfig.getMaxDepth(); |
| 61 | + randomized = ccConfig.getRandomized(); |
| 62 | + relativeSize = ccConfig.getRandomized(); |
| 63 | + timings = ccConfig.getTimings(); |
| 64 | + // String-Listen initialisieren |
| 65 | + usableStrings = dataBaseClient.strings.get(ccConfig.getStringId()); |
| 66 | + currentStrings = new ArrayList<>(); |
33 | 67 |
|
34 |
| - public int[] getDimensions() { |
35 |
| - return dimensions; |
36 |
| - } |
| 68 | + // Zukünftige Unterteilungen setzen (könnte auch null sein) |
| 69 | + CodeChartsPane.defaultHorizontal = ccConfig.getDefaultHorizontal(); |
| 70 | + CodeChartsPane.defaultVertical = ccConfig.getDefaultVertical(); |
| 71 | + CodeChartsPane.showGrid = ccConfig.getShowGrid(); |
37 | 72 |
|
38 |
| - public String[] getStrings() { |
39 |
| - return strings; |
40 |
| - } |
| 73 | + int horizontal = ccConfig.getInitialSize()[0]; |
| 74 | + int vertical = ccConfig.getInitialSize()[1]; |
41 | 75 |
|
42 |
| - public boolean getIsRelative() { |
43 |
| - return isRelative; |
44 |
| - } |
| 76 | + // größ herausfinden (gleich wie Bild) |
| 77 | + double ratio = imageView.getImage().getWidth() / imageView.getImage().getHeight(); |
| 78 | + double width = Math.min(imageView.getFitWidth(), imageView.getFitHeight() * ratio); |
| 79 | + double height = Math.min(imageView.getFitHeight(), imageView.getFitWidth() / ratio); |
45 | 80 |
|
46 |
| - /** |
47 |
| - * Ruft alle Klassen und Funktionen in Reihenfolge auf in der CodeCharts durchgeführt wird. |
48 |
| - * Holt Daten aus der Config |
49 |
| - */ |
50 |
| - public void startCodeCharts() { |
51 |
| - loadConfigData(); |
52 |
| - if (configData == false) { |
53 |
| - errorMessage(); |
54 |
| - } |
55 |
| - // CodeChartsBild bild = new CodeChartsBild("location"); |
56 |
| - // Speichert location in Data für Berechnung in Raster |
57 |
| - // CodeChartsRaste´´r raster = new CodeChartsRaster(); |
58 |
| - // CodeChartsEingabefenster fenster = new CodeChartsEingabefenster(); |
59 |
| - // bild.show(); |
60 |
| - // wait(speed[0]); |
61 |
| - // bild.hide(); |
62 |
| - // raster.show(); |
63 |
| - // wait(speed[1]); |
64 |
| - // String string = fenster.show(); |
65 |
| - // raster.setInput(string); |
66 |
| - // ... |
67 |
| - // raster.sendData(); |
| 81 | + // ROOT PANE |
| 82 | + rootPane = new CodeChartsPane(new ArrayList<>(), -1, -1, width, height); |
| 83 | + rootPane.subdivide(horizontal, vertical); |
| 84 | + rootPane.setVisible(false); |
| 85 | + stackPane.getChildren().add(rootPane); |
68 | 86 | }
|
69 | 87 |
|
70 |
| - /** |
71 |
| - * Gibt Fehlermeldung bei falscher Config data. |
72 |
| - */ |
73 |
| - private void errorMessage() { |
| 88 | + public void startTest() { |
74 | 89 | ;
|
75 | 90 | }
|
76 |
| - |
77 |
| - /** |
78 |
| - * Holt die Daten aus der Config. |
79 |
| - * Speichert die Daten. |
80 |
| - * |
81 |
| - * @return gibt zurück ob fertig geladen. |
82 |
| - */ |
83 |
| - protected boolean loadConfigData() { |
84 |
| - // if (data != vollständig) { |
85 |
| - // configData = false; |
86 |
| - // return configData; |
87 |
| - // } else { |
88 |
| - // configData = true; |
89 |
| - // } |
90 |
| - // speed => Umrechnung von float zu long |
91 |
| - // speed[0] = aus Config; |
92 |
| - // speed[1] = aus Config; |
93 |
| - // dimensions[0] = aus Config; |
94 |
| - // dimensions[1] = aus Config; |
95 |
| - // isRelative = aus Cofig; |
96 |
| - return configData; |
97 |
| - } |
98 | 91 | }
|
0 commit comments