Creates a stencil object.
internal stencil identifier
SVG container for all the stencil's visuals
settings for the whole diagram
Protected
_containerTop level SVG container (group) encapsulating all the visual elements of this stencil.
Protected
_defaultDefault size of the stencil when created.
Override in the descendant stencils to set a size that makes sense for the stencil type.
Protected
_fillStencil's fill color.
Protected
Optional
_frameStencil's frame path. Usually the main stencil visual.
Protected
Optional
_selectorStencil's frame path for selection. Usually an extended (wider) version of the _frame.
Protected
_strokeStencil's outline (stroke) color.
Protected
_strokeProtected
_strokeStencil's outline (stroke) width in pixels.
Specifies whether stencil's fill can be changed by the user.
Stencil height.
Left (x) coordinate of the stencil.
Optional
notesStore any arbitrary string information associated with this stencil in this field.
Holds a collection of connector ports for this stencil.
Specifies whether stencil's stroke properties can be changed by the user.
Top (y) coordinate of the stencil.
Stencil width.
Static
titleDefault name of the stencil.
Static
typeA string representation of the type used in diagram configuration (state) JSON.
Internal stencil identifier used in state/configuration JSON as reference to this stencil.
Returns the bottom edge (y) coordinate (calculated)
Protected
centerXReturns the stencil center X coordinate (calculated).
Protected
centerYReturns the stencil center Y coordinate (calculated).
Top level SVG container (group) encapsulating all the visual elements of this stencil.
Returns stencil's fill color.
Returns the right edge (x) coordinate (calculated).
Protected
settingsSettings for the whole diagram.
Returns stencil's outline (stroke) color.
Returns stencil's outline (stroke) width in pixels.
A string representation of the type used in diagram configuration (state) JSON.
Instance accessor returning the value of static typeName.
Protected
visualReturns the SVG group holding the stencil's visual.
Sets the stencil's visual.
Protected
addProtected
adjustProtected
adjustProtected
createDisables connector ports in specified locations
By default all ports are enabled. Depending on the stencil type it makes sense to disable some (or even all) of the ports.
For example DiamondStencil has all the corner ports disabled as the stencil visual has no visible parts there.
Rest
...portLocations: PortLocation[]locations of the ports to disable.
Protected
getInstance method for getting the stencil path. Calls the static getPathD.
bounding width
bounding height
stencil's SVG path string
Returns coordinates for the port in specified location
port location
port center coordinates
Gets stencil's SVG path for the purpose of reacting to pointer and other events.
Some stencil types may have a visual that is very narrow or otherwise hard to hit with a pointer. This method provides a way to get an alternative invisible path that is easier to hit resulting in better user experience.
By default it returns the same path as the main stencil path though.
target width
target height
SVG path string
Returns stencil state (configuration) used to save the whole diagram for future use as well as for undo/redo operations.
stencil state object
Moves the stencil visual to the specified coordinates.
new stencil coordinates
Restores stencil configuration (settings) from a previously saved state.
previously saved state object.
Static
Protected
getStatic
getReturns a simplified thumbnail representation of the stencil as an SVG image. It is used by the editor and can potentially be used in other places.
image width
image height
thumbnail as an SVG image
Static
Protected
getOptional
onFired when the stencil creation is completed.
Generated using TypeDoc
The
StencilBase
class is the base class for all stencil types in MJS Diagram.It covers the basic functionality and APIs for all other stencil types.