Packagecom.kapit.diagram.library
Classpublic class SVGAssetLibrary
InheritanceSVGAssetLibrary Inheritance com.kapit.xsvg.library.XSVGLibrary

This class is used to store the SVG library used to draw sprites in a DiagramView. The class is a singleton. Only one SVGAssetLibrary can be created and this singleton is used by all DiagramView.

SVGAssertLibrary supports a subset of SVG 1.1. Most of the features needed for sprite definitions are supported :

Sprite definition

To define sprites, Diagrammer uses extensions to standard SVG. They are defined in the namespace http://schemas.kapit.fr/svg/2007/. You must add to the tag in your library the following attribute : xmlns:k="http://schemas.kapit.fr/svg/2007/".

Each sprite must be defined as a group (<g> tag), with the followings attributes :

Actions and anchor point definition

Using css styling, you can define how user can interact with each sprite. To enable input links to a part of a sprite, you must add the style action-accept:link to this part (it can be a group or any basic drawing instruction). To enable output links for a part of a sprite, you must add the style action-click:link to this part. To enable annotation for a part of a sprite, you must add the action-accept:annotation to this part. We usually put this in the group that defines the sprite. As a basic rule, it is better to add a dedicated transparent path to define the link anchors, but depending on the sprite we can use part of sprite.

SVG Extensions

This library implements SVG extensions to provide rendering and manipulation indications to applications.

These extensions use the namespace k, URI: http://schemas.kapit.fr/svg/2007/.

Their main purpose is to :

Attributes :

Tags :

<k:textfield> : generated tag, used internally to manage multiline textfields which are not provided by SVG specification.


Example
This sample show how to create the SVGAssetLibary during application preinitialization
 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  preinitialize="init();"
     ...
  ...
 <mx:XML xmlns="" id="svglib">
 <svg ....
 ...
 </svg>
 </mx:XML>
  ...
  ...
         public function init():void
         {
             var lib:SVGAssetLibrary=new SVGAssetLibrary(svglib);
         }
  ...
 

See also

com.kapit.diagram.view.DiagramView


Public Properties
 PropertyDefined by
  groupnames : Array
[read-only]
SVGAssetLibrary
  librarystylesheet : String
SVGAssetLibrary
  sysgroupnames : Array
[read-only]
SVGAssetLibrary
  systemstylesheet : String
SVGAssetLibrary
Protected Properties
 PropertyDefined by
  _iconcache : Object
[static]
SVGAssetLibrary
  _lib : SVGAssetLibrary = null
[static]
SVGAssetLibrary
  _syslib : XSVGLibrary = null
[static]
SVGAssetLibrary
Public Methods
 MethodDefined by
  
SVGAssetLibrary(svg:XML)
Creates a new SVGAssetLibrary instance from an svg object.
SVGAssetLibrary
  
createSVGDocument(width:Number, height:Number):SVGSVGElement
SVGAssetLibrary
  
getDefaultSpriteID(group:String):String
SVGAssetLibrary
  
SVGAssetLibrary
  
[static] Returns a sole instance of the SVGAssetLibraryclass.
SVGAssetLibrary
  
getSVGAsset(spriteid:String, w:Boolean, h:*, keepAspectRatio:* = true):SVGAsset
SVGAssetLibrary
  
getSVGIcon(spriteid:String, w:Boolean, h:*, keepAspectRatio:* = true):Bitmap
SVGAssetLibrary
  
getSysSVGAsset(spriteid:String, w:*, h:*):SVGAsset
SVGAssetLibrary
  
getSysSVGIcon(spriteid:String, w:Boolean, h:*, keepAspectRatio:* = true):Bitmap
SVGAssetLibrary
  
imageLoadedHandler(el:SVGElement):void
Called by an SVGImageElement on its svgroot when image loading has completed
SVGAssetLibrary
  
initIconsCache(w:Number, h:Number):void
SVGAssetLibrary
Protected Methods
 MethodDefined by
  
_getSVGAsset(lib:XSVGLibrary, spriteid:String, w:Boolean, h:*, keepAspectRatio:* = true):SVGAsset
SVGAssetLibrary
  
cacheSVGIcon(spriteid:String, w:Number, h:Number, asset:SVGAsset, keepAspectRatio:Boolean = true):void
SVGAssetLibrary
  
cloneCachedSVGIcon(spriteid:String, w:Number, h:Number, keepAspectRatio:Boolean = true):Bitmap
SVGAssetLibrary
  
