Java Code Examples for org.pushingpixels.substance.internal.animation.StateTransitionTracker

The following examples show how to use org.pushingpixels.substance.internal.animation.StateTransitionTracker. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Simple constructor.
 * 
 * @param c
 *            Component (text field).
 */
private SubstanceTextFieldUI(JComponent c) {
    super();
    this.textField = (JTextField) c;

    this.transitionModel = new DefaultButtonModel();
    this.transitionModel.setArmed(false);
    this.transitionModel.setSelected(false);
    this.transitionModel.setPressed(false);
    this.transitionModel.setRollover(false);
    this.transitionModel.setEnabled(this.textField.isEnabled());

    this.stateTransitionTracker = new StateTransitionTracker(this.textField,
            this.transitionModel);
    this.stateTransitionTracker.setRepaintCallback(
            () -> SubstanceCoreUtilities.getTextComponentRepaintCallback(textField));
}
 
Example 2
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    if (!(g instanceof Graphics2D)) {
        return;
    }

    JSlider slider = (JSlider) c;
    TransitionAwareUI transitionAwareUI = (TransitionAwareUI) slider.getUI();
    StateTransitionTracker stateTransitionTracker = transitionAwareUI
            .getTransitionTracker();
    Icon iconToDraw = getIcon(slider, stateTransitionTracker);
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.translate(x, y);
    iconToDraw.paintIcon(c, g, 0, 0);
    g2d.dispose();
}
 
Example 3
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    if (!(g instanceof Graphics2D)) {
        return;
    }

    JSlider slider = (JSlider) c;
    TransitionAwareUI transitionAwareUI = (TransitionAwareUI) slider.getUI();
    StateTransitionTracker stateTransitionTracker = transitionAwareUI
            .getTransitionTracker();
    Icon iconToDraw = getIcon(slider, stateTransitionTracker);
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.translate(x, y);
    iconToDraw.paintIcon(c, g, 0, 0);
    g2d.dispose();
}
 
Example 4
/**
 * Paints the text of the specified button.
 * 
 * @param g
 *            Graphic context.
 * @param button
 *            Button
 * @param model
 *            Button model.
 * @param textRect
 *            Text rectangle
 * @param text
 *            Text to paint
 * @param mnemonicIndex
 *            Mnemonic index.
 */
public static void paintText(Graphics g, AbstractButton button, ButtonModel model,
        Rectangle textRect, String text, int mnemonicIndex) {
    TransitionAwareUI transitionAwareUI = (TransitionAwareUI) button.getUI();
    StateTransitionTracker stateTransitionTracker = transitionAwareUI.getTransitionTracker();

    if (button instanceof JMenuItem) {
        // A slightly different path for menu items as we ignore the selection
        // state for visual consistency in menu content
        float menuItemAlpha = SubstanceColorSchemeUtilities.getAlpha(button,
                ComponentState.getState(button.getModel(), button, true));
        paintMenuItemText(g, (JMenuItem) button, textRect, text, mnemonicIndex,
                stateTransitionTracker.getModelStateInfo(), menuItemAlpha);
    } else {
        float buttonAlpha = SubstanceColorSchemeUtilities.getAlpha(button,
                ComponentState.getState(button));
        paintText(g, button, textRect, text, mnemonicIndex,
                stateTransitionTracker.getModelStateInfo(), buttonAlpha);
    }
}
 
Example 5
/**
 * Returns the foreground color for the specified component.
 * 
 * @param component
 *            Component.
 * @param text
 *            Text. If empty or <code>null</code>, the result is <code>null</code>.
 * @param textAlpha
 *            Alpha channel for painting the text. If value is less than 1.0, the result is an
 *            opaque color which is an interpolation between the "real" foreground color and the
 *            background color of the component. This is done to ensure that native text
 *            rasterization will be performed on 6u10 on Windows.
 * @return The foreground color for the specified component.
 */
