Skip to content
Phil Beauvoir edited this page Feb 23, 2024 · 120 revisions

Table of contents

All Objects
Model Objects
Elements
Relationships
Folder

View (Diagram)

.add(element)
.add(relationship)
.createConnection()
.createObject()
.createViewReference()
.isAllowedConceptForViewpoint()
.openInUI()
.viewpoint

Visual Objects

.add(element)
.bounds
.borderType
.concept
.createObject()
.createViewReference()
.deriveLineColor
.figureType
.fillColor
.fontColor
.fontName
.fontSize
.fontStyle
.iconColor
.image
.imageSource
.imagePosition
.gradient
.labelExpression
.labelValue
.lineColor
.lineWidth
.opacity
.outlineOpacity
.refView
.showIcon
.text
.textAlignment
.textPosition
.view

Visual Connections

.addRelativeBendpoint()
.deleteAllBendpoints()
.deleteBendpoint()
.labelVisible
.relativeBendpoints
.setRelativeBendpoint
.source
.style
.target


View (Diagram)

Methods described in this section are are available only on Views - ArchiMate, Sketch and Canvas Views.

.add(element)

Create and return a new diagram object referencing an ArchiMate element with given bounds.

This method only applies to ArchiMate Views.

element is an existing ArchiMate element.

autoNest optional boolean parameter. If true the diagram object will be nested inside of any existing diagram object whose bounds surrounds the new object's bounds.

Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

add(element, x, y, width, height)
add(element, x, y, width, height, autoNest)

Example:

var object= archimateView.add(businessActor, 10, 200, 150, 75);
var object= archimateView.add(businessRole, 10, 200, -1, -1, true);

.add(relationship)

Create and return a new visual object referencing an ArchiMate relationship.

relationship is an existing ArchiMate relationship.

add(relationship, sourceDiagramComponent, targetDiagramComponent)

Example:

var object1 = archimateView.add(actor, 10, 10, 150, 70);
var object2 = archimateView.add(role, 200, 10, 150, 70);
var connection = archimateView.add(relationship, object1, object2);

.createConnection()

Create and return a new non-ArchiMate connection between two objects in a View.

createConnection(source, target);

source - the source object

target - the target object

Connections can not be created between two ArchiMate objects.

Example:

var selectedView = $('view').get(0); // Get first view in the model
var note = selectedView.createObject("diagram-model-note", 10, 200, -1, -1); // Add a note
var group = selectedView.createObject("diagram-model-group", 10, 300, -1, -1); // Add a group
var connection = selectedView.createConnection(note, group); // Create and add a connection
connection.name = "My Connection"; // Give it a name

.createObject()

Create and return a new visual object of type with given bounds.

type can be one of diagram-model-note (or note) or diagram-model-group (or group)

autoNest optional boolean parameter. If true the diagram object will be nested inside of any existing diagram object whose bounds surrounds the new object's bounds.

Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

createObject(type, x, y, width, height)
createObject(type, x, y, width, height, autoNest) 

Example:

var note = archimateView.createObject("diagram-model-note", 10, 200, 200, 100, true);
note.setText("This is a note.\n\nHello World!");

var group = archimateView.createObject("diagram-model-group", 10, 200, -1, -1);

.createViewReference()

Create and return a new View reference object with given bounds.

view is an existing View (diagram model)

autoNest optional boolean parameter. If true the diagram object will be nested inside of any existing diagram object whose bounds surrounds the new object's bounds.

Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

createViewReference(view, x, y, width, height)
createViewReference(view, x, y, width, height, autoNest)

Example:

var view1 = $('view').get(0); // Get first view in the model
var view2 = $('view').get(1); // Get next view in the model
var viewRef = view1.createViewReference(view2, 10, 10, 200, 55); // Create and add a view reference

.isAllowedConceptForViewpoint()

archimateView.isAllowedConceptForViewpoint(conceptName)

Return true if the given concept is allowed in the current Viewpoint of an ArchiMate View.

Example:

var isallowed = archimateView.isAllowedConceptForViewpoint("business-actor"));

.openInUI()

Open the given View in the UI. If the View's model is not currently open in the UI, it is opened before the View is opened.

theView.openInUI();

.viewpoint

Get/set the Viewpoint of an ArchiMate View.

Allowed viewpoint identifier strings that can be set:

application_cooperation
application_usage
business_process_cooperation
capability
goal_realization
implementation_deployment
implementation_migration
information_structure
layered
migration
motivation
organization
outcome_realization
physical
product
project
requirements_realization
resource
service_realization
stakeholder
strategy
technology
technology_usage

