private void restoreState() {

    _isUpdateUI = true;
    {
      _chkIsSynchSmoothing.setSelection( //
          _prefStore.getBoolean(ITourbookPreferences.GRAPH_JAMET_SMOOTHING_IS_SYNCH_SMOOTHING));

      // repeated smoothing
      _spinnerRepeatedSmoothing.setSelection( //
          _prefStore.getInt(ITourbookPreferences.GRAPH_JAMET_SMOOTHING_REPEATED_SMOOTHING));
      _spinnerRepeatedTau.setSelection( //
          (int)
              (_prefStore.getDouble(ITourbookPreferences.GRAPH_JAMET_SMOOTHING_REPEATED_TAU) * 10));

      // altitude
      _chkIsAltitudeSmoothing.setSelection( //
          _prefStore.getBoolean(ITourbookPreferences.GRAPH_JAMET_SMOOTHING_IS_ALTITUDE));

      // gradient
      _spinnerGradientTau.setSelection( //
          (int)
              (_prefStore.getDouble(ITourbookPreferences.GRAPH_JAMET_SMOOTHING_GRADIENT_TAU) * 10));

      // pulse
      _chkIsPulseSmoothing.setSelection( //
          _prefStore.getBoolean(ITourbookPreferences.GRAPH_JAMET_SMOOTHING_IS_PULSE));
      _spinnerPulseTau.setSelection( //
          (int) (_prefStore.getDouble(ITourbookPreferences.GRAPH_JAMET_SMOOTHING_PULSE_TAU) * 10));

      // speed
      _spinnerSpeedTau.setSelection( //
          (int) (_prefStore.getDouble(ITourbookPreferences.GRAPH_JAMET_SMOOTHING_SPEED_TAU) * 10));
    }
    _isUpdateUI = false;
  }
Esempio n. 2
0
  @Override
  public ImageServiceBean createBeanFromPreferences() {

    ImageServiceBean imageServiceBean = new ImageServiceBean();

    if (Platform.getPreferencesService() != null) { // Normally
      IPreferenceStore store =
          new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.dawnsci.plotting");
      imageServiceBean.setOrigin(
          ImageOrigin.forLabel(store.getString(BasePlottingConstants.ORIGIN_PREF)));
      imageServiceBean.setHistogramType(
          HistoType.forLabel(store.getString(BasePlottingConstants.HISTO_PREF)));
      imageServiceBean.setMinimumCutBound(
          HistogramBound.fromString(store.getString(BasePlottingConstants.MIN_CUT)));
      imageServiceBean.setMaximumCutBound(
          HistogramBound.fromString(store.getString(BasePlottingConstants.MAX_CUT)));
      imageServiceBean.setNanBound(
          HistogramBound.fromString(store.getString(BasePlottingConstants.NAN_CUT)));
      imageServiceBean.setLo(store.getDouble(BasePlottingConstants.HISTO_LO));
      imageServiceBean.setHi(store.getDouble(BasePlottingConstants.HISTO_HI));

      try {
        IPaletteService pservice = ServiceLoader.getPaletteService();
        if (pservice != null) {
          final String scheme = store.getString(BasePlottingConstants.COLOUR_SCHEME);

          if (store.getBoolean(BasePlottingConstants.USE_PALETTE_FUNCTIONS)) {
            FunctionContainer container = pservice.getFunctionContainer(scheme);
            if (container != null) {
              imageServiceBean.setFunctionObject(container);
            } else {
              imageServiceBean.setPalette(pservice.getDirectPaletteData(scheme));
            }
          } else {
            // if 8-bit, set direct palette, otherwise set palette functions.
            PaletteData pd;
            try {
              pd = pservice.getDirectPaletteData(scheme);
            } catch (final IllegalArgumentException e) { // scheme does not exist
              final String defaultScheme = pservice.getColorSchemes().iterator().next();
              pd = pservice.getDirectPaletteData(defaultScheme);
              store.setValue(BasePlottingConstants.COLOUR_SCHEME, defaultScheme);
            }
            imageServiceBean.setPalette(pd);
          }
        }
      } catch (Exception e) {
        // Ignored
      }

    } else { // Hard code something

      imageServiceBean.setOrigin(ImageOrigin.TOP_LEFT);
      imageServiceBean.setHistogramType(HistoType.OUTLIER_VALUES);
      imageServiceBean.setMinimumCutBound(HistogramBound.DEFAULT_MINIMUM);
      imageServiceBean.setMaximumCutBound(HistogramBound.DEFAULT_MAXIMUM);
      imageServiceBean.setNanBound(HistogramBound.DEFAULT_NAN);
      imageServiceBean.setLo(00.01);
      imageServiceBean.setHi(99.99);
      imageServiceBean.setPalette(makeJetPalette());
    }

    return imageServiceBean;
  }