public static Color getForegroundColor(JComponent component, String text,
        StateTransitionTracker.ModelStateInfo modelStateInfo, float textAlpha) {
    if ((text == null) || (text.length() == 0))
        return null;

    boolean toEnforceFgColor = (SwingUtilities.getAncestorOfClass(CellRendererPane.class, component) != null)
            || Boolean.TRUE.equals(component.getClientProperty(ENFORCE_FG_COLOR));

    Color fgColor = null;
    if (toEnforceFgColor) {
        fgColor = component.getForeground();
    } else {
        fgColor = SubstanceColorUtilities.getForegroundColor(component, modelStateInfo);
    }

    if (textAlpha < 1.0f) {
        Color bgFillColor = SubstanceColorUtilities.getBackgroundFillColor(component);
        fgColor = SubstanceColorUtilities.getInterpolatedColor(fgColor, bgFillColor, textAlpha);
    }
    return fgColor;
}
 
Example 6
/**
 * Returns the current state for the specified tab.
 * 
 * @param tabIndex
 *            Tab index.
 * @return The current state for the specified tab.
 */
protected ComponentState getTabState(int tabIndex, boolean toAllowIgnoringSelectedState) {
    boolean isEnabled = this.tabPane.isEnabledAt(tabIndex);
    StateTransitionTracker tracker = this.stateTransitionMultiTracker.getTracker(tabIndex);
    boolean ignoreSelectedState = toAllowIgnoringSelectedState
            && (SubstanceCoreUtilities.getSkin(tabPane).getTabFadeEnd() <= 0.5);
    if (tracker == null) {
        boolean isRollover = this.getRolloverTabIndex() == tabIndex;
        boolean isSelected = ignoreSelectedState ? false
                : this.tabPane.getSelectedIndex() == tabIndex;
        return ComponentState.getState(isEnabled, isRollover, isSelected);
    } else {
        ComponentState fromTracker = ignoreSelectedState
                ? tracker.getModelStateInfo().getCurrModelStateNoSelection()
                : tracker.getModelStateInfo().getCurrModelState();
        return fromTracker;
        // return ComponentState.getState(isEnabled,
        // fromTracker.isFacetActive(ComponentStateFacet.ROLLOVER),
        // ignoreSelectedState ? false :
        // fromTracker.isFacetActive(ComponentStateFacet.SELECTION));
    }
}
 
Example 7
/**
 * Returns the current state for the specified path.
 * 
 * @param pathId
 *            Path index.
 * @return The current state for the specified path.
 */
public ComponentState getPathState(TreePathId pathId) {
	boolean isEnabled = this.tree.isEnabled();
	StateTransitionTracker tracker = this.stateTransitionMultiTracker.getTracker(pathId);
	if (tracker == null) {
		int rowIndex = this.tree.getRowForPath(pathId.path);
		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));
	}
}
 
Example 8
public StateTransitionTracker.ModelStateInfo getModelStateInfo(int row,
        Component rendererComponent) {
    if (this.stateTransitionMultiTracker.size() == 0)
        return null;
    StateTransitionTracker tracker = this.stateTransitionMultiTracker.getTracker(row);
    if (tracker == null) {
        return null;
    } else {
        return tracker.getModelStateInfo();
    }
}
 
Example 9
/**
 * Initiates the fade out effect.
 */
private void fadeOutRolloverIndication() {
    if (rolledOverIndex < 0)
        return;

    StateTransitionTracker tracker = getTracker(rolledOverIndex, true,
            list.isSelectedIndex(rolledOverIndex));
    tracker.getModel().setRollover(false);
}
 
Example 10
/**
 * Returns the current state for the specified cell.
 * 
 * @param cellIndex
 *            Cell index.
 * @return The current state for the specified cell.
 */
public ComponentState getCellState(TableCellId cellIndex) {
    boolean isEnabled = this.table.isEnabled();

    StateTransitionTracker tracker = this.stateTransitionMultiTracker.getTracker(cellIndex);
    if (tracker == null) {
        int row = cellIndex.row;
        int column = cellIndex.column;
        TableCellId cellId = this.getId(row, column);
        boolean isRollover = _hasRolloverAnimations() ? rolledOverIndices.contains(cellId) :
                (row == rolledOverRow);
        boolean isSelected = false;
        boolean hasSelectionAnimations = (this.updateInfo != null)
                ? this.updateInfo.hasSelectionAnimations
                : this._hasSelectionAnimations();
        if (hasSelectionAnimations && AnimationConfigurationManager.getInstance()
                .isAnimationAllowed(AnimationFacet.SELECTION, table))
            isSelected = this.selectedIndices.containsKey(cellId);
        else {
            isSelected = this.table.isCellSelected(row, column);
        }
        return ComponentState.getState(isEnabled, isRollover, isSelected);
    } else {
        ComponentState fromTracker = tracker.getModelStateInfo().getCurrModelState();
        return ComponentState.getState(isEnabled,
                fromTracker.isFacetActive(ComponentStateFacet.ROLLOVER),
                fromTracker.isFacetActive(ComponentStateFacet.SELECTION));
    }
}
 
