Search in sources :

Example 1 with TreeNode

use of eu.hansolo.tilesfx.tools.TreeNode in project tilesfx by HanSolo.

the class Demo method init.

@Override
public void init() {
    value = new SimpleDoubleProperty(0);
    // AreaChart Data
    XYChart.Series<String, Number> series1 = new XYChart.Series();
    series1.setName("Whatever");
    series1.getData().add(new XYChart.Data("MO", 23));
    series1.getData().add(new XYChart.Data("TU", 21));
    series1.getData().add(new XYChart.Data("WE", 20));
    series1.getData().add(new XYChart.Data("TH", 22));
    series1.getData().add(new XYChart.Data("FR", 24));
    series1.getData().add(new XYChart.Data("SA", 22));
    series1.getData().add(new XYChart.Data("SU", 20));
    // LineChart Data
    XYChart.Series<String, Number> series2 = new XYChart.Series();
    series2.setName("Inside");
    series2.getData().add(new XYChart.Data("MO", 8));
    series2.getData().add(new XYChart.Data("TU", 5));
    series2.getData().add(new XYChart.Data("WE", 0));
    series2.getData().add(new XYChart.Data("TH", 2));
    series2.getData().add(new XYChart.Data("FR", 4));
    series2.getData().add(new XYChart.Data("SA", 3));
    series2.getData().add(new XYChart.Data("SU", 5));
    XYChart.Series<String, Number> series3 = new XYChart.Series();
    series3.setName("Outside");
    series3.getData().add(new XYChart.Data("MO", 8));
    series3.getData().add(new XYChart.Data("TU", 5));
    series3.getData().add(new XYChart.Data("WE", 0));
    series3.getData().add(new XYChart.Data("TH", 2));
    series3.getData().add(new XYChart.Data("FR", 4));
    series3.getData().add(new XYChart.Data("SA", 3));
    series3.getData().add(new XYChart.Data("SU", 5));
    // WorldMap Data
    for (int i = 0; i < Country.values().length; i++) {
        double value = RND.nextInt(10);
        Color color;
        if (value > 8) {
            color = Tile.RED;
        } else if (value > 6) {
            color = Tile.ORANGE;
        } else if (value > 4) {
            color = Tile.YELLOW_ORANGE;
        } else if (value > 2) {
            color = Tile.GREEN;
        } else {
            color = Tile.BLUE;
        }
        Country.values()[i].setColor(color);
    }
    // TimeControl Data
    TimeSection timeSection = TimeSectionBuilder.create().start(LocalTime.now().plusSeconds(20)).stop(LocalTime.now().plusHours(1)).color(Tile.GRAY).highlightColor(Tile.RED).build();
    timeSection.setOnTimeSectionEntered(e -> System.out.println("Section ACTIVE"));
    timeSection.setOnTimeSectionLeft(e -> System.out.println("Section INACTIVE"));
    // Weather (You can get a DarkSky API key here: https://darksky.net/dev/ )
    DarkSky darkSky = new DarkSky("YOUR DARKSKY API KEY", Unit.CA, Language.ENGLISH, 51.911858, 7.632815);
    // darkSky.update();
    // BarChart Items
    barChartItem1 = new BarChartItem("Gerrit", 47, Tile.BLUE);
    barChartItem2 = new BarChartItem("Sandra", 43, Tile.RED);
    barChartItem3 = new BarChartItem("Lilli", 12, Tile.GREEN);
    barChartItem4 = new BarChartItem("Anton", 8, Tile.ORANGE);
    barChartItem1.setFormatString("%.1f kWh");
    // LeaderBoard Items
    leaderBoardItem1 = new LeaderBoardItem("Gerrit", 47);
    leaderBoardItem2 = new LeaderBoardItem("Sandra", 43);
    leaderBoardItem3 = new LeaderBoardItem("Lilli", 12);
    leaderBoardItem4 = new LeaderBoardItem("Anton", 8);
    // Chart Data
    chartData1 = new ChartData("Item 1", 24.0, Tile.GREEN);
    chartData2 = new ChartData("Item 2", 10.0, Tile.BLUE);
    chartData3 = new ChartData("Item 3", 12.0, Tile.RED);
    chartData4 = new ChartData("Item 4", 13.0, Tile.YELLOW_ORANGE);
    chartData5 = new ChartData("Item 5", 13.0, Tile.BLUE);
    chartData6 = new ChartData("Item 6", 13.0, Tile.BLUE);
    chartData7 = new ChartData("Item 7", 13.0, Tile.BLUE);
    chartData8 = new ChartData("Item 8", 13.0, Tile.BLUE);
    // ChartData.animated = false;
    smoothChartData1 = new ChartData("Item 1", RND.nextDouble() * 25, Tile.BLUE);
    smoothChartData2 = new ChartData("Item 2", RND.nextDouble() * 25, Tile.BLUE);
    smoothChartData3 = new ChartData("Item 3", RND.nextDouble() * 25, Tile.BLUE);
    smoothChartData4 = new ChartData("Item 4", RND.nextDouble() * 25, Tile.BLUE);
    // Creating Tiles
    percentageTile = TileBuilder.create().skinType(SkinType.PERCENTAGE).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Percentage Tile").unit("\u0025").description("Test").maxValue(60).build();
    clockTile = TileBuilder.create().skinType(SkinType.CLOCK).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Clock Tile").text("Whatever text").dateVisible(true).locale(Locale.US).running(true).build();
    gaugeTile = TileBuilder.create().skinType(SkinType.GAUGE).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Gauge Tile").unit("V").threshold(75).build();
    sparkLineTile = TileBuilder.create().skinType(SkinType.SPARK_LINE).prefSize(TILE_WIDTH, TILE_HEIGHT).title("SparkLine Tile").unit("mb").gradientStops(new Stop(0, Tile.GREEN), new Stop(0.5, Tile.YELLOW), new Stop(1.0, Tile.RED)).strokeWithGradient(true).build();
    // sparkLineTile.valueProperty().bind(value);
    areaChartTile = TileBuilder.create().skinType(SkinType.SMOOTHED_CHART).prefSize(TILE_WIDTH, TILE_HEIGHT).title("SmoothedChart Tile").chartType(ChartType.AREA).smoothing(true).tooltipTimeout(1000).tilesFxSeries(new TilesFXSeries<>(series1, Tile.BLUE, new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0, Tile.BLUE), new Stop(1, Color.TRANSPARENT)))).build();
    lineChartTile = TileBuilder.create().skinType(SkinType.SMOOTHED_CHART).prefSize(TILE_WIDTH, TILE_HEIGHT).title("SmoothedChart Tile").smoothing(false).series(series2, series3).build();
    highLowTile = TileBuilder.create().skinType(SkinType.HIGH_LOW).prefSize(TILE_WIDTH, TILE_HEIGHT).title("HighLow Tile").unit("\u20AC").description("Test").text("Whatever text").referenceValue(6.7).value(8.2).build();
    timerControlTile = TileBuilder.create().skinType(SkinType.TIMER_CONTROL).prefSize(TILE_WIDTH, TILE_HEIGHT).title("TimerControl Tile").text("Whatever text").secondsVisible(true).dateVisible(true).timeSections(timeSection).running(true).build();
    numberTile = TileBuilder.create().skinType(SkinType.NUMBER).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Number Tile").text("Whatever text").value(13).unit("mb").description("Test").textVisible(true).build();
    textTile = TileBuilder.create().skinType(SkinType.TEXT).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Text Tile").text("Whatever text").description("May the force be with you\n...always").descriptionAlignment(Pos.TOP_LEFT).textVisible(true).build();
    plusMinusTile = TileBuilder.create().skinType(SkinType.PLUS_MINUS).prefSize(TILE_WIDTH, TILE_HEIGHT).maxValue(30).minValue(0).title("PlusMinus Tile").text("Whatever text").description("Test").unit("\u00B0C").build();
    sliderTile = TileBuilder.create().skinType(SkinType.SLIDER).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Slider Tile").text("Whatever text").description("Test").unit("\u00B0C").barBackgroundColor(Tile.FOREGROUND).build();
    switchTile = TileBuilder.create().skinType(SkinType.SWITCH).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Switch Tile").text("Whatever text").build();
    switchTile.setOnSwitchPressed(e -> System.out.println("Switch pressed"));
    switchTile.setOnSwitchReleased(e -> System.out.println("Switch released"));
    worldTile = TileBuilder.create().prefSize(300, TILE_HEIGHT).skinType(SkinType.WORLDMAP).title("WorldMap Tile").text("Whatever text").textVisible(false).build();
    // Update the weather information by calling weatherTile.updateWeather()
    weatherTile = TileBuilder.create().skinType(SkinType.WEATHER).prefSize(TILE_WIDTH, TILE_HEIGHT).title("YOUR CITY NAME").text("Whatever text").darkSky(darkSky).build();
    timeTile = TileBuilder.create().skinType(SkinType.TIME).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Time Tile").text("Whatever text").duration(LocalTime.of(1, 22)).description("Average reply time").textVisible(true).build();
    barChartTile = TileBuilder.create().skinType(SkinType.BAR_CHART).prefSize(TILE_WIDTH, TILE_HEIGHT).title("BarChart Tile").text("Whatever text").barChartItems(barChartItem1, barChartItem2, barChartItem3, barChartItem4).decimals(0).build();
    customTile = TileBuilder.create().skinType(SkinType.CUSTOM).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Custom Tile").text("Whatever text").graphic(new Button("Click Me")).roundedCorners(false).build();
    leaderBoardTile = TileBuilder.create().skinType(SkinType.LEADER_BOARD).prefSize(TILE_WIDTH, TILE_HEIGHT).title("LeaderBoard Tile").text("Whatever text").leaderBoardItems(leaderBoardItem1, leaderBoardItem2, leaderBoardItem3, leaderBoardItem4).build();
    mapTile = TileBuilder.create().skinType(SkinType.MAP).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Map").text("Some text").description("Description").currentLocation(new Location(51.91178, 7.63379, "Home", TileColor.MAGENTA.color)).pointsOfInterest(new Location(51.914405, 7.635732, "POI 1", TileColor.RED.color), new Location(51.912529, 7.631752, "POI 2", TileColor.BLUE.color), new Location(51.923993, 7.628906, "POI 3", TileColor.YELLOW_ORANGE.color)).mapProvider(MapProvider.TOPO).build();
    radialChartTile = TileBuilder.create().skinType(SkinType.RADIAL_CHART).prefSize(TILE_WIDTH, TILE_HEIGHT).title("RadialChart").text("Some text").textVisible(false).chartData(chartData1, chartData2, chartData3, chartData4).build();
    donutChartTile = TileBuilder.create().skinType(SkinType.DONUT_CHART).prefSize(TILE_WIDTH, TILE_HEIGHT).title("DonutChart").text("Some text").textVisible(false).chartData(chartData1, chartData2, chartData3, chartData4).build();
    circularProgressTile = TileBuilder.create().skinType(SkinType.CIRCULAR_PROGRESS).prefSize(TILE_WIDTH, TILE_HEIGHT).title("CircularProgress").text("Some text").unit("\u0025").build();
    stockTile = TileBuilder.create().skinType(SkinType.STOCK).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Stock").minValue(0).maxValue(1000).averagingPeriod(100).build();
    gaugeSparkLineTile = TileBuilder.create().skinType(SkinType.GAUGE_SPARK_LINE).prefSize(TILE_WIDTH, TILE_HEIGHT).title("GaugeSparkLine").animated(true).textVisible(false).averagingPeriod(25).autoReferenceValue(true).barColor(Tile.YELLOW_ORANGE).barBackgroundColor(Color.rgb(255, 255, 255, 0.1)).sections(new eu.hansolo.tilesfx.Section(0, 33, Tile.LIGHT_GREEN), new eu.hansolo.tilesfx.Section(33, 67, Tile.YELLOW), new eu.hansolo.tilesfx.Section(67, 100, Tile.LIGHT_RED)).sectionsVisible(true).highlightSections(true).strokeWithGradient(true).gradientStops(new Stop(0.0, Tile.LIGHT_GREEN), new Stop(0.33, Tile.LIGHT_GREEN), new Stop(0.33, Tile.YELLOW), new Stop(0.67, Tile.YELLOW), new Stop(0.67, Tile.LIGHT_RED), new Stop(1.0, Tile.LIGHT_RED)).build();
    radarChartTile1 = TileBuilder.create().skinType(SkinType.RADAR_CHART).prefSize(TILE_WIDTH, TILE_HEIGHT).minValue(0).maxValue(50).title("RadarChart Sector").unit("Unit").radarChartMode(Mode.SECTOR).gradientStops(new Stop(0.00000, Color.TRANSPARENT), new Stop(0.00001, Color.web("#3552a0")), new Stop(0.09090, Color.web("#456acf")), new Stop(0.27272, Color.web("#45a1cf")), new Stop(0.36363, Color.web("#30c8c9")), new Stop(0.45454, Color.web("#30c9af")), new Stop(0.50909, Color.web("#56d483")), new Stop(0.72727, Color.web("#9adb49")), new Stop(0.81818, Color.web("#efd750")), new Stop(0.90909, Color.web("#ef9850")), new Stop(1.00000, Color.web("#ef6050"))).text("Test").chartData(chartData1, chartData2, chartData3, chartData4, chartData5, chartData6, chartData7, chartData8).tooltipText("").animated(true).build();
    radarChartTile2 = TileBuilder.create().skinType(SkinType.RADAR_CHART).prefSize(TILE_WIDTH, TILE_HEIGHT).minValue(0).maxValue(50).title("RadarChart Polygon").unit("Unit").radarChartMode(Mode.POLYGON).gradientStops(new Stop(0.00000, Color.TRANSPARENT), new Stop(0.00001, Color.web("#3552a0")), new Stop(0.09090, Color.web("#456acf")), new Stop(0.27272, Color.web("#45a1cf")), new Stop(0.36363, Color.web("#30c8c9")), new Stop(0.45454, Color.web("#30c9af")), new Stop(0.50909, Color.web("#56d483")), new Stop(0.72727, Color.web("#9adb49")), new Stop(0.81818, Color.web("#efd750")), new Stop(0.90909, Color.web("#ef9850")), new Stop(1.00000, Color.web("#ef6050"))).text("Test").chartData(chartData1, chartData2, chartData3, chartData4, chartData5, chartData6, chartData7, chartData8).tooltipText("").animated(true).build();
    smoothAreaChartTile = TileBuilder.create().skinType(SkinType.SMOOTH_AREA_CHART).prefSize(TILE_WIDTH, TILE_HEIGHT).minValue(0).maxValue(40).title("SmoothAreaChart").unit("Unit").text("Test").chartData(smoothChartData1, smoothChartData2, smoothChartData3, smoothChartData4).tooltipText("").animated(true).build();
    countryTile = TileBuilder.create().skinType(SkinType.COUNTRY).prefSize(TILE_WIDTH, TILE_HEIGHT).minValue(0).maxValue(40).title("Country").unit("Unit").country(Country.DE).tooltipText("").animated(true).build();
    ephemerisTile = TileBuilder.create().skinType(SkinType.EPHEMERIS).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Ephemeris").currentLocation(new Location(51.911515, 7.6340026, "Hiltrup")).text("Hiltrup").build();
    characterTile = TileBuilder.create().skinType(SkinType.CHARACTER).prefSize(TILE_WIDTH, TILE_HEIGHT).title("Character").titleAlignment(TextAlignment.CENTER).description("G").build();
    flipTile = TileBuilder.create().skinType(SkinType.FLIP).prefSize(TILE_WIDTH, TILE_HEIGHT).characters(Helper.TIME_0_TO_5).flipTimeInMS(500).flipText(" ").build();
    switchSliderTile = TileBuilder.create().skinType(SkinType.SWITCH_SLIDER).prefSize(TILE_WIDTH, TILE_HEIGHT).title("SwitchSlider").text("Test").build();
    dateTile = TileBuilder.create().skinType(SkinType.DATE).prefSize(TILE_WIDTH, TILE_HEIGHT).build();
    ZonedDateTime now = ZonedDateTime.now();
    List<ChartData> calendarData = new ArrayList<>(10);
    calendarData.add(new ChartData("Item 1", now.minusDays(1).toInstant()));
    calendarData.add(new ChartData("Item 2", now.plusDays(2).toInstant()));
    calendarData.add(new ChartData("Item 3", now.plusDays(10).toInstant()));
    calendarData.add(new ChartData("Item 4", now.plusDays(15).toInstant()));
    calendarData.add(new ChartData("Item 5", now.plusDays(15).toInstant()));
    calendarData.add(new ChartData("Item 6", now.plusDays(20).toInstant()));
    calendarData.add(new ChartData("Item 7", now.plusDays(7).toInstant()));
    calendarData.add(new ChartData("Item 8", now.minusDays(1).toInstant()));
    calendarData.add(new ChartData("Item 9", now.toInstant()));
    calendarData.add(new ChartData("Item 10", now.toInstant()));
    calendarTile = TileBuilder.create().skinType(SkinType.CALENDAR).prefSize(TILE_WIDTH, TILE_HEIGHT).chartData(calendarData).build();
    TreeNode tree = new TreeNode(new ChartData("ROOT"));
    TreeNode first = new TreeNode(new ChartData("1st", 8.3, Tile.BLUE), tree);
    TreeNode second = new TreeNode(new ChartData("2nd", 2.2, Tile.ORANGE), tree);
    TreeNode third = new TreeNode(new ChartData("3rd", 1.4, Tile.PINK), tree);
    TreeNode fourth = new TreeNode(new ChartData("4th", 1.2, Tile.LIGHT_GREEN), tree);
    TreeNode jan = new TreeNode(new ChartData("Jan", 3.5), first);
    TreeNode feb = new TreeNode(new ChartData("Feb", 3.1), first);
    TreeNode mar = new TreeNode(new ChartData("Mar", 1.7), first);
    TreeNode apr = new TreeNode(new ChartData("Apr", 1.1), second);
    TreeNode may = new TreeNode(new ChartData("May", 0.8), second);
    TreeNode jun = new TreeNode(new ChartData("Jun", 0.3), second);
    TreeNode jul = new TreeNode(new ChartData("Jul", 0.7), third);
    TreeNode aug = new TreeNode(new ChartData("Aug", 0.6), third);
    TreeNode sep = new TreeNode(new ChartData("Sep", 0.1), third);
    TreeNode oct = new TreeNode(new ChartData("Oct", 0.5), fourth);
    TreeNode nov = new TreeNode(new ChartData("Nov", 0.4), fourth);
    TreeNode dec = new TreeNode(new ChartData("Dec", 0.3), fourth);
    sunburstTile = TileBuilder.create().skinType(SkinType.SUNBURST).prefSize(TILE_WIDTH, TILE_HEIGHT).title("SunburstTile").textVisible(false).sunburstTree(tree).sunburstBackgroundColor(Tile.BACKGROUND).sunburstTextColor(Tile.BACKGROUND).sunburstUseColorFromParent(true).sunburstTextOrientation(TextOrientation.TANGENT).sunburstAutoTextColor(true).sunburstUseChartDataTextColor(true).sunburstInteractive(true).build();
    matrixTile = TileBuilder.create().skinType(SkinType.MATRIX).prefSize(TILE_WIDTH, TILE_HEIGHT).title("MatrixTileSkin").text("Any Text").textVisible(false).animated(true).matrixSize(8, 50).chartData(chartData1, chartData2, chartData3, chartData4, chartData5, chartData6, chartData7, chartData8).build();
    radialPercentageTile = TileBuilder.create().skinType(SkinType.RADIAL_PERCENTAGE).prefSize(TILE_WIDTH, TILE_HEIGHT).backgroundColor(Color.web("#26262D")).maxValue(1000).title("RadialPercentageSkin").description("Product 1").textVisible(false).chartData(chartData1, chartData2, chartData3).animated(true).referenceValue(100).value(chartData1.getValue()).descriptionColor(Tile.GRAY).barColor(Tile.BLUE).decimals(0).build();
    lastTimerCall = System.nanoTime();
    timer = new AnimationTimer() {

        @Override
        public void handle(long now) {
            if (now > lastTimerCall + 3_500_000_000L) {
                percentageTile.setValue(RND.nextDouble() * percentageTile.getRange() * 1.5 + percentageTile.getMinValue());
                gaugeTile.setValue(RND.nextDouble() * gaugeTile.getRange() * 1.5 + gaugeTile.getMinValue());
                sparkLineTile.setValue(RND.nextDouble() * sparkLineTile.getRange() * 1.5 + sparkLineTile.getMinValue());
                // value.set(RND.nextDouble() * sparkLineTile.getRange() * 1.5 + sparkLineTile.getMinValue());
                // sparkLineTile.setValue(20);
                highLowTile.setValue(RND.nextDouble() * 10);
                series1.getData().forEach(data -> data.setYValue(RND.nextInt(100)));
                series2.getData().forEach(data -> data.setYValue(RND.nextInt(30)));
                series3.getData().forEach(data -> data.setYValue(RND.nextInt(10)));
                chartData1.setValue(RND.nextDouble() * 50);
                chartData2.setValue(RND.nextDouble() * 50);
                chartData3.setValue(RND.nextDouble() * 50);
                chartData4.setValue(RND.nextDouble() * 50);
                chartData5.setValue(RND.nextDouble() * 50);
                chartData6.setValue(RND.nextDouble() * 50);
                chartData7.setValue(RND.nextDouble() * 50);
                chartData8.setValue(RND.nextDouble() * 50);
                barChartTile.getBarChartItems().get(RND.nextInt(3)).setValue(RND.nextDouble() * 80);
                leaderBoardTile.getLeaderBoardItems().get(RND.nextInt(3)).setValue(RND.nextDouble() * 80);
                circularProgressTile.setValue(RND.nextDouble() * 120);
                stockTile.setValue(RND.nextDouble() * 50 + 500);
                gaugeSparkLineTile.setValue(RND.nextDouble() * 100);
                countryTile.setValue(RND.nextDouble() * 100);
                smoothChartData1.setValue(smoothChartData2.getValue());
                smoothChartData2.setValue(smoothChartData3.getValue());
                smoothChartData3.setValue(smoothChartData4.getValue());
                smoothChartData4.setValue(RND.nextDouble() * 25);
                characterTile.setDescription(Helper.ALPHANUMERIC[RND.nextInt(Helper.ALPHANUMERIC.length - 1)]);
                flipTile.setFlipText(Helper.TIME_0_TO_5[RND.nextInt(Helper.TIME_0_TO_5.length - 1)]);
                radialPercentageTile.setValue(chartData1.getValue());
                lastTimerCall = now;
            }
        }
    };
}
Also used : Button(javafx.scene.control.Button) DarkSky(eu.hansolo.tilesfx.weather.DarkSky) Pos(javafx.geometry.Pos) Scene(javafx.scene.Scene) Location(eu.hansolo.tilesfx.tools.Location) TreeNode(eu.hansolo.tilesfx.tools.TreeNode) TileColor(eu.hansolo.tilesfx.Tile.TileColor) CycleMethod(javafx.scene.paint.CycleMethod) ZonedDateTime(java.time.ZonedDateTime) BarChartItem(eu.hansolo.tilesfx.skins.BarChartItem) DoubleProperty(javafx.beans.property.DoubleProperty) LinearGradient(javafx.scene.paint.LinearGradient) Random(java.util.Random) Mode(eu.hansolo.tilesfx.chart.RadarChart.Mode) Unit(eu.hansolo.tilesfx.weather.DarkSky.Unit) XYChart(javafx.scene.chart.XYChart) MapProvider(eu.hansolo.tilesfx.Tile.MapProvider) ArrayList(java.util.ArrayList) Application(javafx.application.Application) Parent(javafx.scene.Parent) PerspectiveCamera(javafx.scene.PerspectiveCamera) ChartData(eu.hansolo.tilesfx.chart.ChartData) Insets(javafx.geometry.Insets) Helper(eu.hansolo.tilesfx.tools.Helper) FlowGridPane(eu.hansolo.tilesfx.tools.FlowGridPane) BackgroundFill(javafx.scene.layout.BackgroundFill) Locale(java.util.Locale) TilesFXSeries(eu.hansolo.tilesfx.chart.TilesFXSeries) Country(eu.hansolo.tilesfx.tools.Country) LocalTime(java.time.LocalTime) TextAlignment(javafx.scene.text.TextAlignment) Language(eu.hansolo.tilesfx.weather.DarkSky.Language) TextOrientation(eu.hansolo.tilesfx.chart.SunburstChart.TextOrientation) Color(javafx.scene.paint.Color) ChartType(eu.hansolo.tilesfx.Tile.ChartType) Stop(javafx.scene.paint.Stop) Node(javafx.scene.Node) Background(javafx.scene.layout.Background) AnimationTimer(javafx.animation.AnimationTimer) List(java.util.List) Stage(javafx.stage.Stage) SkinType(eu.hansolo.tilesfx.Tile.SkinType) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableList(javafx.collections.ObservableList) LeaderBoardItem(eu.hansolo.tilesfx.skins.LeaderBoardItem) CornerRadii(javafx.scene.layout.CornerRadii) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) Stop(javafx.scene.paint.Stop) BarChartItem(eu.hansolo.tilesfx.skins.BarChartItem) ArrayList(java.util.ArrayList) DarkSky(eu.hansolo.tilesfx.weather.DarkSky) Button(javafx.scene.control.Button) ZonedDateTime(java.time.ZonedDateTime) TreeNode(eu.hansolo.tilesfx.tools.TreeNode) ChartData(eu.hansolo.tilesfx.chart.ChartData) AnimationTimer(javafx.animation.AnimationTimer) TileColor(eu.hansolo.tilesfx.Tile.TileColor) Color(javafx.scene.paint.Color) TilesFXSeries(eu.hansolo.tilesfx.chart.TilesFXSeries) LinearGradient(javafx.scene.paint.LinearGradient) XYChart(javafx.scene.chart.XYChart) LeaderBoardItem(eu.hansolo.tilesfx.skins.LeaderBoardItem) Location(eu.hansolo.tilesfx.tools.Location)

