Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.

Migration code from javascript to typescript INodeInsetsProvider

0 votes

Hi

I have some problem with use yours demo sample from demos\complete\hierarchicgrouping.
 
I try to migrate yours code to type script and one fragment isn't work in type script. 
 
Yours code in javascript:
   /** @return {Object} */
    'lookup': function(/**yfiles.graph.INode*/ node, /**yfiles.lang.Class*/ type) {
      if (type === yfiles.input.INodeInsetsProvider.$class) {
        return new DemoGroupStyle.MyInsetsProvider();
      } else if (type === yfiles.input.INodeSizeConstraintProvider.$class) {
        return new DemoGroupStyle.MySizeConstraintProvider();
      }
      return DemoGroupStyle.$super.lookup.call(this, node, type);

    },

  /** @lends {DemoGroupStyle} */
    '$static': {
      /**
       * @class DemoGroupStyle.MyInsetsProvider
       * @augments yfiles.drawing.IInsetsProvider.<yfiles.graph.INode>
       */
      'MyInsetsProvider': new yfiles.lang.ClassDefinition(function() {
        /** @lends {DemoGroupStyle.MyInsetsProvider.prototype} */
        return {
 
          '$with': [yfiles.input.INodeInsetsProvider],
 
          /** @return {yfiles.geometry.Insets} */
          'getInsets': function(/**yfiles.graph.INode*/ item) {
            var  margin = 5;
            return new yfiles.geometry.Insets(
                BORDER_THICKNESS + margin, HEADER_THICKNESS + margin,
                BORDER_THICKNESS + margin, BORDER_THICKNESS + margin);
          }
        };
      }),
 
 
My code in typescript: 

  public lookup(node: yfiles.graph.INode, type: yfiles.lang.Class): Object {

        if (type === yfiles.input.INodeInsetsProvider.$class) {
            return DemoGroupStyle.MyInsetsProvider();
        } else if (type === yfiles.input.INodeSizeConstraintProvider.$class) {
            return new MySizeConstraintProvider();
        }
        return super.lookup(node, type);
    }
 
export class MyInsetsProvider implements yfiles.input.INodeInsetsProvider {
 
    public getInsets(item: yfiles.graph.INode): yfiles.geometry.Insets {
 
        let margin: number = 5;
        return new yfiles.geometry.Insets(
            BORDER_THICKNESS + margin, HEADER_THICKNESS + margin,
            BORDER_THICKNESS + margin, BORDER_THICKNESS + margin);
    }
}
 
In my code i see the metod getInsets is never use.
 
best regard
Wojciech Remplewicz
 
 
closed with the note: Not a yEd question.
asked Jan 18, 2017 in Help by anonymous
closed Jan 18, 2017 by thomas.behr

1 Answer

0 votes

This forum is for yEd questions only. For questions regarding the yFiles for HTML programming library, please contact yWorks support by mail. (Please include your yWorks customer or evaluator ID in your mail when doing so.)

answered Jan 18, 2017 by thomas.behr [yWorks] (126,520 points)
Imprint | Privacy Policy