Example 11
/**
 * Initiates the fade out effect.
 */
private void fadeOutTableHeader() {
    if (SubstanceTableUI.this.rolledOverColumn >= 0) {
        JTableHeader header = SubstanceTableUI.this.table.getTableHeader();
        if ((header == null) || (!header.isVisible()))
            return;
        SubstanceTableHeaderUI ui = (SubstanceTableHeaderUI) header.getUI();

        TableColumnModel columnModel = header.getColumnModel();
        StateTransitionTracker columnTransitionTracker = ui.getTracker(rolledOverColumn,
                true, columnModel.getColumnSelectionAllowed() && columnModel
                        .getSelectionModel().isSelectedIndex(rolledOverColumn));
        columnTransitionTracker.getModel().setRollover(false);
    }
}
 
Example 12
/**
 * Tracks possible usage of glowing icon.
 */
private void trackGlowingIcon() {
    ResizableIcon currIcon = this.commandButton.getIcon();
    if (currIcon instanceof GlowingResizableIcon)
        return;
    if (currIcon == null)
        return;
    boolean isPopupOnly = ((JCommandButton) this.commandButton)
            .getCommandButtonKind() == JCommandButton.CommandButtonKind.POPUP_ONLY;
    StateTransitionTracker tracker = isPopupOnly
            ? this.substanceVisualStateTracker.getPopupStateTransitionTracker()
            : this.substanceVisualStateTracker.getActionStateTransitionTracker();
    this.glowingIcon = new GlowingResizableIcon(currIcon, tracker.getIconGlowTracker());
}
 
Example 13
private void paintButtonIconRegular(Graphics g, Rectangle iconRect) {
    JCommandButton jcb = (JCommandButton) this.commandButton;
    Icon regular = jcb.getIcon();
    if (toUseDisabledIcon() && (jcb.getDisabledIcon() != null) && ((regular != null)
            && !regular.getClass().isAnnotationPresent(TransitionAware.class))) {
        regular = jcb.getDisabledIcon();
    }

    if ((iconRect == null) || (regular == null) || (iconRect.width == 0)
            || (iconRect.height == 0)) {
        return;
    }

    Graphics2D g2d = (Graphics2D) g.create();

    GhostPaintingUtils.paintGhostIcon(g2d, jcb, regular, iconRect);
    g2d.setComposite(WidgetUtilities.getAlphaComposite(jcb, g));

    StateTransitionTracker tracker = this.substanceVisualStateTracker
            .getActionStateTransitionTracker();
    ButtonModel model = commandButton.getActionModel();
    if (jcb.getCommandButtonKind() == CommandButtonKind.POPUP_ONLY) {
        tracker = this.substanceVisualStateTracker.getPopupStateTransitionTracker();
        model = jcb.getPopupModel();
    }
    CommandButtonBackgroundDelegate.paintCommandButtonIcon(g2d, iconRect, jcb, regular,
            this.glowingIcon, model, tracker);
    g2d.dispose();
}
 
