Diagram

@objc
open class Diagram : NSObject, LayoutContainer

Implements the main diagram model class. It acts as a container for diagram elements such as nodes and links. In addition, it defines a set of properties that determine the initial values of the diagram element attributes.

  • Initializes a new instance of the Diagram class.

    Declaration

    Swift

    public override init()

    Return Value

    The newly created Diagram instance.

  • Undocumented

    Declaration

    Swift

    open func resizeToFitItems(_ margins: Double)
  • Undocumented

    Declaration

    Swift

    open func resizeToFitItems(_ margins: Double, onlyVisible: Bool)
  • Returns a point of the alignment grid nearest to the one passed as an argument.

    Remark

    The control aligns items to the alignment grid only during user interaction. This method lets you align coordinates of programmatically created or modified items.

    Declaration

    Swift

    public func alignPointToGrid(_ point: Point) -> Point

    Parameters

    point

    A point specified in diagram coordinates.

    Return Value

    A point from the alignment grid.

  • Undocumented

    Declaration

    Swift

    public func alignRectToGrid(_ rect: Rect) -> Rect
  • Draws the specified rectangle on the specified canvas.

    Declaration

    Swift

    open func draw(_ canvas: Canvas, rect: Rect)

    Parameters

    canvas

    The canvas onto which the rectangle is drawn.

    rect

    The rectangle to draw.

  • Exports the diagram as an UIImage.

    Declaration

    Swift

    @available(iOS 9.0, *)
    public func createImage() -> UIImage?
  • Exports the diagram as image file, saving it at specified path.

    Declaration

    Swift

    @available(iOS 9.0, *)
    public func exportImage(filePath: URL, imageType: CFString) -> Bool
  • Measures the size of specified string as it would be rendered using specified font attributes.

    Declaration

    Swift

    public func measureString(
        string: String,
        fontName: String,
        fontSize: Double,
        fontUnit: MeasureUnit,
        layoutRect: Rect,
        align: HorizontalAlignment = HorizontalAlignment.left,
        bold: Bool = false,
        italic: Bool = false,
        underline: Bool = false)
        -> Size
  • Checks if the specified item is visible.

    Declaration

    Swift

    open func isItemVisible(_ item: DiagramItem) -> Bool

    Parameters

    item

    The DiagramItem to check.

    Return Value

    true if the item is visible; otherwise false.

  • Checks if the specified item is interactive.

    Declaration

    Swift

    open func isItemInteractive(_ item: DiagramItem) -> Bool

    Parameters

    item

    The DiagramItem to check.

    Return Value

    true if the item is interactive; otherwise false.

  • Checks if the specified item is locked.

    Declaration

    Swift

    open func isItemLocked(_ item: DiagramItem) -> Bool

    Parameters

    item

    The DiagramItem to check.

    Return Value

    true if the item is locked; otherwise false.

  • Gets the item at the specified point.

    Declaration

    Swift

    open func getItemAt(_ point: Point, filter: (DiagramItem) -> Bool) -> DiagramItem?

    Parameters

    point

    The Point, which must be within the DiagramItem.

    filter

    A lambda expression that checks the DiagramItem and returns true if check is successful.

    Return Value

    The DiagramItem or nil if none is found.

  • Gets the item at the specified point if it answers the specified criteria.

    Declaration

    Swift

    open func getItemAt(
        _ point: Point, excludeLocked: Bool = true, threshold: Double = 2) -> DiagramItem?

    Parameters

    point

    The Point, which must be within the DiagramItem.

    excludeLocked

    Specifies if locked items should be excluded from the check.

    threshold

    Specifies the offset to the DiagramItem bounderies within which a Point would still be considered within the diagram item.

    Return Value

    The DiagramItem or nil if none is found.

  • Gets the item at the specified point if it answers the specified criteria.

    Declaration

    Swift

    open func getNodeAt(_ point: Point, excludeLocked: Bool = true) -> DiagramNode?

    Parameters

    point

    The Point, which must be within the DiagramItem.

    excludeLocked

    Specifies if locked items should be excluded from the check.

    Return Value

    The DiagramItem or nil if none is found.

  • Gets the DiagramLink at the specified point if it answers the specified criteria.

    Declaration

    Swift

    open func getLinkAt(_ point: Point) -> DiagramLink?

    Parameters

    point

    The Point, which must be within the DiagramLink.

    excludeLocked

    Specifies if locked links should be excluded from the check.

    Return Value

    The DiagramLink or nil if none is found.

  • Returns the node nearest to the specified point.

    Declaration

    Swift

    open func getNearestNode (
        _ point: Point,
        maxDistance: Double,
        ignored: DiagramNode?,
        onlyInteractive: Bool
    )
    -> DiagramNode?

    Parameters

    point

    A Point in the diagram.

    maxDistance

    The maximum distance from the point at which to look for nodes.

    ignored

    A DiagramNode that should be ignored.

    onlyInteractive

    Specifies if only nodes with which theuser can interact should be included in the check.

    Return Value

    The DiagramNode or nil if none is found.

  • Tests if a given Point is within any of the Manipulators in the diagram.

    Declaration

    Swift

    open func hitTestManipulator(_ point: Point) -> Manipulator?

    Parameters

    point

    A Point in the diagram.

    Return Value

    The Manipulator or nil if none is found.

  • Loads the contents of the XML diagram document from the specified file into the control.

    Declaration

    Swift

    open func loadFromXml(_ fileName: String)

    Parameters

    fileName

    The name of the XML file the data should be read from.

  • Loads the contents of the XML diagram document from the specified file into the control.

    Declaration

    Swift

    open func loadFromXml(_ fileUrl: URL)

    Parameters

    fileUrl

    URL of the XML file the data should be read from.

  • Loads the contents of the XML diagram document from the specified XML element into the control.

    Declaration

    Swift

    open func loadFromXml(_ document: XmlElement?)

    Parameters

    document

    The name of the XmlElement the data should be read from. The value can be nil.

  • Undocumented

    Declaration

    Swift

    open func saveToXml(_ fileUrl: URL)
  • Saves the diagram into XML format using the specified XmlDomBuilder document.

    Declaration

    Swift

    open func saveToXml(_ document: XmlDomBuilder)

    Parameters

    document

    A XmlDomBuilder, which writes the diagram contents.

  • Adds a new item to the diagram.

    Declaration

    Swift

    open func addItem(_ item: DiagramItem)

    Parameters

    item

    The DiagramItem to add.

  • Removes the specified item from the diagram.

    Declaration

    Swift

    open func removeItem(_ item: DiagramItem)

    Parameters

    item

    The DiagramItem to remove.

  • Gets the Brush used for painting the background.

    Declaration

    Swift

    open func getEffectiveBackBrush() -> Brush?

    Return Value

    The Brush used for painting the background; nil if none is used.

  • Loads the requested theme from the specified XmlElement and XmlContext.

    Declaration

    Swift

    open func loadTheme(_ parentElement: XmlElement?, name: String, context: XmlContext) -> Theme?

    Parameters

    parentElement

    The XmlElement from which the theme is loaded.

    name

    The name of the Theme

    context

    The XmlContext from which the theme is read.

    Return Value

    The Theme or nil if none is found.

  • Undocumented

    Declaration

    Swift

    open func clear()
  • Updates the indices of the diagram items in runtime according to their Z-order.

    Declaration

    Swift

    open func updateRuntimeIndices()
  • Repaints the diagram.

    Declaration

    Swift

    open func invalidate()
  • Repaints the specified portion of the diagram.

    Declaration

    Swift

    open func invalidate(_ rect: Rect)

    Parameters

    rect

    The rectangle, which should be repainted.

  • Raised when views displaying this diagram should repaint.

    Declaration

    Swift

    public var repaint: Event<RepaintEventArgs>
  • Raised when the user clicks a node.

    Declaration

    Swift

    public var clicked: Event<DiagramEventArgs>
  • Raised when the user double-clicks a node.

    Declaration

    Swift

    public var doubleClicked: Event<DiagramEventArgs>
  • Raised when the user draws a new node.

    Declaration

    Swift

    public var nodeCreated: Event<NodeEventArgs>
  • Raised when the user draws a new link.

    Declaration

    Swift

    public var linkCreated: Event<LinkEventArgs>
  • A validation event raised while the user is drawing a new node.

    Declaration

    Swift

    public var nodeCreating: Event<NodeValidationEventArgs>
  • A validation event raised while the user is drawing a new link.

    Declaration

    Swift

    public var linkCreating: Event<LinkValidationEventArgs>
  • Raised when the user moves or resizes a node.

    Declaration

    Swift

    public var nodeModified: Event<NodeEventArgs>
  • Raised when the user modifies a link.

    Declaration

    Swift

    public var linkModified: Event<LinkEventArgs>
  • A validation event raised while the user is moving or resizing a node.

    Declaration

    Swift

    public var nodeModifying: Event<NodeValidationEventArgs>
  • A validation event raised while the user is modifying a link.

    Declaration

    Swift

    public var linkModifying: Event<LinkValidationEventArgs>
  • Raised when the user clicks a node.

    Declaration

    Swift

    public var nodeClicked: Event<NodeEventArgs>
  • Raised when the user double-clicks a node.

    Declaration

    Swift

    public var nodeDoubleClicked: Event<NodeEventArgs>
  • Raised when the user clicks a link.

    Declaration

    Swift

    public var linkClicked: Event<LinkEventArgs>
  • Raised when the user double-clicks a link.

    Declaration

    Swift

    public var linkDoubleClicked: Event<LinkEventArgs>
  • Raised when the context menu shows after a long press.

    Declaration

    Swift

    public var contextMenuCreated: Event<ContextMenuEventArgs>
  • Raised when a node is deleted, either programmatically or by the user.

    Declaration

    Swift

    public var nodeDeleted: Event<NodeEventArgs>
  • Raised when the user tries to delete a node, this event lets you cancel the operation.

    Declaration

    Swift

    public var nodeDeleting: Event<NodeValidationEventArgs>
  • Raised when a link is deleted, either programmatically or by the user.

    Declaration

    Swift

    public var linkDeleted: Event<LinkEventArgs>
  • Raised when the user tries to delete a link, this event lets you cancel the operation.

    Declaration

    Swift

    public var linkDeleting: Event<LinkValidationEventArgs>
  • Raised when the user edits the text of a node.

    Declaration

    Swift

    public var nodeTextEdited: Event<EditNodeTextEventArgs>
  • A validation event that lets you approve or reject changes made to the text of a node.

    Declaration

    Swift

    public var nodeTextEditing: Event<EditNodeTextEventArgs>
  • Raised when the user edits the text of a link.

    Declaration

    Swift

    public var linkTextEdited: Event<EditLinkTextEventArgs>
  • A validation event that lets you approve or reject changes made to the text of a link.

    Declaration

    Swift

    public var linkTextEditing: Event<EditLinkTextEventArgs>
  • Raised when the user edits the text of a link label.

    Declaration

    Swift

    public var linkLabelEdited: Event<EditLinkLabelEventArgs>
  • A validation event that lets you approve or reject changes made to the text of a link label.

    Declaration

    Swift

    public var linkLabelEditing: Event<EditLinkLabelEventArgs>
  • Raised when the user edits the text of a table cell.

    Declaration

    Swift

    public var cellTextEdited: Event<EditCellTextEventArgs>
  • A validation event that lets you approve or reject changes made to the text of a table cell.

    Declaration

    Swift

    public var cellTextEditing: Event<EditCellTextEventArgs>
  • Raised when the user edits the text of a treeview item.

    Declaration

    Swift

    public var treeItemEdited: Event<EditTreeItemTextEventArgs>
  • A validation event that lets you approve or reject changes made to the text of a treeview item.

    Declaration

    Swift

    public var treeItemEditing: Event<EditTreeItemTextEventArgs>
  • Undocumented

    Declaration

    Swift

    public var nodeCollapsed: Event<NodeValidationEventArgs>
  • Undocumented

    Declaration

    Swift

    public var nodeExpanded: Event<NodeValidationEventArgs>
  • Unsubscribes all events.

    Declaration

    Swift

    open func unsubFromAllEvents()
  • Registers the Diagram class as an item class with the specified attributes.

    Declaration

    Swift

    open class func registerItemClass(_ itemClass: Metatype<AnyObject>, classId: String, classVersion: Int)

    Parameters

    itemClass

    The type of the class.

    classId

    A unique string identifier for the class.

    classVersion

    The version of the class.

  • Registers the Diagram class as a class with the specified attributes.

    Declaration

    Swift

    open class func registerClass(_ classType: Metatype<AnyObject>, classId: String, classVersion: Int)

    Parameters

    itemClass

    The type of the class.

    classId

    A unique string identifier for the class.

    classVersion

    The version of the class.

  • Arranges the diagram with the specified layout.

    Declaration

    Swift

    open func arrange(_ layout: Layout)

    Parameters

    layout

    The Layout to apply.

  • A collection of all DiagramNode-s.

    Declaration

    Swift

    open var nodes: [DiagramNode]
  • A collection of all DiagramLink-s.

    Declaration

    Swift

    open var links: [DiagramLink]
  • The bounds of the diagram.

    Declaration

    Swift

    open var bounds: Rect { get set }
  • The unit ot measure for the diagram.

    Declaration

    Swift

    open var measureUnit: MeasureUnit { get set }
  • The default Brush for painting diagram items or nil.

    Declaration

    Swift

    open var brush: Brush? { get set }
  • Specifies whether the alignment grid is visible.

    Remark

    If it is visible, the grid is painted as either a matrix of points or crossing horizontal and vertical lines. That depends on the value of gridStyle.

    Declaration

    Swift

    public var showGrid: Bool { get set }

    Return Value

    true if the alignment grid is visible, or false otherwise.

  • Specifies whether diagram items should be aligned to a grid.

    Remark

    When enabled, the edges of newly created items are aligned to the nearest grid points. Snapping to alignment grid is done automatically only during user interaction. If items are created or modified through the diagram API, they are located exactly at specified coordinates, potentially unalinged. Use the alignPointToGrid(...) method if you need to find grid points from code.

    Declaration

    Swift

    public var alignToGrid: Bool

    Return Value

    true if items should be aligned to grid, or false otherwise.

  • Specifies the appearance of the alignment grid.

    Declaration

    Swift

    public var gridStyle: GridStyle { get set }

    Return Value

    A member of the GridStyle enumeration.

  • Specifies the color of grid points.

    Declaration

    Swift

    public var gridColor: Color { get set }

    Return Value

    A Color instance. The default value is RGB(140, 140, 150).

  • Specifies the horizontal distance between adjacent grid points.

    Declaration

    Swift

    public var gridSizeX: Double { get set }

    Return Value

    A Double specifying horizontal distance. The default value is 4.

  • Specifies the vertical distance between adjacent grid points.

    Declaration

    Swift

    public var gridSizeY: Double { get set }

    Return Value

    A Double specifying vertical distance. The default value is 4.

  • Specifies horizontal offset of the first point of the alignment grid.

    Declaration

    Swift

    public var gridOffsetX: Double? { get set }

    Return Value

    An optional Double specifying horizontal offset.

  • Specifies vertical offset of the first point of the alignment grid.

    Declaration

    Swift

    public var gridOffsetY: Double? { get set }

    Return Value

    An optional Double specifying vertical offset.

  • The default Theme to apply at the diagram or nil.

    Declaration

    Swift

    open var theme: Theme? { get set }
  • Undocumented

    Declaration

    Swift

    public var shapeNodeStyle: Style { get }
  • The default Style to apply at the diagram or nil.

    Declaration

    Swift

    open var style: Style? { get set }
  • Specifies if links should be rounded.

    Declaration

    Swift

    open var roundedLinks: Bool { get set }
  • Specifies the radius of rounded links.

    Declaration

    Swift

    open var roundedLinksRadius: Double { get set }
  • Specifies the type of LinkCrossings

    Declaration

    Swift

    open var linkCrossings: LinkCrossings
  • Specifies the count of link segments.

    Declaration

    Swift

    open var linkSegments: Int
  • Specifies if links should be routed.

    Declaration

    Swift

    open var routeLinks: Bool
  • Specifies the radius of link crossings.

    Declaration

    Swift

    open var crossingRadius: Double
  • Gets or sets a value specifying how far from a link a click is still considered a hit.

    Declaration

    Swift

    open var linkHitDistance: Double
  • Specifies if incoming links should be expanded.

    Declaration

    Swift

    open var expandOnIncoming: Bool
  • Specifies if unconnected links should be allowed.

    Declaration

    Swift

    open var allowUnconnectedLinks: Bool
  • Specifies if self loops are allowed.

    Declaration

    Swift

    open var allowSelfLoops: Bool
  • Specifies if labels should be rearranged after a layout pass.

    Declaration

    Swift

    open var labelLayoutInvalid: Bool { get set }
  • Specifies a Factory class for this diagram.

    Declaration

    Swift

    open lazy var factory: Factory { get set }
  • Specifies a list with the selected DiagramItem-s.

    Declaration

    Swift

    open var selectedItems: [DiagramItem] { get }
  • Specifies a list with the selected DiagramNode-s.

    Declaration

    Swift

    open var selectedNodes: [DiagramNode] { get }
  • Specifies a list with the selected DiagramLink-s.

    Declaration

    Swift

    open var selectedLinks: [DiagramLink] { get }
  • Clears the selection.

    Declaration

    Swift

    open func clearSelection()
  • Changes the selected item.

    Declaration

    Swift

    open func changeSelection(_ item: DiagramItem?)

    Parameters

    item

    The new DiagramItem to select; nil if none should be selected.

  • Specifies the size of adjustment handles.

    Declaration

    Swift

    open var adjustmentHandlesSize: Double
  • Specifies the offset at which touch gestures nearby a diagram item would be considered as gestures on the item itself.

    Declaration

    Swift

    open var touchThreshold: Double
  • Specifies if anchors should be drawn.

    Declaration

    Swift

    open var showAnchors: ShowAnchors
  • Specifies the render options for the diagram.

    Declaration

    Swift

    open var renderOptions: RenderOptions
  • Gets the diagram items according to their Z-order.

    Declaration

    Swift

    open var items: [DiagramItem] { get }
  • A list with the Layers in the diagram.

    Declaration

    Swift

    open var layers: [Layer]
  • Specifies the index of the default layer.

    Declaration

    Swift

    open var activeLayer: Int
  • Specifies the ShapeLibrary with the default shapes for the diagram or nil if none is used.

    Declaration

    Swift

    open class var defaultShapes: ShapeLibrary? { get set }
  • Indicates whether the control should keep action records for later undo.

    Declaration

    Swift

    public var undoEnabled: Bool { get set }
  • Gets a value indicating whether there is a command in the undo history that can be undone.

    Declaration

    Swift

    public var canUndo: Bool
  • Gets a value indicating whether there is a command in the undo history that can be redone.

    Declaration

    Swift

    public var canRedo: Bool
  • Gets a reference to the diagram’s UndoManager instance.

    Declaration

    Swift

    public var undoManager: UndoManager?
  • Undoes an action saved in the command history.

    Declaration

    Swift

    public func undo()
  • Executes again an action saved in the command history.

    Declaration

    Swift

    public func redo()
  • Starts recording undo/redo commands into a CompositeCommand.

    Declaration

    Swift

    public func startCompositeOperation()
  • Stops recording undo/redo commands into a CompositeCommand and saves the composite in the history queue.

    Declaration

    Swift

    public func commitCompositeOperation()
  • Stops recording undo/redo commands into a CompositeCommand and discards the records created so far.

    Declaration

    Swift

    public func cancelCompositeOperation()
  • Executes the specified command on this diagram.

    Declaration

    Swift

    public func executeCommand(_ command: Command)
  • Undocumented

    Declaration

    Swift

    public static var licenseKey: String { get set }