From 4e746833aecbf7e8f1d36ca0e91acd6aab208dc1 Mon Sep 17 00:00:00 2001 From: Pablo Luna Date: Sat, 16 Apr 2011 14:18:33 +0100 Subject: [PATCH] fixing freemind layout with import --- core-js/src/main/javascript/Executor.js | 2 +- .../src/main/javascript/ConnectionLine.js | 4 +- .../src/main/javascript/RelationshipLine.js | 2 +- .../src/main/javascript/ShrinkConnector.js | 11 ++-- mindplot/src/main/javascript/Topic.js | 30 ++++------ .../commands/AddRelationshipCommand.js | 4 ++ .../layoutManagers/FreeMindLayoutManager.js | 7 +++ .../javascript/layoutManagers/boards/Board.js | 3 + .../boards/freeMindBoards/Board.js | 16 ----- .../javascript/peer/svg/CurvedLinePeer.js | 6 +- .../importer/ImporterException.java | 3 +- .../importer/freemind/FreemindImporter.java | 54 ++++++++--------- wise-webapp/src/test/data/freemind/basic.mmr | 2 +- wise-webapp/src/test/data/freemind/basic.wxml | 2 +- wise-webapp/src/test/data/freemind/fonts.mmr | 2 +- wise-webapp/src/test/data/freemind/fonts.wxml | 2 +- wise-webapp/src/test/data/freemind/i18n.mmr | 2 +- wise-webapp/src/test/data/freemind/i18n.wxml | 2 +- wise-webapp/src/test/data/freemind/icons.mmr | 2 +- wise-webapp/src/test/data/freemind/icons.wxml | 2 +- wise-webapp/src/test/data/freemind/links.mmr | 2 +- wise-webapp/src/test/data/freemind/links.wxml | 2 +- .../src/test/data/freemind/longnodes.mmr | 2 +- .../src/test/data/freemind/longnodes.wxml | 2 +- .../src/test/data/freemind/node-styles.mmr | 2 +- .../src/test/data/freemind/node-styles.wxml | 2 +- .../src/test/data/freemind/relationships.mm | 60 +++++++++++++++++++ .../src/test/data/freemind/relationships.mmr | 3 + .../src/test/data/freemind/relationships.wxml | 1 + 29 files changed, 145 insertions(+), 89 deletions(-) create mode 100644 wise-webapp/src/test/data/freemind/relationships.mm create mode 100644 wise-webapp/src/test/data/freemind/relationships.mmr create mode 100644 wise-webapp/src/test/data/freemind/relationships.wxml diff --git a/core-js/src/main/javascript/Executor.js b/core-js/src/main/javascript/Executor.js index 569777c2..436aac04 100644 --- a/core-js/src/main/javascript/Executor.js +++ b/core-js/src/main/javascript/Executor.js @@ -33,7 +33,7 @@ core.Executor = new Class({ if(!isLoading){ this._pendingFunctions.forEach(function(item){ var result = item.fn.attempt(item.args, item.bind); - core.assert(result, "execution failed"); + core.assert(result!=false, "execution failed"); }); this._pendingFunctions=[]; } diff --git a/mindplot/src/main/javascript/ConnectionLine.js b/mindplot/src/main/javascript/ConnectionLine.js index 9af953b2..aa67df2f 100644 --- a/mindplot/src/main/javascript/ConnectionLine.js +++ b/mindplot/src/main/javascript/ConnectionLine.js @@ -29,7 +29,7 @@ mindplot.ConnectionLine = function(sourceNode, targetNode, lineType) var line; if (targetNode.getType() == mindplot.NodeModel.CENTRAL_TOPIC_TYPE) { - line = this._createLine(lineType,mindplot.ConnectionLine.SIMPLE_CURVED); + line = this._createLine(lineType,mindplot.ConnectionLine.CURVED); // line = new web2d.Line(); if(line.getType()=="CurvedLine"){ var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode); @@ -86,7 +86,7 @@ mindplot.ConnectionLine.prototype._createLine = function(lineType, defaultStyle) mindplot.ConnectionLine.getStrokeColor = function() { - return '#495879'; + return '#c8e794'; }; mindplot.ConnectionLine.prototype.setVisibility = function(value) diff --git a/mindplot/src/main/javascript/RelationshipLine.js b/mindplot/src/main/javascript/RelationshipLine.js index 8e40987c..20d2ac09 100644 --- a/mindplot/src/main/javascript/RelationshipLine.js +++ b/mindplot/src/main/javascript/RelationshipLine.js @@ -84,7 +84,7 @@ mindplot.RelationshipLine.prototype.redraw = function() line2d.setFrom(sPos.x, sPos.y); line2d.setTo(tPos.x, tPos.y); - line2d.moveToBack(); + line2d.moveToFront(); //Positionate Arrows this._positionateArrows(); diff --git a/mindplot/src/main/javascript/ShrinkConnector.js b/mindplot/src/main/javascript/ShrinkConnector.js index 0c15ec66..c168fb9f 100644 --- a/mindplot/src/main/javascript/ShrinkConnector.js +++ b/mindplot/src/main/javascript/ShrinkConnector.js @@ -41,20 +41,23 @@ mindplot.ShirinkConnector = function(topic) var command = new mindplot.commands.GenericFunctionCommand(commandFunc, isShrink, [topicId]); actionRunner.execute(command); - new Event(event).stop(); + var event = new Event(event).stop(); + event.preventDefault(); }); - elipse.addEventListener('click', function(event) + elipse.addEventListener('mousedown', function(event) { // Avoid node creation ... - new Event(event).stop(); + var event = new Event(event).stop(); + event.preventDefault(); }); elipse.addEventListener('dblclick', function(event) { // Avoid node creation ... - new Event(event).stop(); + event = new Event(event).stop(); + event.preventDefault(); }); diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index b26782c1..d6cac74a 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -178,7 +178,7 @@ mindplot.Topic.prototype.buildShape = function(attributes, type) } else if (type == mindplot.NodeModel.SHAPE_TYPE_LINE) { - result = new web2d.Line({strokeWidth:1, strokeOpacity:1}); + result = new web2d.Line({strokeColor:"#c8e794",strokeWidth:1, strokeOpacity:1}); result.setSize = function(width, height) { this.size = {width:width, height:height}; @@ -992,31 +992,32 @@ mindplot.Topic.prototype.moveToBack = function(){ // this._helpers.forEach(function(helper, index){ // helper.moveToBack(); // }); - this.get2DElement().moveToBack(); - var outgoingLine = this.getOutgoingLine(); - + // Update relationship lines + for(var j=0; jn2.getOrder(); + else + return true; + }); delete node.getModel()._finalPosition; result = children; } diff --git a/mindplot/src/main/javascript/layoutManagers/boards/Board.js b/mindplot/src/main/javascript/layoutManagers/boards/Board.js index 41611382..2e9a350e 100644 --- a/mindplot/src/main/javascript/layoutManagers/boards/Board.js +++ b/mindplot/src/main/javascript/layoutManagers/boards/Board.js @@ -24,6 +24,9 @@ mindplot.layoutManagers.boards.Board = new Class({ }, setNodeMarginTop:function(node, delta){ core.assert(false, "no Board implementation found!"); + }, + getNode:function(){ + return this._node; } }); diff --git a/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Board.js b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Board.js index 85745360..626723f0 100644 --- a/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Board.js +++ b/mindplot/src/main/javascript/layoutManagers/boards/freeMindBoards/Board.js @@ -69,22 +69,6 @@ mindplot.layoutManagers.boards.freeMindBoards.Board = mindplot.layoutManagers.bo var nextEntry = result.table[1]; nextEntry.setMarginTop((nextEntry.getPosition() - nextEntry.getTotalMarginTop())-pos.y); } - var parent = node.getParent(); - if(!this._layoutManager._isCentralTopic(parent) && parent.getParent()!=null && (result.index == 0 || result.index==result.table.length-1)){ - var board = this._layoutManager.getTopicBoardForTopic(parent.getParent()); - var res2 = board.findNodeEntryIndex(parent); - var parentEntry = res2.table[res2.index]; - var totalMarginTop = parentEntry.getTotalMarginTop(); - var totalMarginBottom = parentEntry.getTotalMarginBottom(); - var parentPosition = parentEntry.getPosition(); - if(result.index==0 && pos.y < parentPosition){ - var childrenMarginTop = parentEntry.getPosition()-(pos.y-entry.getTotalMarginTop()); - parentEntry.setMarginTop(totalMarginTop-childrenMarginTop); - }else if(result.index==result.table.length-1 && pos.y>parentPosition){ - var childrenMarginBottom = (pos.y+entry.getTotalMarginBottom())-parentEntry.getPosition(); - parentEntry.setMarginBottom(totalMarginBottom - childrenMarginBottom); - } - } } this._updateTable(result.index, result.table,modifiedTopics, false); this._layoutManager._updateParentBoard(node, modifiedTopics); diff --git a/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js b/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js index a2c793c7..08af0470 100644 --- a/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js +++ b/web2d/src/main/javascript/peer/svg/CurvedLinePeer.js @@ -20,7 +20,7 @@ web2d.peer.svg.CurvedLinePeer = function() { var svgElement = window.document.createElementNS(this.svgNamespace, 'path'); web2d.peer.svg.ElementPeer.call(this, svgElement); - this._style={fill:'gray'}; + this._style={fill:'#c8e794'}; this._updateStyle(); this._customControlPoint_1 = false; this._customControlPoint_2 = false; @@ -159,8 +159,8 @@ web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPoint +this._x2+","+this._y2+ (this._lineStyle?" " +(this._control2.x+this._x2)+","+(this._control2.y+this._y2+3)+" " - +(this._control1.x+this._x1)+","+(this._control1.y+this._y1+3)+" " - +this._x1+","+(this._y1+3)+" Z" + +(this._control1.x+this._x1)+","+(this._control1.y+this._y1+5)+" " + +this._x1+","+(this._y1+7)+" Z" :"" ); this._native.setAttribute("d",path); diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/ImporterException.java b/wise-webapp/src/main/java/com/wisemapping/importer/ImporterException.java index 02d800e1..4b90a41c 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/ImporterException.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/ImporterException.java @@ -18,7 +18,8 @@ package com.wisemapping.importer; -import com.sun.istack.internal.NotNull; +import org.jetbrains.annotations.NotNull; + public class ImporterException extends Exception diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java index 9aabf96f..ab21d80c 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java @@ -121,6 +121,7 @@ public class FreemindImporter final TopicType wiseTopic = mindmapObjectFactory.createTopicType(); wiseTopic.setId(String.valueOf(currentId++)); wiseTopic.setCentral(true); + wiseTopic.setPosition("0,0"); convertNodeProperties(freeNode, wiseTopic); @@ -190,12 +191,12 @@ public class FreemindImporter } //Fix coord - if (srcTopic.getOrder() % 2 != 0) { //Odd order. + if (srcTopic.getOrder()!=null && srcTopic.getOrder() % 2 != 0) { //Odd order. String[] srcCtrlPoint = relationship.getSrcCtrlPoint().split(","); int y = Integer.valueOf(srcCtrlPoint[1]) * -1; relationship.setSrcCtrlPoint(srcCtrlPoint[0] + "," + y); } - if (destTopicType.getOrder() % 2 != 0) { //Odd order. + if (destTopicType.getOrder()!=null && destTopicType.getOrder() % 2 != 0) { //Odd order. String[] destCtrlPoint = relationship.getDestCtrlPoint().split(","); int y = Integer.valueOf(destCtrlPoint[1]) * -1; relationship.setDestCtrlPoint(destCtrlPoint[0] + "," + y); @@ -373,35 +374,28 @@ public class FreemindImporter // Which side must be the node be positioned ? String result = freeChild.getWcoords(); if (result == null) { - - final int xaxis; - int y; - if (depth == 1) { - - final String side = freeChild.getPOSITION(); - assert side != null : "This should not happen"; - xaxis = POSITION_LEFT.equals(side) ? -1 : 1; - - // 3 = -100 1 - // 1 = -50 2 - // 0 = 0 3 - // 2 = 50 4 - // 4 = 100 5 - if (order % 2 == 0) { - y = HALF_ROOT_TOPICS_SEPARATION * order; - } else { - y = -HALF_ROOT_TOPICS_SEPARATION * (order + 1); - } - - } else { - final String position = wiseParent.getPosition(); - xaxis = isOnLeftSide(position) ? -1 : 1; - y = 100 * depth; // Todo: This is not right at all. This must be changed. Position must be calculated based on the parent position - + BigInteger vgap = freeChild.getVSHIFT(); + BigInteger hgap = freeChild.getHGAP(); + if(hgap==null){ + hgap = BigInteger.valueOf(0L); } - int x = xaxis * 200 * depth; - result = x + "," + y; - + if(vgap == null){ + vgap = BigInteger.valueOf(20L*order); + } + String[] position = wiseParent.getPosition().split(","); + BigInteger fix = BigInteger.valueOf(1L); + if((freeChild.getPOSITION() !=null && POSITION_LEFT.equals(freeChild.getPOSITION().toLowerCase())) + || freeChild.getPOSITION()==null && isOnLeftSide(wiseParent)) + fix=BigInteger.valueOf(-1L); + BigInteger firstLevelDistance = BigInteger.valueOf(0L); + BigInteger defaultXDistance = BigInteger.valueOf(100L); + if(depth==1){ + firstLevelDistance = BigInteger.valueOf(200L); + defaultXDistance = BigInteger.valueOf(0L); + } + BigInteger x = BigInteger.valueOf(Integer.valueOf(position[0])).add(hgap.multiply(fix).add(firstLevelDistance.multiply(fix)).add(defaultXDistance.multiply(fix))); + BigInteger y = BigInteger.valueOf(Integer.valueOf(position[1])).add(vgap); + result = x.toString()+","+y.toString(); } return result; } diff --git a/wise-webapp/src/test/data/freemind/basic.mmr b/wise-webapp/src/test/data/freemind/basic.mmr index 5752731b..df9fe2e5 100644 --- a/wise-webapp/src/test/data/freemind/basic.mmr +++ b/wise-webapp/src/test/data/freemind/basic.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/basic.wxml b/wise-webapp/src/test/data/freemind/basic.wxml index 8eff41b9..a868e280 100644 --- a/wise-webapp/src/test/data/freemind/basic.wxml +++ b/wise-webapp/src/test/data/freemind/basic.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/fonts.mmr b/wise-webapp/src/test/data/freemind/fonts.mmr index 1d1c5afd..11524e6a 100644 --- a/wise-webapp/src/test/data/freemind/fonts.mmr +++ b/wise-webapp/src/test/data/freemind/fonts.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/fonts.wxml b/wise-webapp/src/test/data/freemind/fonts.wxml index 1e80d593..2c5b7158 100644 --- a/wise-webapp/src/test/data/freemind/fonts.wxml +++ b/wise-webapp/src/test/data/freemind/fonts.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/i18n.mmr b/wise-webapp/src/test/data/freemind/i18n.mmr index 23494d78..c13ce775 100644 --- a/wise-webapp/src/test/data/freemind/i18n.mmr +++ b/wise-webapp/src/test/data/freemind/i18n.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/i18n.wxml b/wise-webapp/src/test/data/freemind/i18n.wxml index df9551b1..3f74480f 100644 --- a/wise-webapp/src/test/data/freemind/i18n.wxml +++ b/wise-webapp/src/test/data/freemind/i18n.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/icons.mmr b/wise-webapp/src/test/data/freemind/icons.mmr index 775c63f8..9a6882f3 100644 --- a/wise-webapp/src/test/data/freemind/icons.mmr +++ b/wise-webapp/src/test/data/freemind/icons.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/icons.wxml b/wise-webapp/src/test/data/freemind/icons.wxml index d7ee93ae..176704de 100644 --- a/wise-webapp/src/test/data/freemind/icons.wxml +++ b/wise-webapp/src/test/data/freemind/icons.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/links.mmr b/wise-webapp/src/test/data/freemind/links.mmr index 1a15b29c..b6937289 100644 --- a/wise-webapp/src/test/data/freemind/links.mmr +++ b/wise-webapp/src/test/data/freemind/links.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/links.wxml b/wise-webapp/src/test/data/freemind/links.wxml index dfcbab9a..454cc984 100644 --- a/wise-webapp/src/test/data/freemind/links.wxml +++ b/wise-webapp/src/test/data/freemind/links.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/longnodes.mmr b/wise-webapp/src/test/data/freemind/longnodes.mmr index dd987d0b..3abe3922 100644 --- a/wise-webapp/src/test/data/freemind/longnodes.mmr +++ b/wise-webapp/src/test/data/freemind/longnodes.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/longnodes.wxml b/wise-webapp/src/test/data/freemind/longnodes.wxml index 152ccb15..d601d0c7 100644 --- a/wise-webapp/src/test/data/freemind/longnodes.wxml +++ b/wise-webapp/src/test/data/freemind/longnodes.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/node-styles.mmr b/wise-webapp/src/test/data/freemind/node-styles.mmr index 353d40b0..0ed5020d 100644 --- a/wise-webapp/src/test/data/freemind/node-styles.mmr +++ b/wise-webapp/src/test/data/freemind/node-styles.mmr @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/node-styles.wxml b/wise-webapp/src/test/data/freemind/node-styles.wxml index ce69fddd..2ed5ef7c 100644 --- a/wise-webapp/src/test/data/freemind/node-styles.wxml +++ b/wise-webapp/src/test/data/freemind/node-styles.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/relationships.mm b/wise-webapp/src/test/data/freemind/relationships.mm new file mode 100644 index 00000000..a6be3801 --- /dev/null +++ b/wise-webapp/src/test/data/freemind/relationships.mm @@ -0,0 +1,60 @@ + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + +

%5El%3A%5El%3A%5El

+ + +
+
+ + + + + + + + + + + + + + +
diff --git a/wise-webapp/src/test/data/freemind/relationships.mmr b/wise-webapp/src/test/data/freemind/relationships.mmr new file mode 100644 index 00000000..e2cc1beb --- /dev/null +++ b/wise-webapp/src/test/data/freemind/relationships.mmr @@ -0,0 +1,3 @@ + + %5El%3A%5El%3A%5El + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/relationships.wxml b/wise-webapp/src/test/data/freemind/relationships.wxml new file mode 100644 index 00000000..db1b710b --- /dev/null +++ b/wise-webapp/src/test/data/freemind/relationships.wxml @@ -0,0 +1 @@ + \ No newline at end of file