Example 14
private static Color getMenuButtonForegroundColor(AbstractCommandButton menuButton,
        StateTransitionTracker.ModelStateInfo modelStateInfo) {
    ComponentState currState = modelStateInfo.getCurrModelStateNoSelection();
    Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo
            .getStateNoSelectionContributionMap();

    SubstanceSlices.ColorSchemeAssociationKind currAssocKind = SubstanceSlices.ColorSchemeAssociationKind.FILL;
    // use HIGHLIGHT on active and non-rollover menu items
    if (!currState.isDisabled() && (currState != ComponentState.ENABLED)
            && !currState.isFacetActive(SubstanceSlices.ComponentStateFacet.ROLLOVER))
        currAssocKind = SubstanceSlices.ColorSchemeAssociationKind.HIGHLIGHT;
    SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities.getColorScheme(menuButton,
            currAssocKind, currState);
    if (currState.isDisabled() || (activeStates == null) || (activeStates.size() == 1)) {
        return colorScheme.getForegroundColor();
    }

    float aggrRed = 0;
    float aggrGreen = 0;
    float aggrBlue = 0;
    for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates
            .entrySet()) {
        ComponentState activeState = activeEntry.getKey();
        float alpha = activeEntry.getValue().getContribution();
        SubstanceSlices.ColorSchemeAssociationKind assocKind = SubstanceSlices.ColorSchemeAssociationKind.FILL;
        // use HIGHLIGHT on active and non-rollover menu items
        if (!activeState.isDisabled() && (activeState != ComponentState.ENABLED)
                && !activeState.isFacetActive(SubstanceSlices.ComponentStateFacet.ROLLOVER))
            assocKind = SubstanceSlices.ColorSchemeAssociationKind.HIGHLIGHT;
        SubstanceColorScheme activeColorScheme = SubstanceColorSchemeUtilities
                .getColorScheme(menuButton, assocKind, activeState);
        Color activeForeground = activeColorScheme.getForegroundColor();
        aggrRed += alpha * activeForeground.getRed();
        aggrGreen += alpha * activeForeground.getGreen();
        aggrBlue += alpha * activeForeground.getBlue();
    }
    return new Color((int) aggrRed, (int) aggrGreen, (int) aggrBlue);
}
 
Example 15
/**
 * Simple constructor.
 * 
 * @param b
 *            The associated button.
 */
public RolloverButtonListener(AbstractButton b,
		StateTransitionTracker stateTransitionTracker) {
	super(b);
	this.button = b;
	this.isMouseInside = false;
	this.stateTransitionTracker = stateTransitionTracker;
}
 
Example 16
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    if (!(g instanceof Graphics2D)) {
        return;
    }

    JSlider slider = (JSlider) c;
    TransitionAwareUI transitionAwareUI = (TransitionAwareUI) slider.getUI();
    StateTransitionTracker stateTransitionTracker = transitionAwareUI.getTransitionTracker();
    Icon iconToDraw = getIcon(slider, stateTransitionTracker);
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.translate(x, y);
    iconToDraw.paintIcon(c, g, 0, 0);
    g2d.dispose();
}
 
Example 17
public static void paintText(Graphics g, JComponent component, Rectangle textRect, String text,
        int mnemonicIndex, StateTransitionTracker.ModelStateInfo modelStateInfo,
        float textAlpha) {
    Color fgColor = getForegroundColor(component, text, modelStateInfo, textAlpha);

    SubstanceTextUtilities.paintText(g, component, textRect, text, mnemonicIndex,
            component.getFont(), fgColor, null);
}
 
Example 18
public static void paintMenuItemText(Graphics g, JMenuItem menuItem, Rectangle textRect,
        String text, int mnemonicIndex, StateTransitionTracker.ModelStateInfo modelStateInfo,
        float textAlpha) {
    Color fgColor = getMenuComponentForegroundColor(menuItem, text, modelStateInfo, textAlpha);

    SubstanceTextUtilities.paintText(g, menuItem, textRect, text, mnemonicIndex,
            menuItem.getFont(), fgColor, null);
}
 
Example 19
public static Color getTextBackgroundFillColor(JComponent comp) {
    Color backgroundFillColor = SubstanceColorUtilities.getBackgroundFillColor(comp);

    JTextComponent componentForTransitions = SubstanceCoreUtilities
            .getTextComponentForTransitions(comp);

    if (componentForTransitions != null) {
        ComponentUI ui = componentForTransitions.getUI();
        if (ui instanceof TransitionAwareUI) {
            TransitionAwareUI trackable = (TransitionAwareUI) ui;
            StateTransitionTracker stateTransitionTracker = trackable.getTransitionTracker();

            Color lighterFill = SubstanceColorUtilities.getLighterColor(backgroundFillColor,
                    0.4f);
            lighterFill = SubstanceColorUtilities.getInterpolatedColor(lighterFill,
                    backgroundFillColor, 0.6);

            float selectionStrength = stateTransitionTracker
                    .getFacetStrength(ComponentStateFacet.SELECTION);
            float rolloverStrength = stateTransitionTracker
                    .getFacetStrength(ComponentStateFacet.ROLLOVER);
            backgroundFillColor = SubstanceColorUtilities.getInterpolatedColor(lighterFill,
                    backgroundFillColor, Math.max(selectionStrength, rolloverStrength) / 4.0f);
        }
    }
    return backgroundFillColor;
}
 