Initializes the system library.
SVGAssetLibrary
  
updateCachedIcons(spriteid:String):void
SVGAssetLibrary
Property detail
groupnamesproperty
groupnames:Array  [read-only]Implementation
    public function get groupnames():Array
_iconcacheproperty 
protected static var _iconcache:Object
_libproperty 
protected static var _lib:SVGAssetLibrary = null
librarystylesheetproperty 
librarystylesheet:String  [read-write]Implementation
    public function get librarystylesheet():String
    public function set librarystylesheet(value:String):void
sysgroupnamesproperty 
sysgroupnames:Array  [read-only]Implementation
    public function get sysgroupnames():Array
_syslibproperty 
protected static var _syslib:XSVGLibrary = null
systemstylesheetproperty 
systemstylesheet:String  [read-write]Implementation
    public function get systemstylesheet():String
    public function set systemstylesheet(value:String):void
Constructor detail
SVGAssetLibrary()constructor
public function SVGAssetLibrary(svg:XML)

Creates a new SVGAssetLibrary instance from an svg object.

Parameters
svg:XML — An svg object from which the SVGAssetLibrary will be created.
Method detail
_getSVGAsset()method
protected function _getSVGAsset(lib:XSVGLibrary, spriteid:String, w:Boolean, h:*, keepAspectRatio:* = true):SVGAssetParameters
lib:XSVGLibrary
 
spriteid:String
 
w:Boolean
 
h:*
 
keepAspectRatio:* (default = true)

Returns
SVGAsset
cacheSVGIcon()method 
protected function cacheSVGIcon(spriteid:String, w:Number, h:Number, asset:SVGAsset, keepAspectRatio:Boolean = true):voidParameters
spriteid:String
 
w:Number
 
h:Number
 
asset:SVGAsset
 
keepAspectRatio:Boolean (default = true)
cloneCachedSVGIcon()method 
protected function cloneCachedSVGIcon(spriteid:String, w:Number, h:Number, keepAspectRatio:Boolean = true):BitmapParameters
spriteid:String
 
w:Number
 
h:Number
 
keepAspectRatio:Boolean (default = true)

Returns
Bitmap
createSVGDocument()method 
public function createSVGDocument(width:Number, height:Number):SVGSVGElementParameters
width:Number
 
height:Number

Returns
SVGSVGElement
getDefaultSpriteID()method 
public function getDefaultSpriteID(group:String):StringParameters
group:String

Returns
String
getDefaultSpriteIDs()method 
public function getDefaultSpriteIDs():Array

Returns
Array
getInstance()method 
public static function getInstance():SVGAssetLibrary

Returns a sole instance of the SVGAssetLibraryclass.

Returns
SVGAssetLibrary — An instance of the SVGAssetLibrary class.
getSVGAsset()method 
public function getSVGAsset(spriteid:String, w:Boolean, h:*, keepAspectRatio:* = true):SVGAssetParameters
spriteid:String
 
w:Boolean
 
h:*
 
keepAspectRatio:* (default = true)

Returns
SVGAsset
getSVGIcon()method 
public function getSVGIcon(spriteid:String, w:Boolean, h:*, keepAspectRatio:* = true):BitmapParameters
spriteid:String
 
w:Boolean
 
h:*
 
keepAspectRatio:* (default = true)

Returns
Bitmap
getSysSVGAsset()method 
public function getSysSVGAsset(spriteid:String, w:*, h:*):SVGAssetParameters
spriteid:String
 
w:*
 
h:*

Returns
SVGAsset
getSysSVGIcon()method 
public function getSysSVGIcon(spriteid:String, w:Boolean, h:*, keepAspectRatio:* = true):BitmapParameters
spriteid:String
 
w:Boolean
 
h:*
 
keepAspectRatio:* (default = true)

Returns
Bitmap
imageLoadedHandler()method 
public override function imageLoadedHandler(el:SVGElement):void

Called by an SVGImageElement on its svgroot when image loading has completed

Parameters
el:SVGElement — SVGElement
initIconsCache()method 
public function initIconsCache(w:Number, h:Number):voidParameters
w:Number
 
h:Number
initSysLibrary()method 
protected function initSysLibrary():void

Initializes the system library.

updateCachedIcons()method 
protected function updateCachedIcons(spriteid:String):voidParameters
spriteid:String