diff --git a/mindplot/src/main/javascript/IconGroup.js b/mindplot/src/main/javascript/IconGroup.js index b486248f..e5efa1ac 100644 --- a/mindplot/src/main/javascript/IconGroup.js +++ b/mindplot/src/main/javascript/IconGroup.js @@ -48,11 +48,12 @@ mindplot.IconGroup = new Class({ seIconSize : function(width, height) { this._iconSize = {width:width,height:height}; - this._group.setCoordSize(width / mindplot.Icon.HEIGHT, height / mindplot.Icon.HEIGHT); + this._resize(this._icons.length); }, addIcon : function(icon) { $defined(icon, "icon is not defined"); + icon.getImage().setVisibility(false); icon.setGroup(this); this._icons.push(icon); @@ -66,6 +67,8 @@ mindplot.IconGroup = new Class({ // Register event for the group .. this._removeTip.decorate(this._topicId, icon); + + icon.getImage().setVisibility(true); }, _findIconFromUrl : function(url) { diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index 3212bb5c..6631f949 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -254,7 +254,7 @@ mindplot.Topic = new Class({ }, _buildIconGroup : function() { - var textHeight = this.getTextShape().getHeight(); + var textHeight = this.getTextShape().getFontHeight(); var result = new mindplot.IconGroup(this.getId(), textHeight); var padding = this._getInnerPadding(); result.setPosition(padding, padding); @@ -426,8 +426,10 @@ mindplot.Topic = new Class({ }, setFontSize : function(value, updateModel) { + var textShape = this.getTextShape(); textShape.setSize(value); + if ($defined(updateModel) && updateModel) { var model = this.getModel(); model.setFontSize(value); @@ -1142,10 +1144,17 @@ mindplot.Topic = new Class({ var textHeight = textShape.getHeight(); var topicPadding = this._getInnerPadding(); + // Adjust the icon size to the size of the text ... var iconGroup = this.getOrBuildIconGroup(); + var fontHeight = this.getTextShape().getFontHeight(); + iconGroup.setPosition(topicPadding, topicPadding); + iconGroup.seIconSize(fontHeight, fontHeight); + + + // Add a extra padding between the text and the icons var iconsWidth = iconGroup.getSize().width; if (iconsWidth != 0) { - // Add a extra padding between the text and the icons + iconsWidth = iconsWidth + (textHeight / 4); } diff --git a/web2d/src/main/javascript/Text.js b/web2d/src/main/javascript/Text.js index 0d0f1640..300fe4e7 100644 --- a/web2d/src/main/javascript/Text.js +++ b/web2d/src/main/javascript/Text.js @@ -31,9 +31,8 @@ web2d.Text = new Class({ this._peer.setText(text); }, - setTextAlignment : function(align) - { - $assert(align,"align can not be null"); + setTextAlignment : function(align) { + $assert(align, "align can not be null"); this._peer.setTextAlignment(align); }, @@ -87,5 +86,10 @@ web2d.Text = new Class({ getHeight : function() { return parseInt(this._peer.getHeight()); + }, + + getFontHeight : function() { + var lines = this._peer.getText().split('\n').length; + return Math.round(this.getHeight() / lines); } }); \ No newline at end of file diff --git a/web2d/src/main/javascript/peer/svg/GroupPeer.js b/web2d/src/main/javascript/peer/svg/GroupPeer.js index 3ea2ecb2..238947e9 100644 --- a/web2d/src/main/javascript/peer/svg/GroupPeer.js +++ b/web2d/src/main/javascript/peer/svg/GroupPeer.js @@ -32,6 +32,10 @@ web2d.peer.svg.GroupPeer = new Class({ var change = this._coordSize.width != width || this._coordSize.height != height; this._coordSize.width = width; this._coordSize.height = height; + + console.log("coordSize.width:" + width); + console.log("coordSize.height:" + height); + if (change) this.updateTransform(); web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle"); @@ -69,6 +73,21 @@ web2d.peer.svg.GroupPeer = new Class({ var cx = this._position.x - this._coordOrigin.x * sx; var cy = this._position.y - this._coordOrigin.y * sy; + console.log("------------------"); + console.log("this._coordSize.width:" + this._coordSize.width); + console.log("this._coordSize.height:" + this._coordSize.height); + + console.log("cx:" + cx); + console.log("cy:" + cy); + + console.log("this._size.width:" + this._size.width); + console.log("this._size.height:" + this._size.height); + + console.log("sx:" + sx); + console.log("sy:" + sy); + console.log("------------------"); + + this._native.setAttribute("transform", "translate(" + cx + "," + cy + ") scale(" + sx + "," + sy + ")"); },