nope/resources/svgjs/README.md

79 lines
3.2 KiB
Markdown
Raw Normal View History

2020-11-02 16:53:22 +00:00
# ZeMA-SGT
A SVG-Render-Engine based on SVG.JS
## Used Libraries
2021-08-04 16:17:23 +00:00
| Library Name | Link | Functionality |
| ------------------ | ------------------------------------------------- | --------------------------------------------------- |
| _SVG.js_ | http://svgjs.com/ | Simplify the SVG-Drawings |
| _svg.select.js_ | https://svgjs.com/docs/2.7/plugins/svg-select-js/ | Enabling selecting of Elements with a defined shape |
| _svg.draggable.js_ | https://github.com/svgdotjs/svg.draggable.js | Enabling dragging of Nodes |
| _svg.resize.js_ | https://github.com/svgdotjs/svg.resize.js | Enabling nice interface for resizing Nodes |
2020-11-02 16:53:22 +00:00
## Functionality
A Graph consits of Nodes and Edges. Action-Containers provide functionalities to interact with the Graph.
### Nodes
2021-08-04 16:17:23 +00:00
- All nodes of a graph are based on a [`IBaseNode`](http://mszema24:8080/m.karkowski/ZeMA-SGT/blob/master/types/IBaseNode.ts).
- [`ISingleNode`](http://mszema24:8080/m.karkowski/ZeMA-SGT/blob/master/types/ISingleNode.ts) extend the IBaseNode, by adding the Possibility to add [`IConnectors`](http://mszema24:8080/m.karkowski/ZeMA-SGT/blob/master/types/IConnector.ts) to the Node.
- [`IContainerNode`](http://mszema24:8080/m.karkowski/ZeMA-SGT/blob/master/types/IContainerNode.ts)'s extend a Single-Nodes and allow adding Childs - `IBaseNodes` - to a Node.
2020-11-02 16:53:22 +00:00
The Type-Definitions are located in `./types`.
#### Events of a Base-Node
2021-08-04 16:17:23 +00:00
2020-11-02 16:53:22 +00:00
A Node fires Event on the following actions:
2021-08-04 16:17:23 +00:00
- onMouseOver
- onMouseOut
- onMouseDown
- onMouseUp
- onClick
- onDoubleClick
- onHover
- onDragging
- onDragEnd
- onResizing
- onResizingEnd
#### Observables of a Base-Node
2020-11-02 16:53:22 +00:00
You can subscribe to the following Content of Elements:
2021-08-04 16:17:23 +00:00
- the _Events_ mentioned above
- localPosition - The position of the Node in relation to its Parent given as Left-Corner
- localCenterPosition - The position of the Node's Center in relation to its Parent given as Left-Corner
- globalPosition - The position of the Node in the Drawing
- globalCenterPosition - The position of the Node's Center in the Drawing
- width
- height
- style
2020-11-02 16:53:22 +00:00
#### Available-Shapes
At the Current release the following shapes are available by default:
2021-08-04 16:17:23 +00:00
- Circular-Images
- Ellipse
- Hexagons
- Rectangles
- Triangles
- Text
2020-11-02 16:53:22 +00:00
They are located in `./src/nodes/basic/`
##### Adding custom Base-Shapes:
To add custom shapes create a the corresponding class in `./src/nodes/basic/`. Then link the class in the assembly (`./src/assembly/manual-assembly.ts`) Therefore a Template is provided in `./src/nodes/basic/Template.dat`
To define your custom shape, the following methods must be provided by your class:
2021-08-04 16:17:23 +00:00
- `updateElement`, which will be called on changes of the shape (its `width` and `height` etc).
- `drawElement`, which will be called during the creation of the Shape
2020-11-02 16:53:22 +00:00
### Customize the Default-Look
To Customize the Default Look edit the `src\DefaultStyle.ts` File. The allowed Structure of a Style is defined in `types\IStyle`. The Default Theme uses the Color-Shapes of the `coperate Theme` (see ngx-admin).