Skip to content
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

CSSTUDIO-2749 Add configuration option 'org.csstudio.display.builder.representation/svg_rendering_resolution_factor' #3197

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import javafx.scene.image.Image;
import org.csstudio.display.builder.model.util.ModelResourceUtil;
import org.csstudio.display.builder.representation.Preferences;
import org.phoebus.ui.javafx.ImageCache;
import org.phoebus.ui.javafx.svg.SVGTranscoder;

Expand Down Expand Up @@ -53,11 +54,20 @@ public class SVGHelper {
*/
public static Image loadSVG(String imageFileName, double width, double height) {
String cachedSVGFileName = imageFileName + "_" + width + "_" + height;

double svg_rendering_resolution_factor;
if (!Double.isNaN(Preferences.svg_rendering_resolution_factor) && Preferences.svg_rendering_resolution_factor > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to enforce a minimum value of 1.0 instead of 0.0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to enforce a minimum value of 1.0 instead of 0.0?

It would certainly be possible. I implemented it like this since values greater than 0 (e.g., 0.5) are meaningful: then SVGs will not appear sharp unless one zooms out.

svg_rendering_resolution_factor = Preferences.svg_rendering_resolution_factor;
}
else {
logger.log(Level.WARNING, "The option 'org.csstudio.display.builder.representation/svg_rendering_resolution_factor' is set to an invalid value. Setting svg_rendering_resolution_factor to 1.0");
svg_rendering_resolution_factor = 1.0;
}
return ImageCache.cache(cachedSVGFileName, () ->
{
// Open the image from the stream created from the resource file.
try (InputStream inputStream = ModelResourceUtil.openResourceStream(imageFileName)) {
return SVGTranscoder.loadSVG(inputStream, width, height);
return SVGTranscoder.loadSVG(inputStream, width*svg_rendering_resolution_factor, height*svg_rendering_resolution_factor);
} catch (Exception ex) {
logger.log(Level.WARNING, String.format("Failure loading image: %s", imageFileName), ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class Preferences
update_accumulation_time, update_delay, plot_update_delay, image_update_delay,
tooltip_length, embedded_timeout;

@Preference
public static double svg_rendering_resolution_factor;

static
{
AnnotatedPreferences.initialize(Preferences.class, "/display_representation_preferences.properties");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,21 @@ tooltip_length=200

# Timeout for load / unload of Embedded Widget content [ms]
embedded_timeout=5000

# 'svg_rendering_resolution_factor' determines a factor
# to multiply the rendering resolution of SVGs with.
# E.g., to render SVGs at double the default resolution
# both horizontally and vertically, the option can be
# set to svg_rendering_resolution_factor=2.0. This option
# can be useful to enable sharper rendering when zooming
# in. However, the additional sharpness comes at the
# cost of a significant increase in memory consumption,
# as described in the next paragraph.
#
# IMPORTANT: The memory consumption scales as the square of
# the value of 'svg_rendering_resolution_factor'! E.g.,
# when svg_rendering_resolution_factor=2.0, then rendered SVGs
# consume 4 times the memory compared to rendered SVGs when
# svg_rendering_resolution_factor=1.0. For this reason,
# this option should almost certainly be a very low number.
svg_rendering_resolution_factor=1.0
Loading