-
-
Notifications
You must be signed in to change notification settings - Fork 19
JavaFX Output Implementation - V2 #141
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
Open
SonarSonic
wants to merge
26
commits into
weisJ:master
Choose a base branch
from
SonarSonic:javafx-final
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
daf606e
Allow access to paint clean-up in GraphicsUtil
SonarSonic 105aa1d
Deprecate Output.setClip() for removal
SonarSonic e5416f1
Upgrade batik to a modular version
SonarSonic 2ff834b
Create JavaFX sub module
SonarSonic 20b4c12
Add AWT to JFX inter-op bridge
SonarSonic 71caf3c
Add FXOutput implementation
SonarSonic f65252c
Add FXSVGCanvas + FXSVGCanvasSkin + renderer implementations
SonarSonic b830054
Add FXOutput unit testing
SonarSonic 850d04b
Add JavaFX test viewer application
SonarSonic 93424ed
Add package-info for jsvg-javafx packages
SonarSonic a944937
Make relevant packages available to jsvg.javafx module
SonarSonic a2e4174
Make FXOutput final
weisJ b6e0408
Add more nullability annotations
weisJ 2a9d4e3
Expose FXOutput
weisJ 544150b
Turn FXSVGRenderer into an interface
weisJ 666bbbe
Fixup expose FXOutput
weisJ a3c25f2
Remove unused function
weisJ b27ab80
Move Javafx renderer implementations into own package
weisJ dcef505
Add convenience task to run JavaFX test application
weisJ 775f25f
Make JavaFX test class non-public
weisJ 5b28fb7
Wrap newSingleThreadExecutor with try-with-resource
weisJ 161541a
Fix JavaFX Test Initialization
SonarSonic 60ad744
Fix FXSVGCanvas not loading the SVGDocument's animation
SonarSonic a12209d
Fix Spotless formatting
SonarSonic 8ae33d5
Hide implementation of FXOutput
weisJ e8ddba4
Run spotless
weisJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import org.gradle.api.tasks.testing.logging.TestExceptionFormat | ||
|
|
||
| plugins { | ||
| `java-library` | ||
| jacoco | ||
| id("biz.aQute.bnd.builder") | ||
| id("org.openjfx.javafxplugin") | ||
| } | ||
|
|
||
| javafx { | ||
| version = rootProject.extra["javafx.version"].toString() | ||
| modules("javafx.controls", "javafx.fxml", "javafx.swing") | ||
| } | ||
|
|
||
| dependencies { | ||
| compileOnly(projects.jsvg) | ||
| compileOnly(libs.nullabilityAnnotations) | ||
| compileOnly(toolLibs.errorprone.annotations) | ||
| compileOnly(libs.osgiAnnotations) | ||
|
|
||
| testImplementation(projects.jsvg) | ||
| testImplementation(testLibs.junit.api) | ||
| testImplementation(testLibs.imageCompare) | ||
| testImplementation(gradleApi()) | ||
|
|
||
| testRuntimeOnly(testLibs.junit.engine) | ||
|
|
||
| testCompileOnly(libs.nullabilityAnnotations) | ||
| testCompileOnly(toolLibs.errorprone.annotations) | ||
| } | ||
| tasks { | ||
|
|
||
| compileTestJava { | ||
| options.release.set(21) | ||
| } | ||
|
|
||
| jar { | ||
| bundle { | ||
| bnd( | ||
| bndFile( | ||
| moduleName = "com.github.weisj.jsvg.javafx", | ||
| requiredModules = | ||
| listOf( | ||
| Requires("com.github.weisj.jsvg"), | ||
| Requires("org.jetbrains.annotations", static = true), | ||
| Requires("com.google.errorprone.annotations", static = true), | ||
| Requires("org.osgi.annotation.bundle", static = true), | ||
| ), | ||
| ), | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| withType<JavaExec> { | ||
| environment("JAVAFX_TEST_SVG_PATH" to File(project.rootDir, "jsvg/src/test/resources").absolutePath) | ||
| } | ||
|
|
||
| test { | ||
| dependsOn(jar) | ||
| doFirst { | ||
| workingDir = File(project.rootDir, "build/ref_test").also { it.mkdirs() } | ||
| } | ||
| useJUnitPlatform() | ||
| testLogging { | ||
| showStandardStreams = true | ||
| showExceptions = true | ||
| showStackTraces = true | ||
| exceptionFormat = TestExceptionFormat.FULL | ||
| } | ||
| } | ||
|
|
||
| register<JavaExec>("SVGViewerFX") { | ||
| group = "application" | ||
| description = "Runs the JavaFX SVG Viewer application." | ||
| classpath = sourceSets.test.get().runtimeClasspath | ||
| mainClass.set("com.github.weisj.jsvg.renderer.jfx.viewer.FXViewerMain") | ||
| } | ||
| } |
52 changes: 52 additions & 0 deletions
52
jsvg-javafx/src/main/java/com/github/weisj/jsvg/renderer/jfx/FXOutput.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * MIT License | ||
| * | ||
| * Copyright (c) 2026 Jannis Weis | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
| * associated documentation files (the "Software"), to deal in the Software without restriction, | ||
| * including without limitation the rights to use, copy, modify, merge, publish, distribute, | ||
| * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all copies or | ||
| * substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT | ||
| * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| * | ||
| */ | ||
| package com.github.weisj.jsvg.renderer.jfx; | ||
|
|
||
| import javafx.scene.canvas.GraphicsContext; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| import com.github.weisj.jsvg.renderer.jfx.impl.FXOutputImpl; | ||
| import com.github.weisj.jsvg.renderer.jfx.impl.bridge.FXRenderingHintsUtil; | ||
| import com.github.weisj.jsvg.renderer.output.Output; | ||
|
|
||
| /** | ||
| * A utility class for retrieving an {@link Output} implementation that uses a {@link GraphicsContext} to draw to. | ||
| */ | ||
| public final class FXOutput { | ||
|
|
||
| private FXOutput() {} | ||
|
|
||
| /** | ||
| * Example usage: | ||
| * <pre><code> | ||
| * Output output = FXOutput.createForGraphicsContext(graphics); | ||
| * svgDocument.renderWithPlatform(NullPlatformSupport.INSTANCE, output, null, null); | ||
| * output.dispose(); | ||
| * </code></pre> | ||
| */ | ||
| public static @NotNull Output createForGraphicsContext(@NotNull GraphicsContext context) { | ||
| FXOutputImpl output = new FXOutputImpl(context); | ||
| FXRenderingHintsUtil.setupDefaultJFXRenderingHints(output); | ||
| return output; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require java 17? If yes we should update the language version for the javafx module to reflect this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're slightly out of sync, so this actually only requires Java 11