Exemplo n.º 1
0
  /** {@inheritDoc} */
  public Map<IPreferenceGroup, Object> eventFired() {
    Sensitivity sensitivity = Sensitivity.fromOrd(slider.getSelection());

    Map<IPreferenceGroup, Object> preferenceControlMap = new HashMap<IPreferenceGroup, Object>();
    preferenceControlMap.put(PreferenceId.SamplingRate.SLIDER_ID, sensitivity);

    // get the actual selected divider mode button and set the specific id
    if (timeframeModeButton.getSelection()) {
      preferenceControlMap.put(
          PreferenceId.SamplingRate.DIVIDER_ID, PreferenceId.SamplingRate.TIMEFRAME_DIVIDER_ID);
    }

    return preferenceControlMap;
  }
Exemplo n.º 2
0
  /** Create a list of cards */
  private List<CardBuilder> createCards(Context context) {
    ArrayList<CardBuilder> cards = new ArrayList<>();

    cards.add(
        DEMO,
        new CardBuilder(context, CardBuilder.Layout.CAPTION).setText(R.string.text_card_demo));

    Sensitivity sensitivity = Sensitivity.values()[mSharedPreferences.getInt("sensitivity", 2)];
    cards.add(
        SENSITIVITY_SETTINGS,
        new CardBuilder(context, CardBuilder.Layout.COLUMNS)
            .setText(
                getString(R.string.text_card_sensitivity_settings)
                    + " "
                    + getString(sensitivity.textId))
            .setIcon(R.drawable.ic_sensitivity_150));

    return cards;
  }
Exemplo n.º 3
0
 /**
  * Converts an ordinal into a {@link Sensitivity}.
  *
  * @param i The ordinal.
  * @return The appropriate column.
  */
 public static Sensitivity fromOrd(int i) {
   if (i < 0 || i >= Sensitivity.values().length) {
     throw new IndexOutOfBoundsException("Invalid ordinal");
   }
   return Sensitivity.values()[i];
 }
Exemplo n.º 4
0
  /** {@inheritDoc} */
  public Composite createControls(Composite parent, FormToolkit toolkit) {
    Section section = toolkit.createSection(parent, Section.TITLE_BAR);
    section.setText("Sampling Rate");
    section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    Composite composite = toolkit.createComposite(section);
    section.setClient(composite);

    GridLayout layout = new GridLayout(4, false);
    layout.marginLeft = 10;
    layout.horizontalSpacing = 10;
    composite.setLayout(layout);
    GridData gridData = new GridData(SWT.MAX, SWT.DEFAULT);
    gridData.grabExcessHorizontalSpace = true;
    composite.setLayoutData(gridData);

    final Label sliderLabel = toolkit.createLabel(composite, "no sensitivity selected", SWT.LEFT);
    GridData data = new GridData(SWT.FILL, SWT.FILL, false, false);
    data.widthHint = sliderLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
    sliderLabel.setLayoutData(data);

    slider = new Scale(composite, SWT.HORIZONTAL);
    toolkit.adapt(slider, true, true);
    slider.setMinimum(0);
    slider.setMaximum(Sensitivity.values().length - 1);
    slider.setIncrement(1);
    slider.setSize(200, 10);
    slider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    slider.addSelectionListener(
        new SelectionAdapter() {
          /** {@inheritDoc} */
          @Override
          public void widgetSelected(SelectionEvent event) {
            Sensitivity sensitivity = Sensitivity.fromOrd(slider.getSelection());

            switch (sensitivity) {
              case NO_SENSITIVITY:
                sliderLabel.setText("no sensitivity selected");
                break;
              case VERY_FINE:
                sliderLabel.setText("very fine");
                break;
              case FINE:
                sliderLabel.setText("fine");
                break;
              case MEDIUM:
                sliderLabel.setText("medium");
                break;
              case COARSE:
                sliderLabel.setText("coarse");
                break;
              case VERY_COARSE:
                sliderLabel.setText("very coarse");
                break;
              default:
                break;
            }
          }
        });
    slider.setSelection(DEFAULT_SENSITIVITY.ordinal());
    slider.notifyListeners(SWT.Selection, null);

    Label modeLabel = toolkit.createLabel(composite, "Sampling Rate Mode: ", SWT.LEFT);
    modeLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));

    timeframeModeButton = toolkit.createButton(composite, "Timeframe dividing", SWT.RADIO);
    timeframeModeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    timeframeModeButton.setSelection(true);

    return composite;
  }