Example 20
/**
 * Simple constructor.
 * 
 * @param item
 *            The associated menu item.
 */
public RolloverMenuItemListener(JMenuItem item,
		StateTransitionTracker stateTransitionTracker) {
	this.item = item;
	this.stateTransitionTracker = stateTransitionTracker;
	this.isMouseInside = false;
}
 
Example 21
/**
 * Handles various mouse move events and initiates the fade animation if necessary.
 * 
 * @param e
 *            Mouse event.
 */
private void handleMoveForHeader(MouseEvent e) {
    if (!SubstanceTableUI.this.table.getColumnSelectionAllowed())
        return;
    JTableHeader header = SubstanceTableUI.this.table.getTableHeader();
    if ((header == null) || (!header.isVisible()))
        return;

    TableHeaderUI ui = header.getUI();
    if (!(ui instanceof SubstanceTableHeaderUI))
        return;

    SubstanceTableHeaderUI sthui = (SubstanceTableHeaderUI) ui;

    // synchronized (SubstanceTableUI.this.table) {
    int row = SubstanceTableUI.this.table.rowAtPoint(e.getPoint());
    int column = SubstanceTableUI.this.table.columnAtPoint(e.getPoint());
    if ((row < 0) || (row >= SubstanceTableUI.this.table.getRowCount()) || (column < 0)
            || (column >= SubstanceTableUI.this.table.getColumnCount())) {
        this.fadeOutTableHeader();
        // System.out.println("Nulling RO column index");
        SubstanceTableUI.this.rolledOverColumn = -1;
    } else {
        // check if this is the same column
        if (SubstanceTableUI.this.rolledOverColumn == column)
            return;

        this.fadeOutTableHeader();

        TableColumnModel columnModel = header.getColumnModel();
        StateTransitionTracker columnTransitionTracker = sthui.getTracker(column, false,
                columnModel.getColumnSelectionAllowed()
                        && columnModel.getSelectionModel().isSelectedIndex(column));
        columnTransitionTracker.getModel().setRollover(true);

        SubstanceTableUI.this.rolledOverColumn = column;
    }
    // }
}
 
Example 22
/**
 * Returns the foreground text color of the specified menu component.
 *
 * @param menuComponent  Menu component.
 * @param modelStateInfo Model state info for the component.
 * @return The foreground text color of the specified menu component.
 */
public static Color getMenuComponentForegroundColor(JMenuItem menuComponent,
        StateTransitionTracker.ModelStateInfo modelStateInfo) {
    ComponentState currState = modelStateInfo.getCurrModelStateNoSelection();
    Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates =
            modelStateInfo.getStateNoSelectionContributionMap();

    ColorSchemeAssociationKind currAssocKind = ColorSchemeAssociationKind.FILL;
    // use HIGHLIGHT on active menu items
    if (!currState.isDisabled() && (currState != ComponentState.ENABLED))
        currAssocKind = ColorSchemeAssociationKind.HIGHLIGHT;
    SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities
            .getColorScheme(menuComponent, currAssocKind, currState);
    if (currState.isDisabled() || (activeStates == null)
            || (activeStates.size() == 1)) {
        return colorScheme.getForegroundColor();
    }

    float aggrRed = 0;
    float aggrGreen = 0;
    float aggrBlue = 0;
    for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry :
            activeStates.entrySet()) {
        ComponentState activeState = activeEntry.getKey();
        float alpha = activeEntry.getValue().getContribution();
        ColorSchemeAssociationKind assocKind = ColorSchemeAssociationKind.FILL;
        // use HIGHLIGHT on active menu items
        if (!activeState.isDisabled()
                && (activeState != ComponentState.ENABLED))
            assocKind = ColorSchemeAssociationKind.HIGHLIGHT;
        SubstanceColorScheme activeColorScheme = SubstanceColorSchemeUtilities
                .getColorScheme(menuComponent, assocKind, activeState);
        Color activeForeground = activeColorScheme.getForegroundColor();
        aggrRed += alpha * activeForeground.getRed();
        aggrGreen += alpha * activeForeground.getGreen();
        aggrBlue += alpha * activeForeground.getBlue();
    }
    return new Color((int) aggrRed, (int) aggrGreen, (int) aggrBlue);
}
 
