mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-22 19:33:48 +01:00
Resize icons on scale.
This commit is contained in:
parent
001ff2e371
commit
b1b0ee0de8
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
@ -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 + ")");
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user