diff --git a/core/config/main.php b/core/config/main.php index cca74b5..c3a38ee 100755 --- a/core/config/main.php +++ b/core/config/main.php @@ -93,5 +93,5 @@ $g_config['vote'] = "./tmp/vote/vote.txt"; $g_config['voteTopics'] = "./tmp/vote/voteTopics.txt_"; $g_config['use_js_cache'] = true; - $g_config['engine_version'] = 83; + $g_config['engine_version'] = 84; ?> diff --git a/script/entities/graph/model/Graph.js b/script/entities/graph/model/Graph.js index 8890cd2..0542f2f 100644 --- a/script/entities/graph/model/Graph.js +++ b/script/entities/graph/model/Graph.js @@ -1184,24 +1184,24 @@ Graph.prototype.clampPositions = function (viewportSize) } // Use to setup scaling. -Graph.prototype.getGraphBBox = function (viewportSize) +// vertexStyle is not used now. +Graph.prototype.getGraphBBox = function (vertexStyle) { var pointMin = new Point(1e5, 1e5); var pointMax = new Point(-1e5, -1e5); var diameter = (new VertexModel()).diameter; - for(i = 0; i < this.vertices.length; i++) + for (i = 0; i < this.vertices.length; i++) { var vertex = this.vertices[i]; - var factor = vertex.diameterFactor(); - var deltaVector = new Point(factor.x * diameter, factor.y * diameter); - pointMin = pointMin.min(vertex.position.subtract(deltaVector)); - pointMax = pointMax.max(vertex.position.add(deltaVector)); + var bbox = vertex.getBBox(vertexStyle == undefined ? vertex.getStyleFor(0) : vertexStyle); + pointMin = pointMin.min(vertex.position.subtract(bbox)); + pointMax = pointMax.max(vertex.position.add(bbox)); } var max_curve_length = 32; - for(i = 0; i < this.edges.length; i++) + for (i = 0; i < this.edges.length; i++) { var edge = this.edges[i]; diff --git a/script/entities/vertex/model/BaseVertex.js b/script/entities/vertex/model/BaseVertex.js index 639ac30..1d1ae61 100644 --- a/script/entities/vertex/model/BaseVertex.js +++ b/script/entities/vertex/model/BaseVertex.js @@ -92,11 +92,6 @@ BaseVertex.prototype.SetId = function (id) this.mainText = this.vertexEnumType.GetVertexText(id); } -BaseVertex.prototype.diameterFactor = function () -{ - return new Point(1.0 + (this.mainText.length ? this.mainText.length / 8.0 : 0), 1.5); -} - BaseVertex.prototype.IsUndefinedPosition = function () { return this.hasUndefinedPosition; @@ -183,4 +178,24 @@ BaseVertex.prototype.getStyleFor = function (index) BaseVertex.prototype.hasOwnStyleFor = function (index) { return this.ownStyles.hasOwnProperty(index); +} + +BaseVertex.prototype.getDefaultDiameterFactor = function (textSize) +{ + var textFactor = defaultVertexDiameter * 8.0 / (2.0 * textSize); + return new Point(1.0 + (this.mainText.length ? this.mainText.length / textFactor : 0), 1.5); +} + +BaseVertex.prototype.getBBox = function (style) +{ + var textSize = DefaultMainTextFontSize; + if (style !== undefined) + { + textSize = style.mainTextFontSize; + } + var defaultDiameter = (new VertexModel()).diameter; + var vertexDiameter = this.model.diameter; + var factor = this.getDefaultDiameterFactor(textSize); + return new Point(Math.max(factor.x * defaultDiameter, vertexDiameter), + Math.max(factor.y * defaultDiameter, vertexDiameter)); } \ No newline at end of file diff --git a/script/pages/create_graph_by_edge_list/api/index.js.cache b/script/pages/create_graph_by_edge_list/api/index.js.cache index 15764da..ebd0ab8 100644 --- a/script/pages/create_graph_by_edge_list/api/index.js.cache +++ b/script/pages/create_graph_by_edge_list/api/index.js.cache @@ -1,4 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=79","/script/shared/point.js?v=79","/script/entities/edge/api/index.js?v=79","/script/entities/edge/model/BaseEdge.js?v=79","/script/entities/edge/model/EdgeModel.js?v=79","/script/entities/vertex/api/index.js?v=79","/script/entities/vertex/model/BaseVertex.js?v=79","/script/entities/vertex/model/VertexModel.js?v=79","/script/entities/graph/model/Graph.js?v=79",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} +moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=80","/script/shared/point.js?v=80","/script/entities/edge/api/index.js?v=80","/script/entities/edge/model/BaseEdge.js?v=80","/script/entities/edge/model/EdgeModel.js?v=80","/script/entities/vertex/api/index.js?v=80","/script/entities/vertex/model/BaseVertex.js?v=80","/script/entities/vertex/model/VertexModel.js?v=80","/script/entities/graph/model/Graph.js?v=80",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} {let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point) {return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point) {return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function() @@ -32,15 +32,22 @@ this.SetWeight(weight);this.ownStyles={};} BaseEdge.prototype.copyFrom=function(other) {this.vertex1=other.vertex1;this.vertex2=other.vertex2;this.arrayStyleStart=other.arrayStyleStart;this.arrayStyleFinish=other.arrayStyleFinish;this.isDirect=other.isDirect;this.weight=other.weight;this.text=other.text;this.useWeight=other.useWeight;this.id=other.id;this.model=new EdgeModel();this.model.copyFrom(other.model);this.upText=other.upText;this.ownStyles=FullObjectCopy(other.ownStyles);} BaseEdge.prototype.SaveToXML=function() -{return"0)?"ownStyles = \""+gEncodeToHTML(JSON.stringify(this.ownStyles))+"\" ":"")+ this.model.SaveToXML()+">";} -BaseEdge.prototype.LoadFromXML=function(xml,graph) +BaseEdge.prototype.LoadFromXML=function(xml,graph,defaultLoadEdges) {var attr=xml.attr('vertex1');if(typeof attr==='undefined') {attr=xml.attr('source');} this.vertex1=graph.FindVertex(typeof attr!=='undefined'?attr:xml.attr('graph1'));var attr=xml.attr('vertex2');if(typeof attr==='undefined') {attr=xml.attr('target');} -this.vertex2=graph.FindVertex(typeof attr!=='undefined'?attr:xml.attr('graph2'));this.isDirect=xml.attr('isDirect')=="true";this.weight=parseFloat(xml.attr('weight'));if(isNaN(this.weight)) +this.vertex2=graph.FindVertex(typeof attr!=='undefined'?attr:xml.attr('graph2'));var directedAttribute=xml.attr('directed');if(typeof directedAttribute!=='undefined') +{this.isDirect=directedAttribute=="true";} +else +{var isDirectedAttribute=xml.attr('isDirect');if(typeof isDirectedAttribute!=='undefined') +{this.isDirect=isDirectedAttribute=="true";} +else +{this.isDirect=defaultLoadEdges=="directed";}} +this.weight=parseFloat(xml.attr('weight'));if(isNaN(this.weight)) {this.weight=1;} this.hasPair=xml.attr('hasPair')=="true";this.useWeight=xml.attr('useWeight')=="true";this.id=xml.attr('id');this.text=xml.attr("text")==null?"":gDecodeFromHTML(xml.attr("text"));this.arrayStyleStart=xml.attr("arrayStyleStart")==null?"":xml.attr("arrayStyleStart");this.arrayStyleFinish=xml.attr("arrayStyleFinish")==null?"":xml.attr("arrayStyleFinish");this.upText=xml.attr('upText');if(typeof this.upText==='undefined') {this.upText="";} @@ -184,8 +191,6 @@ this.model.diameter=parseInt(size);} BaseVertex.prototype.SetId=function(id) {this.id=id;if(this.vertexEnumType!=null) this.mainText=this.vertexEnumType.GetVertexText(id);} -BaseVertex.prototype.diameterFactor=function() -{return new Point(1.0+(this.mainText.length?this.mainText.length/8.0:0),1.5);} BaseVertex.prototype.IsUndefinedPosition=function() {return this.hasUndefinedPosition;} BaseVertex.prototype.HitTest=function(pos) @@ -215,6 +220,12 @@ style=globalApplication.GetStyle("vertex","common");else style=globalApplication.GetStyle("vertex","selected",undefined,index-1);return style;}} BaseVertex.prototype.hasOwnStyleFor=function(index) {return this.ownStyles.hasOwnProperty(index);} +BaseVertex.prototype.getDefaultDiameterFactor=function(textSize) +{var textFactor=defaultVertexDiameter*8.0/(2.0*textSize);return new Point(1.0+(this.mainText.length?this.mainText.length/textFactor:0),1.5);} +BaseVertex.prototype.getBBox=function(style) +{var textSize=DefaultMainTextFontSize;if(style!==undefined) +{textSize=style.mainTextFontSize;} +var defaultDiameter=(new VertexModel()).diameter;var vertexDiameter=this.model.diameter;var factor=this.getDefaultDiameterFactor(textSize);return new Point(Math.max(factor.x*defaultDiameter,vertexDiameter),Math.max(factor.y*defaultDiameter,vertexDiameter));} const defaultVertexDiameter=30;function VertexModel() {this.diameter=globalApplication.GetDefaultVertexSize();} function Graph() @@ -505,10 +516,12 @@ xmlBody=xmlBody+"";additionalField="";if(additionalData.length>0) {additionalField=""} return mainHeader+header+xmlBody+""+additionalField+"";} Graph.prototype.LoadFromXML=function(xmlText,additionalData) -{xmlDoc=$.parseXML(xmlText);var $xml=$(xmlDoc);$graphs=$xml.find("graph");var loadedGraphId=0;var loadedEdgeId=0;$graphs.each(function(){loadedGraphId=parseInt($(this).attr('uidGraph'));loadedEdgeId=parseInt($(this).attr('uidEdge'));});if(isNaN(loadedEdgeId)) +{xmlDoc=$.parseXML(xmlText);var $xml=$(xmlDoc);$graphs=$xml.find("graph");var loadedGraphId=0;var loadedEdgeId=0;var defaultLoadEdges="";$graphs.each(function(){loadedGraphId=parseInt($(this).attr('uidGraph'));loadedEdgeId=parseInt($(this).attr('uidEdge'));defaultLoadEdges=$(this).attr('edgedefault');});if(isNaN(loadedEdgeId)) {loadedEdgeId=this.edgesOffset;}else if(loadedEdgeId0)?"ownStyles = \""+gEncodeToHTML(JSON.stringify(this.ownStyles))+"\" ":"")+ this.model.SaveToXML()+">";} -BaseEdge.prototype.LoadFromXML=function(xml,graph) +BaseEdge.prototype.LoadFromXML=function(xml,graph,defaultLoadEdges) {var attr=xml.attr('vertex1');if(typeof attr==='undefined') {attr=xml.attr('source');} this.vertex1=graph.FindVertex(typeof attr!=='undefined'?attr:xml.attr('graph1'));var attr=xml.attr('vertex2');if(typeof attr==='undefined') {attr=xml.attr('target');} -this.vertex2=graph.FindVertex(typeof attr!=='undefined'?attr:xml.attr('graph2'));this.isDirect=xml.attr('isDirect')=="true";this.weight=parseFloat(xml.attr('weight'));if(isNaN(this.weight)) +this.vertex2=graph.FindVertex(typeof attr!=='undefined'?attr:xml.attr('graph2'));var directedAttribute=xml.attr('directed');if(typeof directedAttribute!=='undefined') +{this.isDirect=directedAttribute=="true";} +else +{var isDirectedAttribute=xml.attr('isDirect');if(typeof isDirectedAttribute!=='undefined') +{this.isDirect=isDirectedAttribute=="true";} +else +{this.isDirect=defaultLoadEdges=="directed";}} +this.weight=parseFloat(xml.attr('weight'));if(isNaN(this.weight)) {this.weight=1;} this.hasPair=xml.attr('hasPair')=="true";this.useWeight=xml.attr('useWeight')=="true";this.id=xml.attr('id');this.text=xml.attr("text")==null?"":gDecodeFromHTML(xml.attr("text"));this.arrayStyleStart=xml.attr("arrayStyleStart")==null?"":xml.attr("arrayStyleStart");this.arrayStyleFinish=xml.attr("arrayStyleFinish")==null?"":xml.attr("arrayStyleFinish");this.upText=xml.attr('upText');if(typeof this.upText==='undefined') {this.upText="";} @@ -184,8 +191,6 @@ this.model.diameter=parseInt(size);} BaseVertex.prototype.SetId=function(id) {this.id=id;if(this.vertexEnumType!=null) this.mainText=this.vertexEnumType.GetVertexText(id);} -BaseVertex.prototype.diameterFactor=function() -{return new Point(1.0+(this.mainText.length?this.mainText.length/8.0:0),1.5);} BaseVertex.prototype.IsUndefinedPosition=function() {return this.hasUndefinedPosition;} BaseVertex.prototype.HitTest=function(pos) @@ -215,6 +220,12 @@ style=globalApplication.GetStyle("vertex","common");else style=globalApplication.GetStyle("vertex","selected",undefined,index-1);return style;}} BaseVertex.prototype.hasOwnStyleFor=function(index) {return this.ownStyles.hasOwnProperty(index);} +BaseVertex.prototype.getDefaultDiameterFactor=function(textSize) +{var textFactor=defaultVertexDiameter*8.0/(2.0*textSize);return new Point(1.0+(this.mainText.length?this.mainText.length/textFactor:0),1.5);} +BaseVertex.prototype.getBBox=function(style) +{var textSize=DefaultMainTextFontSize;if(style!==undefined) +{textSize=style.mainTextFontSize;} +var defaultDiameter=(new VertexModel()).diameter;var vertexDiameter=this.model.diameter;var factor=this.getDefaultDiameterFactor(textSize);return new Point(Math.max(factor.x*defaultDiameter,vertexDiameter),Math.max(factor.y*defaultDiameter,vertexDiameter));} const defaultVertexDiameter=30;function VertexModel() {this.diameter=globalApplication.GetDefaultVertexSize();} function Graph() @@ -505,10 +516,12 @@ xmlBody=xmlBody+"";additionalField="";if(additionalData.length>0) {additionalField=""} return mainHeader+header+xmlBody+""+additionalField+"";} Graph.prototype.LoadFromXML=function(xmlText,additionalData) -{xmlDoc=$.parseXML(xmlText);var $xml=$(xmlDoc);$graphs=$xml.find("graph");var loadedGraphId=0;var loadedEdgeId=0;$graphs.each(function(){loadedGraphId=parseInt($(this).attr('uidGraph'));loadedEdgeId=parseInt($(this).attr('uidEdge'));});if(isNaN(loadedEdgeId)) +{xmlDoc=$.parseXML(xmlText);var $xml=$(xmlDoc);$graphs=$xml.find("graph");var loadedGraphId=0;var loadedEdgeId=0;var defaultLoadEdges="";$graphs.each(function(){loadedGraphId=parseInt($(this).attr('uidGraph'));loadedEdgeId=parseInt($(this).attr('uidEdge'));defaultLoadEdges=$(this).attr('edgedefault');});if(isNaN(loadedEdgeId)) {loadedEdgeId=this.edgesOffset;}else if(loadedEdgeId0)?"ownStyles = \""+gEncodeToHTML(JSON.stringify(this.ownStyles))+"\" ":"")+ this.model.SaveToXML()+">";} -BaseEdge.prototype.LoadFromXML=function(xml,graph) +BaseEdge.prototype.LoadFromXML=function(xml,graph,defaultLoadEdges) {var attr=xml.attr('vertex1');if(typeof attr==='undefined') {attr=xml.attr('source');} this.vertex1=graph.FindVertex(typeof attr!=='undefined'?attr:xml.attr('graph1'));var attr=xml.attr('vertex2');if(typeof attr==='undefined') {attr=xml.attr('target');} -this.vertex2=graph.FindVertex(typeof attr!=='undefined'?attr:xml.attr('graph2'));this.isDirect=xml.attr('isDirect')=="true";this.weight=parseFloat(xml.attr('weight'));if(isNaN(this.weight)) +this.vertex2=graph.FindVertex(typeof attr!=='undefined'?attr:xml.attr('graph2'));var directedAttribute=xml.attr('directed');if(typeof directedAttribute!=='undefined') +{this.isDirect=directedAttribute=="true";} +else +{var isDirectedAttribute=xml.attr('isDirect');if(typeof isDirectedAttribute!=='undefined') +{this.isDirect=isDirectedAttribute=="true";} +else +{this.isDirect=defaultLoadEdges=="directed";}} +this.weight=parseFloat(xml.attr('weight'));if(isNaN(this.weight)) {this.weight=1;} this.hasPair=xml.attr('hasPair')=="true";this.useWeight=xml.attr('useWeight')=="true";this.id=xml.attr('id');this.text=xml.attr("text")==null?"":gDecodeFromHTML(xml.attr("text"));this.arrayStyleStart=xml.attr("arrayStyleStart")==null?"":xml.attr("arrayStyleStart");this.arrayStyleFinish=xml.attr("arrayStyleFinish")==null?"":xml.attr("arrayStyleFinish");this.upText=xml.attr('upText');if(typeof this.upText==='undefined') {this.upText="";} @@ -184,8 +191,6 @@ this.model.diameter=parseInt(size);} BaseVertex.prototype.SetId=function(id) {this.id=id;if(this.vertexEnumType!=null) this.mainText=this.vertexEnumType.GetVertexText(id);} -BaseVertex.prototype.diameterFactor=function() -{return new Point(1.0+(this.mainText.length?this.mainText.length/8.0:0),1.5);} BaseVertex.prototype.IsUndefinedPosition=function() {return this.hasUndefinedPosition;} BaseVertex.prototype.HitTest=function(pos) @@ -215,6 +220,12 @@ style=globalApplication.GetStyle("vertex","common");else style=globalApplication.GetStyle("vertex","selected",undefined,index-1);return style;}} BaseVertex.prototype.hasOwnStyleFor=function(index) {return this.ownStyles.hasOwnProperty(index);} +BaseVertex.prototype.getDefaultDiameterFactor=function(textSize) +{var textFactor=defaultVertexDiameter*8.0/(2.0*textSize);return new Point(1.0+(this.mainText.length?this.mainText.length/textFactor:0),1.5);} +BaseVertex.prototype.getBBox=function(style) +{var textSize=DefaultMainTextFontSize;if(style!==undefined) +{textSize=style.mainTextFontSize;} +var defaultDiameter=(new VertexModel()).diameter;var vertexDiameter=this.model.diameter;var factor=this.getDefaultDiameterFactor(textSize);return new Point(Math.max(factor.x*defaultDiameter,vertexDiameter),Math.max(factor.y*defaultDiameter,vertexDiameter));} const defaultVertexDiameter=30;function VertexModel() {this.diameter=globalApplication.GetDefaultVertexSize();} function Graph() @@ -505,10 +516,12 @@ xmlBody=xmlBody+"";additionalField="";if(additionalData.length>0) {additionalField=""} return mainHeader+header+xmlBody+""+additionalField+"";} Graph.prototype.LoadFromXML=function(xmlText,additionalData) -{xmlDoc=$.parseXML(xmlText);var $xml=$(xmlDoc);$graphs=$xml.find("graph");var loadedGraphId=0;var loadedEdgeId=0;$graphs.each(function(){loadedGraphId=parseInt($(this).attr('uidGraph'));loadedEdgeId=parseInt($(this).attr('uidEdge'));});if(isNaN(loadedEdgeId)) +{xmlDoc=$.parseXML(xmlText);var $xml=$(xmlDoc);$graphs=$xml.find("graph");var loadedGraphId=0;var loadedEdgeId=0;var defaultLoadEdges="";$graphs.each(function(){loadedGraphId=parseInt($(this).attr('uidGraph'));loadedEdgeId=parseInt($(this).attr('uidEdge'));defaultLoadEdges=$(this).attr('edgedefault');});if(isNaN(loadedEdgeId)) {loadedEdgeId=this.edgesOffset;}else if(loadedEdgeId