Skip to content

added conveyor packaging for fx-sampler #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Sep 26, 2023
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ $RECYCLE.BIN/
# intermediated scan results for coverity
/*.tgz

chartfx-samples/output/
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sun.javafx.scene.NodeHelper;
// import com.sun.javafx.perf.PerformanceTracker; // keep for the future in case this becomes public API
import com.sun.management.OperatingSystemMXBean;

Expand Down Expand Up @@ -252,13 +253,17 @@ public boolean isSceneDirty() {
return false;
}
try {
// implementation based on reflection
return dirtyNodesSize.getInt(this.getScene()) != 0 || dirtyRootBits.getInt(this.getScene().getRoot()) != 0;
} catch (IllegalAccessException | IllegalArgumentException exception) {
LOGGER.atError().setCause(exception).log("cannot access scene root's dirtyBits field");
return true;
try {
// alternate implementation (potential issues with Java Jigsaw (com.sun... dependency):
return !NodeHelper.isDirtyEmpty(this.getScene().getRoot());
} catch (Throwable t) {
LOGGER.atError().setCause(exception).log("cannot access scene root's dirtyBits field");
return true;
}
}
// alternate implementation (potential issues with Java Jigsaw (com.sun... dependency):
// return !NodeHelper.isDirtyEmpty(scene.getRoot())
}

protected static double computeAverage(final double newValue, final double oldValue, final double alpha) {
Expand Down
104 changes: 104 additions & 0 deletions chartfx-samples/conveyor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
conveyor.compatibility-level = 11
include required("/stdlib/jdk/21/openjdk.conf")
include required("/stdlib/jvm/javafx/from-jmods.conf")
javafx.version = "21"
app.mac.info-plist.LSMinimumSystemVersion = 11.0 // JavaFX 21 requirement

// Instructions:
// mvn package
// cd chartfx-samples
// run: conveyor run
// x-platform build: conveyor make site

iconDir = "../docs/icons"

app {

// App information
vendor = "GSI"
display-name = "ChartFx Sampler"
description = "Shows various examples of ChartFx charts"
fsname = chartfx-sampler
long-fsname = chartfx-sampler
rdns-name = io.fair_acc.${app.fsname}
version = 11.3.0
revision = 0

// Note: true shows console output for debugging
windows.console = false

// Resources
icons = ${iconDir}"/icon-rounded-*.png"
windows.icons = ${iconDir}"/icon-square-*.png"
windows.manifests.msix.background-color = "#ffffff"
inputs = [
"target/samples-master-SNAPSHOT.jar"
"target/lib/*.jar"
]

// JRE config
jvm {
extract-native-libraries = false
gui.main-class = io.fair_acc.sample.ChartFxSampler

modules = [
// detected by jdeps
java.base
java.desktop
java.instrument
java.logging
java.management
java.rmi
javafx.base
javafx.controls
javafx.fxml
javafx.graphics
javafx.swing
javafx.web
jdk.attach
jdk.management
jdk.unsupported
// detect // uncomment to detect again

// non-detected dependencies
javafx.media,
jdk.zipfs,
]

options = [
// generic vm args from docs
"--add-reads=javafx.graphics=ALL-UNNAMED"
"--add-opens=javafx.controls/com.sun.javafx.charts=ALL-UNNAMED"
"--add-opens=javafx.controls/com.sun.javafx.scene.control.inputmap=ALL-UNNAMED"
"--add-opens=javafx.graphics/com.sun.javafx.iio=ALL-UNNAMED"
"--add-opens=javafx.graphics/com.sun.javafx.iio.common=ALL-UNNAMED"
"--add-opens=javafx.graphics/com.sun.javafx.css=ALL-UNNAMED"
"--add-opens=javafx.base/com.sun.javafx.runtime=ALL-UNNAMED"
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED"

// used for samples w/ lower-level access
"--add-opens=jdk.management/com.sun.management=ALL-UNNAMED"
"--add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED"
"--add-opens=javafx.graphics/javafx.css=ALL-UNNAMED"
"--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED"
"--add-opens=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED"
"--add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED"
"--add-opens=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED"
]

// The FXSampler project only searches for jars/classes in directories
// at or below the working directory. Conveyor packages app contents
// in a sibling directory, so nothing gets found. We can work around
// this by manually setting the working directory. The '&&' token
// is an undocumented token that means "the place where the exe is
// found"
system-properties.user.dir = "&&/../"

}

// Release using GitHub Releases
site.base-url = github.com/fair-acc/chart-fx/releases/latest/download
vcs-url = github.com/fair-acc/chart-fx
license = LGPL 3

}
19 changes: 19 additions & 0 deletions chartfx-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@
<mainClass>io.fair_acc.sample.ChartFxSampler</mainClass>
</configuration>
</plugin>
<plugin> <!-- Copy dependencies for Conveyor -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<includeScope>runtime</includeScope>
<excludeGroupIds>org.openjfx</excludeGroupIds>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
package io.fair_acc.sample;

import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Optional;

import fxsampler.FXSampler;

public class ChartFxSampler {
private static boolean debug = Optional.ofNullable(System.getenv("chartfx.debug"))
.map(Boolean::parseBoolean)
.orElse(false);

public static void main(String[] args) {
if (debug) {
// Debug output for checking classpath
System.out.println("\nJars on ClassPath:");
String classpath = System.getProperty("java.class.path");
Arrays.stream(classpath.split(File.pathSeparator))
.map(String::toString)
.filter(str -> str.endsWith(".jar"))
.map(str -> "* " + str.substring(str.lastIndexOf(File.separatorChar) + 1))
.sorted()
.forEach(System.out::println);

// The FX Sampler only searches for jars/classes at and below the working directory
System.out.println("\nworkingDir = " + Path.of(".").toAbsolutePath().normalize() + "\n");
}

FXSampler.main(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
*/
public class ChartPerformanceGraph extends ChartSample {
private static final Logger LOGGER = LoggerFactory.getLogger(ChartPerformanceGraph.class);
private static final String FILE1 = "./testdata/ChartPerformanceBenchmark25Hz_V8.1.1_JDK8u112.csv";
private static final String FILE2 = "./testdata/ChartPerformanceBenchmark25Hz_V11.1.1_JDK11_JFX13.csv";
private static final String FILE3 = "./testdata/ChartPerformanceBenchmark25Hz_V11.1.2_JDK11_JFX13.csv";
private static final String FILE1 = "testdata/ChartPerformanceBenchmark25Hz_V8.1.1_JDK8u112.csv";
private static final String FILE2 = "testdata/ChartPerformanceBenchmark25Hz_V11.1.1_JDK11_JFX13.csv";
private static final String FILE3 = "testdata/ChartPerformanceBenchmark25Hz_V11.1.2_JDK11_JFX13.csv";

@Override
public Node getChartPanel(final Stage primaryStage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ private XYChart getChartPane(final Slider slider1, final Slider slider2, final S

public DataSet readImage() {
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(Objects.requireNonNull(ContourChartSample.class.getResourceAsStream("./testdata/image.txt"))))) {
new InputStreamReader(Objects.requireNonNull(ContourChartSample.class.getResourceAsStream("testdata/image.txt"))))) {
// final BufferedReader reader = new BufferedReader(new
// InputStreamReader(
// ContourChartSampleReference.class.getResourceAsStream("./testdata/image.txt")));
// ContourChartSampleReference.class.getResourceAsStream("testdata/image.txt")));
@SuppressWarnings("unused")
String skipLine; // NOPMD variable is needed to skip/check line that contains the dimension of the following
// line to be read which we derive from the data itself
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public static void main(final String[] args) {
}

private static double[] readDemoData(int index) {
final String fileName = index <= 1 ? "./rawDataCPS2.dat" : "./rawDataLHCInj.dat";
final String fileName = index <= 1 ? "rawDataCPS2.dat" : "rawDataLHCInj.dat";
try {
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(Objects.requireNonNull(EMDSample.class.getResourceAsStream(fileName))))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class HexagonSamples extends ChartSample {

@Override
public Node getChartPanel(Stage primaryStage) {
final Image image = new Image(Objects.requireNonNull(HexagonSamples.class.getResourceAsStream("./testdata/EU.png")));
final Image image = new Image(Objects.requireNonNull(HexagonSamples.class.getResourceAsStream("testdata/EU.png")));
// Convert the image to hexagons
final HexagonMap map = new HexagonMap(6, image, 80, (q, r, imagePixelColor, map1) -> {
if (imagePixelColor.getBlue() > 0.6) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand Down Expand Up @@ -110,7 +111,7 @@ private void updateHistogram(final String country, final int year, final boolean
}

private void loadDemoData(final String fileName) {
try (BufferedReader csvReader = Files.newBufferedReader(Paths.get(Objects.requireNonNull(this.getClass().getResource(fileName)).toURI()))) {
try (BufferedReader csvReader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(this.getClass().getResourceAsStream(fileName))))) {
// skip first row
String row = csvReader.readLine();
// country,age,men 1980 [%],men 2000 [%],men 2050 [%],women 1980 [%],women 2000 [%],women 2050 [%],men 1980,men 2000,men 2050,women 1980,women 2000,women 2050
Expand Down Expand Up @@ -154,7 +155,7 @@ private void loadDemoData(final String fileName) {
absMenDistribution2000.fill(ageCategory, -Double.parseDouble(data[9]));
absMenDistribution2050.fill(ageCategory, -Double.parseDouble(data[10]));
}
} catch (IOException | URISyntaxException e) {
} catch (IOException e) {
if (LOGGER.isErrorEnabled()) {
LOGGER.atError().setCause(e).log("InterruptedException");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected DataSet createTestData(final double peakOffset) {
}

protected DataSet readImage() {
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(ContourChartSample.class.getResourceAsStream("./testdata/image.txt"))))) {
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(ContourChartSample.class.getResourceAsStream("testdata/image.txt"))))) {
@SuppressWarnings("unused")
String skipLine; // NOPMD variable is needed to skip/check line that contains the dimension of the following
// line to be read which we derive from the data itself
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand Down Expand Up @@ -53,8 +54,7 @@ public class ScatterAndBubbleRendererSample extends ChartSample {
private double maxPopulation = 1.0;

private void loadDemoData(final String fileName) {
try (BufferedReader csvReader = Files
.newBufferedReader(Paths.get(Objects.requireNonNull(this.getClass().getResource(fileName)).toURI()))) {
try (BufferedReader csvReader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(this.getClass().getResourceAsStream(fileName))))) {
// skip first row
String row = csvReader.readLine();
// LOCATION,TIME,LIFEEXP65 – WOMEN,LIFEEXP65 – MEN,TIME,USD_CAP,TIME,MLN_PER
Expand All @@ -68,7 +68,7 @@ private void loadDemoData(final String fileName) {
gdpPerCapita.put(data[0], Double.parseDouble(data[5]));
population.put(data[0], pop);
}
} catch (IOException | URISyntaxException e) {
} catch (IOException e) {
if (LOGGER.isErrorEnabled()) {
LOGGER.atError().setCause(e).log("InterruptedException");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class TestDataSetSource extends AbstractDataSet<TestDataSetSource> implements GridDataSet {
private static final long serialVersionUID = 5374805363297317245L;
private static final Logger LOGGER = LoggerFactory.getLogger(TestDataSetSource.class);
private static final String DATA_SOURCE_FILE = "../testdata/alla-turca.mid";
private static final String DATA_SOURCE_FILE = "alla-turca.mid"; // Note: ".." is not supported in jar files
private static final int AUDIO_SAMPLING_RATE = 11000;
private static final int N_SYNTHESISER_BITS = 16;
private static final int INITIAL_FRAME_SIZE = 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private DataSet readDemoData(final int offset, final int nSamples) {
// initalise return data set
final DoubleDataSet ret = new DoubleDataSet("raw data@" + offset);
// read measurement data: 400 000 samples, 1MS/s
InputStream inputStream = IIRFilterSample.class.getResourceAsStream("./20190319_Schottky_SumX.csv.zip");
InputStream inputStream = IIRFilterSample.class.getResourceAsStream("20190319_Schottky_SumX.csv.zip");
try (ZipInputStream zipStream = new ZipInputStream(inputStream)) {
while (zipStream.getNextEntry() != null) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(zipStream))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Node getChartPanel(Stage primaryStage) {
}

protected static ImageView getIcon(final String iconName) {
return new ImageView(new Image(AcqButtonTests.class.getResourceAsStream("./icons/" + iconName)));
return new ImageView(new Image(AcqButtonTests.class.getResourceAsStream("icons/" + iconName)));
}

public static void main(String[] args) {
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
<links>
<link>https://openjfx.io/javadoc/12/</link>
</links>
<doclint>none</doclint> <!-- TODO: fix javadoc errors -->
</configuration>
<executions>
<execution>
Expand Down