classdef ScrollPaneConstants
  % Constants used to configure scroll bar settings.
  %
  % See also toolpack.component.TSTextArea, toolpack.component.TSList
  
  % Author(s): Bora Eryilmaz
  % Revised:
  % Copyright 2012 The MathWorks, Inc.
  
  % ----------------------------------------------------------------------------
  enumeration
    % Vertical scroll bar policy
    VerticalAsNeeded (javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
    VerticalNever (javax.swing.JScrollPane.VERTICAL_SCROLLBAR_NEVER)
    VerticalAlways (javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS)
    
    % Horizontal scroll bar policy
    HorizontalAsNeeded (javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)
    HorizontalNever (javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)
    HorizontalAlways (javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)
  end
  
  % ----------------------------------------------------------------------------
  properties
    % Matching Java ScrollPaneConstants value.
    JavaEnum
  end
  
  % ----------------------------------------------------------------------------
  methods
    function this = ScrollPaneConstants(data)
      this.JavaEnum = data;
    end
  end
  
  methods (Static)
    function policy = getScrollBarPolicy(javaPolicy)
      % Return matching scroll bar policy value for specified Java constant.
      policies = { ...
        'VerticalAsNeeded', 'VerticalNever', 'VerticalAlways', ...
        'HorizontalAsNeeded', 'HorizontalNever', 'HorizontalAlways'};
      for k = 1:length(policies)
        policy = toolpack.component.ScrollPaneConstants.(policies{k});
        if (javaPolicy == policy.JavaEnum)
          return
        end
      end
    end
  end
end
