Documentation
¶
Overview ¶
Package godraw implements basic types and helper functions to work with mxGraph Model.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cell ¶
type Cell struct {
XMLName xml.Name `xml:"mxCell"`
ID string `xml:"id,attr"`
Value string `xml:"value,attr,omitempty"`
Style Style `xml:"style,attr,omitempty"`
ParentID string `xml:"parent,attr,omitempty"`
Vertex string `xml:"vertex,attr,omitempty"`
Edge string `xml:"edge,attr,omitempty"`
SourceID string `xml:"source,attr,omitempty"`
TargetID string `xml:"target,attr,omitempty"`
Geometry *Geometry
}
A Cell represents an element of the graph model. A cell can be a layer (its ParentID points to the root cell's ID); a vertex in a graph (Vertex="1"); or an edge in a graph (Edge="1").
func NewImage ¶
NewImage returns a new Vertex Cell, configured as an image, with given unique ID (id), parent ID (layerId) and image source URL (url). The new cell contains a default geometry which you might want to change.
func NewImageXY ¶
NewImageXY returns a new Vertex Cell, configured as an image, with given unique ID (id), parent ID (layerId), image source URL (url), and coordinates (x and y).
type Geometry ¶
type Geometry struct {
XMLName xml.Name `xml:"mxGeometry"`
X int `xml:"x,attr,omitempty"`
Y int `xml:"y,attr,omitempty"`
Width string `xml:"width,attr,omitempty"`
Height string `xml:"height,attr,omitempty"`
Relative string `xml:"relative,attr,omitempty"`
As string `xml:"as,attr"`
}
A Geometry can be slightly different for vertices or edges. When used with vertices, it carries the x and y coordinates, the width, and the height of the vertex. For edges, contains optional terminal and control points. In most cases, the "As" attribute will have the value "geometry".
type GraphModel ¶
type GraphModel struct {
XMLName xml.Name `xml:"mxGraphModel"`
Dx int `xml:"dx,attr"`
Dy int `xml:"dy,attr"`
Arrows string `xml:"arrows,attr,omitempty"`
Root []Cell `xml:"root>mxCell"`
}
A GraphModel implements a wrapper around the cells which are in charge of storing the actual graph data structure.
The model must have a top-level root cell which contains the layers (typically one layer is enough). All cells with Parent ID pointing to the root cell is a layer. All other cells shall have parent IDs pointing to layers, not the root cell.
func NewGraph ¶
func NewGraph(layerId string) GraphModel
NewGraph returns a new graph model containing a root cell and one layer with ID layerId.
func (*GraphModel) Add ¶
func (g *GraphModel) Add(c *Cell) *GraphModel
Add adds the given Cell to the root cell of the receiving graph model.
type Style ¶
A Style is a map of key-value pairs to describe the style properties of each cell.
func (Style) MarshalXMLAttr ¶
MarshalXMLAttr returns an XML attribute with the encoded value of Style. It implements xml.MarshalerAttr interface.