/**
   * Installs the given color in the preference store and optionally the color registry.
   *
   * @param definition the color definition
   * @param theme the theme defining the color
   * @param store the preference store from which to set and obtain color data
   * @param setInRegistry whether the color should be put into the registry
   */
  private static void installColor(
      ColorDefinition definition, ITheme theme, IPreferenceStore store, boolean setInRegistry) {

    // TODO: store shouldn't be null, should assert instead of checking null all over

    ColorRegistry registry = theme.getColorRegistry();

    String id = definition.getId();
    String key = createPreferenceKey(theme, id);
    RGB prefColor = store != null ? PreferenceConverter.getColor(store, key) : null;
    RGB defaultColor =
        (definition.getValue() != null)
            ? definition.getValue()
            : registry.getRGB(definition.getDefaultsTo());

    if (prefColor == null || prefColor == PreferenceConverter.COLOR_DEFAULT_DEFAULT) {
      prefColor = defaultColor;
    }

    // if the preference value isn't the default then retain that pref value
    RGB colorToUse = !store.isDefault(key) ? prefColor : defaultColor;

    if (setInRegistry) {
      registry.put(id, colorToUse);
    }

    if (store != null) {
      PreferenceConverter.setDefault(store, key, defaultColor);
    }
  }
 private RGB getColorFromStore(IPreferenceStore store, String key) {
   RGB rgb = null;
   if (store.contains(key)) {
     if (store.isDefault(key)) rgb = PreferenceConverter.getDefaultColor(store, key);
     else rgb = PreferenceConverter.getColor(store, key);
   }
   return rgb;
 }
 /** @return thumbnail size */
 private int getPreferenceImageSize() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   int size =
       preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_IMAGESIZE)
           ? preferenceStore.getDefaultInt(PreferenceConstants.IMAGEEXPLORER_IMAGESIZE)
           : preferenceStore.getInt(PreferenceConstants.IMAGEEXPLORER_IMAGESIZE);
   return size;
 }
 private double getPreferenceAutoContrastHi() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   int v =
       preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_AUTOCONTRAST_HITHRESHOLD)
           ? preferenceStore.getDefaultInt(
               PreferenceConstants.IMAGEEXPLORER_AUTOCONTRAST_HITHRESHOLD)
           : preferenceStore.getInt(PreferenceConstants.IMAGEEXPLORER_AUTOCONTRAST_HITHRESHOLD);
   return v / 100.0;
 }
Example #5
0
 private double getPreferenceAutoContrastLo() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   int v =
       preferenceStore.isDefault(PreferenceConstants.PLOT_VIEW_PLOT2D_AUTOCONTRAST_LOTHRESHOLD)
           ? preferenceStore.getDefaultInt(
               PreferenceConstants.PLOT_VIEW_PLOT2D_AUTOCONTRAST_LOTHRESHOLD)
           : preferenceStore.getInt(PreferenceConstants.PLOT_VIEW_PLOT2D_AUTOCONTRAST_LOTHRESHOLD);
   return v / 100.0;
 }
Example #6
0
 private boolean getPreferenceColourMapExpertMode() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   // try to retrieve setting from last session
   if (preferenceStore.getBoolean(
       getPartName() + "." + PreferenceConstants.PLOT_VIEW_PLOT2D_CMAP_EXPERT)) return true;
   return preferenceStore.isDefault(PreferenceConstants.PLOT_VIEW_PLOT2D_CMAP_EXPERT)
       ? preferenceStore.getDefaultBoolean(PreferenceConstants.PLOT_VIEW_PLOT2D_CMAP_EXPERT)
       : preferenceStore.getBoolean(PreferenceConstants.PLOT_VIEW_PLOT2D_CMAP_EXPERT);
 }
Example #7
0
 private int getPreferenceColourMapChoice() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   // try to retrieve setting from last session
   int i =
       preferenceStore.getInt(
           getPartName() + "." + PreferenceConstants.PLOT_VIEW_PLOT2D_COLOURMAP);
   if (i != 0) return i;
   return preferenceStore.isDefault(PreferenceConstants.PLOT_VIEW_PLOT2D_COLOURMAP)
       ? preferenceStore.getDefaultInt(PreferenceConstants.PLOT_VIEW_PLOT2D_COLOURMAP)
       : preferenceStore.getInt(PreferenceConstants.PLOT_VIEW_PLOT2D_COLOURMAP);
 }
  /**
   * Creates a color from the information stored in the given preference store. Returns <code>null
   * </code> if there is no such information available.
   *
   * @param store the store to read from
   * @param key the key used for the lookup in the preference store
   * @param display the display used create the color
   * @return the created color according to the specification in the preference store
   * @since 3.0
   */
  private Color createColor(IPreferenceStore store, String key, Display display) {

    RGB rgb = null;

    if (store.contains(key)) {

      if (store.isDefault(key)) rgb = PreferenceConverter.getDefaultColor(store, key);
      else rgb = PreferenceConverter.getColor(store, key);

      if (rgb != null) return new Color(display, rgb);
    }

    return null;
  }
Example #9
0
 private static Color createColor(IPreferenceStore store, String key, Display display) {
   // TODO(messick) Remove display or use it instead of color manager
   RGB rgb = null;
   if (store.contains(key)) {
     if (store.isDefault(key)) {
       rgb = PreferenceConverter.getDefaultColor(store, key);
     } else {
       rgb = PreferenceConverter.getColor(store, key);
     }
     if (rgb != null) {
       return getColorManager().getColor(rgb);
     }
   }
   return null;
 }
 /** @return plot name that playback uses */
 public String getPreferencePlaybackView() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   return preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_PLAYBACKVIEW)
       ? preferenceStore.getDefaultString(PreferenceConstants.IMAGEEXPLORER_PLAYBACKVIEW)
       : preferenceStore.getString(PreferenceConstants.IMAGEEXPLORER_PLAYBACKVIEW);
 }
 private int getPreferencePlaybackRate() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   return preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_PLAYBACKRATE)
       ? preferenceStore.getDefaultInt(PreferenceConstants.IMAGEEXPLORER_PLAYBACKRATE)
       : preferenceStore.getInt(PreferenceConstants.IMAGEEXPLORER_PLAYBACKRATE);
 }
 private int getPreferenceTimeDelay() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   return preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_TIMEDELAYBETWEENIMAGES)
       ? preferenceStore.getDefaultInt(PreferenceConstants.IMAGEEXPLORER_TIMEDELAYBETWEENIMAGES)
       : preferenceStore.getInt(PreferenceConstants.IMAGEEXPLORER_TIMEDELAYBETWEENIMAGES);
 }
 private String getPreferenceColourMapChoice() {
   IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore();
   return preferenceStore.isDefault(PreferenceConstants.IMAGEEXPLORER_COLOURMAP)
       ? preferenceStore.getDefaultString(PreferenceConstants.IMAGEEXPLORER_COLOURMAP)
       : preferenceStore.getString(PreferenceConstants.IMAGEEXPLORER_COLOURMAP);
 }