sprotty
Version:
A next-gen framework for graphical views
141 lines • 8.06 kB
TypeScript
/********************************************************************************
* Copyright (c) 2017-2022 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 { VNode } from "snabbdom";
import { Point } from 'sprotty-protocol/lib/utils/geometry';
import { IView, IViewArgs, RenderingContext } from "../base/views/view";
import { ShapeView } from '../features/bounds/views';
import { IntersectingRoutedPoint, Intersection } from '../features/edge-intersection/intersection-finder';
import { SRoutableElementImpl, SRoutingHandleImpl } from '../features/routing/model';
import { EdgeRouterRegistry, RoutedPoint } from '../features/routing/routing';
import { RoutableView } from '../features/routing/views';
import { PointToPointLine } from '../utils/geometry';
import { SCompartmentImpl, SEdgeImpl, SGraphImpl, SLabelImpl } from "./sgraph";
/**
* IView component that turns an SGraph element and its children into a tree of virtual DOM elements.
*/
export declare class SGraphView implements IView {
edgeRouterRegistry: EdgeRouterRegistry;
render(model: Readonly<SGraphImpl>, context: RenderingContext): VNode;
}
export declare class PolylineEdgeView extends RoutableView {
edgeRouterRegistry: EdgeRouterRegistry;
render(edge: Readonly<SEdgeImpl>, context: RenderingContext, args?: IViewArgs): VNode | undefined;
protected renderJunctionPoints(edge: Readonly<SEdgeImpl>, route: RoutedPoint[], context: RenderingContext, args: IViewArgs | undefined): any;
protected renderLine(edge: SEdgeImpl, segments: Point[], context: RenderingContext, args?: IViewArgs): VNode;
protected renderAdditionals(edge: SEdgeImpl, segments: Point[], context: RenderingContext): VNode[];
protected renderDanglingEdge(message: string, edge: SEdgeImpl, context: RenderingContext): VNode;
}
/**
* A `PolylineEdgeView` that renders jumps over intersections.
*
* In order to find intersections, `IntersectionFinder` needs to be configured as a `TYPES.IEdgeRoutePostprocessor`
* so that that intersections are declared as `IntersectingRoutedPoint` in the computed routes.
*
* This view only draws correct line jumps for intersections among straight line segments and doesn't work with bezier curves.
*
* @see IntersectionFinder
* @see IntersectingRoutedPoint
* @see EdgeRouterRegistry
*/
export declare class JumpingPolylineEdgeView extends PolylineEdgeView {
protected jumpOffsetBefore: number;
protected jumpOffsetAfter: number;
protected skipOffsetBefore: number;
protected skipOffsetAfter: number;
protected renderLine(edge: SEdgeImpl, segments: Point[], context: RenderingContext, args?: IViewArgs): VNode;
/**
* Returns a path that takes the intersections into account by drawing a line jump or a gap for intersections on that path.
*/
protected intersectionPath(edge: SEdgeImpl, segments: Point[], intersectingPoint: IntersectingRoutedPoint, args?: IViewArgs): string;
/**
* Returns the intersections sorted by the direction of the `lineSegment`.
*
* The coordinate system goes from left to right and top to bottom.
* Thus, x increases to the right and y increases downwards.
*
* We need to draw the intersections in the order of the direction of the line segment.
* To draw a line pointing north, we need to order intersections by Y in a descending order.
* To draw a line pointing south, we need to order intersections by Y in an ascending order.
*/
protected getIntersectionsSortedBySegmentDirection(lineSegment: PointToPointLine, intersectingPoint: IntersectingRoutedPoint): Intersection[];
/**
* Whether or not to draw a line jump on an intersection for the `currentLineSegment`.
* This should usually be inverse of `shouldDrawLineGapOnIntersection()`.
*/
protected shouldDrawLineJumpOnIntersection(currentLineSegment: PointToPointLine, otherLineSegment: PointToPointLine): boolean;
/**
* Whether or not to draw a line gap on an intersection for the `currentLineSegment`.
* This should usually be inverse of `shouldDrawLineJumpOnIntersection()`.
*/
protected shouldDrawLineGapOnIntersection(currentLineSegment: PointToPointLine, otherLineSegment: PointToPointLine): boolean;
protected getLineSegment(edge: SRoutableElementImpl, intersection: Intersection, args?: IViewArgs, segments?: Point[]): PointToPointLine;
protected getOtherLineSegment(currentEdge: SEdgeImpl, intersection: Intersection, args?: IViewArgs): PointToPointLine | undefined;
protected createJumpPath(intersectionPoint: Point, lineSegment: PointToPointLine): string;
protected createGapPath(intersectionPoint: Point, lineSegment: PointToPointLine): string;
}
/**
* A `PolylineEdgeView` that renders gaps on intersections.
*
* In order to find intersections, `IntersectionFinder` needs to be configured as a `TYPES.IEdgeRoutePostprocessor`
* so that that intersections are declared as `IntersectingRoutedPoint` in the computed routes.
*
* This view only draws correct gaps for intersections among straight line segments and doesn't work with bezier curves.
*
* @see IntersectionFinder
* @see IntersectingRoutedPoint
* @see EdgeRouterRegistry
*/
export declare class PolylineEdgeViewWithGapsOnIntersections extends JumpingPolylineEdgeView {
protected skipOffsetBefore: number;
protected skipOffsetAfter: number;
protected shouldDrawLineJumpOnIntersection(currentLineSegment: PointToPointLine, otherLineSegment: PointToPointLine): boolean;
protected shouldDrawLineGapOnIntersection(currentLineSegment: PointToPointLine, otherLineSegment: PointToPointLine): boolean;
protected createGapPath(intersectionPoint: Point, lineSegment: PointToPointLine): string;
}
export declare class BezierCurveEdgeView extends RoutableView {
edgeRouterRegistry: EdgeRouterRegistry;
render(edge: Readonly<SEdgeImpl>, context: RenderingContext, args?: IViewArgs): VNode | undefined;
protected renderLine(edge: SEdgeImpl, segments: Point[], context: RenderingContext, args?: IViewArgs): VNode;
private buildMainSegment;
private addSpline;
protected renderAdditionals(edge: SEdgeImpl, segments: Point[], context: RenderingContext): VNode[];
protected renderDanglingEdge(message: string, edge: SEdgeImpl, context: RenderingContext): VNode;
}
export declare class SRoutingHandleView implements IView {
edgeRouterRegistry: EdgeRouterRegistry;
minimalPointDistance: number;
render(handle: Readonly<SRoutingHandleImpl>, context: RenderingContext, args?: {
route?: RoutedPoint[];
}): VNode;
getRadius(): number;
}
export declare class SLabelView extends ShapeView {
render(label: Readonly<SLabelImpl>, context: RenderingContext): VNode | undefined;
}
export declare class SCompartmentView implements IView {
render(compartment: Readonly<SCompartmentImpl>, context: RenderingContext, args?: IViewArgs): VNode | undefined;
}
export declare class SBezierCreateHandleView extends SRoutingHandleView {
render(handle: Readonly<SRoutingHandleImpl>, context: RenderingContext, args?: {
route?: RoutedPoint[];
}): VNode;
}
export declare class SBezierControlHandleView extends SRoutingHandleView {
render(handle: Readonly<SRoutingHandleImpl>, context: RenderingContext, args?: {
route?: RoutedPoint[];
}): VNode;
}
//# sourceMappingURL=views.d.ts.map