Package org.pushingpixels.substance.api

Examples of org.pushingpixels.substance.api.ComponentState


    Icon icon = SubstanceCoreUtilities.getIcon(b, null, this.glowingIcon,
        false);

    graphics.setComposite(TransitionLayout.getAlphaComposite(b, g));
    if (fadeTracker.isTracked(b, FadeKind.ROLLOVER)) {
      ComponentState state = ComponentState.getState(b);
      // System.out.println(state.name() + ":" + state.isRollover());
      if (state.isKindActive(FadeKind.ROLLOVER)) {// ==
        // ComponentState.ROLLOVER_UNSELECTED) {
        // Came from default state
        SubstanceCoreUtilities.getIcon(b, null, this.glowingIcon, true)
            .paintIcon(b, graphics, iconRect.x, iconRect.y);
        graphics.setComposite(TransitionLayout.getAlphaComposite(b,
View Full Code Here


    this.setComponentOrientation(list.getComponentOrientation());

    ListUI listUI = list.getUI();
    if (listUI instanceof SubstanceListUI) {
      SubstanceListUI ui = (SubstanceListUI) listUI;
      ComponentState state = ui.getCellState(index, this);
      ComponentState prevState = ui.getPrevCellState(index, this);

      SubstanceColorScheme scheme = (state == ComponentState.DEFAULT) ? ui
          .getDefaultColorScheme()
          : ui.getHighlightColorScheme(state);
          if (scheme == null) {
View Full Code Here

    Graphics2D g2d = (Graphics2D) g.create();
    BackgroundPaintingUtils.updateIfOpaque(g2d, c);
    if (icon != null) {
      icon.paintIcon(c, g2d, paintIconR.x, paintIconR.y);
    }
    ComponentState labelState = label.isEnabled() ? ComponentState.ENABLED
        : ComponentState.DISABLED_UNSELECTED;
    float labelAlpha = SubstanceColorSchemeUtilities.getAlpha(label,
        labelState);
    if (text != null) {
      final View v = (View) c.getClientProperty(BasicHTML.propertyKey);
View Full Code Here

    TransitionAwareUI transitionAwareUI = (TransitionAwareUI) button
        .getUI();
    StateTransitionTracker.ModelStateInfo modelStateInfo = transitionAwareUI
        .getTransitionTracker().getModelStateInfo();

    ComponentState currState = modelStateInfo.getCurrModelState();

    // ComponentState prevState = stateTransitionModel.getPrevModelState();

    // System.out.println(button.getText() + ": " + prevState.name() +
    // " -> "
    // + state.name() + " at "
    // + stateTransitionModel.getTransitionPosition());

    // compute cycle count (for animation)
    float cyclePos = 0.0f;// currState.getCyclePosition();
    // boolean isPulsating = false;
    if (button instanceof JButton) {
      JButton jb = (JButton) button;
      if (RootPaneDefaultButtonTracker.isPulsating(jb)
          && (currState != ComponentState.PRESSED_SELECTED)
          && (currState != ComponentState.PRESSED_UNSELECTED)) {
        // isPulsating = true;
        cyclePos = RootPaneDefaultButtonTracker.getTimelinePosition(jb);
      }
    }

    // compute the straight sides
    Set<SubstanceConstants.Side> straightSides = SubstanceCoreUtilities
        .getSides(button, SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY);

    boolean isRoundButton = StandardButtonShaper.isRoundButton(button);
    float radius = 0.0f;
    if (shaper instanceof RectangularButtonShaper) {
      radius = ((RectangularButtonShaper) shaper).getCornerRadius(button,
          null);
    }

    Set<Side> openSides = SubstanceCoreUtilities.getSides(button,
        SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY);
    // String openKey = "";
    // for (Side oSide : openSides) {
    // openKey += oSide.name() + "-";
    // }
    // String extraModelKey = "";
    // for (String modelKey : extraModelKeys) {
    // extraModelKey += (modelKey + "-");
    // }
    boolean isContentAreaFilled = button.isContentAreaFilled();
    boolean isBorderPainted = button.isBorderPainted();

    // compute color scheme
    SubstanceColorScheme baseBorderScheme = SubstanceColorSchemeUtilities
        .getColorScheme(button, ColorSchemeAssociationKind.BORDER,
            currState);

    // see if need to use attention-drawing animation
    // boolean isWindowModified = false;
    if (button.getUI() instanceof ModificationAwareUI) {
      ModificationAwareUI modificationAwareUI = (ModificationAwareUI) button
          .getUI();
      Timeline modificationTimeline = modificationAwareUI
          .getModificationTimeline();
      if (modificationTimeline != null) {
        if (modificationTimeline.getState() != TimelineState.IDLE) {
          // isWindowModified = true;
          SubstanceColorScheme colorScheme2 = SubstanceColorSchemeUtilities.YELLOW;
          SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities.ORANGE;
          cyclePos = modificationTimeline.getTimelinePosition();

          HashMapKey key1 = SubstanceCoreUtilities.getHashKey(width,
              height, colorScheme.getDisplayName(),
              baseBorderScheme.getDisplayName(), shaper
                  .getDisplayName(), fillPainter
                  .getDisplayName(), borderPainter
                  .getDisplayName(), straightSides,
              openSides, button.getClass().getName(),
              isRoundButton, radius, isContentAreaFilled,
              isBorderPainted, SubstanceSizeUtils
                  .getComponentFontSize(button));
          BufferedImage layer1 = regularBackgrounds.get(key1);
          if (layer1 == null) {
            layer1 = createBackgroundImage(button, shaper,
                fillPainter, borderPainter, width, height,
                colorScheme, baseBorderScheme, openSides,
                isContentAreaFilled, isBorderPainted);

            regularBackgrounds.put(key1, layer1);
          }
          HashMapKey key2 = SubstanceCoreUtilities.getHashKey(width,
              height, colorScheme2.getDisplayName(),
              baseBorderScheme.getDisplayName(), shaper
                  .getDisplayName(), fillPainter
                  .getDisplayName(), borderPainter
                  .getDisplayName(), straightSides,
              openSides, button.getClass().getName(),
              isRoundButton, radius, isContentAreaFilled,
              isBorderPainted, SubstanceSizeUtils
                  .getComponentFontSize(button));
          BufferedImage layer2 = regularBackgrounds.get(key2);
          if (layer2 == null) {
            layer2 = createBackgroundImage(button, shaper,
                fillPainter, borderPainter, width, height,
                colorScheme2, baseBorderScheme, openSides,
                isContentAreaFilled, isBorderPainted);

            regularBackgrounds.put(key2, layer2);
          }

          BufferedImage result = SubstanceCoreUtilities
              .getBlankImage(width, height);
          Graphics2D g2d = result.createGraphics();
          if (cyclePos < 1.0f)
            g2d.drawImage(layer1, 0, 0, null);
          if (cyclePos > 0.0f) {
            g2d.setComposite(AlphaComposite.SrcOver
                .derive(cyclePos));
            g2d.drawImage(layer2, 0, 0, null);
          }
          g2d.dispose();
          return result;
        }
      }
    }

    // see if need to use transition animation. Important - don't do it
    // on pulsating buttons (such as default or close buttons
    // of modified frames).

    Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo
        .getStateContributionMap();

    SubstanceColorScheme baseFillScheme = SubstanceColorSchemeUtilities
        .getColorScheme(button, currState);
    HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(width, height,
        baseFillScheme.getDisplayName(), baseBorderScheme
            .getDisplayName(), shaper.getDisplayName(), fillPainter
            .getDisplayName(), borderPainter.getDisplayName(),
        straightSides, openSides, button.getClass().getName(),
        isRoundButton, (int) (1000 * radius), isContentAreaFilled,
        isBorderPainted, SubstanceSizeUtils
            .getComponentFontSize(button));
    BufferedImage layerBase = regularBackgrounds.get(keyBase);
    if (layerBase == null) {
      layerBase = createBackgroundImage(button, shaper, fillPainter,
          borderPainter, width, height, baseFillScheme,
          baseBorderScheme, openSides, isContentAreaFilled,
          isBorderPainted);
      regularBackgrounds.put(keyBase, layerBase);
    }
    if (currState.isDisabled() || (activeStates.size() == 1)) {
      return layerBase;
    }

    BufferedImage result = SubstanceCoreUtilities.getBlankImage(width,
        height);
    Graphics2D g2d = result.createGraphics();
    // draw the base layer
    g2d.drawImage(layerBase, 0, 0, null);
    // System.out.println("\nPainting base state " + currState);

    // 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;

View Full Code Here

      if (isFlat) {
        // Special handling of flat buttons
        extraAlpha = 0.0f;
        for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates
            .entrySet()) {
          ComponentState activeState = activeEntry.getKey();
          if (activeState.isDisabled())
            continue;
          if (activeState == ComponentState.ENABLED)
            continue;
          extraAlpha += activeEntry.getValue().getContribution();
        }
View Full Code Here

    // background = tree.getBackground();

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

    // Compute the alpha values for the animation.
    boolean hasHighlights = false;
    if (renderer.isEnabled()) {
      if (activeStates != null) {
        for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> stateEntry : activeStates
            .entrySet()) {
          hasHighlights = (SubstanceColorSchemeUtilities
              .getHighlightAlpha(this.tree, stateEntry.getKey())
              * stateEntry.getValue().getContribution() > 0.0f);
          if (hasHighlights)
            break;
        }
      } else {
        hasHighlights = (SubstanceColorSchemeUtilities
            .getHighlightAlpha(this.tree, currState) > 0.0f);
      }
    }

    // System.out.println(row + ":" + prevTheme.getDisplayName() + "["
    // + alphaForPrevBackground + "]:" + currTheme.getDisplayName()
    // + "[" + alphaForCurrBackground + "]");

    // At this point the renderer is an instance of
    // SubstanceDefaultTreeCellRenderer
    JTree.DropLocation dropLocation = tree.getDropLocation();
    Rectangle rowRectangle = new Rectangle(this.tree.getInsets().left,
        bounds.y, this.tree.getWidth() - this.tree.getInsets().right
            - this.tree.getInsets().left, bounds.height);
    if (dropLocation != null && dropLocation.getChildIndex() == -1
        && tree.getRowForPath(dropLocation.getPath()) == row) {
      // mark drop location
      SubstanceColorScheme scheme = SubstanceColorSchemeUtilities
          .getColorScheme(tree,
              ColorSchemeAssociationKind.TEXT_HIGHLIGHT,
              currState);
      SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities
          .getColorScheme(tree, ColorSchemeAssociationKind.BORDER,
              currState);
      HighlightPainterUtils.paintHighlight(g2d, this.rendererPane,
          renderer, rowRectangle, 0.8f, null, scheme, borderScheme);
    } else {
      if (hasHighlights) {
        if (activeStates == null) {
          float alpha = SubstanceColorSchemeUtilities
              .getHighlightAlpha(this.tree, currState);
          if (alpha > 0.0f) {
            SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities
                .getColorScheme(this.tree,
                    ColorSchemeAssociationKind.HIGHLIGHT,
                    currState);
            SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities
                .getColorScheme(this.tree,
                    ColorSchemeAssociationKind.HIGHLIGHT,
                    currState);
            g2d.setComposite(LafWidgetUtilities.getAlphaComposite(
                this.tree, alpha, g));
            // Fix for defect 180 - painting the
            // highlight beneath the entire row
            HighlightPainterUtils.paintHighlight(g2d,
                this.rendererPane, renderer, rowRectangle,
                0.8f, null, fillScheme, borderScheme);
            g2d.setComposite(LafWidgetUtilities.getAlphaComposite(
                this.tree, g));
          }
        } else {
          for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> stateEntry : activeStates
              .entrySet()) {
            ComponentState activeState = stateEntry.getKey();
            float alpha = SubstanceColorSchemeUtilities
                .getHighlightAlpha(this.tree, activeState)
                * stateEntry.getValue().getContribution();
            if (alpha == 0.0f)
              continue;
View Full Code Here

      boolean isRollover = (this.currRolloverPathId != null)
          && pathId.equals(this.currRolloverPathId);
      boolean isSelected = this.tree.isRowSelected(rowIndex);
      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

      ButtonModel model, SubstanceFillPainter fillPainter,
      SubstanceBorderPainter borderPainter, int width, int height) {
    TransitionAwareUI transitionAwareUI = (TransitionAwareUI) combo.getUI();
    StateTransitionTracker.ModelStateInfo modelStateInfo = transitionAwareUI
        .getTransitionTracker().getModelStateInfo();
    ComponentState currState = modelStateInfo.getCurrModelState();

    Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo
        .getStateContributionMap();

    ClassicButtonShaper shaper = ClassicButtonShaper.INSTANCE;
    int comboFontSize = SubstanceSizeUtils.getComponentFontSize(combo);
    float radius = SubstanceSizeUtils
        .getClassicButtonCornerRadius(comboFontSize);

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

    HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(width, height,
        baseFillScheme.getDisplayName(), baseBorderScheme
            .getDisplayName(), fillPainter.getDisplayName(),
        borderPainter.getDisplayName(), combo.getClass().getName(),
        radius, comboFontSize);
    BufferedImage layerBase = regularBackgrounds.get(keyBase);
    if (layerBase == null) {
      layerBase = createBackgroundImage(combo, shaper, fillPainter,
          borderPainter, width, height, baseFillScheme,
          baseBorderScheme, radius);
      regularBackgrounds.put(keyBase, layerBase);
    }
    if (currState.isDisabled() || (activeStates.size() == 1)) {
      return layerBase;
    }

    BufferedImage result = SubstanceCoreUtilities.getBlankImage(width,
        height);
    Graphics2D g2d = result.createGraphics();
    // draw the base layer
    g2d.drawImage(layerBase, 0, 0, null);
    // System.out.println("\nPainting base state " + currState);

    // 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;
View Full Code Here

      if (isFlat) {
        // Special handling of flat combos
        extraAlpha = 0.0f;
        for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates
            .entrySet()) {
          ComponentState activeState = activeEntry.getKey();
          if (activeState.isDisabled())
            continue;
          if (activeState == ComponentState.ENABLED)
            continue;
          extraAlpha += activeEntry.getValue().getContribution();
        }
View Full Code Here

    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
    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 = getThumbVertical(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;

      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.