Example 2 with TreeNode

use of eu.hansolo.tilesfx.tools.TreeNode in project tilesfx by HanSolo.

the class SunburstChart method drawChart.

private void drawChart() {
    levelMap.clear();
    for (int i = 0; i <= maxLevel; i++) {
        levelMap.put(i, new ArrayList<>());
    }
    root.stream().forEach(node -> levelMap.get(node.getDepth()).add(node));
    boolean isInteractive = isInteractive();
    double ringStepSize = size * 0.8 / maxLevel;
    double ringRadiusStep = ringStepSize * 0.5;
    double barWidth = isInteractive ? ringStepSize * 0.5 : ringStepSize * 0.49;
    double textRadiusStep = size * 0.4 / maxLevel;
    double segmentStrokeWidth = ringStepSize * 0.01;
    Color bkgColor = getBackgroundColor();
    Color textColor = getTextColor();
    TextOrientation textOrientation = getTextOrientation();
    double maxTextWidth = barWidth * 0.9;
    chartCtx.clearRect(0, 0, size, size);
    chartCtx.setFill(isInteractive ? Color.TRANSPARENT : bkgColor);
    chartCtx.fillRect(0, 0, size, size);
    chartCtx.setFont(Fonts.latoRegular(barWidth * 0.2));
    chartCtx.setTextBaseline(VPos.CENTER);
    chartCtx.setTextAlign(TextAlignment.CENTER);
    chartCtx.setLineCap(StrokeLineCap.BUTT);
    segments.clear();
    for (int level = 1; level <= maxLevel; level++) {
        List<TreeNode> nodesAtLevel = levelMap.get(level);
        double xy = centerX - ringStepSize * level * 0.5;
        double wh = ringStepSize * level;
        double outerRadius = ringRadiusStep * level + barWidth * 0.5;
        double innerRadius = outerRadius - barWidth;
        double segmentStartAngle;
        double segmentEndAngle = 0;
        for (TreeNode node : nodesAtLevel) {
            ChartData segmentData = node.getData();
            double segmentAngle = node.getParentAngle() * node.getPercentage();
            Color segmentColor = getUseColorFromParent() ? node.getMyRoot().getData().getFillColor() : segmentData.getFillColor();
            segmentStartAngle = 90 + segmentEndAngle;
            segmentEndAngle -= segmentAngle;
            // Only draw if segment fill color is not TRANSPARENT
            if (!Color.TRANSPARENT.equals(segmentData.getFillColor())) {
                double value = segmentData.getValue();
                if (isInteractive) {
                    segments.add(createSegment(-segmentStartAngle, -segmentStartAngle + segmentAngle, innerRadius, outerRadius, segmentColor, bkgColor, node));
                } else {
                    // Segment Fill
                    chartCtx.setLineWidth(barWidth);
                    chartCtx.setStroke(segmentColor);
                    chartCtx.strokeArc(xy, xy, wh, wh, segmentStartAngle, -segmentAngle, ArcType.OPEN);
                    // Segment Stroke
                    double radStart = Math.toRadians(segmentStartAngle);
                    double cosStart = Math.cos(radStart);
                    double sinStart = Math.sin(radStart);
                    double x1 = centerX + innerRadius * cosStart;
                    double y1 = centerY - innerRadius * sinStart;
                    double x2 = centerX + outerRadius * cosStart;
                    double y2 = centerY - outerRadius * sinStart;
                    chartCtx.setLineWidth(segmentStrokeWidth);
                    chartCtx.setStroke(bkgColor);
                    chartCtx.strokeLine(x1, y1, x2, y2);
                }
                // Visible Data
                if (getVisibleData() != VisibleData.NONE && segmentAngle > textOrientation.getMaxAngle()) {
                    double radText = Math.toRadians(segmentStartAngle - (segmentAngle * 0.5));
                    double cosText = Math.cos(radText);
                    double sinText = Math.sin(radText);
                    double textRadius = textRadiusStep * level;
                    double textX = centerX + textRadius * cosText;
                    double textY = centerY - textRadius * sinText;
                    chartCtx.setFill(getUseChartDataTextColor() ? segmentData.getTextColor() : textColor);
                    chartCtx.save();
                    chartCtx.translate(textX, textY);
                    rotateContextForText(chartCtx, segmentStartAngle, -(segmentAngle * 0.5), textOrientation);
                    switch(getVisibleData()) {
                        case VALUE:
                            chartCtx.fillText(String.format(Locale.US, formatString, value), 0, 0, maxTextWidth);
                            break;
                        case NAME:
                            chartCtx.fillText(segmentData.getName(), 0, 0, maxTextWidth);
                            break;
                        case NAME_VALUE:
                            chartCtx.fillText(String.join("", segmentData.getName(), " (", String.format(Locale.US, formatString, value), ")"), 0, 0, maxTextWidth);
                            break;
                    }
                    chartCtx.restore();
                }
            }
        }
    }
    segmentPane.getChildren().setAll(segments);
}
Also used : TreeNode(eu.hansolo.tilesfx.tools.TreeNode) Color(javafx.scene.paint.Color) Paint(javafx.scene.paint.Paint)

