-
Notifications
You must be signed in to change notification settings - Fork 35
jArchi Object
.delete()
.documentation
.id
.model
.name
.type
.prop()
.removeProp()
.copy()
.createArchimateView()
.createCanvasView()
.createElement()
.createImage()
.createRelationship()
.createSketchView()
.createSpecialization()
.findSpecialization()
.getPath()
.merge()
.openInUI()
.purpose
.save()
.setAsCurrent()
.specializations
.junctionType
.merge
.specialization
.accessType
.associationDirected
.influenceStrength
.merge
.source
.specialization
.target
.add()
.createFolder()
.labelExpression
.labelValue
.add(element)
.add(relationship)
.createConnection()
.createObject()
.createViewReference()
.isAllowedConceptForViewpoint()
.openInUI()
.viewpoint
.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
.specialization
.text
.textAlignment
.textPosition
.view
.addRelativeBendpoint()
.deleteAllBendpoints()
.deleteBendpoint()
.labelVisible
.relativeBendpoints
.setRelativeBendpoint
.source
.style
.target
Attributes and methods described in this section are available on all jArchi Object instances
Deletes an object.
customer.delete() // => A Business Actor with variable name, `customer`, is removed from the model
folder.delete() // => A folder, with variable name, `folder`, is removed from the model, as well as its contents
Note - a model cannot be deleted in this way.
Note - an object that is a diagram connection cannot be deleted from the model in this way (it will just remove it from the diagram). To remove a diagram selected object
you need to use .concept like this:
obj.concept.delete();
See also Creating and Deleting Objects
Get/set object's documentation.
object.documentation // => AttributeValue
object.documentation = 'New documentation content'
Get object's id. This attribute is read-only.
object.id // => AttributeValue
Example:
var conceptID = businessActor.id; // id of a concept
var objectID = diagramObject.id; // id of a visual diagram object
var conceptID = diagramObject.concept.id; // id of the concept referenced by a visual diagram object
Returns the container model for an object.
var model = customer.model // => Returns the container model for `customer` object.
var model = folder.model // => Returns the container model for `folder` object.
Get/set object's name.
object.name // => AttributeValue
object.name = 'New name'
Get object's type (see jArchi Collection for a list of types). This attribute is writeable for ArchiMate concepts: changing its value will replace the concept itself and update all references. If setting the concept type would result in an illegal relationship, an exception is thrown.
object.type // => Object's type
object.type = 'business-process' // => change the nature of the ArchiMate concept to 'Business Process'
If no arguments are provided, return the list of properties' key for the object. Return a property value from the object when just property is supplied. If multiple properties exist with the same key, then return only the first one (duplicate=false, which is the default) or an array with all values (duplicate=true) Sets a property on the object when property and value are supplied. Property is updated if it already exists (duplicate=false, which is the default) or added anyway (duplicate=true).
object.prop() //=> properties' key for the first object
object.prop(propName) // => property value (first one if multiple entries)
object.prop(propName, false) // => property value (first one if multiple entries)
object.prop(propName, true) // => property value (array if multiple entries)
object.prop(propName, propValue) // => updated object with property added (if it did not exist) or updated (if it existed)
object.prop(propName, propValue, false) // => updated object with property added (if it not existed) or updated (if it existed)
object.prop(propName, propValue, true) // => updated object with property added (even if it existed)
Removes property from an objects.
object.removeProp(propName) // => all instances of propName are removed
object.removeProp(propName, propValue) // => properties are removed if value matches propValue
Attributes and methods described in this section are available on all jArchi ArchiMate Object instances
Get/set the specialization for an object or concept. The specialization should have been created first.
var specialization = model.createSpecialization("Oscar", "business-actor", image);
object.specialization = "Oscar";
var specializationName = object.specialization;
Note - a specialization is assigned to a concept by its name, not the Specialization
object.
Attributes and methods described in this section are available on the model object
Returns a new reference to the model. Example:
var modelref = model.copy(); // => Copy a reference to the current model
Create a new ArchiMate View in the model.
Create and add a new view (to the default folder) in the model:
model.createArchimateView(name);
Create and add a new view to a given folder in the model:
model.createArchimateView(name, folder);
Examples:
var view = model.createArchimateView("New Archimate View");
var view2 = model.createArchimateView("Archimate View", myFolder);
Create a new Canvas View in the model.
Create and add a new view (to the default folder) in the model:
model.createCanvasView(name);
Create and add a new view to a given folder in the model:
model.createCanvasView(name, folder);
Examples:
var view = model.createCanvasView("New Canvas View");
var view2 = model.createCanvasView("Canvas View", myFolder);
Create and add a new element to its default folder in the model.
model.createElement(element-type, name);
Create and add a new element to a given folder in the model:
model.createElement(element-type, name, folder);
Use the kebab-case type of the element and provide a name. Examples:
var actor = model.createElement("business-actor", "Oscar");
var role = model.createElement("business-role", "Cat");
var node = model.createElement("node", "Node");
var junction = model.createElement("junction", "");
model.createImage(filePath)
Load an image from file and store it in the model.
Returns the image object which can used to assign to a specialization or visual object. If the image is already loaded in the model, it is returned. Images are matched on content not name.
An image object has fields width
and height
.
filePath
The full file path and file name of the image to load.
Example:
var image = model.createImage("path_to/cat.png");
console.log("Image height: " + image.height);
console.log("Image width: " + image.width);
selectedDiagramObject.image = image;
Create and add a new relationship to its default folder in the model.
model.createRelationship(relationship-type, name, source, target);
Create and add a new relationship to a given folder in the model:
model.createRelationship(relationship-type, name, source, target, folder);
Use the kebab-case type of the relationship and provide a name (can be "") and the source and target components. Example:
var actor = model.createElement("business-actor", "Oscar");
var role = model.createElement("business-role", "Cat");
var relationship = model.createRelationship("assignment-relationship", "Assigned to", actor, role);
Create a new Sketch View in the model.
Create and add a new view (to the default folder) in the model:
model.createSketchView(name);
Create and add a new view to a given folder in the model:
model.createSketchView(name, folder);
Examples:
var view = model.createSketchView("New Sketch View");
var view2 = model.createSketchView("Sketch View", myFolder);
model.createSpecialization(name, conceptType)
model.createSpecialization(name, conceptType, image)
Create a new specialization with the given name, concept type and image. If a specialization of the same name and type already exists, an exception is thrown.
name
- The name of the specialization
conceptType
- The concept type in kebab-case format.
image
- An image object previously stored from model.createImage()
, or from a Specialization
object returned from model.getSpecializations()
, or model.findSpecialization()
. Can be omitted or null for no image.
Returns a Specialization
object containing the fields name
, conceptType
, and image
Example:
// Create a new specialization with image for Business Actor called "Oscar"
var image = model.createImage("cat.png");
var specialization = model.createSpecialization("Oscar", "business-actor", image);
// Set the specialization on a concept by using its name
var businessActor = ...;
businessActor.specialization = "Oscar";
// We can get its properties
var name = specialization.name;
var conceptType = specialization.type;
var image = specialization.image;
console.log("Image height: " + image.height);
console.log("Image width: " + image.width);
A Specialization
object's properties can be set:
specialization.name = "New Name";
specialization.conceptType = "business-object";
specialization.image = imageFromAnotherSpecialization;
If a Specialization
object already exists with the given name and/or concept type the name
and conceptType
properties cannot be set.
A Specialization
object can be deleted from the model with specialization.delete()
. All concept references to the specialization are also deleted.
model.findSpecialization(name, type)
Find and return a Specialization
object in the model with the given name and type. If a matching specialization does not exist, null is returned.
Example:
var specialization = model.findSpecialization("Oscar", "business-actor";
Return the path to the file location of the model, or null if not saved.
var filePath = model.getPath();
Merge another model into this model. This is the equivalent of the "Import another model into the selected model" Archi action.
model.merge(filePath, update, updateAll)
model.merge(filePath, update, updateAll, messages)
Merge the model located at filePath
into this model.
filePath
- path to the *.archimate
model file
update
- if true, update/replace target objects with source objects - sub-folders, concepts, folder structure, views
updateAll
- if true update/replace model and top level folders' name, purpose, documentation and properties with source
messages
- an optional empty array into which merge operation messages are stored
Example:
let messages = []; // List of messages returned by merge operation (optional)
model.merge("pathToFile/mymodel.archimate", true, true, messages);
messages.forEach(m => { // Print messages
console.log(m);
});
model.merge(anotherModel, update, updateAll)
model.merge(anotherModel, update, updateAll, messages)
Merge another model into this model.
anotherModel
- another model previously created or loaded in jArchi
update
- if true, update/replace target objects with source objects - sub-folders, concepts, folder structure, views
updateAll
- if true update/replace model and top level folders' name, purpose, documentation and properties with source
messages
- an optional empty array into which merge operation messages are stored
Example:
let messages = []; // List of messages returned by merge operation (optional)
let thatModel = $.model.load("pathToFile/mymodel.archimate");
model.merge(thatModel, true, true, messages);
messages.forEach(m => { // Print messages
console.log(m);
});
Open the model in the UI (Models Tree).
model.openInUI();
Get/set model's purpose (documentation).
var purpose = object.purpose;
object.purpose= 'New purpose content';
Save the model to file.
model.save(); // If the model has previously been saved with a path and file name, save the model
model.save("path/test.archimate"); // Save the model to the given path and file name
Set a model to the current model. The current model is referenced as the global variable model
.
Example:
$.model.load("path/test.archimate").setAsCurrent(); // Load a model and set it as the current model
or:
var myModel = model.load("path/test.archimate");
myModel.setAsCurrent();
Returns a list of all Specialization
objects in the model. A Specialization
object contains the fields name
, conceptType
, and image
Example:
model.specializations.forEach(specialization => {
console.log(specialization.name);
console.log(specialization.type);
console.log(specialization.image);
});
Attributes and methods described in this section are available only on ArchiMate Elements
Applies only to Junctions.
Get/set the type of a Junction.
Allowed types - "and", "or"
// Getters
var type = junction.getJunctionType();
var type = junction.junctionType;
var type = junction.attr("junction-type");
// Setters
junction.setJunctionType("and");
junction.junctionType = "and";
junction.attr("junction-type", "or");
Merge this element and another element.
element.merge(otherElement);
- Existing diagram instances of the other ArchiMate element will be replaced with this element
- Elements have to be of the same type
- Documentation of the other element is appended to this element's documentation
- Properties of the other element are appended to this element's properties
- All source and target relationships of the other element are set to this element
- The other element is not deleted
Attributes and methods described in this section are available only on ArchiMate Relationships
Applies only to Access Relationships.
Get/set the access type of an Access Relationship.
Allowed types - "access", "read", "write", "readwrite"
// Getters
var type = relation.getAccessType();
var type = relation.accessType;
var type = selection.attr("access-type");
// Setters
relation.setAccessType("write");
relation.accessType = "access";
selection.attr("access-type", "readwrite");
Applies only to Association Relationships.
Get/set the directed attribute of an Association Relationship.
// Getters
var isDirected = relation.isAssociationDirected();
var isDirected = relation.associationDirected;
var isDirected = selection.attr("association-directed");
// Setters
relation.setAssociationDirected(true);
relation.associationDirected = true;
selection.attr("association-directed", true);
Applies only to Influence Relationships.
Get/set the strength of an Influence Relationship.
Any string is allowed.
// Getters
var strength = relation.getInfluenceStrength();
var strength = relation.influenceStrength;
var strength = selection.attr("influence-strength");
// Setters
relation.setInfluenceStrength("++");
relation.influenceStrength = "++";
selection.attr("influence-strength", "+++");
Merge this relationship and another relationship.
relation.merge(otherRelation);
- Existing diagram instances of the other ArchiMate relationship will be replaced with this relationship
- Relationships have to be of the same type
- Documentation of the other relationship is appended to this relationship's documentation
- Properties of the other relationship are appended to this relationship's properties
- All source and target relationships of the other relationship are set to this relationship
- The other relationship is not deleted
Get/set the source of an ArchiMate Relationship.
relation.source // => return the concept which is the source of the relationship
relation.source = aConcept // => set the source using a Concept
Get/set the target of an ArchiMate Relationship.
relation.target // => return the concept which is the target of the relationship
relation.target = aConcept // => set the target using a Concept
Attributes and methods described in this section are available only on Folders in the Models Tree
Add a concept, a view or a sub-folder to a folder. If the object already has a parent folder then the object is moved to the folder.
folder.add(concept);
folder.add(view);
folder.add(folder);
Example:
var concept = ....; Reference to an existing concept
var folder = $("folder.My Folder").first(); // Find folder called "My Folder"
folder.add(concept); // Move the concept to this folder
Create a new (sub-)folder.
folder.createFolder("New Folder");
Example:
var folder = $("folder.Business").first(); // Find folder called "Business"
folder.createFolder("Processes"); // Create a sub-folder called Processes
Methods described in this section are are available only on Views - ArchiMate, Sketch and Canvas Views.
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);
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);
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
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);
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
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"));
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();
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;
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".
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);
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;
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;
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
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
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
Get/set whether to derive the line color from the fill color of a visual object.
Example:
diagramObject.deriveLineColor = true;
diagramObject.deriveLineColor = false;
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);
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.
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.
Get/set the font name.
diagramObject.fontName= "Arial";
Get/set the font size (height).
diagramObject.fontSize = 12;
Get/set the font style (normal, bold, italic, bolditalic).
diagramObject.fontStyle = "normal";
diagramObject.fontStyle = "bold";
diagramObject.fontStyle = "italic";
diagramObject.fontStyle = "bolditalic";
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.
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");
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;
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;
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;
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}");
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");
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.
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
Get/set the opacity of a visual object. Does nothing on connections. Value range 0-255.
diagramObject.opacity = 100; // Sets opacity to half
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
Get the referenced View of a View reference object. Applies only to a View reference object.
var view = viewRef.refView;
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;
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);
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;
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;
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
Attributes and methods described in this section are available only on Diagram Connections
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);
Delete all bendpoints on a connection.
connection.deleteAllBendpoints()
Delete a bendpoint at index position on a connection.
connection.deleteBendpoint(index);
Throws an ArchiScriptException
if index position is out of bounds.
Get/set the visibility of a connection label.
connection.labelVisible = false;
var isVisible = connection.labelVisible;
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;
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);
Get the source of a Connection.
connection.source // => return the diagram object/connection which is the source of the connection
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;
Get the target of a Connection.
connection.target // => return the diagram object/connection which is the target of the connection
If you value and use Archi please consider making a donation. Thanks!