From 835911ad0451ad2e776906bd6b9ae25d762e0c0c Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 10 Jul 2022 21:54:45 +0500 Subject: [PATCH 1/4] Major grammar and typo fixes --- .vscode/settings.json | 5 + script/Algorithms.js | 18 ++-- script/{Appilcation.js => Application.js} | 60 ++++++------ script/BaseEdge.js | 6 +- script/BaseEdgeDrawer.js | 64 ++++++------- script/BaseVertex.js | 10 +- script/EdgeModel.js | 44 ++++----- script/EnumVertices.js | 46 ++++----- script/EventHandlers.js | 44 ++++----- script/Graph.js | 94 +++++++++---------- .../{GraphMLCreater.js => GraphMLCreator.js} | 14 +-- script/main.js | 10 +- script/merge.php | 4 +- script/plugins/Floid.js | 2 +- script/texts.js | 32 +++---- 15 files changed, 229 insertions(+), 224 deletions(-) create mode 100644 .vscode/settings.json rename script/{Appilcation.js => Application.js} (96%) rename script/{GraphMLCreater.js => GraphMLCreator.js} (78%) mode change 100755 => 100644 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..83c60d2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": [ + "Emscripten" + ] +} \ No newline at end of file diff --git a/script/Algorithms.js b/script/Algorithms.js index 2d6cb42..76de20c 100644 --- a/script/Algorithms.js +++ b/script/Algorithms.js @@ -3,8 +3,8 @@ * */ -// Return list of vertex with connected vertex. -function getVertexToVertexArray(graph, ignoryDirection) +// Return list of 'vertex = [connected vertices]' +function getVertexToVertexArray(graph, ignoreDirection) { res = {}; @@ -16,7 +16,7 @@ function getVertexToVertexArray(graph, ignoryDirection) res[edge.vertex1.id] = []; } res[edge.vertex1.id].push(edge.vertex2); - if (!edge.isDirect || ignoryDirection) + if (!edge.isDirect || ignoreDirection) { if (!res.hasOwnProperty(edge.vertex2.id)) { @@ -34,7 +34,7 @@ function getVertexToVertexArray(graph, ignoryDirection) var g_Algorithms = []; var g_AlgorithmIds = []; -// Call this function to register your factory algoritm. +// Call this function to register your factory algorithm. function RegisterAlgorithm (factory) { g_Algorithms.push(factory); @@ -48,13 +48,13 @@ function BaseAlgorithm (graph, app) this.app = app; } -// @return name of algorthm. For now we supports only 2 locals: "ru" and "en" +// @return name of algorithm. For now we supports only 2 locals: "ru" and "en" BaseAlgorithm.prototype.getName = function(local) { return "unknown_name_" + local; } -// @return id of algorthm. Please use format: "your id"."algorithm id". Ex. "OlegSh.ConnectedComponent" +// @return id of algorithm. Please use format: "your id"."algorithm id". Ex. "OlegSh.ConnectedComponent" BaseAlgorithm.prototype.getId = function() { return "unknown.unknown"; @@ -109,7 +109,7 @@ BaseAlgorithm.prototype.needRestoreUpText = function() return true; } -// @return true, if you change resotry graph after use. +// @return true, if you change restore graph after use. BaseAlgorithm.prototype.wantRestore = function() { return false; @@ -126,7 +126,7 @@ BaseAlgorithm.prototype.getObjectSelectedGroup = function(object) return 0; } -// This methos is called, when messages was updated on html page. +// This method is called, when messages was updated on html page. BaseAlgorithm.prototype.messageWasChanged = function() {} // Algorithm priority in menu @@ -172,7 +172,7 @@ BaseAlgorithmEx.prototype.CalculateAlgorithm = function(algorithmName, otherPara if (!graph.HasConnectedNodes(graph.vertices[i])) ignoreNodes[graph.vertices[i].id] = 1; - var creator = new GraphMLCreater(graph.vertices, graph.edges, ignoreNodes); + var creator = new GraphMLCreator(graph.vertices, graph.edges, ignoreNodes); var pathObjects = []; var properties = {}; var result = []; diff --git a/script/Appilcation.js b/script/Application.js similarity index 96% rename from script/Appilcation.js rename to script/Application.js index 9dc6b2c..1a042f1 100644 --- a/script/Appilcation.js +++ b/script/Application.js @@ -11,7 +11,7 @@ function Application(document, window) this.canvas = this.document.getElementById('canvas'); this.handler = new AddGraphHandler(this); this.savedGraphName = ""; - this.currentEnumVertesType = new BaseEnumVertices(this, 1);//this.enumVertexesTextList[0]; + this.currentEnumVerticesType = new BaseEnumVertices(this, 1);//this.enumVerticesTextList[0]; this.findPathReport = 1; this.isTimerRender = false; globalApplication = this; @@ -20,7 +20,7 @@ function Application(document, window) this.renderPathLength = 0; this.renderPathCounter = 0; this.renderPathLoops = 0; - this.enumVertexesTextList = [new BaseEnumVertices(this, 1), new BaseEnumVertices(this, 0), new TextEnumVertexs(this), new TextEnumVertexsCyr(this), new TextEnumVertexsGreek(this), new TextEnumVertexsCustom(this)]; + this.enumVerticesTextList = [new BaseEnumVertices(this, 1), new BaseEnumVertices(this, 0), new TextEnumVertices(this), new TextEnumVerticesCyr(this), new TextEnumVerticesGreek(this), new TextEnumVerticesCustom(this)]; this.SetDefaultTransformations(); this.algorithmsValues = {}; this.userAction = function(){}; @@ -58,7 +58,7 @@ function Application(document, window) // List of graph. //Application.prototype.graph.vertices = []; -// Current draged object. +// Current dragged object. Application.prototype.graph = new Graph(); Application.prototype.dragObject = -1; // List of graph.edges. @@ -326,17 +326,17 @@ Application.prototype.GetBaseArcDrawer = function(context, edge) { var arcDrawer = new BaseEdgeDrawer(context); - if (edge.model.type == EdgeModels.cruvled) + if (edge.model.type == EdgeModels.curve) { var curvedArcDrawer = new CurvedArcDrawer(context, edge.model); arcDrawer = new BaseEdgeDrawer(context, { - drawArc : curvedArcDrawer, - startArrowDiretion : curvedArcDrawer, - finishArrowDiretion : curvedArcDrawer, - textCenterObject : curvedArcDrawer, - getPointOnArc : curvedArcDrawer + drawArc : curvedArcDrawer, + startArrowDirection : curvedArcDrawer, + finishArrowDirection : curvedArcDrawer, + textCenterObject : curvedArcDrawer, + getPointOnArc : curvedArcDrawer } ); } @@ -570,7 +570,7 @@ Application.prototype.CreateNewGraph = function(x, y) { var app = this; - this.currentEnumVertesType.GetVertexTextAsync( + this.currentEnumVerticesType.GetVertexTextAsync( function (enumType) { app.graph.AddNewVertex(new BaseVertex(x, y, enumType)); @@ -587,7 +587,7 @@ Application.prototype.CreateNewArc = function(graph1, graph2, isDirect, weight, { var edge = this.AddNewEdge(new BaseEdge(graph1, graph2, isDirect, weight, upText), replaceIfExist); - this.graph.FixEdgeCurved(edge); + this.graph.FixEdgeCurve(edge); var edgeObject = this.graph.edges[edge]; @@ -661,9 +661,9 @@ Application.prototype.FindAllEdges = function(id1, id2) Application.prototype.SetHandlerMode = function(mode) { - var manipolationHandlers = ["default", "addGraph", "addArc", "delete", "findPath", "connectedComponent", "eulerianLoop"]; + var manipulationHandlers = ["default", "addGraph", "addArc", "delete", "findPath", "connectedComponent", "eulerianLoop"]; - if (this.handler && (g_AlgorithmIds.indexOf(mode) >= 0 || manipolationHandlers.indexOf(mode) >= 0)) + if (this.handler && (g_AlgorithmIds.indexOf(mode) >= 0 || manipulationHandlers.indexOf(mode) >= 0)) { this.handler.RestoreAll(); } @@ -799,7 +799,7 @@ Application.prototype.getParameterByName = function (name) Application.prototype.onPostLoadEvent = function() { - this.SetEnumVertexsType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/, "$1")); + this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/, "$1")); var wasLoad = false; var matrix = document.getElementById("inputMatrix").innerHTML; @@ -927,7 +927,7 @@ Application.prototype.SetAdjacencyMatrix = function (matrix, separator) res = false; } - this.graph.SetAdjacencyMatrix(matrix, new Point(this.GetRealWidth(), this.GetRealHeight()), this.currentEnumVertesType, separator); + this.graph.SetAdjacencyMatrix(matrix, new Point(this.GetRealWidth(), this.GetRealHeight()), this.currentEnumVerticesType, separator); this.AutoAdjustViewport(); this.redrawGraph(); return res; @@ -955,7 +955,7 @@ Application.prototype.SetIncidenceMatrix = function (matrix) res = false; } - this.graph.SetIncidenceMatrix(matrix, new Point(this.GetRealWidth(), this.GetRealHeight()), this.currentEnumVertesType); + this.graph.SetIncidenceMatrix(matrix, new Point(this.GetRealWidth(), this.GetRealHeight()), this.currentEnumVerticesType); this.AutoAdjustViewport(); this.redrawGraph(); return res; @@ -1206,17 +1206,17 @@ Application.prototype.SetDefaultHandler = function() this.SetHandlerMode("default"); } -Application.prototype.GetEnumVertexsList = function() +Application.prototype.GetEnumVerticesList = function() { var res = []; - for (var i = 0; i < this.enumVertexesTextList.length; i ++) + for (var i = 0; i < this.enumVerticesTextList.length; i ++) { var one = {}; - one["text"] = this.enumVertexesTextList[i].GetText(); - one["value"] = this.enumVertexesTextList[i].GetValue(); + one["text"] = this.enumVerticesTextList[i].GetText(); + one["value"] = this.enumVerticesTextList[i].GetValue(); - one["select"] = this.enumVertexesTextList[i].GetValue() == this.currentEnumVertesType.GetValue(); + one["select"] = this.enumVerticesTextList[i].GetValue() == this.currentEnumVerticesType.GetValue(); res.push(one); } @@ -1224,13 +1224,13 @@ Application.prototype.GetEnumVertexsList = function() return res; } -Application.prototype.SetEnumVertexsType = function(value) +Application.prototype.SetEnumVerticesType = function(value) { - for (var i = 0; i < this.enumVertexesTextList.length; i ++) + for (var i = 0; i < this.enumVerticesTextList.length; i ++) { - if (this.enumVertexesTextList[i].GetValue() == value) + if (this.enumVerticesTextList[i].GetValue() == value) { - this.currentEnumVertesType = this.enumVertexesTextList[i]; + this.currentEnumVerticesType = this.enumVerticesTextList[i]; document.cookie = "enumType=" + value; break; } @@ -1698,14 +1698,14 @@ Application.prototype.ResetBackgroundStyle = function () this.isBackgroundCommonStyleCustom = false; } -Application.prototype.GetAvalibleCruvledValue = function(neighbourEdges, originalEdge) +Application.prototype.GetAvailableCurveValue = function(neighborEdges, originalEdge) { - return this.graph.GetAvalibleCruvledValue(neighbourEdges, originalEdge); + return this.graph.GetAvailableCurveValue(neighborEdges, originalEdge); } Application.prototype.GraphTypeChanged = function() { - $("#CanvasMessage").text(this.graph.isMulti() ? g_GrapsIsMultiMessage : g_GrapsIsGeneralMessage); + $("#CanvasMessage").text(this.graph.isMulti() ? g_GraphIsMultiMessage : g_GraphIsGeneralMessage); } Application.prototype.UpdateEdgePresets = function(weight) @@ -1793,7 +1793,7 @@ Application.prototype.GetStyle = function(type, styleName, object, index) } Application.prototype._RedrawGraph = function(context, backgroundPosition, backgroundStyle, bDrawSelectedRect, - forceVertexCommon, forceVertexSeleceted, forceEdgeCommon, forceEdgeSelected) + forceVertexCommon, forceVertexSelected, forceEdgeCommon, forceEdgeSelected) { var backgroundDrawer = new BaseBackgroundDrawer(context); @@ -1805,7 +1805,7 @@ Application.prototype._RedrawGraph = function(context, backgroundPosition, backg this.canvasScale); this.UpdateEdgesCurrentStyle(forceEdgeCommon, forceEdgeSelected); - this.UpdateNodesCurrentStyle(forceVertexCommon, forceVertexSeleceted); + this.UpdateNodesCurrentStyle(forceVertexCommon, forceVertexSelected); this.RedrawEdges(context); this.RedrawNodes(context); diff --git a/script/BaseEdge.js b/script/BaseEdge.js index fa168a6..ca8d8ac 100755 --- a/script/BaseEdge.js +++ b/script/BaseEdge.js @@ -194,13 +194,13 @@ BaseEdge.prototype.GetEdgePositions = function() var d1 = diameter1; var d2 = diameter2; - if (this.model.type == EdgeModels.cruvled) + if (this.model.type == EdgeModels.curve) { var dist = position1.distance(position2); - var point1 = this.model.GetCurvedPoint(position1, position2, 10.0 / dist); + var point1 = this.model.GetCurvePoint(position1, position2, 10.0 / dist); direction1 = position1.subtract(point1); - var point2 = this.model.GetCurvedPoint(position1, position2, 1.0 - 10.0 / dist); + var point2 = this.model.GetCurvePoint(position1, position2, 1.0 - 10.0 / dist); direction2 = position2.subtract(point2); d2 = diameter2; diff --git a/script/BaseEdgeDrawer.js b/script/BaseEdgeDrawer.js index c141b4d..c984e85 100644 --- a/script/BaseEdgeDrawer.js +++ b/script/BaseEdgeDrawer.js @@ -34,8 +34,8 @@ const WeightTextCenter = 0, baseStyle.fillStyle = this.fillStyle; if (this.hasOwnProperty('textPadding')) baseStyle.textPadding = this.textPadding; - if (this.hasOwnProperty('textStrockeWidth')) - baseStyle.textStrockeWidth = this.textStrockeWidth; + if (this.hasOwnProperty('textStrokeWidth')) + baseStyle.textStrokeWidth = this.textStrokeWidth; if (this.hasOwnProperty('lineDash')) baseStyle.lineDash = this.lineDash; if (this.hasOwnProperty('additionalTextColor')) @@ -63,7 +63,7 @@ BaseEdgeStyle.prototype.FixNewFields = function (style) delete this.strokeStyle; delete this.fillStyle; delete this.textPadding; - delete this.textStrockeWidth; + delete this.textStrokeWidth; delete this.lineDash; delete this.additionalTextColor; delete this.weightPosition; @@ -82,7 +82,7 @@ function CommonEdgeStyle() this.weightText = '#f0d543'; this.fillStyle = '#68aeba'; this.textPadding = 4; - this.textStrockeWidth = 2; + this.textStrokeWidth = 2; this.lineDash = 0; this.additionalTextColor = '#c7b7c7'; this.weightPosition = WeightTextCenter; @@ -98,7 +98,7 @@ function CommonPrintEdgeStyle() this.weightText = '#000000'; this.fillStyle = '#FFFFFF'; this.textPadding = 4; - this.textStrockeWidth = 2; + this.textStrokeWidth = 2; this.baseStyles.push("common"); } @@ -194,8 +194,8 @@ function BaseEdgeDrawer(context, drawObjects) this.drawObject = null; this.drawArc = null; - this.startArrowDiretion = null; - this.finishArrowDiretion = null; + this.startArrowDirection = null; + this.finishArrowDirection = null; this.textCenterObject = null; this.getPointOnArc = null; @@ -205,10 +205,10 @@ function BaseEdgeDrawer(context, drawObjects) this.drawObject = drawObjects.drawObject; if (drawObjects.hasOwnProperty("drawArc")) this.drawArc = drawObjects.drawArc; - if (drawObjects.hasOwnProperty("startArrowDiretion")) - this.startArrowDiretion = drawObjects.startArrowDiretion; - if (drawObjects.hasOwnProperty("finishArrowDiretion")) - this.finishArrowDiretion = drawObjects.finishArrowDiretion; + if (drawObjects.hasOwnProperty("startArrowDirection")) + this.startArrowDirection = drawObjects.startArrowDirection; + if (drawObjects.hasOwnProperty("finishArrowDirection")) + this.finishArrowDirection = drawObjects.finishArrowDirection; if (drawObjects.hasOwnProperty("textCenterObject")) this.textCenterObject = drawObjects.textCenterObject; if (drawObjects.hasOwnProperty("getPointOnArc")) @@ -242,13 +242,13 @@ BaseEdgeDrawer.prototype.Draw = function(baseEdge, arcStyle) if (hasStartStyle) { - var dirArrow = this.GetStartArrowDiretion(positions[0], positions[1], lengthArrow); + var dirArrow = this.GetStartArrowDirection(positions[0], positions[1], lengthArrow); arcPos1 = arcPos1.add(dirArrow.multiply(lengthArrow / 2)); } if (hasFinishStyle) { - var dirArrow = this.GetFinishArrowDiretion(positions[0], positions[1], lengthArrow); + var dirArrow = this.GetFinishArrowDirection(positions[0], positions[1], lengthArrow); arcPos2 = arcPos2.add(dirArrow.multiply(-lengthArrow / 2)); } @@ -259,11 +259,11 @@ BaseEdgeDrawer.prototype.Draw = function(baseEdge, arcStyle) if (hasStartStyle) { - this.DrawArrow(positions[0], this.GetStartArrowDiretion(positions[0], positions[1], lengthArrow), lengthArrow, widthArrow); + this.DrawArrow(positions[0], this.GetStartArrowDirection(positions[0], positions[1], lengthArrow), lengthArrow, widthArrow); } if (hasFinishStyle) { - this.DrawArrow(positions[1], this.GetFinishArrowDiretion(positions[0], positions[1], lengthArrow), lengthArrow, widthArrow); + this.DrawArrow(positions[1], this.GetFinishArrowDirection(positions[0], positions[1], lengthArrow), lengthArrow, widthArrow); } this.SetupStyle(baseEdge, arcStyle); @@ -336,7 +336,7 @@ BaseEdgeDrawer.prototype.DrawWeight = function(position1, position2, text, arcSt this.context.font = "bold 16px sans-serif"; this.context.textBaseline = "middle"; - this.context.lineWidth = arcStyle.textStrockeWidth; + this.context.lineWidth = arcStyle.textStrokeWidth; this.context.fillStyle = arcStyle.fillStyle; var widthText = this.context.measureText(text).width; @@ -399,11 +399,11 @@ BaseEdgeDrawer.prototype.DrawArrow = function(position, direction, length, width this.context.fill(); } -BaseEdgeDrawer.prototype.GetStartArrowDiretion = function(position1, position2, lengthArrow) +BaseEdgeDrawer.prototype.GetStartArrowDirection = function(position1, position2, lengthArrow) { - if (this.startArrowDiretion && this.startArrowDiretion != this) + if (this.startArrowDirection && this.startArrowDirection != this) { - return this.startArrowDiretion.GetStartArrowDiretion(position1, position2, lengthArrow); + return this.startArrowDirection.GetStartArrowDirection(position1, position2, lengthArrow); } var direction = position1.subtract(position2); @@ -411,11 +411,11 @@ BaseEdgeDrawer.prototype.GetStartArrowDiretion = function(position1, position2, return direction; } -BaseEdgeDrawer.prototype.GetFinishArrowDiretion = function(position1, position2, lengthArrow) +BaseEdgeDrawer.prototype.GetFinishArrowDirection = function(position1, position2, lengthArrow) { - if (this.finishArrowDiretion && this.finishArrowDiretion != this) + if (this.finishArrowDirection && this.finishArrowDirection != this) { - return this.finishArrowDiretion.GetFinishArrowDiretion(position1, position2, lengthArrow); + return this.finishArrowDirection.GetFinishArrowDirection(position1, position2, lengthArrow); } var direction = position2.subtract(position1); @@ -441,14 +441,14 @@ BaseEdgeDrawer.prototype.GetTextCenterPoint = function (position1, position2, ha return centerPoint; } -BaseEdgeDrawer.prototype.GetPointOnArc = function (position1, position2, procent) +BaseEdgeDrawer.prototype.GetPointOnArc = function (position1, position2, percent) { if (this.getPointOnArc && this.getPointOnArc != this) { - return this.getPointOnArc.GetPointOnArc(position1, position2, procent); + return this.getPointOnArc.GetPointOnArc(position1, position2, percent); } - return Point.interpolate(position1, position2, procent); + return Point.interpolate(position1, position2, percent); } function ProgressArcDrawer(context, baseDrawer, progress) @@ -526,25 +526,25 @@ CurvedArcDrawer.prototype.DrawArc = function(position1, position2, arcStyle) this.context.setLineDash([]); } -CurvedArcDrawer.prototype.GetStartArrowDiretion = function(position1, position2, lengthArrow) +CurvedArcDrawer.prototype.GetStartArrowDirection = function(position1, position2, lengthArrow) { var dist = position1.distance(position2); - var direction = position1.subtract(this.model.GetCurvedPoint(position1, position2, lengthArrow / dist)); + var direction = position1.subtract(this.model.GetCurvePoint(position1, position2, lengthArrow / dist)); direction.normalize(1.0); return direction; } -CurvedArcDrawer.prototype.GetFinishArrowDiretion = function(position1, position2, lengthArrow) +CurvedArcDrawer.prototype.GetFinishArrowDirection = function(position1, position2, lengthArrow) { var dist = position1.distance(position2); - var direction = position2.subtract(this.model.GetCurvedPoint(position1, position2, 1.0 - lengthArrow / dist)); + var direction = position2.subtract(this.model.GetCurvePoint(position1, position2, 1.0 - lengthArrow / dist)); direction.normalize(1.0); return direction; } CurvedArcDrawer.prototype.GetTextCenterPoint = function (position1, position2, hasPair, arcStyle) { - var centerPoint = this.model.GetCurvedPoint(position1, position2, 0.5) + var centerPoint = this.model.GetCurvePoint(position1, position2, 0.5) if (position1.equals(position2)) { centerPoint.y = centerPoint.y - Math.cos(this.model.GetLoopShiftAngel()) * this.model.GetLoopSize() * 2; @@ -554,7 +554,7 @@ CurvedArcDrawer.prototype.GetTextCenterPoint = function (position1, position2, h return centerPoint; } -CurvedArcDrawer.prototype.GetPointOnArc = function (position1, position2, procent) +CurvedArcDrawer.prototype.GetPointOnArc = function (position1, position2, percent) { - return this.model.GetCurvedPoint(position1, position2, procent); + return this.model.GetCurvePoint(position1, position2, percent); } diff --git a/script/BaseVertex.js b/script/BaseVertex.js index a2ee0d3..d71c8f9 100755 --- a/script/BaseVertex.js +++ b/script/BaseVertex.js @@ -113,9 +113,9 @@ BaseVertex.prototype.HitTest = function (pos) } else { - var relativPos = (new Point(pos.x, pos.y)).subtract(this.position); - var lineFinish1 = relativPos.add(new Point(1000, 0)); - var lineFinish2 = relativPos.add(new Point(-1000, 0)); + var relativePos = (new Point(pos.x, pos.y)).subtract(this.position); + var lineFinish1 = relativePos.add(new Point(1000, 0)); + var lineFinish2 = relativePos.add(new Point(-1000, 0)); var pointsVertex1 = GetPointsForShape(shape, this.model.diameter + width); pointsVertex1.push(pointsVertex1[0]); @@ -125,12 +125,12 @@ BaseVertex.prototype.HitTest = function (pos) for (var i = 0; i < pointsVertex1.length - 1; i ++) { - var hitTest = Point.hitTest(relativPos, lineFinish1, pointsVertex1[i], pointsVertex1[i + 1]); + var hitTest = Point.hitTest(relativePos, lineFinish1, pointsVertex1[i], pointsVertex1[i + 1]); if (hitTest != null) { hitNumber1++; } - hitTest = Point.hitTest(relativPos, lineFinish2, pointsVertex1[i], pointsVertex1[i + 1]); + hitTest = Point.hitTest(relativePos, lineFinish2, pointsVertex1[i], pointsVertex1[i + 1]); if (hitTest != null) { hitNumber2++; diff --git a/script/EdgeModel.js b/script/EdgeModel.js index 87ff050..f9bf3aa 100755 --- a/script/EdgeModel.js +++ b/script/EdgeModel.js @@ -3,7 +3,7 @@ * */ -var EdgeModels = {"line": 0, "cruvled" : 1}; +var EdgeModels = {"line": 0, "curve" : 1}; const defaultEdgeWidth = 4; @@ -11,19 +11,19 @@ function EdgeModel() { this.width = globalApplication.GetDefaultEdgeWidth(); this.type = EdgeModels.line; - this.curvedValue = EdgeModel.prototype.defaultCruved; + this.curveValue = EdgeModel.prototype.defaultCurve; this.default = true; this.sizeOfLoop = 24; this.loopShiftAngel = Math.PI / 6; } -EdgeModel.prototype.defaultCruved = 0.1; +EdgeModel.prototype.defaultCurve = 0.1; EdgeModel.prototype.copyFrom = function(other) { this.width = other.width; this.type = other.type; - this.curvedValue = other.curvedValue; + this.curveValue = other.curveValue; this.default = other.default; } @@ -31,7 +31,7 @@ EdgeModel.prototype.SaveToXML = function () { return "model_width=\"" + this.width + "\" " + "model_type=\"" + this.type + "\" " + - "model_curvedValue=\"" + this.curvedValue + "\" " + "model_curveValue=\"" + this.curveValue + "\" " "model_default=\"" + this.default + "\" "; } @@ -39,11 +39,11 @@ EdgeModel.prototype.LoadFromXML = function (xml, graph) { this.width = xml.attr('model_width') == null ? this.width : parseFloat(xml.attr("model_width")); this.type = xml.attr('model_type') == null ? this.type : xml.attr("model_type"); - this.curvedValue = xml.attr('model_curvedValue') == null ? this.curvedValue : parseFloat(xml.attr("model_curvedValue")); + this.curveValue = xml.attr('model_curveValue') == null ? this.curveValue : parseFloat(xml.attr("model_curveValue")); this.default = xml.attr('model_default') == null ? this.default : parseFloat(xml.attr("model_default")); } -EdgeModel.prototype.GetCurvedPoint = function(position1, position2, t) +EdgeModel.prototype.GetCurvePoint = function(position1, position2, t) { var points = this.GetBezierPoints(position1, position2); var firstBezierPoint = points[0]; @@ -76,7 +76,7 @@ EdgeModel.prototype.GetBezierPoints = function(position1, position2) direction.normalize(1.0); var normal = direction.normal(); - var deltaOffsetPixels = delta * this.curvedValue; + var deltaOffsetPixels = delta * this.curveValue; var yOffset = normal.multiply(deltaOffsetPixels); var firstBezierPointShift = (direction.multiply(delta * 0.2)).add(yOffset); var secondBezierPointShift = (direction.multiply(-delta * 0.2)).add(yOffset); @@ -91,8 +91,8 @@ EdgeModel.prototype.HitTest = function(position1, position2, mousePos) { if (this.type == EdgeModels.line) return this.HitTestLine(position1, position2, mousePos); - else if (this.type == EdgeModels.cruvled) - return this.HitTestCurved(position1, position2, mousePos); + else if (this.type == EdgeModels.curve) + return this.HitTestCurve(position1, position2, mousePos); return false; } @@ -139,7 +139,7 @@ EdgeModel.prototype.HitTestLine = function(position1, position2, mousePos, facto return false; } -EdgeModel.prototype.HitTestCurved = function(position1, position2, mousePos) +EdgeModel.prototype.HitTestCurve = function(position1, position2, mousePos) { var pos1 = position1; var pos2 = position2; @@ -159,7 +159,7 @@ EdgeModel.prototype.HitTestCurved = function(position1, position2, mousePos) var start = position1; for (var i = 0; i < interval_count; i ++) { - var finish = this.GetCurvedPoint(position1, position2, i / interval_count); + var finish = this.GetCurvePoint(position1, position2, i / interval_count); if (this.HitTestLine(start, finish, mousePos, 2.0)) return true; @@ -170,33 +170,33 @@ EdgeModel.prototype.HitTestCurved = function(position1, position2, mousePos) return false; } -EdgeModel.prototype.ChangeCurvedValue = function (delta) +EdgeModel.prototype.ChangeCurveValue = function (delta) { if (this.type == EdgeModels.line) { - this.type = EdgeModels.cruvled; - this.curvedValue = 0.0; + this.type = EdgeModels.curve; + this.curveValue = 0.0; } - this.curvedValue = this.curvedValue + delta; + this.curveValue = this.curveValue + delta; - if (Math.abs(this.curvedValue) <= 0.01) + if (Math.abs(this.curveValue) <= 0.01) this.type = EdgeModels.line; this.default = false; } -EdgeModel.prototype.SetCurvedValue = function (value) +EdgeModel.prototype.SetCurveValue = function (value) { if (this.type == EdgeModels.line) { - this.type = EdgeModels.cruvled; - this.curvedValue = 0.0; + this.type = EdgeModels.curve; + this.curveValue = 0.0; } - this.curvedValue = value; + this.curveValue = value; - if (Math.abs(this.curvedValue) <= 0.01) + if (Math.abs(this.curveValue) <= 0.01) this.type = EdgeModels.line; this.default = false; diff --git a/script/EnumVertices.js b/script/EnumVertices.js index e583558..7395a98 100755 --- a/script/EnumVertices.js +++ b/script/EnumVertices.js @@ -1,10 +1,10 @@ /* - Classes for create text for vertexs. + Classes for creating text for vertices. */ /** - * Base Enum Vertexs. + * Base Enum Vertices. * */ function BaseEnumVertices(app, startNumber) @@ -55,7 +55,7 @@ TextEnumTitle.prototype.GetVertexText = function(id) * Text Enum * */ -function TextEnumVertexs(app) +function TextEnumVertices(app) { BaseEnumVertices.apply(this, arguments); this.pattern = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -63,9 +63,9 @@ function TextEnumVertexs(app) // inheritance. -TextEnumVertexs.prototype = Object.create(BaseEnumVertices.prototype); +TextEnumVertices.prototype = Object.create(BaseEnumVertices.prototype); -TextEnumVertexs.prototype.GetVertexText = function(id) +TextEnumVertices.prototype.GetVertexText = function(id) { var res = ""; @@ -81,12 +81,12 @@ TextEnumVertexs.prototype.GetVertexText = function(id) } -TextEnumVertexs.prototype.GetText = function() +TextEnumVertices.prototype.GetText = function() { return "A, B, ... Z"; } -TextEnumVertexs.prototype.GetValue = function() +TextEnumVertices.prototype.GetValue = function() { return "Latin"; } @@ -95,22 +95,22 @@ TextEnumVertexs.prototype.GetValue = function() * Text Enum * */ -function TextEnumVertexsCyr(app) +function TextEnumVerticesCyr(app) { - TextEnumVertexs.apply(this, arguments); + TextEnumVertices.apply(this, arguments); this.pattern = "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"; } // inheritance. -TextEnumVertexsCyr.prototype = Object.create(TextEnumVertexs.prototype); +TextEnumVerticesCyr.prototype = Object.create(TextEnumVertices.prototype); -TextEnumVertexsCyr.prototype.GetText = function() +TextEnumVerticesCyr.prototype.GetText = function() { return "А, Б, ... Я"; } -TextEnumVertexsCyr.prototype.GetValue = function() +TextEnumVerticesCyr.prototype.GetValue = function() { return "Cyrillic"; } @@ -120,22 +120,22 @@ TextEnumVertexsCyr.prototype.GetValue = function() * Text Enum * */ -function TextEnumVertexsGreek(app) +function TextEnumVerticesGreek(app) { - TextEnumVertexs.apply(this, arguments); + TextEnumVertices.apply(this, arguments); this.pattern = "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ"; } // inheritance. -TextEnumVertexsGreek.prototype = Object.create(TextEnumVertexs.prototype); +TextEnumVerticesGreek.prototype = Object.create(TextEnumVertices.prototype); -TextEnumVertexsGreek.prototype.GetText = function() +TextEnumVerticesGreek.prototype.GetText = function() { return "Α, Β, ... Ω"; } -TextEnumVertexsGreek.prototype.GetValue = function() +TextEnumVerticesGreek.prototype.GetValue = function() { return "Greek"; } @@ -144,7 +144,7 @@ TextEnumVertexsGreek.prototype.GetValue = function() * Text Enum * */ -function TextEnumVertexsCustom(app) +function TextEnumVerticesCustom(app) { BaseEnumVertices.apply(this, arguments); this.pattern = ""; @@ -153,25 +153,25 @@ function TextEnumVertexsCustom(app) // inheritance. -TextEnumVertexsCustom.prototype = Object.create(BaseEnumVertices.prototype); +TextEnumVerticesCustom.prototype = Object.create(BaseEnumVertices.prototype); -TextEnumVertexsCustom.prototype.GetText = function() +TextEnumVerticesCustom.prototype.GetText = function() { return g_customEnumVertex; } -TextEnumVertexsCustom.prototype.GetValue = function() +TextEnumVerticesCustom.prototype.GetValue = function() { return "Custom"; } -TextEnumVertexsCustom.prototype.GetVertexTextAsync = function(callback) +TextEnumVerticesCustom.prototype.GetVertexTextAsync = function(callback) { this.ShowDialog(callback, g_addVertex, g_addVertex, "A"); } -TextEnumVertexsCustom.prototype.ShowDialog = function(callback, buttonText, titleTitle, title) +TextEnumVerticesCustom.prototype.ShowDialog = function(callback, buttonText, titleTitle, title) { var dialogButtons = {}; app = this.app; diff --git a/script/EventHandlers.js b/script/EventHandlers.js index 6ccac37..666674c 100644 --- a/script/EventHandlers.js +++ b/script/EventHandlers.js @@ -226,7 +226,7 @@ BaseHandler.prototype.addContextMenu = function() handler.RenameVertex(enumType.GetVertexText(0), handler.contextMenuObject); userAction("RenameVertex_contextMenu"); }; - var customEnum = new TextEnumVertexsCustom(handler.app); + var customEnum = new TextEnumVerticesCustom(handler.app); customEnum.ShowDialog(callback, g_rename, g_renameVertex, handler.contextMenuObject.mainText); } }); @@ -481,8 +481,8 @@ function DefaultHandler(app) DefaultHandler.prototype = Object.create(BaseHandler.prototype); // Is pressed DefaultHandler.prototype.pressed = false; -// Cuvled change value. -DefaultHandler.prototype.curvedValue = 0.1; +// Curve change value. +DefaultHandler.prototype.curveValue = 0.1; DefaultHandler.prototype.GetSelectedVertex = function() { @@ -633,7 +633,7 @@ DefaultHandler.prototype.MouseUp = function(pos) }; $('#message').unbind(); $('#message').on('click', '#renameButton', function(){ - var customEnum = new TextEnumVertexsCustom(handler.app); + var customEnum = new TextEnumVerticesCustom(handler.app); customEnum.ShowDialog(callback, g_rename, g_renameVertex, handler.selectedObject.mainText); }); $('#message').on('click', '#changeCommonStyle', function(){ @@ -717,7 +717,7 @@ DefaultHandler.prototype.MouseUp = function(pos) $('#message').on('click', '#incCurvel', function(){ handler.app.PushToStack("ChangeCurvelEdge"); - handler.selectedObject.model.ChangeCurvedValue(DefaultHandler.prototype.curvedValue); + handler.selectedObject.model.ChangeCurveValue(DefaultHandler.prototype.curveValue); handler.needRedraw = true; handler.app.redrawGraph(); userAction("Edge.Bend"); @@ -725,7 +725,7 @@ DefaultHandler.prototype.MouseUp = function(pos) $('#message').on('click', '#decCurvel', function(){ handler.app.PushToStack("ChangeCurvelEdge"); - handler.selectedObject.model.ChangeCurvedValue(-DefaultHandler.prototype.curvedValue); + handler.selectedObject.model.ChangeCurveValue(-DefaultHandler.prototype.curveValue); handler.needRedraw = true; handler.app.redrawGraph(); userAction("Edge.Bend"); @@ -841,11 +841,11 @@ DefaultHandler.prototype.MouseUp = function(pos) handler.app.AddNewEdge(newObject); if (!toNewVertex) { - var neighbourEdges = handler.app.graph.getNeighbourEdges(newObject); - if (neighbourEdges.length >= 1) + var neighborEdges = handler.app.graph.getNeighborEdges(newObject); + if (neighborEdges.length >= 1) { - var cruvled = handler.app.GetAvalibleCruvledValue(neighbourEdges, newObject); - newObject.model.SetCurvedValue(cruvled); + var curve = handler.app.GetAvailableCurveValue(neighborEdges, newObject); + newObject.model.SetCurveValue(curve); } } newSelected.push(newObject); @@ -956,7 +956,7 @@ AddGraphHandler.prototype.InitControls = function() var enumVertexsText = document.getElementById("enumVertexsText"); if (enumVertexsText) { - var enumsList = this.app.GetEnumVertexsList(); + var enumsList = this.app.GetEnumVerticesList(); for (var i = 0; i < enumsList.length; i ++) { var option = document.createElement('option'); @@ -980,7 +980,7 @@ AddGraphHandler.prototype.ChangedType = function() { var enumVertexsText = document.getElementById("enumVertexsText"); - this.app.SetEnumVertexsType(enumVertexsText.options[enumVertexsText.selectedIndex].value); + this.app.SetEnumVerticesType(enumVertexsText.options[enumVertexsText.selectedIndex].value); } @@ -1062,7 +1062,7 @@ ConnectionGraphHandler.prototype.SelectFirst = function() let hasDirectedEdges = this.app.graph.hasDirectEdge(); let hasUndirectedEdges = this.app.graph.hasUndirectEdge(); - this.message = g_selectFisrtVertexToConnect + this.GetSelect2VertexMenu(); + this.message = g_selectFirstVertexToConnect + this.GetSelect2VertexMenu(); if (!hasEdges) { return; @@ -1071,7 +1071,7 @@ ConnectionGraphHandler.prototype.SelectFirst = function() this.message = ".
" + " " + "