Skip to content

Commit

Permalink
Set X position 0 for headless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmanusta committed Oct 18, 2023
1 parent 5b4d975 commit f3c26c7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/kodedu/boot/CmdlineConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public boolean isCmdStart() {
return !files.isEmpty();
}

public boolean isHeadless() {
return headless;
}

@Override
public String toString() {
return "CmdlineConfig{" +
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/kodedu/config/ConfigurationBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kodedu.config;

import com.kodedu.boot.AppStarter;
import com.kodedu.controller.ApplicationController;
import com.kodedu.helper.IOHelper;
import com.kodedu.service.ThreadService;
Expand Down Expand Up @@ -115,6 +116,11 @@ protected void fadeOut(Label label, String text) {
}

protected void saveJson(JsonStructure jsonStructure) {

if (AppStarter.config.isHeadless()) {
return;
}

Map<String, Object> properties = new HashMap<>(1);
properties.put(JsonGenerator.PRETTY_PRINTING, true);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kodedu.service.extension.chart;

import com.kodedu.boot.AppStarter;
import com.kodedu.service.extension.ImageInfo;

import java.util.Map;
Expand All @@ -13,4 +14,8 @@ public interface ChartBuilderService {
public boolean chartBuild(String chartContent, ImageInfo imageInfo, Map<String,
String> optMap, CompletableFuture completableFuture);

default double getXPosition() {
return AppStarter.config.isHeadless() ? 0 : -5000;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ public boolean chartBuild(String chartContent, ImageInfo imageInfo, Map<String,
node.setStyle(String.format("-fx-text-fill: %s; -fx-font-size: %s;", titleColor, titleSize));
}

pieChart.setLayoutX(-28000);
pieChart.setLayoutY(-28000);
pieChart.setLayoutX(getXPosition());
pieChart.setLayoutY(0);

threadService.runActionLater(() -> {
controller.getRootAnchor().getChildren().add(pieChart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ public boolean chartBuild(String chartContent, ImageInfo imageInfo, Map<String,
yAxis.setSide(Side.valueOf(optMap.get("y-side").toUpperCase()));
}

xyChart.setLayoutX(-7000);
xyChart.setLayoutY(-7000);
xyChart.setLayoutX(getXPosition());
xyChart.setLayoutY(0);

controller.getRootAnchor().getChildren().add(xyChart);
WritableImage writableImage = xyChart.snapshot(new SnapshotParameters(), null);
Expand Down

0 comments on commit f3c26c7

Please sign in to comment.