diff --git a/lang/de/home.php b/lang/de/home.php index 96b686c..49cce22 100644 --- a/lang/de/home.php +++ b/lang/de/home.php @@ -185,4 +185,11 @@ $g_lang['selected_edge_style'] = "Selected edge style"; $g_lang['common_vertex_style'] = "Common vertex style"; $g_lang['selected_vertex_style'] = "Selected vertex style"; + + $g_lang['shape'] = "Shape"; + $g_lang['circle'] = "Circle"; + $g_lang['squere'] = "Square"; + $g_lang['triangle'] = "Triangle"; + $g_lang['pentagon'] = "Pentagon"; + $g_lang['vertex_diameter'] = "Vertex size"; ?> diff --git a/lang/el/home.php b/lang/el/home.php index 948bdda..3b2d7c6 100644 --- a/lang/el/home.php +++ b/lang/el/home.php @@ -223,4 +223,11 @@ $g_lang['selected_edge_style'] = "Selected edge style"; $g_lang['common_vertex_style'] = "Common vertex style"; $g_lang['selected_vertex_style'] = "Selected vertex style"; + + $g_lang['shape'] = "Shape"; + $g_lang['circle'] = "Circle"; + $g_lang['squere'] = "Square"; + $g_lang['triangle'] = "Triangle"; + $g_lang['pentagon'] = "Pentagon"; + $g_lang['vertex_diameter'] = "Vertex size"; ?> diff --git a/lang/en/home.php b/lang/en/home.php index 8f3ec4f..6da7366 100755 --- a/lang/en/home.php +++ b/lang/en/home.php @@ -222,4 +222,11 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang['selected_edge_style'] = "Selected edge style"; $g_lang['common_vertex_style'] = "Common vertex style"; $g_lang['selected_vertex_style'] = "Selected vertex style"; + + $g_lang['shape'] = "Shape"; + $g_lang['circle'] = "Circle"; + $g_lang['squere'] = "Square"; + $g_lang['triangle'] = "Triangle"; + $g_lang['pentagon'] = "Pentagon"; + $g_lang['vertex_diameter'] = "Vertex size"; ?> diff --git a/lang/es/home.php b/lang/es/home.php index dde0d1c..077edf6 100755 --- a/lang/es/home.php +++ b/lang/es/home.php @@ -222,4 +222,11 @@ Tenemos traducciones en griego 🇬🇷. diff --git a/lang/fr/home.php b/lang/fr/home.php index c7c3d61..0753c50 100644 --- a/lang/fr/home.php +++ b/lang/fr/home.php @@ -189,5 +189,12 @@ $g_lang['common_edge_style'] = "Common edge style"; $g_lang['selected_edge_style'] = "Selected edge style"; $g_lang['common_vertex_style'] = "Common vertex style"; - $g_lang['selected_vertex_style'] = "Selected vertex style"; + $g_lang['selected_vertex_style'] = "Selected vertex style"; + + $g_lang['shape'] = "Shape"; + $g_lang['circle'] = "Circle"; + $g_lang['squere'] = "Square"; + $g_lang['triangle'] = "Triangle"; + $g_lang['pentagon'] = "Pentagon"; + $g_lang['vertex_diameter'] = "Vertex size"; ?> \ No newline at end of file diff --git a/lang/nl/home.php b/lang/nl/home.php index b74e1b7..697196c 100644 --- a/lang/nl/home.php +++ b/lang/nl/home.php @@ -186,5 +186,12 @@ $g_lang['common_edge_style'] = "Common edge style"; $g_lang['selected_edge_style'] = "Selected edge style"; $g_lang['common_vertex_style'] = "Common vertex style"; - $g_lang['selected_vertex_style'] = "Selected vertex style"; + $g_lang['selected_vertex_style'] = "Selected vertex style"; + + $g_lang['shape'] = "Shape"; + $g_lang['circle'] = "Circle"; + $g_lang['squere'] = "Square"; + $g_lang['triangle'] = "Triangle"; + $g_lang['pentagon'] = "Pentagon"; + $g_lang['vertex_diameter'] = "Vertex size"; ?> diff --git a/lang/pt/home.php b/lang/pt/home.php index a69c365..534fa48 100644 --- a/lang/pt/home.php +++ b/lang/pt/home.php @@ -188,4 +188,11 @@ $g_lang['selected_edge_style'] = "Selected edge style"; $g_lang['common_vertex_style'] = "Common vertex style"; $g_lang['selected_vertex_style'] = "Selected vertex style"; + + $g_lang['shape'] = "Shape"; + $g_lang['circle'] = "Circle"; + $g_lang['squere'] = "Square"; + $g_lang['triangle'] = "Triangle"; + $g_lang['pentagon'] = "Pentagon"; + $g_lang['vertex_diameter'] = "Vertex size"; ?> diff --git a/lang/ru/home.php b/lang/ru/home.php index 5e28559..7060bd7 100755 --- a/lang/ru/home.php +++ b/lang/ru/home.php @@ -223,4 +223,11 @@ $g_lang['selected_edge_style'] = "Стиль выделенной дуги"; $g_lang['common_vertex_style'] = "Стиль обычной вершины"; $g_lang['selected_vertex_style'] = "Стиль выделенной вершины"; + + $g_lang['shape'] = "Форма"; + $g_lang['circle'] = "Круг"; + $g_lang['squere'] = "Квадрат"; + $g_lang['triangle'] = "Треугльник"; + $g_lang['pentagon'] = "Пятиугольник"; + $g_lang['vertex_diameter'] = "Размер вершины"; ?> diff --git a/lang/sv/home.php b/lang/sv/home.php index f48e043..3e7fba5 100644 --- a/lang/sv/home.php +++ b/lang/sv/home.php @@ -18,7 +18,7 @@ $g_lang["orint_edge"] = "Riktad"; $g_lang["not_orint_edge"] = "Oriktad"; $g_lang["show_adjacency_matrix"] = "Grannmatris"; - $g_lang["save"] = "Spara kanttyp (riktad eller inte)"; + $g_lang["save"] = "Spara"; $g_lang["cancel"] = "Annullera"; $g_lang["adjacency_matrix_description"] = "Ställ in grannmatris. Använd komma \",\" som separator"; $g_lang["adjacency_matrix_bad_format"] = "Matrisen är felaktig. Använd komma \",\" som separator. Matrisen ska vara kvadratisk"; @@ -184,4 +184,11 @@ $g_lang['selected_edge_style'] = "Selected edge style"; $g_lang['common_vertex_style'] = "Common vertex style"; $g_lang['selected_vertex_style'] = "Selected vertex style"; + + $g_lang['shape'] = "Shape"; + $g_lang['circle'] = "Circle"; + $g_lang['squere'] = "Square"; + $g_lang['triangle'] = "Triangle"; + $g_lang['pentagon'] = "Pentagon"; + $g_lang['vertex_diameter'] = "Vertex size"; ?> diff --git a/script/Appilcation.js b/script/Appilcation.js index 4b9c18c..cd959b7 100644 --- a/script/Appilcation.js +++ b/script/Appilcation.js @@ -50,6 +50,8 @@ function Application(document, window) this.edgePresets = [1, 3, 5, 7, 11, 42]; this.maxEdgePresets = 6; this.selectionRect = null; + + this.defaultVertexSize = null; }; // List of graph. @@ -400,6 +402,7 @@ Application.prototype.RedrawNodes = function(context) Application.prototype.UpdateNodesCurrentStyle = function(ForceCommonStyle, ForceSelectedStyle) { + var force = ForceCommonStyle !== undefined || ForceSelectedStyle !== undefined; var commonStyle = (ForceCommonStyle === undefined) ? this.vertexCommonStyle : ForceCommonStyle; var selectedStyle = (ForceSelectedStyle === undefined) ? this.vertexSelectedVertexStyles : ForceSelectedStyle; @@ -414,7 +417,7 @@ Application.prototype.UpdateNodesCurrentStyle = function(ForceCommonStyle, Force } var currentStyle = null; - if (this.graph.vertices[i].hasOwnStyleFor((selected ? 1 : 0) + selectedGroup)) + if (this.graph.vertices[i].hasOwnStyleFor((selected ? 1 : 0) + selectedGroup) && !force) currentStyle = this.graph.vertices[i].getStyleFor((selected ? 1 : 0) + selectedGroup); else currentStyle = selected ? selectedStyle[selectedGroup] : commonStyle; @@ -1401,6 +1404,10 @@ Application.prototype.SaveUserSettings = function() checkValue.push({field: "backgroundCommonStyle", value: this.backgroundCommonStyle, check: this.isBackgroundCommonStyleCustom}); + + checkValue.push({field: "defaultVertexSize", + value: this.defaultVertexSize, + check: this.defaultVertexSize != null}); //checkValue.push({field: "vertexPrintCommonStyle", // value: this.vertexPrintCommonStyle}); @@ -1453,6 +1460,11 @@ Application.prototype.LoadUserSettings = function(json) value: this.vertexSelectedVertexStyles, check: "isVertexSelectedVertexStylesCustom", deep: true}); + + checkValue.push({field: "defaultVertexSize", + value: "defaultVertexSize", + check: null, + deep: false}); //checkValue.push({field: "vertexPrintCommonStyle", // value: this.vertexPrintCommonStyle}); @@ -1462,7 +1474,7 @@ Application.prototype.LoadUserSettings = function(json) checkValue.push({field: "backgroundCommonStyle", value: this.backgroundCommonStyle, - check: "isBackgroundCommonStyleCustom", + check: this.isBackgroundCommonStyleCustom, deep: false}); var decoderStr = this.DecodeFromHTML(json); @@ -1473,24 +1485,32 @@ Application.prototype.LoadUserSettings = function(json) checkValue.forEach(function(entry) { if (parsedSave.hasOwnProperty(entry.field)) { - for(var k in parsedSave[entry.field]) + if (typeof parsedSave[entry.field] === 'number') { - if (!entry.deep) + app[entry.value] = parseInt(parsedSave[entry.field]); + } + else + { + for(var k in parsedSave[entry.field]) { - if (entry.value.ShouldLoad(k)) - entry.value[k] = parsedSave[entry.field][k]; - } - else - { - for(var deepK in parsedSave[entry.field][k]) + if (!entry.deep) { - if (entry.value[k].ShouldLoad(deepK)) - entry.value[k][deepK] = parsedSave[entry.field][k][deepK]; + if (entry.value.ShouldLoad(k)) + entry.value[k] = parsedSave[entry.field][k]; + } + else + { + for(var deepK in parsedSave[entry.field][k]) + { + if (entry.value[k].ShouldLoad(deepK)) + entry.value[k][deepK] = parsedSave[entry.field][k][deepK]; + } } } } - app[entry.check] = true; + if (entry.check != null) + app[entry.check] = true; } }); } @@ -1717,3 +1737,35 @@ Application.prototype.GetSelectedEdges = function() return res; } + +Application.prototype.SetDefaultVertexSize = function(diameter) +{ + var oldDefaultDiameter = this.GetDefaultVertexSize(); + this.defaultVertexSize = diameter; + + for (i = 0; i < this.graph.vertices.length; i ++) + { + if (this.graph.vertices[i].model.diameter == oldDefaultDiameter) + { + this.graph.vertices[i].model.diameter = diameter; + } + } +} + +Application.prototype.GetDefaultVertexSize = function(diameter) +{ + if (this.defaultVertexSize != null) + return this.defaultVertexSize; + else + return defaultVertexDiameter; +} + +Application.prototype.ResetVertexSize = function() +{ + this.defaultVertexSize = null; + + for (i = 0; i < this.graph.vertices.length; i ++) + { + this.graph.vertices[i].model.diameter = this.GetDefaultVertexSize(); + } +} diff --git a/script/BaseVertex.js b/script/BaseVertex.js index 1198f3c..a1460c5 100755 --- a/script/BaseVertex.js +++ b/script/BaseVertex.js @@ -38,7 +38,8 @@ BaseVertex.prototype.SaveToXML = function () "id=\"" + this.id + "\" " + "mainText=\"" + gEncodeToHTML(this.mainText) + "\" " + "upText=\"" + gEncodeToHTML(this.upText) + "\" " + - ((Object.keys(this.ownStyles).length > 0) ? "ownStyles = \"" + gEncodeToHTML(JSON.stringify(this.ownStyles)) + "\"": "") + + ((Object.keys(this.ownStyles).length > 0) ? "ownStyles = \"" + gEncodeToHTML(JSON.stringify(this.ownStyles)) + "\" ": "") + + "size=\"" + this.model.diameter + "\" " + ">"; } @@ -78,6 +79,10 @@ BaseVertex.prototype.LoadFromXML = function (xml) } } } + + var size = xml.attr('size'); + if (typeof size !== 'undefined') + this.model.diameter = parseInt(size); } BaseVertex.prototype.SetId = function (id) diff --git a/script/EventHandlers.js b/script/EventHandlers.js index 820efcc..5cc9e46 100644 --- a/script/EventHandlers.js +++ b/script/EventHandlers.js @@ -1408,7 +1408,8 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes) $( "#vertexStrokeColor" ).val(fullStyle.strokeStyle); $( "#vertexTextColor" ).val(fullStyle.mainTextColor); $( "#vertexStrokeSize" ).val(fullStyle.lineWidth); - $( "#vertexShape" ).val(fullStyle.shape); + $( "#vertexShape" ).val(fullStyle.shape); + $( "#vertexSize" ).val(forAll ? (new VertexModel()).diameter : selectedVertexes[0].model.diameter); } var redrawVertex = function() @@ -1429,6 +1430,8 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes) if (fullStyle.shape != $( "#vertexShape" ).val()) style.shape = parseInt($( "#vertexShape" ).val()); + + var diameter = parseInt($( "#vertexSize" ).val()); var canvas = document.getElementById( "VertexPreview" ); var context = canvas.getContext('2d'); @@ -1442,6 +1445,8 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes) var baseVertex = new BaseVertex(canvas.width / 2, canvas.height / 2, new BaseEnumVertices(this)); baseVertex.mainText = "1"; baseVertex.upText = "Up Text"; + baseVertex.model.diameter = diameter; + if (!forAll) baseVertex.ownStyles = selectedVertexes[0].ownStyles; @@ -1451,12 +1456,28 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes) } //var dialogButtons = []; + var applyDiameter = function(diameter) + { + if (forAll) + { + app.SetDefaultVertexSize(diameter); + } + else + { + selectedVertexes.forEach(function(vertex) { + vertex.model.diameter = diameter; + }); + } + }; dialogButtons[g_default] = { text : g_default, class : "MarginLeft", click : function() { + + applyDiameter(forAll ? (new VertexModel()).diameter : app.GetDefaultVertexSize()); + if (forAll) { app.ResetVertexStyle(index); @@ -1473,15 +1494,21 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes) }; dialogButtons[g_save] = function() { + + applyDiameter(parseInt($( "#vertexSize" ).val())); + if (forAll) { app.SetVertexStyle(index, style); } else { - selectedVertexes.forEach(function(vertex) { - vertex.setOwnStyle(index, style); - }); + if (JSON.stringify(originStyle) !== JSON.stringify(style)) + { + selectedVertexes.forEach(function(vertex) { + vertex.setOwnStyle(index, style); + }); + } } app.redrawGraph(); $( this ).dialog( "close" ); @@ -1508,12 +1535,15 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes) $( "#vertexStrokeColor" ).unbind(); $( "#vertexTextColor" ).unbind(); $( "#vertexStrokeSize" ).unbind(); + $( "#vertexShape" ).unbind(); + $( "#vertexSize" ).unbind(); $( "#vertexFillColor" ).change(redrawVertex); $( "#vertexStrokeColor" ).change(redrawVertex); $( "#vertexTextColor" ).change(redrawVertex); $( "#vertexStrokeSize" ).change(redrawVertex); - $( "#vertexShape" ).change(redrawVertex); + $( "#vertexShape" ).change(redrawVertex); + $( "#vertexSize" ).change(redrawVertex); } /** diff --git a/script/VertexModel.js b/script/VertexModel.js index 231c017..68849fd 100755 --- a/script/VertexModel.js +++ b/script/VertexModel.js @@ -3,8 +3,9 @@ * */ + const defaultVertexDiameter = 30; function VertexModel() { - this.diameter = 30; + this.diameter = globalApplication.GetDefaultVertexSize(); } diff --git a/tpl/home.php b/tpl/home.php index b041ca4..23d3a14 100755 --- a/tpl/home.php +++ b/tpl/home.php @@ -411,7 +411,7 @@
- +
@@ -421,16 +421,22 @@
- +
-
+ +
+ +
+ +
+