Home
Categories
Dictionnary
Download
Project Details
FAQ
License

LoaderParameters


    1  Parameters
       1.1  styleSheets
       1.2  scale
       1.3  width
       1.4  scaleLineWidth
       1.5  centerImage
       1.6  applyViewportPosition
    2  See also

The LoaderParameters class allows to specify how you want to load the SVG content by the SVGLoader.

Parameters

styleSheets

The styleSheets parameter allows to set an external StyleSheet to apply to the SVG result.

For example:

      LoaderParameters params = new LoaderParameters();
      params.stylesheet = <the stylesheets path>
      SVGImage image = SVGLoader.load(<my svg>, params);

scale

The scale parameter allows to scale the SVG result. Note that:
  • An alternate way to define a scaling is to use the width parameter. These two parameters are mutually exclusive. If the scale and width are both present, the scale will be applied and width will be ignored
By default the SVG result is not scaled.

For example:

      LoaderParameters params = new LoaderParameters();
      params.scale = 0.5d;
      SVGImage image = SVGLoader.load(<my svg>, params);

The parser will not apply a transform on the result of the parsing but will scale each coordinate during the parsing. For example, if you have the following svg content:
         <line x1="0" y1="0" x2="200" y2="200" />

and you apply the previous parmaters during the loading, the result will be as if you had:
         <line x1="0" y1="0" x2="100" y2="100" />



width

The width parameter allows to scale the SVG result by specifying the desired width of the result. Note that:
  • An alternate way to define a scaling is to use the scale parameter
  • The parser will not apply a transform on the result of the parsing but will scale each coordinate during the parsing
By default the SVG result with will not be scaled.

For example:

      LoaderParameters params = new LoaderParameters();
      params.width = 50;
      SVGImage image = SVGLoader.load(<my svg>, params);

scaleLineWidth

The scaleLineWidth parameter specifies if line widths will also be scaled if the scale or width parameter is used to scale the SVG result.

By default the line widths will also be scaled.

For example:

      LoaderParameters params = new LoaderParameters();
      params.scale = 0.5d;
      params.scaleLineWidth = false;
      SVGImage image = SVGLoader.load(<my svg>, params);

centerImage

The centerImage parameter specifies if the resulting SVG Node position must be centered.

By default the SVG Node position will not be centered.

For example:

      LoaderParameters params = new LoaderParameters();
      params.centerImage = true;
      SVGImage image = SVGLoader.load(<my svg>, params);

applyViewportPosition

The applyViewportPosition parameter specifies if the x and x coordinates of the viewPort position must be taken into account in the result.

By default the SVG viewPort position will be taken into account.

For example:

      LoaderParameters params = new LoaderParameters();
      params.applyViewportPosition = false;
      SVGImage image = SVGLoader.load(<my svg>, params);

See also


Categories: fromsvg

Copyright 2021-2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD-3-Clause License