Package org.pushingpixels.substance.api.painter.fill

Examples of org.pushingpixels.substance.api.painter.fill.SubstanceFillPainter


    insets.top /= 2;
    insets.left /= 2;
    insets.bottom /= 2;
    insets.right /= 2;

    SubstanceFillPainter fillPainter = SubstanceCoreUtilities
        .getFillPainter(this.slider);
    SubstanceBorderPainter borderPainter = SubstanceCoreUtilities
        .getBorderPainter(this.slider);
    float radius = SubstanceSizeUtils
        .getClassicButtonCornerRadius(SubstanceSizeUtils
            .getComponentFontSize(slider)) / 2.0f;
    int borderDelta = (int) Math.floor(SubstanceSizeUtils
        .getBorderStrokeWidth(SubstanceSizeUtils
            .getComponentFontSize(slider)) / 2.0);

    // fill selected portion
    if (this.slider.isEnabled()) {
      if (this.slider.getOrientation() == SwingConstants.HORIZONTAL) {
        int middleOfThumb = this.thumbRect.x
            + (this.thumbRect.width / 2) - paintRect.x;
        int fillMinX;
        int fillMaxX;

        if (drawInverted) {
          fillMinX = middleOfThumb;
          fillMaxX = width;
        } else {
          fillMinX = 0;
          fillMaxX = middleOfThumb;
        }

        int fillWidth = fillMaxX - fillMinX;
        int fillHeight = height + 1;
        if ((fillWidth > 0) && (fillHeight > 0)) {
          Shape contour = SubstanceOutlineUtilities.getBaseOutline(
              fillWidth, fillHeight, radius, null, borderDelta);
          g2d.translate(fillMinX, 0);
          fillPainter.paintContourBackground(g2d, this.slider,
              fillWidth, fillHeight, contour, false, fillScheme,
              false);
          borderPainter.paintBorder(g2d, this.slider, fillWidth,
              fillHeight, contour, null, borderScheme);
        }
      } else {
        int middleOfThumb = this.thumbRect.y
            + (this.thumbRect.height / 2) - paintRect.y;
        int fillMin;
        int fillMax;

        if (this.drawInverted()) {
          fillMin = 0;
          fillMax = middleOfThumb;
          // fix for issue 368 - inverted vertical sliders
          g2d.translate(width + 2 - middleOfThumb, 0);
        } else {
          fillMin = middleOfThumb;
          fillMax = width + 1;
        }

        int fillWidth = fillMax - fillMin;
        int fillHeight = height + 1;
        if ((fillWidth > 0) && (fillHeight > 0)) {
          Shape contour = SubstanceOutlineUtilities.getBaseOutline(
              fillWidth, fillHeight, radius, null, borderDelta);

          fillPainter.paintContourBackground(g2d, this.slider,
              fillWidth, fillHeight, contour, false, fillScheme,
              false);
          borderPainter.paintBorder(g2d, this.slider, fillWidth,
              fillHeight, contour, null, borderScheme);
        }
View Full Code Here


      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)
          continue;

        SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities
            .getColorScheme(slider, activeState);
        SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities
            .getColorScheme(slider,
                ColorSchemeAssociationKind.BORDER, activeState);

        HashMapKey key = SubstanceCoreUtilities.getHashKey(this.size,
            width, fillScheme.getDisplayName(), borderScheme
                .getDisplayName(),
            fillPainter.getDisplayName(), borderPainter
                .getDisplayName(), this.isMirrorred);

        Icon layer = SliderHorizontalIcon.icons.get(key);
        if (layer == null) {
          layer = getSingleLayer(slider, width, delta, fillPainter,
View Full Code Here

      width = Math.min(width, this.size - 2);
      if (width % 2 == 0)
        width--;
      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());

      Icon baseLayer = SliderRoundIcon.icons.get(baseKey);
      if (baseLayer == null) {
        baseLayer = getSingleLayer(slider, width, delta, fillPainter,
            borderPainter, baseFillScheme, baseBorderScheme);
        SliderRoundIcon.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)
          continue;

        SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities
            .getColorScheme(slider, activeState);
        SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities
            .getColorScheme(slider,
                ColorSchemeAssociationKind.BORDER, activeState);

        HashMapKey key = SubstanceCoreUtilities.getHashKey(this.size,
            width, fillScheme.getDisplayName(), borderScheme
                .getDisplayName(),
            fillPainter.getDisplayName(), borderPainter
                .getDisplayName());

        Icon layer = SliderRoundIcon.icons.get(key);
        if (layer == null) {
          layer = getSingleLayer(slider, width, delta, fillPainter,
View Full Code Here

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

      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,
          height, slider.getComponentOrientation(), baseFillScheme
              .getDisplayName(), baseBorderScheme
              .getDisplayName(), fillPainter.getDisplayName(),
          borderPainter.getDisplayName(), this.isMirrorred);

      Icon baseLayer = SliderVerticalIcon.icons.get(baseKey);
      if (baseLayer == null) {
        baseLayer = getSingleLayer(slider, height, delta, fillPainter,
            borderPainter, baseFillScheme, baseBorderScheme);
        SliderVerticalIcon.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)
          continue;

        SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities
            .getColorScheme(slider, activeState);
        SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities
            .getColorScheme(slider,
                ColorSchemeAssociationKind.BORDER, activeState);

        HashMapKey key = SubstanceCoreUtilities.getHashKey(this.size,
            height, slider.getComponentOrientation(), fillScheme
                .getDisplayName(), borderScheme
                .getDisplayName(),
            fillPainter.getDisplayName(), borderPainter
                .getDisplayName(), this.isMirrorred);

        Icon layer = SliderVerticalIcon.icons.get(key);
        if (layer == null) {
          layer = getSingleLayer(slider, height, delta, fillPainter,
View Full Code Here

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

    SubstanceFillPainter fillPainter = SubstanceCoreUtilities
        .isSpinnerButton(button) ? MatteFillPainter.INSTANCE
        : SubstanceImageCreator.SimplisticSoftBorderReverseFillPainter.INSTANCE;

    BufferedImage baseLayer = getPairwiseFullAlphaBackground(button,
        fillPainter, shaper, width, height, side, baseFillScheme,
View Full Code Here

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

    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);
    boolean isCheckMarkFadingOut = !currState
        .isFacetActive(ComponentStateFacet.SELECTION);

    int fontSize = SubstanceSizeUtils.getComponentFontSize(this.menuItem);
    int checkMarkSize = this.size + 3;

    HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(fontSize,
        checkMarkSize, fillPainter.getDisplayName(), borderPainter
            .getDisplayName(),
        baseFillColorScheme.getDisplayName(), baseMarkColorScheme
            .getDisplayName(), baseBorderColorScheme
            .getDisplayName(), visibility, isCheckMarkFadingOut);
    Icon iconBase = iconMap.get(keyBase);
    if (iconBase == null) {
      iconBase = new ImageIcon(SubstanceImageCreator.getCheckBox(
          this.menuItem, fillPainter, borderPainter, checkMarkSize,
          currState, baseFillColorScheme, baseMarkColorScheme,
          baseBorderColorScheme, visibility, isCheckMarkFadingOut));
      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;

      float stateContribution = activeEntry.getValue().getContribution();
      if (stateContribution > 0.0f) {
        g2d.setComposite(AlphaComposite.SrcOver
            .derive(stateContribution));
        SubstanceColorScheme fillColorScheme = SubstanceColorSchemeUtilities
            .getColorScheme(this.menuItem,
                ColorSchemeAssociationKind.FILL, activeState);
        SubstanceColorScheme markColorScheme = SubstanceColorSchemeUtilities
            .getColorScheme(this.menuItem,
                ColorSchemeAssociationKind.MARK, activeState);
        SubstanceColorScheme borderColorScheme = SubstanceColorSchemeUtilities
            .getColorScheme(this.menuItem,
                ColorSchemeAssociationKind.BORDER, activeState);

        HashMapKey keyLayer = SubstanceCoreUtilities.getHashKey(
            fontSize, checkMarkSize, fillPainter.getDisplayName(),
            borderPainter.getDisplayName(), fillColorScheme
                .getDisplayName(), markColorScheme
                .getDisplayName(), borderColorScheme
                .getDisplayName(), visibility);
        Icon iconLayer = iconMap.get(keyLayer);
View Full Code Here

TOP

Related Classes of org.pushingpixels.substance.api.painter.fill.SubstanceFillPainter

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.