GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • @maxgraph/core

This view

  • Original page
  • New address

GeezerVison is showing maxgraph.github.io — Geometry | @maxgraph/core

  • Geometry

Class Geometry

For vertices, the geometry consists of the x- and y-location, and the width and height. For edges, the geometry consists of the optional terminal- and control points. The terminal points are only required if an edge is unconnected, and are stored in the sourcePoint and targetPoint variables, respectively.

Example

If an edge is unconnected, that is, it has no source or target terminal, then a geometry with terminal points for a new edge can be defined as follows.

geometry.setTerminalPoint(new Point(x1, y1), true);
geometry.points: [new Point(x2, y2)];
geometry.setTerminalPoint(new Point(x3, y3), false);

Control points are used regardless of the connected state of an edge and may be ignored or interpreted differently depending on the edge's edgeStyle.

To disable automatic reset of control points after a cell has been moved or resized, AbstractGraph.resetEdgesOnMove and AbstractGraph.resetEdgesOnResize may be used.

Edge Labels

Using the x- and y-coordinates of a cell's geometry, it is possible to position the label on edges on a specific location on the actual edge shape as it appears on the screen. The x-coordinate of an edge's geometry is used to describe the distance from the center of the edge from -1 to 1 with 0 being the center of the edge and the default value. The y-coordinate of an edge's geometry is used to describe the absolute, orthogonal distance in pixels from that point. In addition, the Geometry.offset is used as an absolute offset vector from the resulting point.

This coordinate system is applied if relative is true, otherwise the offset defines the absolute vector from the edge's center point to the label and the values for x and y are ignored.

The width and height parameter for edge geometries can be used to set the label width and height (eg. for word wrapping).

Ports

The term "port" refers to a relatively positioned, connectable child cell, which is used to specify the connection between the parent and another cell in the graph. Ports are typically modeled as vertices with relative geometries.

Offsets

The offset field is interpreted in 3 different ways, depending on the cell and the geometry. For edges, the offset defines the absolute offset for the edge label. For relative geometries, the offset defines the absolute offset for the origin (top, left corner) of the vertex, otherwise the offset defines the absolute offset for the label inside the vertex or group.

Hierarchy (View Summary)

  • Rectangle
    • Geometry
  • Defined in view/geometry/Geometry.ts:85
Index

Constructors

constructor

Properties

_height _width _x _y alternateBounds offset points relative sourcePoint targetPoint TRANSLATE_CONTROL_POINTS

Accessors

height width x y

Methods

add clone equals getCenterX getCenterY getPoint getTerminalPoint grow intersect rotate rotate90 scale setRect setRelative setTerminalPoint swap translate fromRectangle

Constructors

constructor

  • new Geometry(x?: number, y?: number, width?: number, height?: number): Geometry

    Parameters

    • x: number = 0
    • y: number = 0
    • width: number = 0
    • height: number = 0

    Returns Geometry

    Overrides Rectangle.constructor

    • Defined in view/geometry/Geometry.ts:86

Properties

_height

_height: number = 0

Holds the height of the rectangle.

Default

0

Inherited from Rectangle._height

  • Defined in view/geometry/Rectangle.ts:47

_width

_width: number = 0

Holds the width of the rectangle.

Default

0

Inherited from Rectangle._width

  • Defined in view/geometry/Rectangle.ts:41

_x

_x: number = 0

Holds the x-coordinate of the point. Default is 0.

Inherited from Rectangle._x

  • Defined in view/geometry/Point.ts:39

_y

_y: number = 0

Holds the y-coordinate of the point. Default is 0.

Inherited from Rectangle._y

  • Defined in view/geometry/Point.ts:44

alternateBounds

alternateBounds: Rectangle | null = null

Stores alternate values for x, y, width and height in a rectangle. See swap to exchange the values. Default is null.

See

swap

  • Defined in view/geometry/Geometry.ts:101

offset

offset: Point | null = null

For edges, this holds the offset (in pixels) from the position defined by x and y on the edge.

For relative geometries (for vertices), this defines the absolute offset from the point defined by the relative coordinates.

For absolute geometries (for vertices), this defines the offset for the label.

Default

null
  • Defined in view/geometry/Geometry.ts:135

points

points: Point[] | null = null