Setting the viewpoint identifier to the empty string "" sets it to no viewpoint.

The returned viewpoint JS object consists of the viewpoint ID and the human readable name.

Example:

archimateView.viewpoint = "implementation_deployment";
var vp = archimateView.viewpoint;
var id = vp.id;
var name = vp.name;

Visual Objects

Attributes and methods described in this section are available only on Visual Objects (i.e., boxes and connections that appear on a diagram and inherit from DiagramModelObject and DiagramModelConnection).

Colors are coded as hex triplet (red, green, blue) with a leading hash. For example red is coded as "#ff0000".

.add(element)

Create and return a new nested visual object referencing an ArchiMate element with given bounds.

element is an existing ArchiMate element.

Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

add(element, x, y, width, height) 

Example:

var object= groupObject.add(businessActor, 10, 200, -1, -1);
var object= groupObject.add(businessRole, 10, 200, 50, 70);

.borderType

Get/set the border type for Note and Group objects.

Allowed values for Notes are defined as constants:

BORDER.DOGEAR (value of 0)
BORDER.RECTANGLE (value of 1)
BORDER.NONE (value of 2)
note.borderType = BORDER.DOGEAR;

Allowed values for Groups are defined as constants:

BORDER.TABBED (value of 0)
BORDER.RECTANGLE (value of 1)
group.borderType = BORDER.TABBED;

.bounds

Get/set the bounds of a visual object. Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

x, y, width and height are optional

diagramObject.bounds = {x: 10, y: 10, width: 120, height: 55};
diagramObject.bounds = {x: 10, y: 10, width: -1, height: -1};
diagramObject.bounds = {x: 10, y: 10};
var x = diagramObject.bounds.x;
var y = diagramObject.bounds.y;
var width = diagramObject.bounds.width;
var height = diagramObject.bounds.height;

.concept

Get the ArchiMate concept related to a visual object or connection.

var concept = object.concept; // => given that object is a View Object, return the related ArchiMate concept
var concept = connection.concept; // => given that connection is a View Connection, return the related ArchiMate concept

.createObject()

Create and return a new visual object of type with given bounds.

type can be one of diagram-model-note (or note) or diagram-model-group (or group)

Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

createObject(type, x, y, width, height)

Example:

var group = selectedView.createObject("diagram-model-group", 10, 200, -1, -1); // Create top-level Group
var note = group.createObject("diagram-model-note", 10, 10, 150, 70); // Add a Note in this Group

.createViewReference()

Create and return a new View reference object with given bounds.

view is an existing View (diagram model)

Setting width or height to -1 uses the default width and height as set in Archi's Preferences.

createViewReference(view, x, y, width, height)

Example:

var view1 = $('view').get(0); // Choose first view in the model
var diagramElement = ...; // Get an element in another View
var viewRef = diagramElement.createViewReference(view1, 10, 10, -1, -1); // Create and add a view reference

.deriveLineColor

Get/set whether to derive the line color from the fill color of a visual object.

Example:

diagramObject.deriveLineColor = true;
diagramObject.deriveLineColor = false;

.figureType

Get/set the figure type for of a visual object. This applies to ArchiMate element diagram objects that support two different figure types.

Permitted values are 0 and 1.

var type = object.figureType();
var type = object.figureType; 
object.figureType = 1;
object.setFigureType(0);

.fillColor

Get/set the fill color for a visual object. Does not apply to connections. Setting to null sets as user's default color.

diagramObject.fillColor = "#ff0000"; // Sets fill color to red
diagramObject.fillColor = "#00ff00"; // Sets fill color to green
diagramObject.fillColor = null; // Sets fill color to default color.

.fontColor

Get/set the font color. A null value sets to default.

diagramObject.fontColor = "#ff0000"; // Sets font color to red
diagramObject.fontColor = "#00ff00"; // Sets font color to green
diagramObject.fontColor = null; // Sets font color to default color.

.fontName

Get/set the font name.

diagramObject.fontName= "Arial";

.fontSize

Get/set the font size (height).

diagramObject.fontSize = 12;

.fontStyle

Get/set the font style (normal, bold, italic, bolditalic).

diagramObject.fontStyle = "normal";
diagramObject.fontStyle = "bold";
diagramObject.fontStyle = "italic";
diagramObject.fontStyle = "bolditalic";

.iconColor

Get/set the color of the ArchiMate icon in the top-right corner of an ArchiMate object.

A null value or empty string sets to default color.

