New Locator for labels attached on Connections

Draw2D 4.4.4 also includes the ability to place text or labels along the connections between ports. This is down by the usage of the draw2d.layout.locator.ParallelMidpointLocator.

Sample code for usage

var LabelConnection= draw2d.Connection.extend({
    
    init:function()
    {
      this._super();
    
      // Create any Draw2D figure as decoration for the connection
      //
      this.label = new draw2d.shape.basic.Label("I'm a Label");
      this.label.setColor(null);
      this.label.setFontColor("#0d0d0d");
 
      // use no special router - direct connection
      this.setRouter(null);

      // add the new decoration to the connection with a position locator.
      //
      this.addFigure(this.label, new draw2d.layout.locator.ParallelMidpointLocator(this));
    },

});



blogEntryTopper