Package org.pushingpixels.substance.internal.ui

Examples of org.pushingpixels.substance.internal.ui.SubstanceTreeUI


    this.hasFocus = hasFocus;
    this.setText(stringValue);

    TreeUI treeUI = tree.getUI();
    if (treeUI instanceof SubstanceTreeUI) {
      SubstanceTreeUI ui = (SubstanceTreeUI) treeUI;
      TreePathId pathId = new TreePathId(tree.getPathForRow(row));
      ComponentState state = ui.getPathState(pathId);
      ComponentState prevState = ui.getPrevPathState(pathId);
      SubstanceColorScheme scheme = (state == ComponentState.DEFAULT) ? ui
          .getDefaultColorScheme()
          : SubstanceColorSchemeUtilities.getColorScheme(tree,
              ColorSchemeAssociationKind.HIGHLIGHT, state);
      if (scheme == null) {
        scheme = SubstanceColorSchemeUtilities.getColorScheme(tree,
            ColorSchemeAssociationKind.HIGHLIGHT, state);
      }

      SubstanceColorScheme prevScheme = scheme;
      if (prevState != state) {
        prevScheme = (prevState == ComponentState.DEFAULT) ? ui
            .getDefaultColorScheme()
            : SubstanceColorSchemeUtilities
                .getColorScheme(tree,
                    ColorSchemeAssociationKind.HIGHLIGHT,
                    prevState);
        if (prevScheme == null) {
          prevScheme = (prevState == ComponentState.DEFAULT) ? SubstanceColorSchemeUtilities
              .getColorScheme(tree, prevState)
              : SubstanceColorSchemeUtilities.getColorScheme(
                  tree, ColorSchemeAssociationKind.HIGHLIGHT,
                  prevState);
        }
      }

      Color color = SubstanceColorUtilities
          .getInterpolatedForegroundColor(tree, pathId, scheme,
              state, prevScheme, prevState, FadeKind.SELECTION,
              FadeKind.ROLLOVER);

      // System.out.println("[" + row + "," + column + "] - "
      // + prevState.name() + ":" + state.name() + ":" + color);

      super.setForeground(new ColorUIResource(color));
    } else {
      if (sel)
        this.setForeground(UIManager
            .getColor("Tree.selectionForeground"));
      else
        this.setForeground(UIManager.getColor("Tree.textForeground"));
    }

    if (SubstanceLookAndFeel.isCurrentLookAndFeel())
      SubstanceStripingUtils.applyStripedBackground(tree, row, this);

    // There needs to be a way to specify disabled icons.
    if (!tree.isEnabled()) {
      this.setEnabled(false);
      if (leaf) {
        this.setDisabledIcon(SubstanceImageCreator
            .toGreyscale(SubstanceImageCreator.makeTransparent(
                tree, this.getDefaultLeafIcon(), 0.5)));
      } else if (expanded) {
        this.setDisabledIcon(SubstanceImageCreator
            .toGreyscale(SubstanceImageCreator.makeTransparent(
                tree, this.getDefaultOpenIcon(), 0.5)));
        // setIcon(SubstanceImageCreator.toGreyscale(
        // SubstanceImageCreator
        // .makeTransparent(getDefaultOpenIcon(), 0.5)));
      } else {
        this.setDisabledIcon(SubstanceImageCreator
            .toGreyscale(SubstanceImageCreator.makeTransparent(
                tree, this.getDefaultClosedIcon(), 0.5)));
        // setIcon(SubstanceImageCreator.toGreyscale(
        // SubstanceImageCreator
        // .makeTransparent(getDefaultClosedIcon(), 0.5)));
      }
    } else {
      this.setEnabled(true);
      if (leaf) {
        this.setIcon(this.getDefaultLeafIcon());
      } else if (expanded) {
        this.setIcon(this.getDefaultOpenIcon());
      } else {
        this.setIcon(this.getDefaultClosedIcon());
      }
    }
    this.setComponentOrientation(tree.getComponentOrientation());

    this.setOpaque(false);

    this.selected = sel;

    if (treeUI instanceof SubstanceTreeUI) {
      SubstanceTreeUI ui = (SubstanceTreeUI) treeUI;
      Insets regInsets = ui.getCellRendererInsets();
      this
          .setBorder(new BorderUIResource.EmptyBorderUIResource(
              regInsets));
    }
View Full Code Here


    this.hasFocus = hasFocus;
    this.setText(stringValue);

    TreeUI treeUI = tree.getUI();
    if (treeUI instanceof SubstanceTreeUI) {
      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();
            aggrRed += schemeFg.getRed() * contribution;
            aggrGreen += schemeFg.getGreen() * contribution;
            aggrBlue += schemeFg.getBlue() * contribution;
          }
          super.setForeground(new ColorUIResource(new Color(
              (int) aggrRed, (int) aggrGreen, (int) aggrBlue)));
        }
      } else {
        SubstanceColorScheme scheme = getColorSchemeForState(tree, ui,
            currState);
        if (isDropLocation) {
          scheme = SubstanceColorSchemeUtilities.getColorScheme(tree,
              ColorSchemeAssociationKind.TEXT_HIGHLIGHT,
              currState);
        }
        super.setForeground(new ColorUIResource(scheme
            .getForegroundColor()));
      }
    } else {
      if (sel)
        this.setForeground(UIManager
            .getColor("Tree.selectionForeground"));
      else
        this.setForeground(UIManager.getColor("Tree.textForeground"));
    }

    if (SubstanceLookAndFeel.isCurrentLookAndFeel())
      SubstanceStripingUtils.applyStripedBackground(tree, row, this);

    // There needs to be a way to specify disabled icons.
    if (!tree.isEnabled()) {
      this.setEnabled(false);
      if (leaf) {
        this.setDisabledIcon(SubstanceImageCreator
            .toGreyscale(SubstanceImageCreator.makeTransparent(
                tree, this.getDefaultLeafIcon(), 0.5)));
      } else if (expanded) {
        this.setDisabledIcon(SubstanceImageCreator
            .toGreyscale(SubstanceImageCreator.makeTransparent(
                tree, this.getDefaultOpenIcon(), 0.5)));
        // setIcon(SubstanceImageCreator.toGreyscale(
        // SubstanceImageCreator
        // .makeTransparent(getDefaultOpenIcon(), 0.5)));
      } else {
        this.setDisabledIcon(SubstanceImageCreator
            .toGreyscale(SubstanceImageCreator.makeTransparent(
                tree, this.getDefaultClosedIcon(), 0.5)));
        // setIcon(SubstanceImageCreator.toGreyscale(
        // SubstanceImageCreator
        // .makeTransparent(getDefaultClosedIcon(), 0.5)));
      }
    } else {
      this.setEnabled(true);
      if (leaf) {
        this.setIcon(this.getDefaultLeafIcon());
      } else if (expanded) {
        this.setIcon(this.getDefaultOpenIcon());
      } else {
        this.setIcon(this.getDefaultClosedIcon());
      }
    }
    this.setComponentOrientation(tree.getComponentOrientation());

    this.setOpaque(false);

    this.selected = sel;

    if (treeUI instanceof SubstanceTreeUI) {
      SubstanceTreeUI ui = (SubstanceTreeUI) treeUI;
      Insets regInsets = ui.getCellRendererInsets();
      this
          .setBorder(new BorderUIResource.EmptyBorderUIResource(
              regInsets));
    }

View Full Code Here

TOP

Related Classes of org.pushingpixels.substance.internal.ui.SubstanceTreeUI

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.