Array of Point which specifies the control points along the edge. These points are the intermediate points on the edge, for the endpoints use targetPoint and sourcePoint or set the terminals of the edge to a non-null value.

Default

null
  • Defined in view/geometry/Geometry.ts:124

relative

relative: boolean = false

Specifies if the coordinates in the geometry are to be interpreted as relative coordinates.

For edges, this is used to define the location of the edge label relative to the edge as rendered on the display.

For vertices, this specifies the relative location inside the bounds of the parent cell.

If this is false, then the coordinates are relative to the origin of the parent cell or, for edges, the edge label position is relative to the center of the edge as rendered on screen.

Default

false.
  • Defined in view/geometry/Geometry.ts:150

sourcePoint

sourcePoint: Point | null = null

Defines the source Point of the edge. This is used if the corresponding edge does not have a source vertex. Otherwise, it is ignored.

Default

null
  • Defined in view/geometry/Geometry.ts:108

targetPoint

targetPoint: Point | null = null

Defines the source Point of the edge. This is used if the corresponding edge does not have a target vertex. Otherwise, it is ignored.

Default

null
  • Defined in view/geometry/Geometry.ts:115

TRANSLATE_CONTROL_POINTS

TRANSLATE_CONTROL_POINTS: boolean = true

Global switch to translate the points in translate. Default is true.

  • Defined in view/geometry/Geometry.ts:93

Accessors

height

  • get height(): number

    Returns number

    Inherited from Rectangle.height

    • Defined in view/geometry/Rectangle.ts:59
  • set height(height: number): void

    Parameters

    • height: number

    Returns void

    Inherited from Rectangle.height

    • Defined in view/geometry/Rectangle.ts:63

width

  • get width(): number

    Returns number

    Inherited from Rectangle.width

    • Defined in view/geometry/Rectangle.ts:49
  • set width(width: number): void

    Parameters

    • width: number

    Returns void

    Inherited from Rectangle.width

    • Defined in view/geometry/Rectangle.ts:53

x

  • get x(): number

    Returns number

    Inherited from Rectangle.x

    • Defined in view/geometry/Point.ts:46
  • set x(x: number): void

    Parameters

    • x: number

    Returns void

    Inherited from Rectangle.x

    • Defined in view/geometry/Point.ts:50

y

  • get y(): number

    Returns number

    Inherited from Rectangle.y

    • Defined in view/geometry/Point.ts:56
  • set y(y: number): void

    Parameters

    • y: number

    Returns void

    Inherited from Rectangle.y

    • Defined in view/geometry/Point.ts:60

Methods

add

  • add(rect: Rectangle): void

    Adds the given rectangle to this rectangle.

    Parameters

    • rect: Rectangle

    Returns void

    Inherited from Rectangle.add

    • Defined in view/geometry/Rectangle.ts:103

clone

  • clone(): Geometry

    Returns a clone of this Point.

    Returns Geometry

    Overrides Rectangle.clone

    • Defined in view/geometry/Geometry.ts:363

equals

  • equals(geom: Geometry | null): boolean

    Returns true if the given object equals this geometry.

    Parameters

    • geom: Geometry | null

    Returns boolean

    Overrides Rectangle.equals

    • Defined in view/geometry/Geometry.ts:345

getCenterX

  • getCenterX(): number

    Returns the x-coordinate of the center point.

    Returns number

    Inherited from Rectangle.getCenterX

    • Defined in view/geometry/Rectangle.ts:89

getCenterY

  • getCenterY(): number

    Returns the y-coordinate of the center point.

    Returns number

    Inherited from Rectangle.getCenterY

    • Defined in view/geometry/Rectangle.ts:96

getPoint

  • getPoint(): Point

    Returns the top, left corner as a new Point.

    Returns Point

    Inherited from Rectangle.getPoint

    • Defined in view/geometry/Rectangle.ts:146

getTerminalPoint

  • getTerminalPoint(isSource: boolean): Point | null

    Returns the Point representing the source or target point of this edge. This is only used if the edge has no source or target vertex.

    Parameters

    • isSource: boolean

      that specifies if the source or target point should be returned.

    Returns Point | null

    • Defined in view/geometry/Geometry.ts:184