Example 3 with TreeNode

use of eu.hansolo.tilesfx.tools.TreeNode in project tilesfx by HanSolo.

the class SunburstChart method createSegment.

private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Color FILL, final Color STROKE, final TreeNode NODE) {
    double startAngleRad = Math.toRadians(START_ANGLE + 90);
    double endAngleRad = Math.toRadians(END_ANGLE + 90);
    boolean largeAngle = Math.abs(END_ANGLE - START_ANGLE) > 180.0;
    double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
    double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);
    double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
    double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);
    double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
    double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);
    double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
    double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);
    MoveTo moveTo1 = new MoveTo(x1, y1);
    LineTo lineTo2 = new LineTo(x2, y2);
    ArcTo arcTo3 = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
    LineTo lineTo4 = new LineTo(x4, y4);
    ArcTo arcTo1 = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);
    Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);
    path.setFill(FILL);
    path.setStroke(STROKE);
    String tooltipText = new StringBuilder(NODE.getData().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getData().getValue())).toString();
    Tooltip.install(path, new Tooltip(tooltipText));
    path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));
    return path;
}
Also used : Path(javafx.scene.shape.Path) Path(javafx.scene.shape.Path) Fonts(eu.hansolo.tilesfx.fonts.Fonts) TreeNode(eu.hansolo.tilesfx.tools.TreeNode) LineTo(javafx.scene.shape.LineTo) ArcTo(javafx.scene.shape.ArcTo) HashMap(java.util.HashMap) IntegerProperty(javafx.beans.property.IntegerProperty) InvalidationListener(javafx.beans.InvalidationListener) ArrayList(java.util.ArrayList) Insets(javafx.geometry.Insets) Helper(eu.hansolo.tilesfx.tools.Helper) BorderWidths(javafx.scene.layout.BorderWidths) VPos(javafx.geometry.VPos) TreeNodeEvent(eu.hansolo.tilesfx.events.TreeNodeEvent) BackgroundFill(javafx.scene.layout.BackgroundFill) Locale(java.util.Locale) Map(java.util.Map) MoveTo(javafx.scene.shape.MoveTo) TextAlignment(javafx.scene.text.TextAlignment) Helper.clamp(eu.hansolo.tilesfx.tools.Helper.clamp) Tooltip(javafx.scene.control.Tooltip) Pane(javafx.scene.layout.Pane) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) GraphicsContext(javafx.scene.canvas.GraphicsContext) Node(javafx.scene.Node) Border(javafx.scene.layout.Border) ObjectPropertyBase(javafx.beans.property.ObjectPropertyBase) WeakEventHandler(javafx.event.WeakEventHandler) Canvas(javafx.scene.canvas.Canvas) IntegerPropertyBase(javafx.beans.property.IntegerPropertyBase) Background(javafx.scene.layout.Background) BorderStrokeStyle(javafx.scene.layout.BorderStrokeStyle) BooleanPropertyBase(javafx.beans.property.BooleanPropertyBase) BorderStroke(javafx.scene.layout.BorderStroke) ArcType(javafx.scene.shape.ArcType) BooleanProperty(javafx.beans.property.BooleanProperty) List(java.util.List) Region(javafx.scene.layout.Region) Paint(javafx.scene.paint.Paint) DefaultProperty(javafx.beans.DefaultProperty) EventType(eu.hansolo.tilesfx.events.TreeNodeEvent.EventType) StrokeLineCap(javafx.scene.shape.StrokeLineCap) ObservableList(javafx.collections.ObservableList) CornerRadii(javafx.scene.layout.CornerRadii) MoveTo(javafx.scene.shape.MoveTo) LineTo(javafx.scene.shape.LineTo) ArcTo(javafx.scene.shape.ArcTo) Tooltip(javafx.scene.control.Tooltip) TreeNodeEvent(eu.hansolo.tilesfx.events.TreeNodeEvent)

