Comments (4)
Hi! Sorry for the late reply, unfortunately i don't get notified when new issues are created.... do you by any chance still have a code sample for me to try this out? Is this on high dpi displays?
from javafxsvg.
I've tested this on a 2560x1440 monitor. As you can see in the linked pull request, the only thing I did is something like:
final String iconPath = "/icons/icon.svg";
Button testButton = new Button("Press");
testButton.setStyle("-fx-background-image: url('" + MyClass.class.getResource(iconPath).toExternalForm() + "');");
As I've described in the pull request, the issue might be related to some system dependent library installation.
If you have any idea what could cause this, I can try to add javafxsvg to our application again.
from javafxsvg.
Is it possible that you use other styles to set the size of the background image, like -fx-background-size: cover;
? I think the issue here is, that javafxsvg just cannot determine the actual size of the target svg to be displayed and thus falls back to a default size (wich is 400x400) for rendering and then, the image is scaled down by javafx in order to make it fit into the button making it look rather blurry.
Unfortunately, I don't really have a good solution to this because i don't think there is any means for javafxsvg to determine the size to the target element when embedding it as a css background image.
There might however be a workaround: If the SVG has the correct size stored in attributes, this might be used by javafxsvg to render the image in the correct size. To use this, make sure you have width
and height
attribute defined in your svg and then enable svg support like this:
SvgImageLoaderFactory.install(new AttributeDimensionProvider());
Now, attributes from the svg will be used as the default size if no size is explicitly requested by javafx (e.g. if you have an image control with a given size). You can also create your own dimension provider by implementing DimensionProvider
. It'll always be used, when javafx does not request images in a specific size. I have no idea why javafx does not provide image dimensions when using css background images, even if -fx-background-size
is set...
I hope this helps!
from javafxsvg.
The thing is that our GUI can be scaled (e.g. for UHD resolutions). This and the fact that we provide the image as part of a theme required us to set it as background image in CSS (at least we could not find a better solution). Therefore your analysis might very well be true.
I don't think we can store the size in the SVG attributes because we need different sizes depending on the GUI scaling.
While implementing a custom DimensionProvider
could work, it seems a bit too complicated for the result (we currently use .png and those look nice).
So if this is something in javafx which you cannot work around, feel free to close the issue.
from javafxsvg.
Related Issues (13)
- Add support for retina displays HOT 2
- NoSuchMethodError with JDK 1.8.0_51 HOT 3
- Image width and height will be ignored HOT 3
- Maven
- Java 9 support HOT 9
- big size HOT 2
- Contribute to OpenJFX HOT 3
- Anti-Aliasing? HOT 4
- High DPI displays render blurry SVGs in Java 9+ HOT 1
- Doesn't work after bundling application
- Error on SvgImageLoaderFactory.install()
- Image height and width not respected
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javafxsvg.