diagramObject.iconColor = "#ff0000"; // Sets icon color to red
diagramObject.iconColor = "#00ff00"; // Sets icon color to green
diagramObject.iconColor = ""; // Sets icon color to default color.

.image

Get/set the image for the visual object (does not apply to connections).

If the object is an ArchiMate element, the image will only display if the value of .imageSource is set to IMAGE_SOURCE.CUSTOM.

Example:

// Load an image and assign it to an ArchiMate element
object.imageSource = IMAGE_SOURCE.CUSTOM;
object.image = model.createImage("path_to/cat.png");

// Use an image from another object in the same model and assign it to another object
object.imageSource = IMAGE_SOURCE.CUSTOM; // Only needed if this is an ArchiMate object
object.image = anotherObject.image;

// Load an image and assign it to a Note or Group
object.image = model.createImage("path_to/cat.png");

.imageSource

Get/set the type of image source type for ArchiMate elements (does not apply to connections). This does not apply to Notes and Groups.

Allowed values are defined as constants:

IMAGE_SOURCE.SPECIALIZATION (value of 0)
IMAGE_SOURCE.CUSTOM (value of 1)

Example:

archimateDiagramObject.imageSource = IMAGE_SOURCE.CUSTOM;

.imagePosition

Get/set the image position for visual object (does not apply to connections).

Allowed values are defined as constants:

IMAGE_POSITION.TOP_LEFT (value of 0)
IMAGE_POSITION.TOP_CENTRE (value of 1)
IMAGE_POSITION.TOP_RIGHT (value of 2)
IMAGE_POSITION.MIDDLE_LEFT (value of 3)
IMAGE_POSITION.MIDDLE_CENTRE (value of 4)
IMAGE_POSITION.MIDDLE_RIGHT (value of 5)
IMAGE_POSITION.BOTTOM_LEFT (value of 6)
IMAGE_POSITION.BOTTOM_CENTRE (value of 7)
IMAGE_POSITION.BOTTOM_RIGHT (value of 8)
IMAGE_POSITION.FILL (value of 9)

Example:

diagramObject.imagePosition = IMAGE_POSITION.FILL;

.gradient

Get/set the gradient for a visual object (does not apply to connections).

Allowed values are defined as constants:

GRADIENT.NONE (value of -1)
GRADIENT.TOP (value of 0)
GRADIENT.LEFT (value of 1)
GRADIENT.RIGHT (value of 2)
GRADIENT.BOTTOM (value of 3)

Example:

diagramObject.gradient = GRADIENT.TOP;

.labelExpression

Get/set the label expression of a visual object, connection, or folder.

// Getters
var expression = object.getLabelExpression();
var expression = object.labelExpression;
var expression = object.attr("label-expression");

// Setters
object.setLabelExpression("${name}");
object.labelExpression = "${name}";
object.attr("label-expression", "${name}");

.labelValue

Returns the calculated value of a visual object, connection, or folder's label expression.

var labelValue = object.getLabelValue();
var labelValue = object.labelValue;
var labelValue = object.attr("label-value");

.lineColor

Get/set the line color of a visual object or connection. If preference for line color derived from fill color is set, this has no effect. A null value sets to default.

diagramObject.lineColor = "#ff0000"; // Sets line color to red
diagramConnection.lineColor = "#00ff00"; // Sets line color to green
diagramObject.lineColor = null; // Sets line color to default color.

.lineWidth

Get/set the line width of a visual object or connection.

connection.lineWidth = 1; // Sets line width to normal
connection.lineWidth = 2; // Sets line width to medium
connection.lineWidth = 3; // Sets line width to heavy

.opacity

Get/set the opacity of a visual object. Does nothing on connections. Value range 0-255.

diagramObject.opacity = 100; // Sets opacity to half

.outlineOpacity

Get/set the outline opacity of a visual object. Does nothing on connections. Value range 0-255.

diagramObject.outlineOpacity = 100; // Sets outline opacity to half

.refView

Get the referenced View of a View reference object. Applies only to a View reference object.

var view = viewRef.refView;

.showIcon

Get/set whether to show the small icon for an ArchiMate object or View Reference.

Allowed values are defined as constants:

SHOW_ICON.IF_NO_IMAGE (value of 0)
SHOW_ICON.ALWAYS (value of 1)
SHOW_ICON.NEVER (value of 2)

Example:

diagramObject.showIcon = SHOW_ICON.NEVER;

.text

Get/set the text for a Note object.

var note = archimateView.createObject("note", 10, 200, 150, 200);
note.setText("This is a note.");
console.log(note.text);