Example 23
/**
 * Installs tracking listeners on the specified button.
 * 
 * @param b
 *            Button.
 * @param toInstallRolloverListener
 *            If <code>true</code>, the button will have the rollover
 *            listener installed on it.
 */
public void installListeners(final AbstractButton b, boolean toInstallRolloverListener) {
	this.stateTransitionTracker = new StateTransitionTracker(b, b.getModel());
	if (b instanceof SubstanceScrollButton) {
		this.stateTransitionTracker.setRepaintCallback(() -> {
				JScrollBar scrollBar = (JScrollBar) SwingUtilities
						.getAncestorOfClass(JScrollBar.class, b);
			return new SwingRepaintCallback(Objects.requireNonNullElse(scrollBar, b));
		});
	}
	this.stateTransitionTracker.registerModelListeners();
	this.stateTransitionTracker.registerFocusListeners();
	if (toInstallRolloverListener) {
		this.substanceButtonListener = new RolloverButtonListener(b,
				this.stateTransitionTracker);
		b.addMouseListener(this.substanceButtonListener);
		b.addMouseMotionListener(this.substanceButtonListener);
		b.addFocusListener(this.substanceButtonListener);
		b.addPropertyChangeListener(this.substanceButtonListener);
		b.addChangeListener(this.substanceButtonListener);
	}

	this.substancePropertyListener = (PropertyChangeEvent evt) -> {
		if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt.getPropertyName())) {
			stateTransitionTracker.setModel((ButtonModel) evt.getNewValue());
		}
	};
	b.addPropertyChangeListener(this.substancePropertyListener);
}
 
Example 24
/**
 * Handles various mouse move events and initiates the fade animation if necessary.
 *
 * @param e Mouse event.
 */
private void handleMove(MouseEvent e) {
    // no rollover effects on non-Substance renderers
    ListCellRenderer cellRenderer = list.getCellRenderer();
    boolean isSubstanceRenderer =
            (cellRenderer instanceof SubstanceDefaultListCellRenderer) ||
                    (cellRenderer instanceof SubstancePanelListCellRenderer);
    if (!isSubstanceRenderer) {
        fadeOutRolloverIndication();
        resetRolloverIndex();
        return;
    }

    int roIndex = list.locationToIndex(e.getPoint());
    if ((roIndex >= 0) && (roIndex < list.getModel().getSize())) {
        // test actual hit
        if (!list.getCellBounds(roIndex, roIndex).contains(e.getPoint())) {
            roIndex = -1;
        }
    }
    if ((roIndex < 0) || (roIndex >= list.getModel().getSize())) {
        fadeOutRolloverIndication();
        // System.out.println("Nulling RO index");
        resetRolloverIndex();
    } else {
        // check if this is the same index
        if ((rolledOverIndex >= 0) && (rolledOverIndex == roIndex))
            return;

        fadeOutRolloverIndication();

        // rollover on a new row
        StateTransitionTracker tracker = getTracker(roIndex, false,
                list.isSelectedIndex(roIndex));
        tracker.getModel().setRollover(true);
        rolledOverIndex = roIndex;
    }
}
 
Example 25
public StateTransitionTracker.ModelStateInfo getModelStateInfo(int columnIndex) {
    if (this.stateTransitionMultiTracker.size() == 0)
        return null;
    StateTransitionTracker tracker = this.stateTransitionMultiTracker.getTracker(columnIndex);
    if (tracker == null) {
        return null;
    } else {
        return tracker.getModelStateInfo();
    }
}
 
Example 26
/**
 * Creates the UI delegate for the specified component (password field).
 *
 * @param c Component.
 */
