@maxgraph/core
Version:
maxGraph is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.
51 lines (50 loc) • 1.64 kB
TypeScript
import Rectangle from '../../geometry/Rectangle.js';
import Shape from '../Shape.js';
import AbstractCanvas2D from '../../canvas/AbstractCanvas2D.js';
/**
* Extends {@link Shape} to implement a double ellipse shape.
*
* This shape is registered under `doubleEllipse` in {@link CellRenderer} when using {@link Graph} or calling {@link registerDefaultShapes}.
*
* If a custom shape is needed to only fill the inner ellipse, then this shape's {@link paintVertexShape} method should be overridden
* like in the following example:
*
* ```typescript
* class SampleShape extends DoubleEllipseShape {
* paintVertexShape(c: AbstractCanvas2D, x: number, y: number, w: number, h: number) {
* c.ellipse(x, y, w, h);
* c.stroke();
*
* const inset = this.style.margin ?? Math.min(3 + this.strokewidth, Math.min(w / 5, h / 5));
* x += inset;
* y += inset;
* w -= 2 * inset;
* h -= 2 * inset;
*
* if (w > 0 && h > 0) {
* c.ellipse(x, y, w, h);
* }
*
* c.fillAndStroke();
* }
* }
* ```
*
* @category Vertex Shapes
*/
declare class DoubleEllipseShape extends Shape {
constructor(bounds: Rectangle, fill: string, stroke: string, strokeWidth?: number);
/**
* Paints the background.
*/
paintBackground(c: AbstractCanvas2D, x: number, y: number, w: number, h: number): void;
/**
* Paints the foreground.
*/
paintForeground(c: AbstractCanvas2D, x: number, y: number, w: number, h: number): void;
/**
* @returns the bounds for the label.
*/
getLabelBounds(rect: Rectangle): Rectangle;
}
export default DoubleEllipseShape;