Esempio n. 3
0
  public void earlyStartup() {
    // TODO 自動生成されたメソッド・スタブ

    // プリファレンスで定めた値のセット
    IPreferenceStore store = getDefault().getPreferenceStore();
    KeywordProgramming.BEST_R = store.getInt(PreferenceInitializer.BEST_R);
    KeywordProgramming.HEIGHT = store.getInt(PreferenceInitializer.HEIGHT);
    KeywordProgramming.COMBINATION_SIZE = store.getInt(PreferenceInitializer.COMBINATION_SIZE);
    KeywordProgramming.MAX_ARGUMETNT_SIZE = store.getInt(PreferenceInitializer.MAX_ARGUMETNT_SIZE);
    KeywordProgramming.BEST_FIRST_SIZE = store.getInt(PreferenceInitializer.BEST_FIRST_SIZE);

    // 符号も注意する。
    ExplanationVector.setWeight(-store.getDouble(PreferenceInitializer.INITIAL_WEIGHT_0), 0);
    ExplanationVector.setWeight(store.getDouble(PreferenceInitializer.INITIAL_WEIGHT_1), 1);
    ExplanationVector.setWeight(-store.getDouble(PreferenceInitializer.INITIAL_WEIGHT_2), 2);
    ExplanationVector.setWeight(store.getDouble(PreferenceInitializer.INITIAL_WEIGHT_3), 3);
    ExplanationVector.setWeight(store.getDouble(PreferenceInitializer.INITIAL_WEIGHT_4), 4);

    ExplanationVector.setConstFreq((store.getDouble(PreferenceInitializer.CONST_FREQ)));

    // 符号要らない。
    ExplanationVector.setStep(store.getDouble(PreferenceInitializer.LOCAL_STEP_WIDTH_0), 0);
    ExplanationVector.setStep(store.getDouble(PreferenceInitializer.LOCAL_STEP_WIDTH_1), 1);
    ExplanationVector.setStep(store.getDouble(PreferenceInitializer.LOCAL_STEP_WIDTH_2), 2);
    ExplanationVector.setStep(store.getDouble(PreferenceInitializer.LOCAL_STEP_WIDTH_3), 3);

    // リスナの設定。
    store.addPropertyChangeListener(
        new IPropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent event) {
            // TODO Auto-generated method stub
            String propertyName = event.getProperty();
            Object newValue = event.getNewValue();
            if (propertyName.equals(PreferenceInitializer.HEIGHT)) {
              KeywordProgramming.HEIGHT = (Integer) event.getNewValue();
            } else if (propertyName.equals(PreferenceInitializer.BEST_R)) {
              KeywordProgramming.BEST_R = (Integer) event.getNewValue();
            } else if (propertyName.equals(PreferenceInitializer.COMBINATION_SIZE)) {
              KeywordProgramming.COMBINATION_SIZE = (Integer) event.getNewValue();
            } else if (propertyName.equals(PreferenceInitializer.MAX_ARGUMETNT_SIZE)) {
              KeywordProgramming.MAX_ARGUMETNT_SIZE = (Integer) event.getNewValue();
            } else if (propertyName.equals(PreferenceInitializer.BEST_FIRST_SIZE)) {
              KeywordProgramming.BEST_FIRST_SIZE = (Integer) event.getNewValue();
            } else if (propertyName.equals(PreferenceInitializer.INITIAL_WEIGHT_0)) {
              ExplanationVector.setWeight(-(Double) newValue, 0);
            } else if (propertyName.equals(PreferenceInitializer.INITIAL_WEIGHT_1)) {
              ExplanationVector.setWeight((Double) newValue, 1);
            } else if (propertyName.equals(PreferenceInitializer.INITIAL_WEIGHT_2)) {
              ExplanationVector.setWeight(-(Double) newValue, 2);
            } else if (propertyName.equals(PreferenceInitializer.INITIAL_WEIGHT_3)) {
              ExplanationVector.setWeight((Double) newValue, 3);
            } else if (propertyName.equals(PreferenceInitializer.INITIAL_WEIGHT_4)) {
              ExplanationVector.setWeight((Double) newValue, 4);
            } else if (propertyName.equals(PreferenceInitializer.CONST_FREQ)) {
              ExplanationVector.setConstFreq((Double) newValue);
            } else if (propertyName.equals(PreferenceInitializer.LOCAL_STEP_WIDTH_0)) {
              ExplanationVector.setStep((Double) newValue, 0);
            } else if (propertyName.equals(PreferenceInitializer.LOCAL_STEP_WIDTH_1)) {
              ExplanationVector.setStep((Double) newValue, 1);
            } else if (propertyName.equals(PreferenceInitializer.LOCAL_STEP_WIDTH_2)) {
              ExplanationVector.setStep((Double) newValue, 2);
            } else if (propertyName.equals(PreferenceInitializer.LOCAL_STEP_WIDTH_3)) {
              ExplanationVector.setStep((Double) newValue, 3);
            }
          }
        });

    // プラグインの中にあるファイルの読み込み

    // classesファイル
    Path c_path = new Path(classesFileName);
    URL c_fileURL = FileLocator.find(bundle, c_path, null);
    InputStream c_in;
    // functionsファイル
    Path f_path = new Path(functionsFileName);
    URL f_fileURL = FileLocator.find(bundle, f_path, null);
    InputStream f_in;

    // functionsファイル
    Path fr_path = new Path(KeywordProgramming.FREQUENCY_FILE_NAME);
    URL fr_fileURL = FileLocator.find(bundle, fr_path, null);
    InputStream fr_in;
    try {
      c_in = c_fileURL.openStream();
      BufferedReader c_reader = new BufferedReader(new InputStreamReader(c_in));
      f_in = f_fileURL.openStream();
      BufferedReader f_reader = new BufferedReader(new InputStreamReader(f_in));
      fr_in = fr_fileURL.openStream();
      BufferedReader fr_reader = new BufferedReader(new InputStreamReader(fr_in));

      ConsoleTest3.loadOriginalFiles(c_reader, f_reader);
      // 行頭をマーク
      //			c_reader.mark(1024);
      //			f_reader.mark(1024);
      //			fr_reader.mark(1024);
      //
      // 型,関数,頻度ファイル読み込み
      //			KeywordProgramming.loadFiles(c_reader, f_reader, fr_reader);
      //
      // 行頭に戻す
      //			c_reader.reset();
      //			f_reader.reset();
      //			fr_reader.reset();
      //
      // 再読み込み
      //			keywordProgramming.exp.KeywordProgramming.loadFiles(c_reader, f_reader, fr_reader);
      //			keywordProgramming.exp.KeywordProgramming.setOriginalTypesAndFunctions();

      // クローズ
      c_reader.close();
      f_reader.close();
      fr_reader.close();
      c_in.close();
      f_in.close();
      fr_in.close();
    } catch (IOException e) {
      // TODO 自動生成された catch ブロック
      e.printStackTrace();
    }

    // ログファイルの読み込み
    //		int numOfFiles = store.getInt(PreferenceInitializer.NUMBER_OF_PAST_LOG_FOR_ONLINE);
    int numOfFiles = 50;
    TestSite.loadLogFiles(numOfFiles);

    // 出力コンソールの用意
    createConsoleStream();
  }