コード例 #1
0
  /**
   * Returns the color scheme to be used for painting the specified visual area of the component
   * under the specified component state.
   *
   * @param comp Component.
   * @param associationKind Color scheme association kind.
   * @param componentState Component state.
   * @return Color scheme to be used for painting the specified visual area of the component under
   *     the specified component state.
   * @see #registerColorScheme(SubstanceColorScheme, ComponentState...)
   * @since version 5.1
   */
  public SubstanceColorScheme getColorScheme(
      ColorSchemeAssociationKind associationKind, ComponentState componentState) {
    if (associationKind == ColorSchemeAssociationKind.FILL)
      return this.getColorScheme(componentState);

    SubstanceColorScheme registered = this.colorSchemeMap.get(associationKind).get(componentState);
    if (registered != null) return registered;

    // if (componentState.isActive()) {
    // for now look for the best fit only on active states
    Map<ComponentState, ComponentState> bestFitForState = this.bestFillMap.get(associationKind);
    if (!bestFitForState.containsKey(componentState)) {
      Collection<ComponentState> registeredStates =
          this.colorSchemeMap.get(associationKind).keySet();
      bestFitForState.put(componentState, componentState.bestFit(registeredStates));
    }
    ComponentState bestFit = bestFitForState.get(componentState);
    if (bestFit != null) {
      registered = this.colorSchemeMap.get(associationKind).get(bestFit);
      if (registered != null) return registered;
    }
    // }

    ColorSchemeAssociationKind fallback = associationKind.getFallback();
    if (fallback == null) return null;

    return getColorScheme(fallback, componentState);
  }