-
Notifications
You must be signed in to change notification settings - Fork 35
Features In Development
Note - these features require Archi 4.9.0
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 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 = imageFromAnotherImage;
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.
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);
});
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";
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("cat.png");
console.log("Image height: " + image.height);
console.log("Image width: " + image.width);
selectedDiagramObject.image = image;
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;
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 image for the object.
The image will only display if the value of .imageSource
is set to IMAGE_SOURCE.CUSTOM
.
Example:
// Load an image and assign it
object.imageSource = IMAGE_SOURCE.CUSTOM;
object.image = model.createImage("cat.png");
// Use an image from another object in the same model
object.imageSource = IMAGE_SOURCE.CUSTOM;
object.image = anotherObject.image;
Get/set the type of image source.
Allowed values are defined as constants:
IMAGE_SOURCE.SPECIALIZATION (value of 0)
IMAGE_SOURCE.CUSTOM (value of 1)
Example:
diagramObject.imageSource = IMAGE_SOURCE.CUSTOM;
Get/set the image position.
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.
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;
$.process.release.archiName
- Returns the app name - Archi
$.process.release.archiVersion
- Returns the app version, for example 4.9.0.202109160630
$.process.release.jArchiName
- Returns the jArchi name - Archi Scripting (jArchi)
$.process.release.jArchiVersion
- Returns the jArchi version, for example 1.2.0.202109160630
Render a view to file image
$.model.renderViewToFile(view, filePath, format)
view
- The view to render
filePath
- The full file path and file name of the image
format
- Image format - one of "PNG", "BMP", "JPG", "JPEG"
Render a view to file image with options
$.model.renderViewToFile(view, filePath, format, options)
view
- The view to render
filePath
- The full file path and file name of the image
format
- Image format - one of "PNG", "BMP", "JPG", "JPEG"
options
- Image scale and margin insets. Scale can be a decimal number from 0.5 to 4. Default margin is 10.
Example -
var options = {margin: 50, scale: 2};
$.model.renderViewToFile(view, "myView.png", "PNG", options);
Render a view as an SVG String
$.model.renderViewAsSVGString(view, setViewBox)
view
- The view to render
setViewBox
- true/false. If true sets the view box bounds to the bounds of the diagram
Returns the SVG image as a string.
Render a view to file image in SVG format
$.model.renderViewToSVG(view, filePath, setViewBox)
view
- The view to render
filePath
- The full file path and file name of the image
setViewBox
- true/false. If true sets the view box bounds to the bounds of the diagram.
Render a view to file image in PDF format
$.model.renderViewToPDF(view, filePath)
view
- The view to render
filePath
- The full file path and file name of the image
If you value and use Archi please consider making a donation. Thanks!