-
Notifications
You must be signed in to change notification settings - Fork 200
Examples fixed #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples fixed #88
Changes from all commits
eed5652
32f5c19
b79ac4b
1179e26
8546ca9
f7743a6
f117758
fa6ee48
c9eb40e
560a33a
eac9d3e
ad616f0
a1abe79
0d789a0
5278f8b
fc8ed77
2ec2d18
a6dba2f
f98ee5e
c6a1299
ae11bc4
92b2d6a
7b6b959
51e7206
59f764e
0bdae3b
f93db32
e2ae0aa
3369322
89c5a95
bf71b5c
62226e8
0e0dd57
fd492e8
d5e0492
a1b33cd
6ed6b97
1ee4326
4213252
4a63940
91d8190
806506b
435859d
4ddbdf5
88e68be
43084be
e92e7af
0822840
68f4a86
cbf2a1f
80f8a1d
bbc183a
9aae8fa
cc91fda
761fb3f
d44b881
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,9 @@ import MaxLog from '../gui/MaxLog'; | |
| import { getFunctionName } from '../util/StringUtils'; | ||
| import { importNode, isNode } from '../util/domUtils'; | ||
| import ObjectCodec from './ObjectCodec'; | ||
| import GraphDataModel from '../view/GraphDataModel'; | ||
| import Geometry from '../view/geometry/Geometry'; | ||
| import Point from '../view/geometry/Point'; | ||
|
|
||
| const createXmlDocument = () => { | ||
| return document.implementation.createDocument('', '', null); | ||
|
|
@@ -339,6 +342,20 @@ class Codec { | |
| * @param into Optional object to be decodec into. | ||
| */ | ||
| decode(node: Element, into?: any): any { | ||
|
|
||
|
|
||
| //****Edit note - there may be other classes needed here????****** | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ?? |
||
| const classMap = { | ||
| "GraphDataModel": GraphDataModel, | ||
| "Geometry": Geometry, | ||
| "Point":Point, | ||
| "Array": Array, | ||
| "Object": Object, | ||
| "Boolean": Boolean, | ||
|
|
||
|
|
||
|
|
||
| }; | ||
| this.updateElements(); | ||
| let obj = null; | ||
|
|
||
|
|
@@ -347,11 +364,11 @@ class Codec { | |
|
|
||
| try { | ||
| // @ts-ignore | ||
| ctor = window[node.nodeName]; | ||
| ctor = classMap[node.nodeName] | ||
| if (ctor == undefined) console.log(node.nodeName) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do proper Error management |
||
| } catch (err) { | ||
| // ignore | ||
| console.log(err)// ignore | ||
| } | ||
|
|
||
| const dec = CodecRegistry.getCodec(ctor); | ||
|
|
||
| if (dec != null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,7 @@ export type CellStateStyle = { | |
| imageBorder?: ColorValue; | ||
| imageHeight?: number; | ||
| imageWidth?: number; | ||
| imageVerticalAlign?: VAlignValue; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For indicator only? There was no need for this in the original mxGraph code, why do we need this now? |
||
| indicatorColor?: ColorValue; | ||
| indicatorDirection?: DirectionValue; | ||
| indicatorHeight?: number; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,22 @@ export const mixInto = (dest: any) => (mixin: any) => { | |
| } | ||
| }; | ||
|
|
||
| //getBBox of SVG element before rendered in DOM | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please write proper JSDoc |
||
|
|
||
| export function svgBBox (svgEl: SVGGElement){ | ||
| let tempDiv = document.createElement('div') | ||
| tempDiv.setAttribute('style', "position:absolute; visibility:hidden; width:0, height:0") | ||
| document.body.appendChild(tempDiv) | ||
| let tempSvg = document.createElementNS("http://www.w3.org/2000/svg", 'svg') | ||
| tempDiv.appendChild(tempSvg) | ||
| let tempEl = svgEl.cloneNode(true) | ||
| tempSvg.appendChild(tempEl) | ||
| let bb = (<SVGGElement>tempEl).getBBox() | ||
| document.body.removeChild(tempDiv) | ||
| return bb | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Returns the value for the given key in the given associative array or | ||
| * the given default value if the value is null. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,11 +25,11 @@ export const clone = function _clone(obj: any, transients: string[] | null=null, | |
| i != ObjectIdentity.FIELD_NAME && | ||
| (transients == null || transients.indexOf(i) < 0) | ||
| ) { | ||
| if (!shallow && typeof obj[i] === 'object') { | ||
| if (!shallow && typeof obj[i] === 'object') { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra change + formatting issue |
||
| clone[i] = _clone(obj[i]); | ||
| } else { | ||
| clone[i] = obj[i]; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,8 +19,10 @@ import Rectangle from '../view/geometry/Rectangle'; | |
| import Cell from '../view/cell/Cell'; | ||
| import GraphDataModel from '../view/GraphDataModel'; | ||
| import CellArray from '../view/cell/CellArray'; | ||
| import {clone} from './cloneUtils' | ||
| import { CellStateStyle, CellStyle, NumericCellStateStyleKeys } from 'src/types'; | ||
|
|
||
|
|
||
| /** | ||
| * Removes the cursors from the style of the given DOM node and its | ||
| * descendants. | ||
|
|
@@ -438,9 +440,10 @@ export const setCellStyles = ( | |
|
|
||
| if (cell) { | ||
| const style = cell.getStyle(); | ||
| style[key] = value; | ||
| const styleClone =clone(style) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why changing this? |
||
| styleClone[key] = value; | ||
|
|
||
| model.setStyle(cell, style); | ||
| model.setStyle(cell, styleClone); | ||
| } | ||
| } | ||
| } finally { | ||
|
|
@@ -490,6 +493,7 @@ export const setStyle = (style: string | null, key: string, value: any) => { | |
| next < 0 ? ';' : style.substring(next) | ||
| }`; | ||
| } else { | ||
|
|
||
| style = style.substring(0, index) + (next < 0 ? ';' : style.substring(next)); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -580,10 +580,8 @@ class Graph extends EventSource { | |
| const newParent = change.child.getParent(); | ||
| this.view.invalidate(change.child, true, true); | ||
|
|
||
| if ( | ||
| newParent && | ||
| (!this.getDataModel().contains(newParent) || newParent.isCollapsed()) | ||
| ) { | ||
| if (newParent == null || !this.getDataModel().contains(newParent) || newParent.isCollapsed()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's review mxgraph original code or explain why you need to change the logic here. |
||
| { | ||
| this.view.invalidate(change.child, true, true); | ||
| this.removeStateForCell(change.child); | ||
|
|
||
|
|
@@ -1370,7 +1368,7 @@ class Graph extends EventSource { | |
| setAllowLoops(value: boolean) { | ||
| this.allowLoops = value; | ||
| } | ||
|
|
||
| /** | ||
| * Returns {@link recursiveResize}. | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -389,7 +389,7 @@ export class GraphDataModel extends EventSource { | |
| * @param {Cell} cell that represents the possible layer. | ||
| */ | ||
| isLayer(cell: Cell) { | ||
| return this.isRoot(cell.getParent()); | ||
| return cell != null && this.isRoot(cell.getParent()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -994,9 +994,10 @@ class SvgCanvas2D extends AbstractCanvas2D { | |
| * Private helper function to create SVG elements | ||
| */ | ||
| roundrect(x: number, y: number, w: number, h: number, dx: number, dy: number) { | ||
| if (!this.node) return; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check original mxgraph implementation, I don't understand why we need to change the logic |
||
|
|
||
| this.rect(x, y, w, h); //creates this.node | ||
|
|
||
| this.rect(x, y, w, h); | ||
| if(!this.node)return | ||
|
|
||
| if (dx > 0) { | ||
| this.node.setAttribute('rx', String(this.format(dx * this.state.scale))); | ||
|
|
@@ -1559,7 +1560,7 @@ class SvgCanvas2D extends AbstractCanvas2D { | |
| tr += `rotate(${rotation},${this.format(x * s.scale)},${this.format(y * s.scale)})`; | ||
| } | ||
|
|
||
| if (dir != null) { | ||
| if (dir != '') { | ||
| node.setAttribute('direction', dir); | ||
| } | ||
|
|
||
|
|
@@ -1819,9 +1820,9 @@ class SvgCanvas2D extends AbstractCanvas2D { | |
| } | ||
|
|
||
| bbox = new Rectangle( | ||
| (x + 1) * s.scale, | ||
| x * s.scale, | ||
| (y + 2) * s.scale, | ||
| w * s.scale, | ||
| (w +1) * s.scale, | ||
| (h + 1) * s.scale | ||
| ); | ||
|
Comment on lines
1822
to
1827
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am pretty sure the previous implementation cames from the orignal mxGraph. |
||
| } | ||
|
|
@@ -1835,7 +1836,7 @@ class SvgCanvas2D extends AbstractCanvas2D { | |
| n.setAttribute('width', String(Math.ceil(bbox.width + 2))); | ||
| n.setAttribute('height', String(Math.ceil(bbox.height))); | ||
|
|
||
| const sw = s.fontBorderColor ? Math.max(1, this.format(s.scale)) : 0; | ||
| const sw = s.fontBorderColor !== 'none' ? Math.max(1, this.format(s.scale)) : 0; | ||
| n.setAttribute('stroke-width', String(sw)); | ||
|
|
||
| // Workaround for crisp rendering - only required if not exporting | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra change