From adam at adamsiembida.com Sat Jul 17 19:05:42 2021 From: adam at adamsiembida.com (Adam Siembida) Date: Sat, 17 Jul 2021 19:05:42 +0000 Subject: Are there any plans to add native SVG support? Message-ID: With 4k monitors, retina displays, mobile devices, multi-monitor setups etc. becoming more popular, I've been finding that the lack of native SVG support is a practical omission from JavaFX. Just about any modern framework can support it, but in JavaFX you have to go about dissecting SVG files with a text editor and pulling out the path information, or do roundabout solutions like adding it to backgrounds through CSS, or messing around with font icons. This issues has been most glaring for me when trying to work with icons, like in toolbars, menus, and buttons. I recently found out about an (undocumented?) feature in JavaFX where you can make multiple image files with with special suffixes denoting screen densities (x2, x3, etc), which are automatically selected somehow. This has been a help in making my icons look better on my 4k monitor, but it would have been much easier, future proof, and less laborious to use simply use SVG files instead. My final issue with the lack of SVG support is a branding issue. For someone who has never used JavaFX before and are taking a look at it for the first time, the lack of SVG support might make JavaFX seem... old and outdated: "oh this framework is from before the days of vector graphics" (not saying it is old or outdated!). Does anyone know if native SVG support is something that is being considered for JavaFX? If not, does anyone else think that this is important feature that should be considered for adding to JavaFX? -Adam From kevin.rushforth at oracle.com Mon Jul 19 16:52:01 2021 From: kevin.rushforth at oracle.com (Kevin Rushforth) Date: Mon, 19 Jul 2021 09:52:01 -0700 Subject: Are there any plans to add native SVG support? In-Reply-To: References: Message-ID: <3671abd3-0615-0cd3-f66c-d2034453f960@oracle.com> JavaFX has some limited SVG support for geometry; see SVGPath [1]. What's missing is support for SVG images. There is an open Enhancement request tracked as JDK-8267753 [2]. It would be a fair amount of work to implement this, and there is no current plan, but it would be a useful way to allow applications to specify resolution-independent images. -- Kevin [1] https://openjfx.io/javadoc/16/javafx.graphics/javafx/scene/shape/SVGPath.html [2] https://bugs.openjdk.java.net/browse/JDK-8267753 On 7/17/2021 12:05 PM, Adam Siembida wrote: > With 4k monitors, retina displays, mobile devices, multi-monitor setups etc. becoming more popular, I've been finding that the lack of native SVG support is a practical omission from JavaFX. Just about any modern framework can support it, but in JavaFX you have to go about dissecting SVG files with a text editor and pulling out the path information, or do roundabout solutions like adding it to backgrounds through CSS, or messing around with font icons. > > This issues has been most glaring for me when trying to work with icons, like in toolbars, menus, and buttons. I recently found out about an (undocumented?) feature in JavaFX where you can make multiple image files with with special suffixes denoting screen densities (x2, x3, etc), which are automatically selected somehow. This has been a help in making my icons look better on my 4k monitor, but it would have been much easier, future proof, and less laborious to use simply use SVG files instead. > > My final issue with the lack of SVG support is a branding issue. For someone who has never used JavaFX before and are taking a look at it for the first time, the lack of SVG support might make JavaFX seem... old and outdated: "oh this framework is from before the days of vector graphics" (not saying it is old or outdated!). > > Does anyone know if native SVG support is something that is being considered for JavaFX? If not, does anyone else think that this is important feature that should be considered for adding to JavaFX? > > -Adam From nlisker at gmail.com Mon Jul 19 17:00:03 2021 From: nlisker at gmail.com (Nir Lisker) Date: Mon, 19 Jul 2021 20:00:03 +0300 Subject: Are there any plans to add native SVG support? In-Reply-To: <3671abd3-0615-0cd3-f66c-d2034453f960@oracle.com> References: <3671abd3-0615-0cd3-f66c-d2034453f960@oracle.com> Message-ID: There is even an older one: https://bugs.openjdk.java.net/browse/JDK-8091950 On Mon, Jul 19, 2021 at 7:53 PM Kevin Rushforth wrote: > JavaFX has some limited SVG support for geometry; see SVGPath [1]. > What's missing is support for SVG images. There is an open Enhancement > request tracked as JDK-8267753 [2]. It would be a fair amount of work to > implement this, and there is no current plan, but it would be a useful > way to allow applications to specify resolution-independent images. > > -- Kevin > > [1] > > https://openjfx.io/javadoc/16/javafx.graphics/javafx/scene/shape/SVGPath.html > [2] https://bugs.openjdk.java.net/browse/JDK-8267753 > > > On 7/17/2021 12:05 PM, Adam Siembida wrote: > > With 4k monitors, retina displays, mobile devices, multi-monitor setups > etc. becoming more popular, I've been finding that the lack of native SVG > support is a practical omission from JavaFX. Just about any modern > framework can support it, but in JavaFX you have to go about dissecting SVG > files with a text editor and pulling out the path information, or do > roundabout solutions like adding it to backgrounds through CSS, or messing > around with font icons. > > > > This issues has been most glaring for me when trying to work with icons, > like in toolbars, menus, and buttons. I recently found out about an > (undocumented?) feature in JavaFX where you can make multiple image files > with with special suffixes denoting screen densities (x2, x3, etc), which > are automatically selected somehow. This has been a help in making my icons > look better on my 4k monitor, but it would have been much easier, future > proof, and less laborious to use simply use SVG files instead. > > > > My final issue with the lack of SVG support is a branding issue. For > someone who has never used JavaFX before and are taking a look at it for > the first time, the lack of SVG support might make JavaFX seem... old and > outdated: "oh this framework is from before the days of vector graphics" > (not saying it is old or outdated!). > > > > Does anyone know if native SVG support is something that is being > considered for JavaFX? If not, does anyone else think that this is > important feature that should be considered for adding to JavaFX? > > > > -Adam > > From hal at ntnu.no Tue Jul 20 16:00:57 2021 From: hal at ntnu.no (=?utf-8?B?SGFsbHZhcmQgVHLDpnR0ZWJlcmc=?=) Date: Tue, 20 Jul 2021 16:00:57 +0000 Subject: Make development of fxml-based applications easier particularly for beginners Message-ID: <594BC55F-CB1C-4FD7-8655-FA6E4C368C59@contoso.com> Hi, I have taught JavaFX and FXML in an introductory course on object-oriented programming for several years, and now we also use it in a follow-up course. We use FXML from the start (before they learn much about inheritance) and there are two things that make development more difficult/cumbersome than necessary?: - the need for making a dedicated Application subclass even if it just loads a specific FXML file and the rest is handled by the controller - the lack of understandable error reporting (exception messages in stack traces) when something goes wrong either during load or in the initialize method The first issue is annoying when students are working on small assignments or trying out small examples, since there must exist a separate java file with only boilerplate code. To handle this I created my own FxmlApplication class that I provided in a jar and made an Eclipse plugin with a new launch type so they could right-click on any fxml file and choose Run As > FXML application. However, this plugin stopped working when JavaFX was modularized. The second issue isn't as easy to handle, but it could also be handled by a special Application subclass that catches (relevant) exceptions during fxml loading and tries to make sense of the exception and provide meaningful error output. In addition to these problems there are minor issues, among others that students expect the top pane to have keyboard focus. My suggestion is to enhance JavaFX with a (new) FxmlApplication class that extends Application and provides the following logic: - a start method that looks for an application argument that can be interpreted as a reference to an fxml file (URL or resource) - if no fxml file reference is provided it defaults to the name of the application class (in case FxmlApplication is itself subclassed) with .fxml appended - if the fxml file cannot be accessed, an understandable error message is given (rather than e.g. saying location is null in a stack trace) - the fxml file is loaded, and if the result is not a Scene, it is wrapped in one before being given to the Stage - the loading is wrapped in expection handling code that tries to provide understandable error messages for typical cases (e.g. misspelled element or attribute name), rather than just ending up with a stack trace that is difficult to make sense of With such a standard Application class, it shouldn't be difficult to make IDEs support running fxml files directly as explained above. What do you think and how should I proceed? Regards, Hallvard --- Hallvard Tr?tteberg (hal at idi.ntnu.no) Associate Professor, ISSE group, Dept. of Computer Science at the Norwegian University of Science and Technology