Example 4 with TreeNode

use of eu.hansolo.tilesfx.tools.TreeNode in project tilesfx by HanSolo.

the class SunburstChart method prepareData.

private void prepareData() {
    root = tree.getTreeRoot();
    maxLevel = root.getMaxLevel();
    // Create map of all nodes per level
    levelMap.clear();
    for (int i = 0; i <= maxLevel; i++) {
        levelMap.put(i, new ArrayList<>());
    }
    root.stream().forEach(node -> levelMap.get(node.getDepth()).add(node));
    for (int level = 1; level < maxLevel; level++) {
        List<TreeNode> treeNodeList = levelMap.get(level);
        treeNodeList.stream().filter(node -> node.getChildren().isEmpty()).forEach(node -> node.addNode(new TreeNode(new ChartData("", 0, Color.TRANSPARENT), node)));
    }
}
Also used : Path(javafx.scene.shape.Path) Fonts(eu.hansolo.tilesfx.fonts.Fonts) TreeNode(eu.hansolo.tilesfx.tools.TreeNode) LineTo(javafx.scene.shape.LineTo) ArcTo(javafx.scene.shape.ArcTo) HashMap(java.util.HashMap) IntegerProperty(javafx.beans.property.IntegerProperty) InvalidationListener(javafx.beans.InvalidationListener) ArrayList(java.util.ArrayList) Insets(javafx.geometry.Insets) Helper(eu.hansolo.tilesfx.tools.Helper) BorderWidths(javafx.scene.layout.BorderWidths) VPos(javafx.geometry.VPos) TreeNodeEvent(eu.hansolo.tilesfx.events.TreeNodeEvent) BackgroundFill(javafx.scene.layout.BackgroundFill) Locale(java.util.Locale) Map(java.util.Map) MoveTo(javafx.scene.shape.MoveTo) TextAlignment(javafx.scene.text.TextAlignment) Helper.clamp(eu.hansolo.tilesfx.tools.Helper.clamp) Tooltip(javafx.scene.control.Tooltip) Pane(javafx.scene.layout.Pane) Color(javafx.scene.paint.Color) ObjectProperty(javafx.beans.property.ObjectProperty) GraphicsContext(javafx.scene.canvas.GraphicsContext) Node(javafx.scene.Node) Border(javafx.scene.layout.Border) ObjectPropertyBase(javafx.beans.property.ObjectPropertyBase) WeakEventHandler(javafx.event.WeakEventHandler) Canvas(javafx.scene.canvas.Canvas) IntegerPropertyBase(javafx.beans.property.IntegerPropertyBase) Background(javafx.scene.layout.Background) BorderStrokeStyle(javafx.scene.layout.BorderStrokeStyle) BooleanPropertyBase(javafx.beans.property.BooleanPropertyBase) BorderStroke(javafx.scene.layout.BorderStroke) ArcType(javafx.scene.shape.ArcType) BooleanProperty(javafx.beans.property.BooleanProperty) List(java.util.List) Region(javafx.scene.layout.Region) Paint(javafx.scene.paint.Paint) DefaultProperty(javafx.beans.DefaultProperty) EventType(eu.hansolo.tilesfx.events.TreeNodeEvent.EventType) StrokeLineCap(javafx.scene.shape.StrokeLineCap) ObservableList(javafx.collections.ObservableList) CornerRadii(javafx.scene.layout.CornerRadii) TreeNode(eu.hansolo.tilesfx.tools.TreeNode) Paint(javafx.scene.paint.Paint)

