limj
2023-10-24 93652435728de839582440eefd5122c281181d35
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
  }
}