From c74d2de32d50d2fce3e40590f49d9d3aab333312 Mon Sep 17 00:00:00 2001 From: Paulo Veiga Date: Mon, 29 Aug 2011 20:10:05 -0300 Subject: [PATCH] Fix flicker. Remove more code. --- mindplot/pom.xml | 1 - .../src/main/javascript/RelationshipLine.js | 22 ++-- mindplot/src/main/javascript/ScreenManager.js | 13 +- .../javascript/commands/AddTopicCommand.js | 3 +- .../commands/MoveControlPointCommand.js | 4 +- .../src/main/javascript/util/Converter.js | 31 ----- web2d/pom.xml | 2 - web2d/src/main/javascript/Element.js | 26 +--- .../main/javascript/peer/svg/ElementPeer.js | 4 +- .../src/main/javascript/peer/svg/TextPeer.js | 124 +++++++----------- wise-doc/src/main/webapp/css/editor.css | 8 ++ 11 files changed, 83 insertions(+), 155 deletions(-) delete mode 100644 mindplot/src/main/javascript/util/Converter.js diff --git a/mindplot/pom.xml b/mindplot/pom.xml index beeee7e3..2e522d63 100644 --- a/mindplot/pom.xml +++ b/mindplot/pom.xml @@ -82,7 +82,6 @@ - diff --git a/mindplot/src/main/javascript/RelationshipLine.js b/mindplot/src/main/javascript/RelationshipLine.js index 65b71aa0..83d83ec0 100644 --- a/mindplot/src/main/javascript/RelationshipLine.js +++ b/mindplot/src/main/javascript/RelationshipLine.js @@ -88,7 +88,7 @@ mindplot.RelationshipLine = new Class({ this._positionateConnector(targetTopic); if (this.isOnFocus()) { - this._refreshSelectedShape(); + this._refreshShape(); } this._focusShape.moveToBack(); this._controlPointsController.redraw(); @@ -149,17 +149,19 @@ mindplot.RelationshipLine = new Class({ setOnFocus : function(focus) { // Change focus shape - if (focus) { - this._refreshSelectedShape(); - this._controlPointsController.setLine(this); - } - this._focusShape.setVisibility(focus); + if (this.isOnFocus() != focus) { + if (focus) { + this._refreshShape(); + this._controlPointsController.setLine(this); + } + this._focusShape.setVisibility(focus); - this._controlPointsController.setVisibility(focus); - this._onFocus = focus; + this._controlPointsController.setVisibility(focus); + this._onFocus = focus; + } }, - _refreshSelectedShape : function () { + _refreshShape : function () { var sPos = this._line2d.getFrom(); var tPos = this._line2d.getTo(); var ctrlPoints = this._line2d.getControlPoints(); @@ -171,8 +173,6 @@ mindplot.RelationshipLine = new Class({ shapeCtrlPoints[1].x = ctrlPoints[1].x; shapeCtrlPoints[1].y = ctrlPoints[1].y; this._focusShape.updateLine(); - //this._focusShape.setSrcControlPoint(ctrlPoints[0]); - //this._focusShape.setDestControlPoint(ctrlPoints[1]); }, addEvent : function(type, listener) { diff --git a/mindplot/src/main/javascript/ScreenManager.js b/mindplot/src/main/javascript/ScreenManager.js index 04f8a37b..c1b7c36d 100644 --- a/mindplot/src/main/javascript/ScreenManager.js +++ b/mindplot/src/main/javascript/ScreenManager.js @@ -28,8 +28,10 @@ mindplot.ScreenManager = new Class({ event.stopPropagation() }); - // @Todo: This must be resolved in other way ... - mindplot.util.Converter.setScreenManager(this); + this._divContainer.addEvent('dblclick', function(event) { + event.stopPropagation() ; + event.preventDefault(); + }); }, setScale : function(scale) { @@ -62,9 +64,9 @@ mindplot.ScreenManager = new Class({ } }, - getWorkspaceElementPosition : function(e) { + _getElementPosition : function(elem) { // Retrieve current element position. - var elementPosition = e.getPosition(); + var elementPosition = elem.getPosition(); var x = elementPosition.x; var y = elementPosition.y; @@ -105,10 +107,9 @@ mindplot.ScreenManager = new Class({ //Retrieve topic Position var topic = iconGroup.getTopic(); - var topicPosition = this.getWorkspaceElementPosition(topic); + var topicPosition = this._getElementPosition(topic); topicPosition.x = topicPosition.x - (parseInt(topic.getSize().width) / 2); - // Remove decimal part.. return {x:x + topicPosition.x,y:y + topicPosition.y}; }, diff --git a/mindplot/src/main/javascript/commands/AddTopicCommand.js b/mindplot/src/main/javascript/commands/AddTopicCommand.js index b2b34e70..3f916f02 100644 --- a/mindplot/src/main/javascript/commands/AddTopicCommand.js +++ b/mindplot/src/main/javascript/commands/AddTopicCommand.js @@ -47,8 +47,9 @@ mindplot.commands.AddTopicCommand = new Class( if (this._animated) { core.Utils.setVisibilityAnimated([topic,topic.getOutgoingLine()], true, doneFn); - } else + } else { doneFn.attempt(); + } }, undoExecute: function(commandContext) { diff --git a/mindplot/src/main/javascript/commands/MoveControlPointCommand.js b/mindplot/src/main/javascript/commands/MoveControlPointCommand.js index ee11efc5..1bce65a8 100644 --- a/mindplot/src/main/javascript/commands/MoveControlPointCommand.js +++ b/mindplot/src/main/javascript/commands/MoveControlPointCommand.js @@ -57,7 +57,7 @@ mindplot.commands.MoveControlPointCommand = new Class({ break; } if (this._line.isOnFocus()) { - this._line._refreshSelectedShape(); + this._line._refreshShape(); this._ctrlPointControler.setLine(this._line); } this._line.getLine().updateLine(this._point); @@ -86,7 +86,7 @@ mindplot.commands.MoveControlPointCommand = new Class({ this._line.getLine().updateLine(this._point); if (this._line.isOnFocus()) { this._ctrlPointControler.setLine(line); - line._refreshSelectedShape(); + line._refreshShape(); } } }); \ No newline at end of file diff --git a/mindplot/src/main/javascript/util/Converter.js b/mindplot/src/main/javascript/util/Converter.js deleted file mode 100644 index bc5dd201..00000000 --- a/mindplot/src/main/javascript/util/Converter.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright [2011] [wisemapping] - * - * Licensed under WiseMapping Public License, Version 1.0 (the "License"). - * It is basically the Apache License, Version 2.0 (the "License") plus the - * "powered by wisemapping" text requirement on every single page; - * you may not use this file except in compliance with the License. - * You may obtain a copy of the license at - * - * http://www.wisemapping.org/license - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -mindplot.util.Converter = { - - topicToScreenPosition : function(topic) { - $assert(topic, "topic is not defined"); - $assert(this._screenManager, "screenManager is not defined"); - - return this._screenManager.getWorkspaceElementPosition(topic); - } -}; - -mindplot.util.Converter.setScreenManager = function(instance) { - this._screenManager = instance; -}; \ No newline at end of file diff --git a/web2d/pom.xml b/web2d/pom.xml index f58cc9bd..c8357c89 100644 --- a/web2d/pom.xml +++ b/web2d/pom.xml @@ -66,10 +66,8 @@ ${basedir}/target/tmp/peer/svg/LinePeer-min.js ${basedir}/target/tmp/peer/svg/TahomaFont-min.js ${basedir}/target/tmp/peer/svg/VerdanaFont-min.js - ${basedir}/target/tmp/Element-min.js ${basedir}/target/tmp/Elipse-min.js - ${basedir}/target/tmp/EventDispatcher-min.js ${basedir}/target/tmp/Font-min.js ${basedir}/target/tmp/Group-min.js ${basedir}/target/tmp/Image-min.js diff --git a/web2d/src/main/javascript/Element.js b/web2d/src/main/javascript/Element.js index 3841b8bc..f9337f4f 100644 --- a/web2d/src/main/javascript/Element.js +++ b/web2d/src/main/javascript/Element.js @@ -87,19 +87,7 @@ web2d.Element.prototype.positionRelativeTo = function(elem, options) { * */ web2d.Element.prototype.addEvent = function(type, listener) { - if (!this._supportedEvents.include(type)) { - throw "Unsupported event type: " + type; - } - - // Concat previous event listeners for a given type. - if (!this._dispatcherByEventType[type]) { - this._dispatcherByEventType[type] = new web2d.EventDispatcher(this); - - var eventListener = this._dispatcherByEventType[type].eventListener; - this._peer.addEvent(type, eventListener); - } - - this._dispatcherByEventType[type].addListener(type, listener); + this._peer.addEvent(type, listener); }; /** * @@ -113,17 +101,7 @@ web2d.Element.prototype.addEvent = function(type, listener) { * This interace will be invoked passing an event as argument and the 'this' referece in the function will be the element. */ web2d.Element.prototype.removeEvent = function(type, listener) { - var dispatcher = this._dispatcherByEventType[type]; - if (dispatcher == null) { - throw "There is no listener previously registered"; - } - var result = dispatcher.removeListener(type, listener); - - // If there is not listeners, EventDispatcher must be removed. - if (dispatcher.getListenersCount() <= 0) { - this._peer.removeEvent(type, dispatcher.eventListener); - this._dispatcherByEventType[type] = null; - } + this._peer.removeEvent(type, listener); }; /** diff --git a/web2d/src/main/javascript/peer/svg/ElementPeer.js b/web2d/src/main/javascript/peer/svg/ElementPeer.js index efe5aac6..982eb656 100644 --- a/web2d/src/main/javascript/peer/svg/ElementPeer.js +++ b/web2d/src/main/javascript/peer/svg/ElementPeer.js @@ -85,12 +85,12 @@ web2d.peer.svg.ElementPeer.prototype.removeChild = function(elementPeer) { */ web2d.peer.svg.ElementPeer.prototype.addEvent = function(type, listener) { - this._native.addEventListener(type, listener, false); + this._native.addEvent(type, listener); }; web2d.peer.svg.ElementPeer.prototype.removeEvent = function(type, listener) { - this._native.removeEventListener(type, listener, false); + this._native.removeEvent(type, listener); }; web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height) { diff --git a/web2d/src/main/javascript/peer/svg/TextPeer.js b/web2d/src/main/javascript/peer/svg/TextPeer.js index 1195cc61..58d1b545 100644 --- a/web2d/src/main/javascript/peer/svg/TextPeer.js +++ b/web2d/src/main/javascript/peer/svg/TextPeer.js @@ -1,26 +1,24 @@ /* -* Copyright [2011] [wisemapping] -* -* Licensed under WiseMapping Public License, Version 1.0 (the "License"). -* It is basically the Apache License, Version 2.0 (the "License") plus the -* "powered by wisemapping" text requirement on every single page; -* you may not use this file except in compliance with the License. -* You may obtain a copy of the license at -* -* http://www.wisemapping.org/license -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright [2011] [wisemapping] + * + * Licensed under WiseMapping Public License, Version 1.0 (the "License"). + * It is basically the Apache License, Version 2.0 (the "License") plus the + * "powered by wisemapping" text requirement on every single page; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the license at + * + * http://www.wisemapping.org/license + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -web2d.peer.svg.TextPeer = function() -{ +web2d.peer.svg.TextPeer = function() { var svgElement = window.document.createElementNS(this.svgNamespace, 'text'); web2d.peer.svg.ElementPeer.call(this, svgElement); - this._native.setAttribute("focusable", "false"); this._position = {x:0,y:0}; this._font = new web2d.Font("Arial", this); }; @@ -29,24 +27,21 @@ objects.extend(web2d.peer.svg.TextPeer, web2d.peer.svg.ElementPeer); //todo: use ths method to specify the maximum size of the text box /*web2d.web2d.peer.svg.TextPeer.prototype.setSize = function(width, height) -{ - web2d.web2d.peer.svg.TextPeer.superClass.setSize.call(this,width,height); - this._native.setAttribute('rx', width / 2); - this._native.setAttribute('ry', height /ose 2); -}; -*/ + { + web2d.web2d.peer.svg.TextPeer.superClass.setSize.call(this,width,height); + this._native.setAttribute('rx', width / 2); + this._native.setAttribute('ry', height /ose 2); + }; + */ -web2d.peer.svg.TextPeer.prototype.appendChild = function(element) -{ +web2d.peer.svg.TextPeer.prototype.appendChild = function(element) { this._native.appendChild(element._native); }; -web2d.peer.svg.TextPeer.prototype.setText = function(text) -{ +web2d.peer.svg.TextPeer.prototype.setText = function(text) { text = core.Utils.escapeInvalidTags(text); var child = this._native.firstChild; - if ($defined(child)) - { + if ($defined(child)) { this._native.removeChild(child); } this._text = text; @@ -54,51 +49,42 @@ web2d.peer.svg.TextPeer.prototype.setText = function(text) this._native.appendChild(textNode); }; -web2d.peer.svg.TextPeer.prototype.getText = function() -{ +web2d.peer.svg.TextPeer.prototype.getText = function() { return this._text; }; -web2d.peer.svg.TextPeer.prototype.setPosition = function(x, y) -{ +web2d.peer.svg.TextPeer.prototype.setPosition = function(x, y) { this._position = {x:x, y:y}; var height = this._font.getSize(); - if($defined(this._parent) && $defined(this._native.getBBox)) + if ($defined(this._parent) && $defined(this._native.getBBox)) height = this.getHeight(); var size = parseInt(height); - this._native.setAttribute('y', y+size*3/4); + this._native.setAttribute('y', y + size * 3 / 4); //y+size/2 this._native.setAttribute('x', x); }; -web2d.peer.svg.TextPeer.prototype.getPosition = function() -{ +web2d.peer.svg.TextPeer.prototype.getPosition = function() { return this._position; }; -web2d.peer.svg.TextPeer.prototype.setFont = function(font, size, style, weight) -{ - if ($defined(font)) - { +web2d.peer.svg.TextPeer.prototype.setFont = function(font, size, style, weight) { + if ($defined(font)) { this._font = new web2d.Font(font, this); } - if ($defined(style)) - { + if ($defined(style)) { this._font.setStyle(style); } - if ($defined(weight)) - { + if ($defined(weight)) { this._font.setWeight(weight); } - if ($defined(size)) - { + if ($defined(size)) { this._font.setSize(size); } this._updateFontStyle(); }; -web2d.peer.svg.TextPeer.prototype._updateFontStyle = function() -{ +web2d.peer.svg.TextPeer.prototype._updateFontStyle = function() { this._native.setAttribute('font-family', this._font.getFontFamily()); this._native.setAttribute('font-size', this._font.getGraphSize()); this._native.setAttribute('font-style', this._font.getStyle()); @@ -108,41 +94,34 @@ web2d.peer.svg.TextPeer.prototype._updateFontStyle = function() this._native.xFontScale = scale.toFixed(1); }; -web2d.peer.svg.TextPeer.prototype.setColor = function(color) -{ +web2d.peer.svg.TextPeer.prototype.setColor = function(color) { this._native.setAttribute('fill', color); }; -web2d.peer.svg.TextPeer.prototype.getColor = function() -{ +web2d.peer.svg.TextPeer.prototype.getColor = function() { return this._native.getAttribute('fill'); }; -web2d.peer.svg.TextPeer.prototype.setTextSize = function (size) -{ +web2d.peer.svg.TextPeer.prototype.setTextSize = function (size) { this._font.setSize(size); this._updateFontStyle(); }; -web2d.peer.svg.TextPeer.prototype.setContentSize = function(width, height) -{ +web2d.peer.svg.TextPeer.prototype.setContentSize = function(width, height) { this._native.xTextSize = width.toFixed(1) + "," + height.toFixed(1); }; -web2d.peer.svg.TextPeer.prototype.setStyle = function (style) -{ +web2d.peer.svg.TextPeer.prototype.setStyle = function (style) { this._font.setStyle(style); this._updateFontStyle(); }; -web2d.peer.svg.TextPeer.prototype.setWeight = function (weight) -{ +web2d.peer.svg.TextPeer.prototype.setWeight = function (weight) { this._font.setWeight(weight); this._updateFontStyle(); }; -web2d.peer.svg.TextPeer.prototype.setFontFamily = function (family) -{ +web2d.peer.svg.TextPeer.prototype.setFontFamily = function (family) { var oldFont = this._font; this._font = new web2d.Font(family, this); this._font.setSize(oldFont.getSize()); @@ -151,8 +130,7 @@ web2d.peer.svg.TextPeer.prototype.setFontFamily = function (family) this._updateFontStyle(); }; -web2d.peer.svg.TextPeer.prototype.getFont = function () -{ +web2d.peer.svg.TextPeer.prototype.getFont = function () { return { font:this._font.getFont(), size:parseInt(this._font.getSize()), @@ -161,28 +139,24 @@ web2d.peer.svg.TextPeer.prototype.getFont = function () }; }; -web2d.peer.svg.TextPeer.prototype.setSize = function (size) -{ +web2d.peer.svg.TextPeer.prototype.setSize = function (size) { this._font.setSize(size); this._updateFontStyle(); }; -web2d.peer.svg.TextPeer.prototype.getWidth = function () -{ +web2d.peer.svg.TextPeer.prototype.getWidth = function () { var computedWidth = this._native.getBBox().width; var width = parseInt(computedWidth); width = width + this._font.getWidthMargin(); return width; }; -web2d.peer.svg.TextPeer.prototype.getHeight = function () -{ +web2d.peer.svg.TextPeer.prototype.getHeight = function () { var computedHeight = this._native.getBBox().height; return parseInt(computedHeight); }; -web2d.peer.svg.TextPeer.prototype.getHtmlFontSize = function () -{ +web2d.peer.svg.TextPeer.prototype.getHtmlFontSize = function () { return this._font.getHtmlSize(); }; diff --git a/wise-doc/src/main/webapp/css/editor.css b/wise-doc/src/main/webapp/css/editor.css index d57fe3cc..0dfeaf86 100644 --- a/wise-doc/src/main/webapp/css/editor.css +++ b/wise-doc/src/main/webapp/css/editor.css @@ -6,6 +6,14 @@ html { overflow: hidden; } +body { + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -o-user-select: none; + user-select: none; +} + #waitDialog { position: absolute; top: 10px;