content: //******************************************************************************
  // SCICHART® Copyright SciChart Ltd. 2011-2021. All rights reserved.
  //
  // Web: http://www.scichart.com
  // Support: support@scichart.com
  // Sales:   sales@scichart.com
  //
  // ThemeManager3DChartFragment.java is part of SCICHART®, High Performance Scientific Charts
  // For full terms and conditions of the license, see http://www.scichart.com/scichart-eula/
  //
  // This source code is protected by international copyright law. Unauthorized
  // reproduction, reverse-engineering, or distribution of all or any portion of
  // this source code is strictly prohibited.
  //
  // This source code contains confidential and proprietary trade secrets of
  // SciChart Ltd., and should at no time be copied, transferred, sold,
  // distributed or made available without express written permission.
  //******************************************************************************
  
  package com.scichart.examples.fragments.examples3d.style3DChart;
  
  import android.view.LayoutInflater;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.Spinner;
  
  import androidx.annotation.NonNull;
  
  import com.scichart.charting.themes.ThemeManager;
  import com.scichart.charting3d.model.dataSeries.xyz.XyzDataSeries3D;
  import com.scichart.charting3d.visuals.SciChartSurface3D;
  import com.scichart.charting3d.visuals.axes.NumericAxis3D;
  import com.scichart.charting3d.visuals.pointMarkers.SpherePointMarker3D;
  import com.scichart.charting3d.visuals.renderableSeries.metadataProviders.PointMetadataProvider3D;
  import com.scichart.charting3d.visuals.renderableSeries.metadataProviders.PointMetadataProvider3D.PointMetadata3D;
  import com.scichart.charting3d.visuals.renderableSeries.scatter.ScatterRenderableSeries3D;
  import com.scichart.core.framework.UpdateSuspender;
  import com.scichart.drawing.utility.ColorUtil;
  import com.scichart.examples.R;
  import com.scichart.examples.components.SpinnerStringAdapter;
  import com.scichart.examples.data.DataManager;
  import com.scichart.examples.databinding.ExampleThemeManager3dChartFragmentBinding;
  import com.scichart.examples.fragments.base.ExampleBaseFragment;
  import com.scichart.examples.utils.ItemSelectedListenerBase;
  
  import java.util.List;
  
  public class ThemeManager3DChartFragment extends ExampleBaseFragment<ExampleThemeManager3dChartFragmentBinding> {
      private final static int BLACK_STEEL = 0;
      private final static int BRIGHT_SPARK = 1;
      private final static int CHROME = 2;
      private final static int ELECTRIC = 3;
      private final static int EXPRESSION_DARK = 4;
      private final static int EXPRESSION_LIGHT = 5;
      private final static int OSCILLOSCOPE = 6;
      private final static int SCI_CHART_V4_DARK = 7;
      private final static int BERRY_BLUE = 8;
  
      @NonNull
      @Override
      protected ExampleThemeManager3dChartFragmentBinding inflateBinding(@NonNull LayoutInflater inflater) {
          return ExampleThemeManager3dChartFragmentBinding.inflate(inflater);
      }
  
      @Override
      protected void initExample(@NonNull ExampleThemeManager3dChartFragmentBinding binding) {
          final DataManager dataManager = DataManager.getInstance();
  
          final NumericAxis3D xAxis = sciChart3DBuilder.newNumericAxis3D().withGrowBy(.1, .1).build();
          final NumericAxis3D yAxis = sciChart3DBuilder.newNumericAxis3D().withGrowBy(.1, .1).build();
          final NumericAxis3D zAxis = sciChart3DBuilder.newNumericAxis3D().withGrowBy(.1, .1).build();
  
          final PointMetadataProvider3D pointMetaDataProvider = new PointMetadataProvider3D();
          final List<PointMetadata3D> metadata = pointMetaDataProvider.metadata;
  
          final XyzDataSeries3D<Double, Double, Double> xyzDataSeries3D = new XyzDataSeries3D<>(Double.class, Double.class, Double.class);
          for (int i = 0; i < 1250; i++) {
              final double x = dataManager.getGaussianRandomNumber(5, 1.5);
              final double y = dataManager.getGaussianRandomNumber(5, 1.5);
              final double z = dataManager.getGaussianRandomNumber(5, 1.5);
              xyzDataSeries3D.append(x, y, z);
  
              metadata.add(new PointMetadata3D(dataManager.getRandomColor(), dataManager.getRandomScale()));
          }
  
          final SpherePointMarker3D pointMarker = sciChart3DBuilder.newSpherePointMarker3D()
                  .withFill(ColorUtil.LimeGreen)
                  .withSize(2f)
                  .build();
  
          final ScatterRenderableSeries3D rs = sciChart3DBuilder.newScatterSeries3D()
                  .withDataSeries(xyzDataSeries3D)
                  .withPointMarker(pointMarker)
                  .withMetadataProvider(pointMetaDataProvider)
                  .build();
  
          final SciChartSurface3D surface3d = binding.surface3d;
          UpdateSuspender.using(surface3d, () -> {
              surface3d.setXAxis(xAxis);
              surface3d.setYAxis(yAxis);
              surface3d.setZAxis(zAxis);
              surface3d.getRenderableSeries().add(rs);
              surface3d.getChartModifiers().add(sciChart3DBuilder.newModifierGroupWithDefaultModifiers().build());
          });
  
          final Spinner themeSelector = binding.themeSelector;
          themeSelector.setAdapter(new SpinnerStringAdapter(getActivity(), R.array.style_list));
          themeSelector.setSelection(7);
          themeSelector.setOnItemSelectedListener(new ItemSelectedListenerBase() {
              @Override
              public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                  setTheme(position);
              }
          });
      }
  
      private void setTheme(int position) {
          int themeId;
          switch (position) {
              case BLACK_STEEL:
                  themeId = R.style.SciChart_BlackSteel;
                  break;
              case BRIGHT_SPARK:
                  themeId = R.style.SciChart_Bright_Spark;
                  break;
              case CHROME:
                  themeId = R.style.SciChart_ChromeStyle;
                  break;
              case ELECTRIC:
                  themeId = R.style.SciChart_ElectricStyle;
                  break;
              case EXPRESSION_DARK:
                  themeId = R.style.SciChart_ExpressionDarkStyle;
                  break;
              case EXPRESSION_LIGHT:
                  themeId = R.style.SciChart_ExpressionLightStyle;
                  break;
              case OSCILLOSCOPE:
                  themeId = R.style.SciChart_OscilloscopeStyle;
                  break;
              case SCI_CHART_V4_DARK:
                  themeId = R.style.SciChart_SciChartv4DarkStyle;
                  break;
              case BERRY_BLUE:
                  themeId = R.style.SciChart_BerryBlue;
                  break;
              default:
                  themeId = ThemeManager.DEFAULT_THEME;
                  break;
          }
  
          binding.surface3d.setTheme(themeId);
      }
  }
  