Giter VIP home page Giter VIP logo

javafxsvg's Introduction

JavaFxSVG

Codacy Badge

A simple library to add SVG support to JavaFX, allowing to use SVG graphics just like any other image type.

More details about the project can be found at the codecentric blog: Adding a custom image renderer to JavaFX 8

Installation

If you are using maven, just add JavaFxSVG to the dependencies

<dependency>
	<groupId>de.codecentric.centerdevice</groupId>
	<artifactId>javafxsvg</artifactId>
	<version>1.3.0</version>
</dependency>

Usage

Add this line to your application:

SvgImageLoaderFactory.install();

preferably before any JavaFX code is executed. After this, you can use SVG images just as any other Image in your application.

If the JavaFX container does not specify any width or height, the image is rendered with default dimensions (currently 400x400). To changes this behavior, a DimensionProvider can be passed with the install command:

SvgImageLoaderFactory.install(new PrimitiveDimensionProvider());

will try to determine the actual size of the SVG (as specified by width and height attributes) and use this as a fallback size.

Known Issues

Currently, SVGs are required to start with either "<svg" or "<?xml" due to some rather static signature matching. As a result, svg might not be displayed when starting with whitespace characters or comment.

javafxsvg's People

Contributors

codacy-badger avatar comfreek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javafxsvg's Issues

Error on SvgImageLoaderFactory.install()

java.lang.IncompatibleClassChangeError: Expected static method 'void com.sun.javafx.iio.ImageStorage.addImageLoaderFactory(com.sun.javafx.iio.ImageLoaderFactory)'
	at de.codecentric.centerdevice.javafxsvg.SvgImageLoaderFactory.install(SvgImageLoaderFactory.java:26)
	at de.codecentric.centerdevice.javafxsvg.SvgImageLoaderFactory.install(SvgImageLoaderFactory.java:20)

Mac OSX 12.4
Java version 17
openjfx 19-ea+8

Image height and width not respected

Both fitWidth/Height in an ImageView and width/height when loading an Image do not seem to be respected.
See also #5

Using version 1.3.0, though the latest tag in the repo is 1.2.1, huh?

Java 9 support

Hi,

I like this library but I was wondering what will happen with it in Java 9?
Internally it uses com.sun.javafx.iio.

Thanks,
Diego

big size

I used this awesome lib in a 2MB app, but it raised the size to almost 8MB just by using it. Could the size drop in the future or is the "svg support" so resource heavy thing? Thanks

Contribute to OpenJFX

Greetings,

Would you be willing to contribute javafxsvg to openjdk.java.net/projects/openjfx ?

If so, and if there is anything I can do to help, please let me know.

Best regards,
Henri

High DPI displays render blurry SVGs in Java 9+

    private Method lookupScaleMethod() throws NoSuchMethodException {
      Method scaleMethod;
      try {
        scaleMethod = Screen.class.getDeclaredMethod("getScale"); // until 8u51
      } catch (NoSuchMethodException e) {
        scaleMethod = Screen.class.getDeclaredMethod("getRenderScale");
      }
      scaleMethod.setAccessible(true);
      return scaleMethod;
    }

Both of these methods no longer work for determining the scale factor for the screen, but Java 9 introduced the public methods screen.getOutputScaleX and screen.getOutputScaleY which makes the above code obsolete.

I would have made a pull request instead of an issue, but using these new methods would make the new release incompatible with Java 8 and below, and I don't know how the owner of this repo would prefer to deal with that.

If creating a Java 9+ version of this project is acceptable, I can submit a pull request using these methods.

Anti-Aliasing?

First off, I just want to say: I love this loader. Thanks for making it, it really makes working with SVG a breeze.

One thing I noticed is that when the SVG is drawn, it looks kind of pixellated. Is there any way to ensure anti-aliasing is applied and/or a more aggressive version? At the moment, this is what our logo currently looks like using your plugin:
image

Compared to what it looks like on, say, a browser:
image

Maven

Hey, i tried today to add your program to test it out
but i got problems with including it into my program.

Is there something wrong with your maven distribution? because in you nexus is no such entry

Add support for retina displays

On retina displays, svgs should be rendered with doubled pixel density. Unfortunately this currently seems to be possible only by adding @2x to the filename. This seems redundant for svg images, so it'd be great to support this without having to duplicate the original image.

Image width and height will be ignored

When you create a image with the width and height parameter set, your SVG-Imageloader will ignore those and pick the default svg-size instead.
new Image("myImage.svg", 100, 100, false, false);
new Image("myImage.svg", 100, 0, true, false);

I debugged a little bit and noticed that BufferedImageTranscoder.setImageSize is called twice. One time with the specified width and height and another time with the default size.
The second time it is called from within SVGAbstractTranscoder.transcode

I really like your SVG support and I'm still using it a lot, but some of my images need to be scaled up first.
Thanks in advanced

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.