Quintiq file version 2.0
#parent: CustomDrawSCO/CustomDrawDataLayerLabels
Response OnDrawObject (
  Node object
) id:Response_CustomDrawSCO_CustomDrawDataLayerLabels_OnDrawObject
{
  #keys: '[136682.0.1905115950]'
  CanBindMultiple: false
  DefinitionID: 'Responsedef_WebCustomDrawDataLayer_OnDrawObject'
  QuillAction
  {
    Body:
    [*
      // Draw node labels
      view := object.ViewBase().astype( SupplyChainView );
      if ( not isnull( view ) )
      {
        
        //Set font color
        surface.Font().Name( view.FontName() );
        surface.Font().Size( view.FontSize() )
        surface.Font().Bold( true );
        
        color := Color::Color(0, 0, 0);
        if ( object.TextColor() <> '' )
        {
          color := guard( Color::Color( object.TextColor() ), ColorScheme.SupplyChainOverview_NodeText() );
        }
        surface.TextColor( color );
      
        if ( text = '' )
        {
          text := object.Name();
        }
      
        fontheight := view.FontSize() + 3; // +3 needed to make text actually fit in fontheight
       /* fontheight := ceil( fontheight / CustomDrawSCO.ZoomY() )*/ // Make fontheight independent of zoom level
        rows := text.Tokenize( String::NewLine() ).Size();
        maxlength := max( text.Tokenize( String::NewLine() ), Elements, e, e.Length() )
        width := region.BoundingRect().Width();
        totalwidth := width *  ceil( maxlength / 2 ) ; //assume each width only fits 3 chars
        offset := [Number] ( ( totalwidth - width ) / 2 );
      
        y := region.BoundingRect().Height();
        if ( object.IsTextTop() )
        {
          y := region.BoundingRect().Top() - ( rows * fontheight );
        }
      
        if( object.IsNameVisible() )
        {
          textformat := TextFormat::Construct();
          textformat.AlignMiddle().AlignCenter().NoEndEllipsis();
      
          surface.TextZoom( region.BoundingRect().Left() - offset, y , totalwidth, ( fontheight * rows ), text, textformat )
        }
      }
    *]
    GroupServerCalls: false
  }
}
