Package org.pushingpixels.substance.api

Examples of org.pushingpixels.substance.api.ComponentState


    int width = Math.max(1, thumbBounds.width);
    int height = Math.max(1, thumbBounds.height);

    StateTransitionTracker.ModelStateInfo modelStateInfo = this.compositeStateTransitionTracker
        .getModelStateInfo();
    ComponentState currState = modelStateInfo.getCurrModelState();
    // enabled scroll bar is always painted as active
    // if (currState == ComponentState.ENABLED)
    // currState = ComponentState.SELECTED;

    SubstanceColorScheme baseFillScheme = (currState != ComponentState.ENABLED) ? SubstanceColorSchemeUtilities
        .getColorScheme(this.scrollbar, currState)
        : SubstanceColorSchemeUtilities.getActiveColorScheme(
            this.scrollbar, currState);
    SubstanceColorScheme baseBorderScheme = SubstanceColorSchemeUtilities
        .getColorScheme(this.scrollbar,
            ColorSchemeAssociationKind.BORDER, currState);
    BufferedImage baseLayer = getThumbHorizontal(this.scrollbar, width,
        height, baseFillScheme, baseBorderScheme);

    Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo
        .getStateContributionMap();
    if (currState.isDisabled() || (activeStates.size() == 1)) {
      return baseLayer;
    }

    BufferedImage result = SubstanceCoreUtilities.getBlankImage(baseLayer
        .getWidth(), baseLayer.getHeight());
    Graphics2D g2d = result.createGraphics();
    g2d.drawImage(baseLayer, 0, 0, null);

    for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates
        .entrySet()) {
      ComponentState activeState = activeEntry.getKey();
      if (activeState == modelStateInfo.getCurrModelState())
        continue;
      // if (activeState == ComponentState.ENABLED)
      // activeState = ComponentState.SELECTED;
View Full Code Here


   */
  protected ComponentState getState(JButton scrollButton) {
    if (scrollButton == null)
      return null;

    ComponentState result = ((TransitionAwareUI) scrollButton.getUI())
        .getTransitionTracker().getModelStateInfo().getCurrModelState();
    if ((result == ComponentState.ENABLED)
        && SubstanceCoreUtilities.hasFlatAppearance(this.scrollbar,
            false)) {
      result = null;
View Full Code Here

    SubstanceFillPainter fillPainter = SubstanceCoreUtilities
        .getFillPainter(this.menuItem);
    SubstanceBorderPainter borderPainter = SubstanceCoreUtilities
        .getBorderPainter(this.menuItem);
    ComponentState currState = modelStateInfo.getCurrModelState();

    SubstanceColorScheme baseFillColorScheme = SubstanceColorSchemeUtilities
        .getColorScheme(this.menuItem, ColorSchemeAssociationKind.FILL,
            currState);
    SubstanceColorScheme baseMarkColorScheme = SubstanceColorSchemeUtilities
        .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK,
            currState);
    SubstanceColorScheme baseBorderColorScheme = SubstanceColorSchemeUtilities
        .getColorScheme(this.menuItem,
            ColorSchemeAssociationKind.BORDER, currState);
    float visibility = stateTransitionTracker
        .getFacetStrength(ComponentStateFacet.SELECTION);

    HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(fontSize,
        checkMarkSize, fillPainter.getDisplayName(), borderPainter
            .getDisplayName(),
        baseFillColorScheme.getDisplayName(), baseMarkColorScheme
            .getDisplayName(), baseBorderColorScheme
            .getDisplayName(), visibility);
    Icon iconBase = iconMap.get(keyBase);
    if (iconBase == null) {
      iconBase = new ImageIcon(SubstanceImageCreator.getRadioButton(
          this.menuItem, fillPainter, borderPainter, checkMarkSize,
          currState, 0, baseFillColorScheme, baseMarkColorScheme,
          baseBorderColorScheme, visibility));
      iconMap.put(keyBase, iconBase);
    }
    if (currState.isDisabled() || (activeStates.size() == 1)) {
      return iconBase;
    }

    BufferedImage result = SubstanceCoreUtilities.getBlankImage(iconBase
        .getIconWidth(), iconBase.getIconHeight());
    Graphics2D g2d = result.createGraphics();
    // draw the base layer
    iconBase.paintIcon(this.menuItem, g2d, 0, 0);

    // draw other active layers
    for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates
        .entrySet()) {
      ComponentState activeState = activeEntry.getKey();
      // System.out.println("Painting state " + activeState + "[curr is "
      // + currState + "] with " + activeEntry.getValue());
      if (activeState == currState)
        continue;
View Full Code Here

    StateTransitionTracker.ModelStateInfo modelStateInfo = stateTransitionTracker
        .getModelStateInfo();
    Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = isMenu ? modelStateInfo
        .getStateNoSelectionContributionMap()
        : modelStateInfo.getStateContributionMap();
    ComponentState currState = isMenu ? modelStateInfo
        .getCurrModelStateNoSelection() : modelStateInfo
        .getCurrModelState();

    // Use HIGHLIGHT for rollover menus (arrow icons)
    // and MARK for the rest
    ColorSchemeAssociationKind baseAssociationKind = isMenu
        && currState.isFacetActive(ComponentStateFacet.ROLLOVER) ? ColorSchemeAssociationKind.HIGHLIGHT
        : ColorSchemeAssociationKind.MARK;
    SubstanceColorScheme baseScheme = SubstanceColorSchemeUtilities
        .getColorScheme(this.component, baseAssociationKind, currState);
    float baseAlpha = SubstanceColorSchemeUtilities.getAlpha(
        this.component, currState);

    HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(this.component
        .getClass().getName(), this.orientation, SubstanceSizeUtils
        .getComponentFontSize(this.component), baseScheme
        .getDisplayName(), baseAlpha);
    Icon layerBase = iconMap.get(keyBase);
    if (layerBase == null) {
      Icon baseFullOpacity = this.delegate.getColorSchemeIcon(baseScheme);
      if (baseAlpha == 1.0f) {
        layerBase = baseFullOpacity;
        iconMap.put(keyBase, layerBase);
      } else {
        BufferedImage baseImage = SubstanceCoreUtilities.getBlankImage(
            baseFullOpacity.getIconWidth(), baseFullOpacity
                .getIconHeight());
        Graphics2D g2base = baseImage.createGraphics();
        g2base.setComposite(AlphaComposite.SrcOver.derive(baseAlpha));
        baseFullOpacity.paintIcon(this.component, g2base, 0, 0);
        g2base.dispose();
        layerBase = new ImageIcon(baseImage);
        iconMap.put(keyBase, layerBase);
      }
    }
    // System.out.println("Contribution map in painting");
    // for (Map.Entry<ComponentState,
    // StateTransitionTracker.StateContributionInfo> existing : activeStates
    // .entrySet()) {
    // System.out.println("\t" + existing.getKey() + " in ["
    // + existing.getValue().start + ":" + existing.getValue().end
    // + "] : " + existing.getValue().curr);
    // }

    if (currState.isDisabled() || (activeStates.size() == 1)) {
      return layerBase;
    }

    BufferedImage result = SubstanceCoreUtilities.getBlankImage(layerBase
        .getIconWidth(), layerBase.getIconHeight());
    Graphics2D g2d = result.createGraphics();
    // draw the base layer
    // System.out.println("Painting currState " + currState + ":" +
    // baseAlpha);
    layerBase.paintIcon(this.component, g2d, 0, 0);

    // draw the other active layers
    for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates
        .entrySet()) {
      ComponentState activeState = activeEntry.getKey();
      // System.out.println("Painting state " + activeState + "[curr is "
      // + currState + "] with " + activeEntry.getValue());
      if (activeState == currState)
        continue;

      float stateContribution = activeEntry.getValue().getContribution();
      // System.out.println("Painting activeState "
      // + activeState
      // + ":"
      // + stateContribution
      // + "*"
      // + SubstanceColorSchemeUtilities.getAlpha(this.component,
      // activeState));
      if (stateContribution > 0.0f) {
        g2d.setComposite(AlphaComposite.SrcOver
            .derive(stateContribution));

        ColorSchemeAssociationKind associationKind = isMenu
            && activeState
                .isFacetActive(ComponentStateFacet.ROLLOVER) ? ColorSchemeAssociationKind.HIGHLIGHT
            : ColorSchemeAssociationKind.MARK;
        SubstanceColorScheme scheme = SubstanceColorSchemeUtilities
            .getColorScheme(this.component, associationKind,
                activeState);
View Full Code Here

    StateTransitionTracker.ModelStateInfo modelStateInfo = getModelStateInfo(
        row, rendererComponent);
    Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = ((modelStateInfo == null) ? null
        : modelStateInfo.getStateContributionMap());
    ComponentState currState = ((modelStateInfo == null) ? getCellState(
        row, rendererComponent) : modelStateInfo.getCurrModelState());

    // if the renderer is disabled, do not show any highlights
    boolean hasHighlights = false;
    if (rendererComponent.isEnabled()) {
      if (activeStates != null) {
        for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> stateEntry : activeStates
            .entrySet()) {
          hasHighlights = (this.updateInfo
              .getHighlightAlpha(stateEntry.getKey())
              * stateEntry.getValue().getContribution() > 0.0f);
          if (hasHighlights)
            break;
        }
      } else {
        hasHighlights = (this.updateInfo.getHighlightAlpha(currState) > 0.0f);
      }
    }

    JList.DropLocation dropLocation = list.getDropLocation();
    if (dropLocation != null && !dropLocation.isInsert()
        && dropLocation.getIndex() == row) {
      // mark drop location
      SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities
          .getColorScheme(list,
              ColorSchemeAssociationKind.TEXT_HIGHLIGHT,
              currState);
      SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities
          .getColorScheme(list, ColorSchemeAssociationKind.BORDER,
              currState);
      Rectangle cellRect = new Rectangle(cx, cy, cw, ch);
      HighlightPainterUtils.paintHighlight(g2d, this.rendererPane,
          rendererComponent, cellRect, 0.8f, null, fillScheme,
          borderScheme);
    } else {
      if (hasHighlights) {
        Rectangle cellRect = new Rectangle(cx, cy, cw, ch);
        if (activeStates == null) {
          float alpha = this.updateInfo.getHighlightAlpha(currState);
          if (alpha > 0.0f) {
            SubstanceColorScheme fillScheme = this.updateInfo
                .getHighlightColorScheme(currState);
            SubstanceColorScheme borderScheme = this.updateInfo
                .getHighlightBorderColorScheme(currState);
            g2d.setComposite(LafWidgetUtilities.getAlphaComposite(
                list, alpha, g));
            HighlightPainterUtils.paintHighlight(g2d,
                this.rendererPane, rendererComponent, cellRect,
                0.8f, null, fillScheme, borderScheme);
            g2d.setComposite(LafWidgetUtilities.getAlphaComposite(
                list, g));
          }
        } else {
          for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> stateEntry : activeStates
              .entrySet()) {
            ComponentState activeState = stateEntry.getKey();
            float alpha = this.updateInfo
                .getHighlightAlpha(activeState)
                * stateEntry.getValue().getContribution();
            if (alpha == 0.0f)
              continue;
View Full Code Here

      boolean isRollover = (rolledOverIndex >= 0)
          && (rolledOverIndex == cellIndex);
      boolean isSelected = selectedIndices.containsKey(cellIndex);
      return ComponentState.getState(isEnabled, isRollover, isSelected);
    } else {
      ComponentState fromTracker = tracker.getModelStateInfo()
          .getCurrModelState();
      return ComponentState.getState(isEnabled,
          fromTracker.isFacetActive(ComponentStateFacet.ROLLOVER),
          fromTracker.isFacetActive(ComponentStateFacet.SELECTION));
    }
  }
View Full Code Here

    if (listUI instanceof SubstanceListUI) {
      SubstanceListUI ui = (SubstanceListUI) listUI;

      StateTransitionTracker.ModelStateInfo modelStateInfo = ui
          .getModelStateInfo(index, this);
      ComponentState currState = ui.getCellState(index, this);

      // special case for drop location
      JList.DropLocation dropLocation = list.getDropLocation();
      boolean isDropLocation = (dropLocation != null
          && !dropLocation.isInsert() && dropLocation.getIndex() == index);

      if (!isDropLocation && (modelStateInfo != null)) {
        Map<ComponentState, StateContributionInfo> activeStates = modelStateInfo
            .getStateContributionMap();
        SubstanceColorScheme colorScheme = getColorSchemeForState(list,
            ui, currState);
        if (currState.isDisabled() || (activeStates == null)
            || (activeStates.size() == 1)) {
          super.setForeground(new ColorUIResource(colorScheme
              .getForegroundColor()));
        } else {
          float aggrRed = 0;
          float aggrGreen = 0;
          float aggrBlue = 0;

          for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : modelStateInfo
              .getStateContributionMap().entrySet()) {
            ComponentState activeState = activeEntry.getKey();
            SubstanceColorScheme scheme = getColorSchemeForState(
                list, ui, activeState);
            Color schemeFg = scheme.getForegroundColor();
            float contribution = activeEntry.getValue()
                .getContribution();
View Full Code Here

      if (index == -1) {
        StateTransitionTracker stateTransitionTracker = comboUI
            .getTransitionTracker();
        ModelStateInfo modelStateInfo = stateTransitionTracker
            .getModelStateInfo();
        ComponentState currState = modelStateInfo.getCurrModelState();
        float comboAlpha = SubstanceColorSchemeUtilities.getAlpha(
            combo, currState);
        Color fg = SubstanceTextUtilities
            .getForegroundColor(combo, ((JLabel) result).getText(),
                modelStateInfo, comboAlpha);
        result.setForeground(fg);
      } else {
        // use highlight color scheme for selected and rollover
        // elements in the drop down list
        StateTransitionTracker.ModelStateInfo modelStateInfo = listUI
            .getModelStateInfo(index, result);
        ComponentState currState = listUI.getCellState(index, result);
        if (modelStateInfo == null) {
          SubstanceColorScheme scheme = getColorSchemeForState(list,
              index, listUI, currState);
          // SubstanceColorScheme scheme =
          // SubstanceColorSchemeUtilities
          // .getColorScheme(list, kindForCurr, currState);
          result.setForeground(new ColorUIResource(scheme
              .getForegroundColor()));
        } else {
          Map<ComponentState, StateContributionInfo> activeStates = modelStateInfo
              .getStateContributionMap();
          SubstanceColorScheme colorScheme = getColorSchemeForState(
              list, index, listUI, currState);
          if (currState.isDisabled() || (activeStates == null)
              || (activeStates.size() == 1)) {
            super.setForeground(new ColorUIResource(colorScheme
                .getForegroundColor()));
          } else {
            float aggrRed = 0.0f;
            float aggrGreen = 0.0f;
            float aggrBlue = 0.0f;
            for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : modelStateInfo
                .getStateContributionMap().entrySet()) {
              ComponentState activeState = activeEntry.getKey();
              float activeContribution = activeEntry.getValue()
                  .getContribution();
              if (activeContribution == 0.0f)
                continue;
View Full Code Here

      SubstanceTreeUI ui = (SubstanceTreeUI) treeUI;
      TreePathId pathId = new TreePathId(tree.getPathForRow(row));

      StateTransitionTracker.ModelStateInfo modelStateInfo = ui
          .getModelStateInfo(pathId);
      ComponentState currState = ui.getPathState(pathId);

      // special case for drop location
      JTree.DropLocation dropLocation = tree.getDropLocation();
      boolean isDropLocation = (dropLocation != null
          && dropLocation.getChildIndex() == -1 && tree
          .getRowForPath(dropLocation.getPath()) == row);

      if (!isDropLocation && (modelStateInfo != null)) {
        Map<ComponentState, StateContributionInfo> activeStates = modelStateInfo
            .getStateContributionMap();
        SubstanceColorScheme colorScheme = getColorSchemeForState(tree,
            ui, currState);
        if (currState.isDisabled() || (activeStates == null)
            || (activeStates.size() == 1)) {
          super.setForeground(new ColorUIResource(colorScheme
              .getForegroundColor()));
        } else {
          float aggrRed = 0;
          float aggrGreen = 0;
          float aggrBlue = 0;

          for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : modelStateInfo
              .getStateContributionMap().entrySet()) {
            ComponentState activeState = activeEntry.getKey();
            SubstanceColorScheme scheme = getColorSchemeForState(
                tree, ui, activeState);
            Color schemeFg = scheme.getForegroundColor();
            float contribution = activeEntry.getValue()
                .getContribution();
View Full Code Here

        StateTransitionTracker stateTransitionTracker) {
      StateTransitionTracker.ModelStateInfo modelStateInfo = stateTransitionTracker
          .getModelStateInfo();
      Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo
          .getStateContributionMap();
      ComponentState currState = stateTransitionTracker
          .getModelStateInfo().getCurrModelState();

      float activeStrength = stateTransitionTracker.getActiveStrength();
      int width = (int) (this.size * (2.0 + activeStrength) / 3.0);
      width = Math.min(width, this.size - 2);
      int delta = (this.size - width) / 2;

      SubstanceFillPainter fillPainter = SubstanceCoreUtilities
          .getFillPainter(slider);
      SubstanceBorderPainter borderPainter = SubstanceCoreUtilities
          .getBorderPainter(slider);

      SubstanceColorScheme baseFillScheme = SubstanceColorSchemeUtilities
          .getColorScheme(slider, currState);
      SubstanceColorScheme baseBorderScheme = SubstanceColorSchemeUtilities
          .getColorScheme(slider, ColorSchemeAssociationKind.BORDER,
              currState);

      HashMapKey baseKey = SubstanceCoreUtilities.getHashKey(this.size,
          width, baseFillScheme.getDisplayName(), baseBorderScheme
              .getDisplayName(), fillPainter.getDisplayName(),
          borderPainter.getDisplayName(), this.isMirrorred);

      Icon baseLayer = SliderHorizontalIcon.icons.get(baseKey);
      if (baseLayer == null) {
        baseLayer = getSingleLayer(slider, width, delta, fillPainter,
            borderPainter, baseFillScheme, baseBorderScheme);
        SliderHorizontalIcon.icons.put(baseKey, baseLayer);
      }

      if (currState.isDisabled() || (activeStates.size() == 1))
        return baseLayer;

      BufferedImage result = SubstanceCoreUtilities.getBlankImage(
          baseLayer.getIconWidth(), baseLayer.getIconHeight());
      Graphics2D g2d = result.createGraphics();
      baseLayer.paintIcon(slider, g2d, 0, 0);

      for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates
          .entrySet()) {
        ComponentState activeState = activeEntry.getKey();
        if (activeState == currState)
          continue;

        float contribution = activeEntry.getValue().getContribution();
        if (contribution == 0.0f)
View Full Code Here

TOP

Related Classes of org.pushingpixels.substance.api.ComponentState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.