sprotty
Version:
A next-gen framework for graphical views
107 lines • 4.74 kB
TypeScript
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { SModelElement } from 'sprotty-protocol/lib/model';
import { Bounds, Point } from 'sprotty-protocol/lib/utils/geometry';
import { FluentIterable } from '../../utils/iterable';
/**
* Base class for all elements of the internal diagram model.
* Each model element must have a unique ID and a type that is used to look up its view.
*/
export declare class SModelElementImpl {
type: string;
id: string;
features?: FeatureSet;
cssClasses?: string[];
get root(): SModelRootImpl;
get index(): ModelIndexImpl;
/**
* A feature is a symbol identifying some functionality that can be enabled or disabled for
* a model element. The set of supported features is determined by the `features` property.
*/
hasFeature(feature: symbol): boolean;
}
export interface FeatureSet {
has(feature: symbol): boolean;
}
export declare function isParent(element: SModelElement | SModelElementImpl): element is SModelElement & {
children: SModelElement[];
};
/**
* A parent element may contain child elements, thus the diagram model forms a tree.
*/
export declare class SParentElementImpl extends SModelElementImpl {
readonly children: ReadonlyArray<SChildElementImpl>;
add(child: SChildElementImpl, index?: number): void;
remove(child: SChildElementImpl): void;
removeAll(filter?: (e: SChildElementImpl) => boolean): void;
move(child: SChildElementImpl, newIndex: number): void;
/**
* Transform the given bounds from the local coordinate system of this element to the coordinate
* system of its parent. This function should consider any transformation that is applied to the
* view of this element and its contents.
* The base implementation assumes that this element does not define a local coordinate system,
* so it leaves the bounds unchanged.
*/
localToParent(point: Point | Bounds): Bounds;
/**
* Transform the given bounds from the coordinate system of this element's parent to its local
* coordinate system. This function should consider any transformation that is applied to the
* view of this element and its contents.
* The base implementation assumes that this element does not define a local coordinate system,
* so it leaves the bounds unchanged.
*/
parentToLocal(point: Point | Bounds): Bounds;
}
/**
* A child element is contained in a parent element. All elements except the model root are child
* elements. In order to keep the model class hierarchy simple, every child element is also a
* parent element, although for many elements the array of children is empty (i.e. they are
* leafs in the model element tree).
*/
export declare class SChildElementImpl extends SParentElementImpl {
readonly parent: SParentElementImpl;
}
/**
* Base class for the root element of the diagram model tree.
*/
export declare class SModelRootImpl extends SParentElementImpl {
revision?: number;
canvasBounds: Bounds;
constructor(index?: ModelIndexImpl);
}
export declare function createRandomId(length?: number): string;
/**
* Used to speed up model element lookup by id.
*/
export interface IModelIndex {
add(element: SModelElement): void;
remove(element: SModelElement): void;
contains(element: SModelElement): boolean;
getById(id: string): SModelElement | undefined;
}
/**
* This index implementation is for the _internal model_ that is used for rendering.
*/
export declare class ModelIndexImpl implements IModelIndex {
private readonly id2element;
add(element: SModelElementImpl): void;
remove(element: SModelElementImpl): void;
contains(element: SModelElementImpl): boolean;
getById(id: string): SModelElementImpl | undefined;
getAttachedElements(element: SModelElementImpl): FluentIterable<SModelElementImpl>;
all(): FluentIterable<SModelElementImpl>;
}
//# sourceMappingURL=smodel.d.ts.map