chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
62
63
64
65
66
67
68
69
70
71
Quintiq file version 2.0
#parent: #root
Method GetColor (
  LibOpt_Component object
) as internal[Color] id:Method_LibOpt_FormComponentGraph_GetColor
{
  #keys: '[140544.1.799764107]'
  Body:
  [*
    color_string := object.UIColor();
    
    color := null( Color, owning );
    
    if( [Boolean]ValueHolderShowHeatMap.Value() )
    { //use heat map
      colorLow := Color::Color( [Number]ValueHolderHeatMapLow.Value() );
      colorMid := Color::Color( [Number]ValueHolderHeatMapMid.Value() ); 
      colorHi := Color::Color( [Number]ValueHolderHeatMapHigh.Value() );     
      
      durationZero := Duration::Zero(); 
      
      minDuration := durationZero; 
      maxDuration := durationZero;
      avgDuration := durationZero;
      
      objDuration := object.GetDuration( minDuration, maxDuration, avgDuration );
      
      if( maxDuration <> durationZero ) //check if some durations are not 0
      {
        if( objDuration <= avgDuration )
        {         
          range := avgDuration - minDuration;
          ratio := 0.0;
          if( range <> durationZero )
          {
            ratio := ( objDuration - minDuration )/ range;
          }
          
          color := Color::Interpolate( colorLow, colorMid, ratio );       
        }
        else
        {
          range := maxDuration - avgDuration;
          ratio := 0.0;
          if( range <> durationZero )
          {
            ratio := ( objDuration - avgDuration ) / range;
          }
          
          color := Color::Interpolate( colorMid, colorHi, ratio );       
        }
      }
    }
    else
    { //use component colors
      if( color_string.SubString( 0, 1 ) = '#' )
      {
        color_num := LibOpt_Utility::GetColorFromHex( color_string.SubString( 1, color_string.Length() - 1 ) )
        color := Color::Color( color_num );
      }
      else
      {
        color := Color::Color( color_string );
      }
    }
                          
    return &color;
  *]
  Declarative: true
  ReturnsOwning: true
}