Example 5 with TreeNode

use of eu.hansolo.tilesfx.tools.TreeNode in project tilesfx by HanSolo.

the class TileBuilder method build.

public final Tile build() {
    final Tile CONTROL;
    if (properties.containsKey("skinType")) {
        SkinType skinType = ((ObjectProperty<SkinType>) properties.get("skinType")).get();
        CONTROL = new Tile(skinType);
        switch(skinType) {
            case SMOOTHED_CHART:
                break;
            case BAR_CHART:
                break;
            case CLOCK:
                break;
            case GAUGE:
                CONTROL.setAnimated(true);
                CONTROL.setTickLabelDecimals(0);
                CONTROL.setBarColor(Tile.FOREGROUND);
                CONTROL.setThresholdColor(Tile.BLUE);
                CONTROL.setThresholdVisible(true);
                break;
            case HIGH_LOW:
                CONTROL.setMaxValue(Double.MAX_VALUE);
                CONTROL.setDecimals(2);
                CONTROL.setTickLabelDecimals(1);
                break;
            case PERCENTAGE:
                CONTROL.setAnimated(true);
                CONTROL.setThresholdColor(Tile.GRAY);
                CONTROL.setTickLabelDecimals(0);
                break;
            case PLUS_MINUS:
                break;
            case SLIDER:
                CONTROL.setBarBackgroundColor(Tile.FOREGROUND);
                break;
            case SPARK_LINE:
                CONTROL.setTextVisible(false);
                CONTROL.setAnimated(false);
                CONTROL.setAveragingEnabled(true);
                CONTROL.setAveragingPeriod(10);
                CONTROL.setDecimals(0);
                CONTROL.setTickLabelDecimals(0);
                break;
            case SWITCH:
                break;
            case WORLDMAP:
                CONTROL.setPrefSize(380, 250);
                break;
            case TIMER_CONTROL:
                CONTROL.setSectionsVisible(true);
                CONTROL.setHighlightSections(true);
                CONTROL.setCheckSectionsForValue(true);
                break;
            case NUMBER:
                break;
            case TEXT:
                break;
            case WEATHER:
                break;
            case TIME:
                break;
            case CUSTOM:
                break;
            case LEADER_BOARD:
                break;
            case MAP:
                break;
            case RADIAL_CHART:
                CONTROL.setAnimated(true);
                break;
            case DONUT_CHART:
                CONTROL.setAnimated(true);
                break;
            case CIRCULAR_PROGRESS:
                CONTROL.setBarBackgroundColor(CONTROL.getBackgroundColor().brighter());
                CONTROL.setAnimated(true);
                break;
            case STOCK:
                CONTROL.setAnimated(false);
                CONTROL.setAveragingPeriod(720);
                CONTROL.setAveragingEnabled(true);
                CONTROL.setDecimals(2);
                CONTROL.setTickLabelDecimals(2);
                CONTROL.setThresholdColor(Tile.GRAY);
                CONTROL.setTextVisible(false);
                break;
            case GAUGE_SPARK_LINE:
                CONTROL.setBarColor(Tile.BLUE);
                CONTROL.setAngleRange(270);
                break;
            case SMOOTH_AREA_CHART:
                CONTROL.setSmoothing(true);
                CONTROL.setChartType(ChartType.AREA);
                break;
            case RADAR_CHART:
                break;
            case COUNTRY:
                break;
            case EPHEMERIS:
                break;
            case CHARACTER:
                break;
            case FLIP:
                break;
            case SWITCH_SLIDER:
                CONTROL.setBarBackgroundColor(Tile.FOREGROUND);
                break;
            case DATE:
                CONTROL.setTitleAlignment(TextAlignment.CENTER);
                CONTROL.setTextAlignment(TextAlignment.CENTER);
                break;
            case CALENDAR:
                CONTROL.setTitleAlignment(TextAlignment.CENTER);
                CONTROL.setTextAlignment(TextAlignment.CENTER);
                break;
            case SUNBURST:
                break;
            case MATRIX:
                break;
            case RADIAL_PERCENTAGE:
                CONTROL.setBarBackgroundColor(CONTROL.getBackgroundColor().brighter());
                CONTROL.setAnimated(true);
                break;
            default:
                break;
        }
    } else {
        CONTROL = new Tile();
    }
    // Make sure that sections, areas and markers will be added first
    if (properties.keySet().contains("sectionsArray")) {
        CONTROL.setSections(((ObjectProperty<Section[]>) properties.get("sectionsArray")).get());
    }
    if (properties.keySet().contains("sectionsList")) {
        CONTROL.setSections(((ObjectProperty<List<Section>>) properties.get("sectionsList")).get());
    }
    if (properties.keySet().contains("characterArray")) {
        CONTROL.setCharacters(((ObjectProperty<String[]>) properties.get("characterArray")).get());
    }
    if (properties.keySet().contains("foregroundBaseColor")) {
        CONTROL.setForegroundBaseColor(((ObjectProperty<Color>) properties.get("foregroundBaseColor")).get());
    }
    if (properties.keySet().contains("minValue")) {
        CONTROL.setMinValue(((DoubleProperty) properties.get("minValue")).get());
    }
    if (properties.keySet().contains("maxValue")) {
        CONTROL.setMaxValue(((DoubleProperty) properties.get("maxValue")).get());
    }
    if (properties.keySet().contains("alarmsArray")) {
        CONTROL.setAlarms(((ObjectProperty<Alarm[]>) properties.get("alarmsArray")).get());
    }
    if (properties.keySet().contains("alarmsList")) {
        CONTROL.setAlarms(((ObjectProperty<List<Alarm>>) properties.get("alarmsList")).get());
    }
    if (properties.keySet().contains("timeSectionsArray")) {
        CONTROL.setTimeSections(((ObjectProperty<TimeSection[]>) properties.get("timeSectionsArray")).get());
    }
    if (properties.keySet().contains("timeSectionsList")) {
        CONTROL.setTimeSections(((ObjectProperty<List<TimeSection>>) properties.get("timeSectionsList")).get());
    }
    if (properties.keySet().contains("seriesArray")) {
        CONTROL.setSeries(((ObjectProperty<Series<String, Number>[]>) properties.get("seriesArray")).get());
    }
    if (properties.keySet().contains("seriesList")) {
        CONTROL.setSeries(((ObjectProperty<List<Series<String, Number>>>) properties.get("seriesList")).get());
    }
    if (properties.keySet().contains("tilesFxSeriesArray")) {
        CONTROL.setTilesFXSeries(((ObjectProperty<TilesFXSeries<String, Number>[]>) properties.get("tilesFxSeriesArray")).get());
    }
    if (properties.keySet().contains("tilesFxSeriesList")) {
        CONTROL.setTilesFXSeries(((ObjectProperty<List<TilesFXSeries<String, Number>>>) properties.get("tilesFxSeriesList")).get());
    }
    if (properties.keySet().contains("barChartItemsArray")) {
        CONTROL.setBarChartItems(((ObjectProperty<BarChartItem[]>) properties.get("barChartItemsArray")).get());
    }
    if (properties.keySet().contains("barChartItemsList")) {
        CONTROL.setBarChartItems(((ObjectProperty<List<BarChartItem>>) properties.get("barChartItemsList")).get());
    }
    if (properties.keySet().contains("leaderBoardItemsArray")) {
        CONTROL.setLeaderBoardItems(((ObjectProperty<LeaderBoardItem[]>) properties.get("leaderBoardItemsArray")).get());
    }
    if (properties.keySet().contains("leaderBoardItemsList")) {
        CONTROL.setLeaderBoardItems(((ObjectProperty<List<LeaderBoardItem>>) properties.get("leaderBoardItemsList")).get());
    }
    if (properties.keySet().contains("gradientStopsArray")) {
        CONTROL.setGradientStops(((ObjectProperty<Stop[]>) properties.get("gradientStopsArray")).get());
    }
    if (properties.keySet().contains("gradientStopsList")) {
        CONTROL.setGradientStops(((ObjectProperty<List<Stop>>) properties.get("gradientStopsList")).get());
    }
    if (properties.keySet().contains("chartDataArray")) {
        CONTROL.setChartData(((ObjectProperty<ChartData[]>) properties.get("chartDataArray")).get());
    }
    if (properties.keySet().contains("chartDataList")) {
        CONTROL.setChartData(((ObjectProperty<List<ChartData>>) properties.get("chartDataList")).get());
    }
    if (properties.keySet().contains("poiArray")) {
        CONTROL.setPoiLocations(((ObjectProperty<Location[]>) properties.get("poiArray")).get());
    }
    if (properties.keySet().contains("poiList")) {
        CONTROL.setPoiList(((ObjectProperty<List<Location>>) properties.get("poiList")).get());
    }
    if (properties.keySet().contains("trackArray")) {
        CONTROL.setTrack(((ObjectProperty<Location[]>) properties.get("trackArray")).get());
    }
    if (properties.keySet().contains("trackList")) {
        CONTROL.setTrack(((ObjectProperty<List<Location>>) properties.get("trackList")).get());
    }
    for (String key : properties.keySet()) {
        if ("prefSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            CONTROL.setPrefSize(dim.getWidth(), dim.getHeight());
        } else if ("minSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            CONTROL.setMinSize(dim.getWidth(), dim.getHeight());
        } else if ("maxSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            CONTROL.setMaxSize(dim.getWidth(), dim.getHeight());
        } else if ("prefWidth".equals(key)) {
            CONTROL.setPrefWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("prefHeight".equals(key)) {
            CONTROL.setPrefHeight(((DoubleProperty) properties.get(key)).get());
        } else if ("minWidth".equals(key)) {
            CONTROL.setMinWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("minHeight".equals(key)) {
            CONTROL.setMinHeight(((DoubleProperty) properties.get(key)).get());
        } else if ("maxWidth".equals(key)) {
            CONTROL.setMaxWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("maxHeight".equals(key)) {
            CONTROL.setMaxHeight(((DoubleProperty) properties.get(key)).get());
        } else if ("scaleX".equals(key)) {
            CONTROL.setScaleX(((DoubleProperty) properties.get(key)).get());
        } else if ("scaleY".equals(key)) {
            CONTROL.setScaleY(((DoubleProperty) properties.get(key)).get());
        } else if ("layoutX".equals(key)) {
            CONTROL.setLayoutX(((DoubleProperty) properties.get(key)).get());
        } else if ("layoutY".equals(key)) {
            CONTROL.setLayoutY(((DoubleProperty) properties.get(key)).get());
        } else if ("translateX".equals(key)) {
            CONTROL.setTranslateX(((DoubleProperty) properties.get(key)).get());
        } else if ("translateY".equals(key)) {
            CONTROL.setTranslateY(((DoubleProperty) properties.get(key)).get());
        } else if ("padding".equals(key)) {
            CONTROL.setPadding(((ObjectProperty<Insets>) properties.get(key)).get());
        } else if ("styleClass".equals(key)) {
            CONTROL.getStyleClass().setAll("tile");
            CONTROL.getStyleClass().addAll(((ObjectProperty<String[]>) properties.get(key)).get());
        } else if ("autoScale".equals(key)) {
            CONTROL.setAutoScale(((BooleanProperty) properties.get(key)).get());
        } else if ("value".equals(key)) {
            CONTROL.setValue(((DoubleProperty) properties.get(key)).get());
        } else if ("decimals".equals(key)) {
            CONTROL.setDecimals(((IntegerProperty) properties.get(key)).get());
        } else if ("tickLabelDecimals".equals(key)) {
            CONTROL.setTickLabelDecimals(((IntegerProperty) properties.get(key)).get());
        } else if ("title".equals(key)) {
            CONTROL.setTitle(((StringProperty) properties.get(key)).get());
        } else if ("titleAlignment".equals(key)) {
            CONTROL.setTitleAlignment(((ObjectProperty<TextAlignment>) properties.get(key)).get());
        } else if ("description".equals(key)) {
            CONTROL.setDescription(((StringProperty) properties.get(key)).get());
        } else if ("descriptionAlignment".equals(key)) {
            CONTROL.setDescriptionAlignment(((ObjectProperty<Pos>) properties.get(key)).get());
        } else if ("unit".equals(key)) {
            CONTROL.setUnit(((StringProperty) properties.get(key)).get());
        } else if ("selected".equals(key)) {
            CONTROL.setActive(((BooleanProperty) properties.get(key)).get());
        } else if ("averagingEnabled".equals(key)) {
            CONTROL.setAveragingEnabled(((BooleanProperty) properties.get(key)).get());
        } else if ("averagingPeriod".equals(key)) {
            CONTROL.setAveragingPeriod(((IntegerProperty) properties.get(key)).get());
        } else if ("startFromZero".equals(key)) {
            CONTROL.setStartFromZero(((BooleanProperty) properties.get(key)).get());
        } else if ("returnToZero".equals(key)) {
            CONTROL.setReturnToZero(((BooleanProperty) properties.get(key)).get());
        } else if ("minMeasuredValueVisible".equals(key)) {
            CONTROL.setMinMeasuredValueVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("maxMeasuredValueVisible".equals(key)) {
            CONTROL.setMaxMeasuredValueVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("oldValueVisible".equals(key)) {
            CONTROL.setOldValueVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("valueVisible".equals(key)) {
            CONTROL.setValueVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("foregroundColor".equals(key)) {
            CONTROL.setForegroundColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("backgroundColor".equals(key)) {
            CONTROL.setBackgroundColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("borderColor".equals(key)) {
            CONTROL.setBorderColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("borderWidth".equals(key)) {
            CONTROL.setBorderWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("knobColor".equals(key)) {
            CONTROL.setKnobColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("animated".equals(key)) {
            CONTROL.setAnimated(((BooleanProperty) properties.get(key)).get());
        } else if ("animationDuration".equals(key)) {
            CONTROL.setAnimationDuration(((LongProperty) properties.get(key)).get());
        } else if ("startAngle".equals(key)) {
            CONTROL.setStartAngle(((DoubleProperty) properties.get(key)).get());
        } else if ("angleRange".equals(key)) {
            CONTROL.setAngleRange(((DoubleProperty) properties.get(key)).get());
        } else if ("needleColor".equals(key)) {
            CONTROL.setNeedleColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("barColor".equals(key)) {
            CONTROL.setBarColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("barBackgroundColor".equals(key)) {
            CONTROL.setBarBackgroundColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("locale".equals(key)) {
            CONTROL.setLocale(((ObjectProperty<Locale>) properties.get(key)).get());
        } else if ("numberFormat".equals(key)) {
            CONTROL.setNumberFormat(((ObjectProperty<NumberFormat>) properties.get(key)).get());
        } else if ("shadowsEnabled".equals(key)) {
            CONTROL.setShadowsEnabled(((BooleanProperty) properties.get(key)).get());
        } else if ("style".equals(key)) {
            CONTROL.setStyle(((StringProperty) properties.get(key)).get());
        } else if ("innerShadowEnabled".equals(key)) {
            CONTROL.setInnerShadowEnabled(((BooleanProperty) properties.get(key)).get());
        } else if ("thresholdVisible".equals(key)) {
            CONTROL.setThresholdVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("averageVisible".equals(key)) {
            CONTROL.setAverageVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("sectionsVisible".equals(key)) {
            CONTROL.setSectionsVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("sectionsAlwaysVisible".equals(key)) {
            CONTROL.setSectionsAlwaysVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("sectionTextVisible".equals(key)) {
            CONTROL.setSectionTextVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("sectionIconsVisible".equals(key)) {
            CONTROL.setSectionIconsVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("highlightSections".equals(key)) {
            CONTROL.setHighlightSections(((BooleanProperty) properties.get(key)).get());
        } else if ("titleColor".equals(key)) {
            CONTROL.setTitleColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("descriptionColor".equals(key)) {
            CONTROL.setDescriptionColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("unitColor".equals(key)) {
            CONTROL.setUnitColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("valueColor".equals(key)) {
            CONTROL.setValueColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("thresholdColor".equals(key)) {
            CONTROL.setThresholdColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("orientation".equals(key)) {
            CONTROL.setOrientation(((ObjectProperty<Orientation>) properties.get(key)).get());
        } else if ("checkSectionsForValue".equals(key)) {
            CONTROL.setCheckSectionsForValue(((BooleanProperty) properties.get(key)).get());
        } else if ("checkThreshold".equals(key)) {
            CONTROL.setCheckThreshold(((BooleanProperty) properties.get(key)).get());
        } else if ("onValueChanged".equals(key)) {
            CONTROL.currentValueProperty().addListener(((ObjectProperty<InvalidationListener>) properties.get(key)).get());
        } else if ("keepAspect".equals(key)) {
            CONTROL.setKeepAspect(((BooleanProperty) properties.get(key)).get());
        } else if ("threshold".equals(key)) {
            CONTROL.setThreshold(((DoubleProperty) properties.get(key)).get());
        } else if ("referenceValue".equals(key)) {
            CONTROL.setReferenceValue(((DoubleProperty) properties.get(key)).get());
        } else if ("autoReferenceValue".equals(key)) {
            CONTROL.setAutoReferenceValue(((BooleanProperty) properties.get(key)).get());
        } else if ("customFontEnabled".equals(key)) {
            CONTROL.setCustomFontEnabled(((BooleanProperty) properties.get(key)).get());
        } else if ("customFont".equals(key)) {
            CONTROL.setCustomFont(((ObjectProperty<Font>) properties.get(key)).get());
        } else if ("alertMessage".equals(key)) {
            CONTROL.setAlertMessage(((StringProperty) properties.get(key)).get());
        } else if ("smoothing".equals(key)) {
            CONTROL.setSmoothing(((BooleanProperty) properties.get(key)).get());
        } else if ("time".equals(key)) {
            CONTROL.setTime(((ObjectProperty<ZonedDateTime>) properties.get(key)).get());
        } else if ("text".equals(key)) {
            CONTROL.setText(((StringProperty) properties.get(key)).get());
        } else if ("textAlignment".equals(key)) {
            CONTROL.setTextAlignment(((ObjectProperty<TextAlignment>) properties.get(key)).get());
        } else if ("discreteSeconds".equals(key)) {
            CONTROL.setDiscreteSeconds(((BooleanProperty) properties.get(key)).get());
        } else if ("discreteMinutes".equals(key)) {
            CONTROL.setDiscreteMinutes(((BooleanProperty) properties.get(key)).get());
        } else if ("discreteHours".equals(key)) {
            CONTROL.setDiscreteHours(((BooleanProperty) properties.get(key)).get());
        } else if ("secondsVisible".equals(key)) {
            CONTROL.setSecondsVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("textVisible".equals(key)) {
            CONTROL.setTextVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("dateVisible".equals(key)) {
            CONTROL.setDateVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("textColor".equals(key)) {
            CONTROL.setTextColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("dateColor".equals(key)) {
            CONTROL.setDateColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("hourTickMarkColor".equals(key)) {
            CONTROL.setHourTickMarkColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("minuteTickMarkColor".equals(key)) {
            CONTROL.setMinuteTickMarkColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("alarmColor".equals(key)) {
            CONTROL.setAlarmColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("hourTickMarksVisible".equals(key)) {
            CONTROL.setHourTickMarksVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("minuteTickMarksVisible".equals(key)) {
            CONTROL.setMinuteTickMarksVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("hourColor".equals(key)) {
            CONTROL.setHourColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("minuteColor".equals(key)) {
            CONTROL.setMinuteColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("secondColor".equals(key)) {
            CONTROL.setSecondColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("onAlarm".equals(key)) {
            CONTROL.setOnAlarm(((ObjectProperty<AlarmEventListener>) properties.get(key)).get());
        } else if ("onTimeEvent".equals(key)) {
            CONTROL.setOnTimeEvent(((ObjectProperty<TimeEventListener>) properties.get(key)).get());
        } else if ("alarmsEnabled".equals(key)) {
            CONTROL.setAlarmsEnabled(((BooleanProperty) properties.get(key)).get());
        } else if ("alarmsVisible".equals(key)) {
            CONTROL.setAlarmsVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("running".equals(key)) {
            CONTROL.setRunning(((BooleanProperty) properties.get(key)).get());
        } else if ("increment".equals(key)) {
            CONTROL.setIncrement(((DoubleProperty) properties.get(key)).get());
        } else if ("activeColor".equals(key)) {
            CONTROL.setActiveColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("darkSky".equals(key)) {
            CONTROL.setDarkSky(((ObjectProperty<DarkSky>) properties.get(key)).get());
        } else if ("duration".equals(key)) {
            CONTROL.setDuration(((ObjectProperty<LocalTime>) properties.get(key)).get());
        } else if ("strokeWithGradient".equals(key)) {
            CONTROL.setStrokeWithGradient(((BooleanProperty) properties.get(key)).get());
        } else if ("fillWithGradient".equals(key)) {
            CONTROL.setFillWithGradient(((BooleanProperty) properties.get(key)).get());
        } else if ("graphic".equals(key)) {
            CONTROL.setGraphic(((ObjectProperty<Node>) properties.get(key)).get());
        } else if ("roundedCorners".equals(key)) {
            CONTROL.setRoundedCorners(((BooleanProperty) properties.get(key)).get());
        } else if ("textSize".equals(key)) {
            CONTROL.setTextSize(((ObjectProperty<TextSize>) properties.get(key)).get());
        } else if ("currentLocation".equals(key)) {
            CONTROL.setCurrentLocation(((ObjectProperty<Location>) properties.get(key)).get());
        } else if ("trackColor".equals(key)) {
            CONTROL.setTrackColor(((ObjectProperty<TileColor>) properties.get(key)).get());
        } else if ("mapProvider".equals(key)) {
            CONTROL.setMapProvider(((ObjectProperty<MapProvider>) properties.get(key)).get());
        } else if ("tooltipText".equals(key)) {
            CONTROL.setTooltipText(((StringProperty) properties.get(key)).get());
        } else if ("xAxis".equals(key)) {
            CONTROL.setXAxis(((ObjectProperty<Axis>) properties.get(key)).get());
        } else if ("yAxis".equals(key)) {
            CONTROL.setYAxis(((ObjectProperty<Axis>) properties.get(key)).get());
        } else if ("radarChartMode".equals(key)) {
            CONTROL.setRadarChartMode(((ObjectProperty<RadarChart.Mode>) properties.get(key)).get());
        } else if ("chartGridColor".equals(key)) {
            CONTROL.setChartGridColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("country".equals(key)) {
            CONTROL.setCountry(((ObjectProperty<Country>) properties.get(key)).get());
        } else if ("countryGroup".equals(key)) {
            CONTROL.setCountryGroup(((ObjectProperty<CountryGroup>) properties.get(key)).get());
        } else if ("sortedData".equals(key)) {
            CONTROL.setSortedData(((BooleanProperty) properties.get(key)).get());
        } else if ("flipTimeInMS".equals(key)) {
            CONTROL.setFlipTimeInMS(((LongProperty) properties.get(key)).get());
        } else if ("flipText".equals(key)) {
            CONTROL.setFlipText(((StringProperty) properties.get(key)).get());
        } else if ("dataPointsVisible".equals(key)) {
            CONTROL.setDataPointsVisible(((BooleanProperty) properties.get(key)).get());
        } else if ("sunburstTree".equals(key)) {
            CONTROL.getSunburstChart().setTree(((ObjectProperty<TreeNode>) properties.get(key)).get());
        } else if ("sunburstBackgroundColor".equals(key)) {
            CONTROL.getSunburstChart().setBackgroundColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("sunburstTextColor".equals(key)) {
            CONTROL.getSunburstChart().setTextColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("sunburstUseColorFromParent".equals(key)) {
            CONTROL.getSunburstChart().setUseColorFromParent(((BooleanProperty) properties.get(key)).get());
        } else if ("sunburstTextOrientation".equals(key)) {
            CONTROL.getSunburstChart().setTextOrientation(((ObjectProperty<TextOrientation>) properties.get(key)).get());
        } else if ("sunburstVisibleData".equals(key)) {
            CONTROL.getSunburstChart().setVisibleData(((ObjectProperty<VisibleData>) properties.get(key)).get());
        } else if ("sunburstInteractive".equals(key)) {
            CONTROL.getSunburstChart().setInteractive(((BooleanProperty) properties.get(key)).get());
        } else if ("sunburstAutoTextColor".equals(key)) {
            CONTROL.getSunburstChart().setAutoTextColor(((BooleanProperty) properties.get(key)).get());
        } else if ("sunburstUseChartDataTextColor".equals(key)) {
            CONTROL.getSunburstChart().setUseChartDataTextColor(((BooleanProperty) properties.get(key)).get());
        } else if ("snapToTicks".equals(key)) {
            CONTROL.setSnapToTicks(((BooleanProperty) properties.get(key)).get());
        } else if ("minorTickCount".equals(key)) {
            CONTROL.setMinorTickCount(((IntegerProperty) properties.get(key)).get());
        } else if ("majorTickUnit".equals(key)) {
            CONTROL.setMajorTickUnit(((DoubleProperty) properties.get(key)).get());
        } else if ("matrixSize".equals(key)) {
            final int COLS = ((IntegerProperty) properties.get("matrixColumns")).get();
            final int ROWS = ((IntegerProperty) properties.get("matrixRows")).get();
            CONTROL.setMatrixSize(COLS, ROWS);
        } else if ("chartType".equals(key)) {
            CONTROL.setChartType(((ObjectProperty<ChartType>) properties.get(key)).get());
        } else if ("tooltipTimeout".equals(key)) {
            CONTROL.setTooltipTimeout(((DoubleProperty) properties.get(key)).get());
        } else if ("notificationBackgroundColor".equals(key)) {
            CONTROL.setNotificationBackgroundColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("notificationForegroundColor".equals(key)) {
            CONTROL.setNotificationForegroundColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("showNotifier".equals(key)) {
            CONTROL.showNotifier(((BooleanProperty) properties.get(key)).get());
        }
    }
    properties.clear();
    return CONTROL;
}
Also used : TreeNode(eu.hansolo.tilesfx.tools.TreeNode) Node(javafx.scene.Node) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) DarkSky(eu.hansolo.tilesfx.weather.DarkSky) TimeEventListener(eu.hansolo.tilesfx.events.TimeEventListener) ZonedDateTime(java.time.ZonedDateTime) RadarChart(eu.hansolo.tilesfx.chart.RadarChart) List(java.util.List) TileColor(eu.hansolo.tilesfx.Tile.TileColor) Axis(javafx.scene.chart.Axis) ObjectProperty(javafx.beans.property.ObjectProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) IntegerProperty(javafx.beans.property.IntegerProperty) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) TileColor(eu.hansolo.tilesfx.Tile.TileColor) Color(javafx.scene.paint.Color) Dimension2D(javafx.geometry.Dimension2D) SkinType(eu.hansolo.tilesfx.Tile.SkinType) TextSize(eu.hansolo.tilesfx.Tile.TextSize) ChartType(eu.hansolo.tilesfx.Tile.ChartType) TextOrientation(eu.hansolo.tilesfx.chart.SunburstChart.TextOrientation) Orientation(javafx.geometry.Orientation) CountryGroup(eu.hansolo.tilesfx.tools.CountryGroup) Pos(javafx.geometry.Pos) VisibleData(eu.hansolo.tilesfx.chart.SunburstChart.VisibleData) TextAlignment(javafx.scene.text.TextAlignment) SimpleLongProperty(javafx.beans.property.SimpleLongProperty) LongProperty(javafx.beans.property.LongProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) DoubleProperty(javafx.beans.property.DoubleProperty) NumberFormat(java.text.NumberFormat)

Aggregations

TreeNode (eu.hansolo.tilesfx.tools.TreeNode)5 Color (javafx.scene.paint.Color)5 List (java.util.List)4 Node (javafx.scene.Node)4 TextAlignment (javafx.scene.text.TextAlignment)4 Helper (eu.hansolo.tilesfx.tools.Helper)3 ArrayList (java.util.ArrayList)3 Locale (java.util.Locale)3 BooleanProperty (javafx.beans.property.BooleanProperty)3 IntegerProperty (javafx.beans.property.IntegerProperty)3 ObjectProperty (javafx.beans.property.ObjectProperty)3 ObservableList (javafx.collections.ObservableList)3 Insets (javafx.geometry.Insets)3 Background (javafx.scene.layout.Background)3 BackgroundFill (javafx.scene.layout.BackgroundFill)3 CornerRadii (javafx.scene.layout.CornerRadii)3 Paint (javafx.scene.paint.Paint)3 TreeNodeEvent (eu.hansolo.tilesfx.events.TreeNodeEvent)2 EventType (eu.hansolo.tilesfx.events.TreeNodeEvent.EventType)2 Fonts (eu.hansolo.tilesfx.fonts.Fonts)2