.textAlignment

Get/set the text alignment for a visual object or connection.

Allowed values are defined as constants:

TEXT_ALIGNMENT.LEFT (value of 1)
TEXT_ALIGNMENT.CENTER (value of 2)
TEXT_ALIGNMENT.RIGHT (value of 4)
diagramObject.textAlignment = TEXT_ALIGNMENT.LEFT;
connection.textAlignment = TEXT_ALIGNMENT.CENTER;

.textPosition

Get/set the text position for a visual object or connection.

Allowed values for objects are defined as constants:

TEXT_POSITION.TOP (value of 0)
TEXT_POSITION.CENTER (value of 1)
TEXT_POSITION.BOTTOM (value of 2)
diagramObject.textPosition = TEXT_POSITION.CENTER;

Allowed values for connections are defined as constants:

CONNECTION_TEXT_POSITION.SOURCE (value of 0)
CONNECTION_TEXT_POSITION.MIDDLE (value of 1)
CONNECTION_TEXT_POSITION.TARGET (value of 2)

Example:

connection.textPosition = CONNECTION_TEXT_POSITION.TARGET;

.view

Get the view that contains this visual object or connection.

var view = object.view; // => given that object is a View Object, return the containing View
var view = connection.view; // => given that connection is a View Connection, return the containing View

Visual Connections

Attributes and methods described in this section are available only on Diagram Connections

.addRelativeBendpoint()

Add a bendpoint to a relative position on a connection at index position.

connection.addRelativeBendpoint(bendpoint, index)

Example:

// New bendpoint 1
var bp1 = {
    startX: 200,
    startY: 200,
    endX: 10,
    endY: 10
}

// New bendpoint 2
var bp2 = {
    startX: 100,
    startY: 100,
    endX: 20,
    endY: 30
}

// Select the first connection in an opened View
var connection = selection.filter("relationship").first();

// Add bendpoints at index positions
connection.addRelativeBendpoint(bp1, 0);
connection.addRelativeBendpoint(bp2, 1);

.deleteAllBendpoints()

Delete all bendpoints on a connection.

connection.deleteAllBendpoints()

.deleteBendpoint()

Delete a bendpoint at index position on a connection.

connection.deleteBendpoint(index);

Throws an ArchiScriptException if index position is out of bounds.

.labelVisible

Get/set the visibility of a connection label.

connection.labelVisible = false;
var isVisible = connection.labelVisible;

.relativeBendpoints

Get the relative bendpoint positions of a connection.

Returns an array list of bendpoints in this format:

endY:
endX:
startY:
startX:
connection.relativeBendpoints

Example:

var bendpoints = connection.getRelativeBendpoints();
var bendpoints = connection.relativeBendpoints;

.setRelativeBendpoint()

Set a connection's existing bendpoint to a new position.

connection.setRelativeBendpoint(bendpoint, index)

Example:

// New bendpoint position
var bp = {
    startX: 200,
    startY: 200,
    endX: 10,
    endY: 10
}

// Select a connection which has some bendpoints
var connection = ...;

// Set the bendpoint at index position 0 to new bendpoint
// Will throw an exception if index is out of range
connection.setRelativeBendpoint(bp, 0);

.source

Get the source of a Connection.

connection.source // => return the diagram object/connection which is the source of the connection

.style

Set the style of a non-ArchiMate Connection.

connection.style = styleBits;

Allowed values are defined as constants and can be OR'd together with the | operator:

CONNECTION_STYLE.LINE_SOLID (value of 0)
CONNECTION_STYLE.ARROW_FILL_TARGET (value of 1)
CONNECTION_STYLE.LINE_DASHED (value of 2)
CONNECTION_STYLE.LINE_DOTTED (value of 4)
CONNECTION_STYLE.ARROW_NONE (value of 0)
CONNECTION_STYLE.ARROW_FILL_SOURCE (value of 8)
CONNECTION_STYLE.ARROW_HOLLOW_TARGET (value of 16)
CONNECTION_STYLE.ARROW_HOLLOW_SOURCE (value of 32)
CONNECTION_STYLE.ARROW_LINE_TARGET (value of 64)
CONNECTION_STYLE.ARROW_LINE_SOURCE (value of 128)

Example:

connection.style = CONNECTION_STYLE.LINE_DASHED | CONNECTION_STYLE.ARROW_HOLLOW_SOURCE | CONNECTION_STYLE.ARROW_FILL_TARGET;

.target

Get the target of a Connection.

connection.target // => return the diagram object/connection which is the target of the connection