private SubstancePasswordFieldUI(JComponent c) {
    super();
    this.passwordField = (JPasswordField) c;

    this.transitionModel = new DefaultButtonModel();
    this.transitionModel.setArmed(false);
    this.transitionModel.setSelected(false);
    this.transitionModel.setPressed(false);
    this.transitionModel.setRollover(false);
    this.transitionModel.setEnabled(this.passwordField.isEnabled());

    this.stateTransitionTracker = new StateTransitionTracker(this.passwordField,
            this.transitionModel);
}
 
Example 27
private StateTransitionTracker.ModelStateInfo getModelStateInfo(int tabIndex) {
    if (this.stateTransitionMultiTracker.size() == 0)
        return null;
    StateTransitionTracker tracker = this.stateTransitionMultiTracker.getTracker(tabIndex);
    if (tracker == null) {
        return null;
    } else {
        return tracker.getModelStateInfo();
    }
}
 
Example 28
@Override
protected void paintIcon(Graphics g, int tabPlacement, int tabIndex, Icon icon,
        Rectangle iconRect, boolean isSelected) {
    if (icon == null)
        return;

    Graphics2D g2d = (Graphics2D) g.create();
    g2d.translate(iconRect.x, iconRect.y);
    if (SubstanceCoreUtilities.useThemedDefaultIcon(this.tabPane)) {
        ComponentState currState = this.getTabState(tabIndex, true);
        StateTransitionTracker tabTracker = stateTransitionMultiTracker.getTracker(tabIndex);

        if (tabTracker == null) {
            if (currState.isFacetActive(ComponentStateFacet.ROLLOVER)
                    || currState.isFacetActive(ComponentStateFacet.SELECTION)
                    || currState.isDisabled()) {
                // use the original (full color or disabled) icon
                icon.paintIcon(this.tabPane, g2d, 0, 0);
                return;
            }
        }

        Icon themed = SubstanceCoreUtilities.getThemedIcon(this.tabPane, tabIndex, icon);
        if (tabTracker == null) {
            themed.paintIcon(this.tabPane, g2d, 0, 0);
        } else {
            icon.paintIcon(this.tabPane, g2d, 0, 0);
            g2d.setComposite(WidgetUtilities.getAlphaComposite(this.tabPane,
                    1.0f - tabTracker.getFacetStrength(ComponentStateFacet.ROLLOVER), g2d));
            themed.paintIcon(this.tabPane, g2d, 0, 0);
        }
    } else {
        icon.paintIcon(this.tabPane, g2d, 0, 0);
    }
    g2d.dispose();
}
 
Example 29
/**
 * Handles various mouse move events and initiates the fade animation if
 * necessary.
 * 
 * @param e
 *            Mouse event.
 */
private void handleMove(MouseEvent e) {
	TreePath closestPath = tree.getClosestPathForLocation(e.getX(), e.getY());
	Rectangle bounds = tree.getPathBounds(closestPath);
	if (bounds == null) {
		this.fadeOut();
		currRolloverPathId = null;
		return;
	}
	if ((e.getY() < bounds.y) || (e.getY() > (bounds.y + bounds.height))) {
		this.fadeOut();
		currRolloverPathId = null;
		return;
	}
	// check if this is the same index
	TreePathId newPathId = new TreePathId(closestPath);
	if ((currRolloverPathId != null) && newPathId.equals(currRolloverPathId)) {
		// System.out.println("Same location " +
		// System.currentTimeMillis());
		// System.out.print("Current : ");
		// for (Object o1 : currPathId.path.getPath()) {
		// System.out.print(o1);
		// }
		// System.out.println("");
		// System.out.print("Closest : ");
		// for (Object o2 : newPathId.path.getPath()) {
		// System.out.print(o2);
		// }
		// System.out.println("");
		return;
	}

	this.fadeOut();

	StateTransitionTracker tracker = getTracker(newPathId, false,
			selectedPaths.containsKey(newPathId));
	tracker.getModel().setRollover(true);

	currRolloverPathId = newPathId;
}
 
Example 30
/**
 * Initiates the fade out effect.
 */
private void fadeOut() {
	if (currRolloverPathId == null)
		return;

	StateTransitionTracker tracker = getTracker(currRolloverPathId, true,
			selectedPaths.containsKey(currRolloverPathId));
	tracker.getModel().setRollover(false);
}