diff --git a/api/src/org/labkey/api/attachments/SvgSource.java b/api/src/org/labkey/api/attachments/SvgSource.java index 0e5e542aebe..bf7c068a45d 100644 --- a/api/src/org/labkey/api/attachments/SvgSource.java +++ b/api/src/org/labkey/api/attachments/SvgSource.java @@ -3,6 +3,7 @@ import org.apache.batik.anim.dom.SVGDOMImplementation; import org.apache.batik.transcoder.TranscoderException; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import org.labkey.api.util.PageFlowUtil; import org.labkey.api.view.NotFoundException; @@ -19,6 +20,8 @@ public class SvgSource { private final String _filteredSvg; + private Float _height = null; + public SvgSource(String svg) { if (StringUtils.isBlank(svg)) @@ -29,11 +32,19 @@ public SvgSource(String svg) if (!svg.contains("xmlns=\"" + SVGDOMImplementation.SVG_NAMESPACE_URI + "\"") && !svg.contains("xmlns='" + SVGDOMImplementation.SVG_NAMESPACE_URI + "'")) svg = svg.replace(" { @@ -740,8 +738,9 @@ public void validate(Object o, Errors errors) * Content-type of request must be text/xml, not any kind of multipart * Returns a PNG image. */ + @SuppressWarnings("unused") @RequiresPermission(ReadPermission.class) - public class ExportImageAction extends ExportSVGAction + public static class ExportImageAction extends ExportSVGAction { @Override public ModelAndView handleRequest() throws Exception @@ -753,7 +752,14 @@ public ModelAndView handleRequest() throws Exception DocumentConversionService svc = DocumentConversionService.get(); if (null != svc) - svc.svgToPng(getSVGSource(), response.getOutputStream()); + { + // Ensure high resolution image even if browser submits a small SVG. See Issue 53390. + SvgSource svgSource = getSVGSource(); + Float height = svgSource.getHeight(); + if (height != null) + height = Math.max(height * 2, 2000); + svc.svgToPng(svgSource, response.getOutputStream(), height); + } return null; } @@ -764,8 +770,9 @@ public ModelAndView handleRequest() throws Exception * Content-type of request must be text/xml, not any kind of multipart * Returns a PDF document containing the visualization as a scalable vector graphic */ + @SuppressWarnings("unused") @RequiresPermission(ReadPermission.class) - public class ExportPDFAction extends ExportSVGAction + public static class ExportPDFAction extends ExportSVGAction { @Override public ModelAndView handleRequest() throws Exception @@ -1133,74 +1140,62 @@ public ApiResponse execute(SaveVisualizationForm form, BindException errors) thr } } - @RequiresPermission(ReadPermission.class) - public class TimeChartWizardAction extends SimpleViewAction + private abstract class AbstractChartWizardAction extends SimpleViewAction { - String _navTitle = "Chart Wizard"; + private String _navTitle = "Chart Wizard"; @Override public ModelAndView getView(ChartWizardReportForm form, BindException errors) throws Exception { form.setAllowToggleMode(true); - form.setRenderType("time_chart"); // issue 27439: allow chart wizard report lookup by name if reportId not provided Report report = getReport(form); if (form.getReportId() == null && report != null && report.getDescriptor() != null) form.setReportId(report.getDescriptor().getReportId()); - JspView timeChartWizard = new JspView<>("/org/labkey/visualization/views/chartWizard.jsp", form); - timeChartWizard.setTitle(_navTitle); - timeChartWizard.setFrame(WebPartView.FrameType.NONE); - VBox boxView = new VBox(timeChartWizard); + JspView chartWizard = new JspView<>("/org/labkey/visualization/views/chartWizard.jsp", form); + chartWizard.setTitle(_navTitle); + chartWizard.setFrame(WebPartView.FrameType.NONE); if (report != null) - { _navTitle = report.getDescriptor().getReportName(); - } - return boxView; + return chartWizard; } @Override public void addNavTrail(NavTree root) { - setHelpTopic("timeChart"); root.addChild(_navTitle); } } @RequiresPermission(ReadPermission.class) - @Action(ActionType.SelectData.class) // TODO rename to just ChartWizardAction - public class GenericChartWizardAction extends SimpleViewAction + @Action(ActionType.SelectData.class) + public class TimeChartWizardAction extends AbstractChartWizardAction { - String _navTitle = "Chart Wizard"; - @Override public ModelAndView getView(ChartWizardReportForm form, BindException errors) throws Exception { - form.setAllowToggleMode(true); - - // issue 27439: allow chart wizard report lookup by name if reportId not provided - Report report = getReport(form); - if (form.getReportId() == null && report != null && report.getDescriptor() != null) - form.setReportId(report.getDescriptor().getReportId()); - - JspView view = new JspView<>("/org/labkey/visualization/views/chartWizard.jsp", form); - view.setTitle(_navTitle); - view.setFrame(WebPartView.FrameType.NONE); - - if (report != null) - _navTitle = report.getDescriptor().getReportName(); + form.setRenderType("time_chart"); + setHelpTopic("timeChart"); - return view; + return super.getView(form, errors); } + } + @RequiresPermission(ReadPermission.class) + @Action(ActionType.SelectData.class) + // TODO rename to just ChartWizardAction + public class GenericChartWizardAction extends AbstractChartWizardAction + { @Override - public void addNavTrail(NavTree root) + public ModelAndView getView(ChartWizardReportForm form, BindException errors) throws Exception { setHelpTopic("reportsAndViews"); - root.addChild(_navTitle); + + return super.getView(form, errors); } }