Skip to content

Features In Development

Phil Beauvoir edited this page Sep 30, 2021 · 13 revisions

Upcoming Features for jArchi 1.2

Note - these features require Archi 4.9.0

Specialization Functions

model.createSpecialization()

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, that is returned.

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:

var image = model.createImage("cat.png");
var specialization = model.createSpecialization("Oscar", "business-actor", image);
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 these 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.specializations

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()

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()

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;

concept.specialization

Get/set the specialization name for a concept. Will create a new specialization with that name and concept type if it does not already exist.

concept.specialization = "My Specialization";
var specializationName = concept.specialization;

Object Functions

.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;

.image

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;

.imageSource

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;

.imagePosition

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;

.gradient

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;

Utility Functions

$.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

View Image Functions

$.model.renderViewToFile()

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"

$.model.renderViewToFile(options)

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);

$.model.renderViewAsSVGString()

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.

$.model.renderViewToSVG()

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.

$.model.renderViewToPDF()

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