1
我試圖創建一個可編輯標籤,如示例connection_labeledit_inplace中的標籤。在Graphiti中,如何將標籤上的編輯器附加到圖
我遇到的問題是我想將標籤附加到自定義VectorFigure中以代替連接。當這樣做時,標籤只是圖中的一部分,不會啓動編輯器。
ivr.shape.menu.MenuItem = graphiti.VectorFigure.extend({
NAME:"ivr.shape.menu.MenuItem",
MyOutputPortLocator : graphiti.layout.locator.Locator.extend({
init: function(parent)
{
this._super(parent);
},
relocate:function(index, figure){
var w = figure.getParent().getWidth();
var h = figure.getParent().getHeight();
figure.setPosition(w, h/2);
}
}),
/**
* @constructor
* Creates a new figure element which are not assigned to any canvas.
*
*/
init: function(width, height) {
this._super();
this.setBackgroundColor(new graphiti.util.Color(200,200,200));
this.setColor(new graphiti.util.Color(50,50,50));
// set some good defaults
//
if(typeof width === "undefined"){
this.setDimension(100, 15);
}
else{
this.setDimension(width, height);
}
// add port
var outputLocator = new this.MyOutputPortLocator(this);
this.createPort("output",outputLocator);
this.label = new graphiti.shape.basic.Label("I'm a Label");
this.label.setColor("#0d0d0d");
this.label.setFontColor("#0d0d0d");
this.addFigure(this.label, new graphiti.layout.locator.LeftLocator(this));
this.label.installEditor(new graphiti.ui.LabelInplaceEditor());
},
repaint : function(attributes)
{
if(this.repaintBlocked===true || this.shape===null){
return;
}
if (typeof attributes === "undefined") {
attributes = {};
}
var box = this.getBoundingBox();
var center = box.getCenter();
var path = ["M",box.x,",",box.y];
path.push("l", box.w-10, ",0");
path.push("l10,", box.h/2);
path.push("l-10,", box.h/2);
path.push("L",box.x,",", box.getBottomLeft().y);
path.push("Z");
var strPath = path.join("");
attributes.path = strPath;
this._super(attributes);
},
/**
* @method
* Called by the framework. Don't call them manually.
*
* @private
**/
createShapeElement:function()
{
// create dummy line
return this.canvas.paper.path("M0 0L1 1");
}
});
在這個例子中,我把在標籤上圖的左邊,但顯然我會做出把標籤上的數字定位器(以防萬一它改變的東西)
對我的問題是,來自'graphiti.Canvas.getBestFigure()'的工作方式。該函數僅檢查直接附加到'graphity.Canvas'的元素。此外,該函數缺少一些遞歸來傳播子項上的事件。
當然,我採取了最新的,我知道我可以趕上點擊一個數字。問題是這個事件不會傳播給附在畫布上的一個人物形象。 – Zerzio 2012-07-21 07:32:28
版本1.0.0不存在,文檔告訴它現在應該工作。大。 – Zerzio 2012-09-19 17:41:40