grow

  • grow(amount: number): void

    Grows the rectangle by the given amount, that is, this method subtracts the given amount from the x- and y-coordinates and adds twice the amount to the width and height.

    Parameters

    • amount: number

    Returns void

    Inherited from Rectangle.grow

    • Defined in view/geometry/Rectangle.ts:136

intersect

  • intersect(rect: Rectangle): void

    Changes this rectangle to where it overlaps with the given rectangle.

    Parameters

    • rect: Rectangle

    Returns void

    Inherited from Rectangle.intersect

    • Defined in view/geometry/Rectangle.ts:118

rotate

  • rotate(angle: number, cx: Point): void

    Rotates the geometry by the given angle around the given center. That is, x and y of the geometry, the sourcePoint, targetPoint and all points are translated by the given amount. x and y are only translated if relative is false.

    Parameters

    • angle: number

      that specifies the rotation angle in degrees.

    • cx: Point

      that specifies the center of the rotation.

    Returns void

    • Defined in view/geometry/Geometry.ts:214

rotate90

  • rotate90(): void

    Rotates this rectangle by 90 degree around its center point.

    Returns void

    Inherited from Rectangle.rotate90

    • Defined in view/geometry/Rectangle.ts:153

scale

  • scale(sx: number, sy: number, fixedAspect: boolean): void

    Scales the geometry by the given amount. That is, x and y of the geometry, the sourcePoint, targetPoint and all points are scaled by the given amount. x, y, width and height are only scaled if relative is false. If fixedAspect is true, then the smaller value is used to scale the width and the height.

    Parameters

    • sx: number

      that specifies the horizontal scale factor.

    • sy: number

      that specifies the vertical scale factor.

    • fixedAspect: boolean

      boolean to keep the aspect ratio fixed.

    Returns void

    • Defined in view/geometry/Geometry.ts:305

setRect

  • setRect(x: number, y: number, width: number, height: number): void

    Sets this rectangle to the specified values

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number

    Returns void

    Inherited from Rectangle.setRect

    • Defined in view/geometry/Rectangle.ts:79

setRelative

  • setRelative(isRelative: boolean): void

    Parameters

    • isRelative: boolean

    Returns void

    • Defined in view/geometry/Geometry.ts:152

setTerminalPoint

  • setTerminalPoint(point: Point | null, isSource: boolean): Point | null

    Sets the sourcePoint or targetPoint to the given Point and returns the new point.

    Parameters

    • point: Point | null

      to be used as the new source or target point.

    • isSource: boolean

      that specifies if the source or target point should be set.

    Returns Point | null

    • Defined in view/geometry/Geometry.ts:195

swap

  • swap(): void

    Swaps the x, y, width and height with the values stored in alternateBounds and puts the previous values into alternateBounds as a rectangle. This operation is carried-out in-place, that is, using the existing geometry instance. If this operation is called during a graph model transactional change, then the geometry should be cloned before calling this method and setting the geometry of the cell using GraphDataModel.setGeometry.

    Returns void

    • Defined in view/geometry/Geometry.ts:165

translate

  • translate(dx: number, dy: number): void

    Translates the geometry by the specified amount. That is, x and y of the geometry, the sourcePoint, targetPoint and all points are translated by the given amount. x and y are only translated if relative is false. If TRANSLATE_CONTROL_POINTS is false, then points are not modified by this function.

    Parameters

    • dx: number

      that specifies the x-coordinate of the translation.

    • dy: number

      that specifies the y-coordinate of the translation.

    Returns void

    • Defined in view/geometry/Geometry.ts:264

StaticfromRectangle

  • fromRectangle(rect: Rectangle): Rectangle

    Returns a new Rectangle which is a copy of the given rectangle.

    Parameters

    • rect: Rectangle

    Returns Rectangle

    Inherited from Rectangle.fromRectangle

    • Defined in view/geometry/Rectangle.ts:72

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

ExampleEdge LabelsPortsOffsets
Constructors
constructor
Properties
_height_width_x_yalternateBoundsoffsetpointsrelativesourcePointtargetPointTRANSLATE_CONTROL_POINTS
Accessors
heightwidthxy
Methods
addcloneequalsgetCenterXgetCenterYgetPointgetTerminalPointgrowintersectrotaterotate90scalesetRectsetRelativesetTerminalPointswaptranslatefromRectangle
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.