swpalmer at gmail.com
Mon Sep 10 11:13:05 PDT 2012
On 2012-09-10, at 1:57 PM, Greg Brown <greg.x.brown at oracle.com> wrote:
>> The FXML loader only takes a URL. If you have a resource that you may load multiple times, how efficient is it? I have used a XSLT to convert SVG into FXML so I can get scalable icons in my application. There are two concern:
>> 1) If I choose to convert from SVG to FXML at runtime I need to make a temporary file for the FXML loader as it doesn't take a DOM or a String as a source.
> Why not just apply your transform at compile time such that only FXML is processed at runtime, rather than both SVG and FXML?
That is what I am doing in this case… but support for the other case seems like a minor change. Why must FXML be loaded from only a URL? Base on your response to #2, I see it is useful to use the URL as a key to looking up in the cache, but the more generic possibility of FXMLLoader.load(java.io.InputStream) would open a few doors for developers where now they must climb in through the window. (Arguably you could enable the cache by default for the URL form and use the InputStream form as a workaround for the few cases where the caching is not desired.)
>> 2) The exact same component hierarchy is being parsed over and over (these icons may appear many many times in the GUI) - It might make sense for there to be an intermediate form that new copies of the FXML node hierarchy could be created from.
> A new flag was added to FXMLLoader for 8.0 to address this exact case. When this flag is set to true, information about the loaded FXML document is cached across calls to load() so that subsequent calls do not take as long to execute.
More information about the openjfx-dev