Skip to content

Javadoc of SVGRasterizer is incomplete or wrong #2515

@laeubi

Description

@laeubi

I just noticed that the javadoc is probably incomplete or wrong when I reviewed another PR in that area:

public interface SVGRasterizer {
/**
* Rasterizes an SVG image from the provided {@code InputStream} using the
* specified zoom.
*
* @param stream the SVG image as an {@link InputStream}.
* @param zoom the scaling factor (in percent) e.g. {@code 200} for doubled
* size. This value must be greater zero.
* @return the {@link ImageData} for the rasterized image, or {@code null} if
* the input is not a valid SVG file or cannot be processed.
*/
public ImageData rasterizeSVG(InputStream stream, int zoom) throws IOException;
}

I see the following issues:

  1. IOException is thrown but not documented under what condition this happens, the @return claims it return null on invalid data but why not throw IOException always it seems odd to have null here (then maybe Optional would have been a better choice) and what invalid means.
  2. In the head it talks about a "zoom" (also parameter is named) but then in the description it says it is a scaling factor in percent, where a factor usually has no unit and percent itself is usually defined as 1% be a factor of 0.01 so for a scaling factor that represents the double size one would expect to have 2.0 as a factor.

For example, 45% (read as "forty-five percent") is equal to the fraction ⁠45/100⁠, or 0.45.

So I think the javadoc should be streamlined here to avoid confusion even if it is an internal API and only has one implementation at the moment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions