com.larvalabs.svgandroid
Class SVGBuilder

java.lang.Object
  extended by com.larvalabs.svgandroid.SVGBuilder

public class SVGBuilder
extends Object

Builder for reading SVGs. Specify input, specify any parsing options (optional), then call build() to parse and return a SVG.

Since:
24/12/2012

Constructor Summary
SVGBuilder()
           
 
Method Summary
 SVG build()
          Loads, reads, parses the SVG.
 SVGBuilder clearColorSwap()
           
 SVGBuilder readFromAsset(android.content.res.AssetManager assetMngr, String svgPath)
          Parse SVG data from an Android application asset.
 SVGBuilder readFromInputStream(InputStream svgData)
          Parse SVG data from an input stream.
 SVGBuilder readFromResource(android.content.res.Resources resources, int resId)
          Parse SVG data from an Android application resource.
 SVGBuilder readFromString(String svgData)
          Parse SVG data from a string.
 SVGBuilder setCloseInputStreamWhenDone(boolean closeInputStream)
          Whether or not to close the input stream after reading (ie.
 SVGBuilder setColorFilter(android.graphics.ColorFilter colorFilter)
          Applies a ColorFilter to the paint objects used to render the SVG.
 SVGBuilder setColorSwap(int searchColor, int replaceColor)
          Replaces a single colour with another.
 SVGBuilder setFillColorFilter(android.graphics.ColorFilter colorFilter)
          Applies a ColorFilter to fills in the SVG.
 SVGBuilder setStrokeColorFilter(android.graphics.ColorFilter colorFilter)
          Applies a ColorFilter to strokes in the SVG.
 SVGBuilder setWhiteMode(boolean whiteMode)
          In white-mode, fills are drawn in white and strokes are not drawn at all.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVGBuilder

public SVGBuilder()
Method Detail

readFromInputStream

public SVGBuilder readFromInputStream(InputStream svgData)
Parse SVG data from an input stream.

Parameters:
svgData - the input stream, with SVG XML data in UTF-8 character encoding.
Returns:
the parsed SVG.

readFromString

public SVGBuilder readFromString(String svgData)
Parse SVG data from a string.

Parameters:
svgData - the string containing SVG XML data.

readFromResource

public SVGBuilder readFromResource(android.content.res.Resources resources,
                                   int resId)
Parse SVG data from an Android application resource.

Parameters:
resources - the Android context resources.
resId - the ID of the raw resource SVG.

readFromAsset

public SVGBuilder readFromAsset(android.content.res.AssetManager assetMngr,
                                String svgPath)
                         throws IOException
Parse SVG data from an Android application asset.

Parameters:
assetMngr - the Android asset manager.
svgPath - the path to the SVG file in the application's assets.
Throws:
IOException - if there was a problem reading the file.

clearColorSwap

public SVGBuilder clearColorSwap()

setColorSwap

public SVGBuilder setColorSwap(int searchColor,
                               int replaceColor)
Replaces a single colour with another.

Parameters:
searchColor - The colour in the SVG.
replaceColor - The desired colour.

setWhiteMode

public SVGBuilder setWhiteMode(boolean whiteMode)
In white-mode, fills are drawn in white and strokes are not drawn at all.


setColorFilter

public SVGBuilder setColorFilter(android.graphics.ColorFilter colorFilter)
Applies a ColorFilter to the paint objects used to render the SVG.


setStrokeColorFilter

public SVGBuilder setStrokeColorFilter(android.graphics.ColorFilter colorFilter)
Applies a ColorFilter to strokes in the SVG.


setFillColorFilter

public SVGBuilder setFillColorFilter(android.graphics.ColorFilter colorFilter)
Applies a ColorFilter to fills in the SVG.


setCloseInputStreamWhenDone

public SVGBuilder setCloseInputStreamWhenDone(boolean closeInputStream)
Whether or not to close the input stream after reading (ie. after calling build().
(default is true)


build

public SVG build()
          throws SVGParseException
Loads, reads, parses the SVG.

Returns:
the parsed SVG.
Throws:
SVGParseException - if there is an error while parsing.


Copyright © 2012. All Rights Reserved.