- I
- I
Remarks
Examples
const node = graph.createNode(
[0, 0, 50, 50],
new ImageNodeStyle({
// path to the image or data URI which should be referenced in the SVGImageElement
href: './resources/my-image.png',
}),
)See Also
Developer's Guide
Members
Constructors
Properties
If this value is positive and finite, the image will be scaled to the largest rectangle that a) has a width-to-height ratio that matches this value and b) fits into the node's size. Otherwise, the image is scaled to the node's size (and aspect ratio) without further restrictions.
The default value is 0. I.e. image is scaled to the node's size (and aspect ratio).
Examples
// the image for the style
const imageUrl = './resources/printer.svg'
// determine the intrinsic aspect ratio of the image
const imageAspectRatio = await ImageNodeStyle.getAspectRatio(imageUrl)
const style = new ImageNodeStyle({
href: imageUrl,
// always keep the intrinsic aspect ratio independent of the node's size
aspectRatio: imageAspectRatio,
})See Also
Developer's Guide
Gets or sets the Fill of the image backgroundShape for this style.
The default value is null.
The background shape is only rendered, if at least one of backgroundStroke or backgroundFill have been set to non-null values.
Gets or sets the background shape for this style.
The default value is RECTANGLE.
The background shape is only rendered, if at least one of backgroundStroke or backgroundFill have been set to non-null values.
When the background backgroundShape is rendered, it takes precedence over the normalizedOutline as the outline geometry.
Gets or sets the Stroke of the image backgroundShape for this style.
The default value is null.
The background shape is only rendered, if at least one of backgroundStroke or backgroundFill have been set to non-null values.
The default value is an empty string, in which case no class is set for the visualization.
Multiple classes can be set by separating them with spaces, just like with the SVG class attribute.
The default value is null.
ImageNodeStyle uses the SVG <image> element to render images and therefore supports all image types that are supported by the user's browser. The href property of the style is the href attribute of the image. It should either be a valid absolute URL, or an URL that is relative to the webpage that contains the GraphComponent, or null.
If the href fails to load, a black rectangle will be rendered instead.
See Also
Developer's Guide
Gets or sets the normalized outline of the image that will be displayed.
This shape will be used to refine hit testing behavior and edge cropping. For example, it is used to satisfy requests to isInBox and isHit. It may be left null in which case the node's layout rectangle is taken as the outline.
The default value is null.
When the background backgroundShape is rendered, it takes precedence over the normalizedOutline as the outline geometry.
Examples
const outlinePath = new GeneralPath()
outlinePath.appendEllipse(new Rect(0, 0, 1, 1), true)
const style = new ImageNodeStyle({
href: imageUrl,
normalizedOutline: outlinePath,
})See Also
Developer's Guide
Gets the renderer implementation that can be queried for implementations that provide details about the visual appearance and visual behavior for a given node and this style instance.
const creator = style.renderer.getVisualCreator(node, style)
const visual = creator.createVisual(context)Implements
INodeStyle.rendererMethods
Return Value
- Object
- A shallow copy of this instance.
Implements
ICloneable.cloneStatic Methods
Parameters
- image: string
- The image URL
Return Value
- Promise<number>
- The aspect ratio of the image
Examples
// the image for the style
const imageUrl = './resources/printer.svg'
// determine the intrinsic aspect ratio of the image
const imageAspectRatio = await ImageNodeStyle.getAspectRatio(imageUrl)
const style = new ImageNodeStyle({
href: imageUrl,
// always keep the intrinsic aspect ratio independent of the node's size
aspectRatio: imageAspectRatio,
})