001: /*
002: * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of Substance Kirill Grouchnikov nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030: package org.jvnet.substance.painter.highlight;
031:
032: import java.awt.*;
033: import java.util.Set;
034:
035: import org.jvnet.substance.SubstanceLookAndFeel;
036: import org.jvnet.substance.color.ColorScheme;
037: import org.jvnet.substance.utils.SubstanceConstants.Side;
038:
039: /**
040: * Utilities for painting higlight backgrounds.
041: *
042: * @author Kirill Grouchnikov
043: */
044: public class SubstanceHighlightUtils {
045: // /**
046: // * Updates the specified component with the background that matches the
047: // * provided parameters.
048: // *
049: // * @param g
050: // * Graphic context.
051: // * @param c
052: // * Component.
053: // * @param width
054: // * Background width.
055: // * @param height
056: // * Background height.
057: // * @param theme
058: // * Theme for the background.
059: // * @param borderAlpha
060: // * Border alpha.
061: // */
062: // public static void paintHighlight(Graphics g, Component c,
063: // ComponentState currState, ComponentState prevState, Rectangle rect,
064: // float borderAlpha) {
065: // // fix for bug 65
066: // if ((rect.width <= 0) || (rect.height <= 0))
067: // return;
068: //
069: // SubstanceHighlightPainter highlightPainter = SubstanceLookAndFeel
070: // .getCurrentHighlightPainter();
071: // Graphics2D g2d = (Graphics2D) g.create(rect.x, rect.y, rect.width,
072: // rect.height);
073: //
074: // SubstanceTheme theme = SubstanceCoreUtilities.getTheme(c, true, true)
075: // .getHighlightTheme(c, currState);
076: // SubstanceTheme theme2 = SubstanceCoreUtilities.getTheme(c, true, true)
077: // .getHighlightTheme(c, prevState);
078: //
079: // highlightPainter.paintHighlight(g2d, c, rect.width, rect.height,
080: // borderAlpha, null, theme.getColorScheme(), theme2
081: // .getColorScheme(), currState.getCycleCount());
082: // g2d.dispose();
083: // }
084:
085: /**
086: * Updates the specified component with the background that matches the
087: * provided parameters.
088: *
089: * @param g
090: * Graphic context.
091: * @param c
092: * Component.
093: * @param rect
094: * Rectangle to highlight.
095: * @param borderAlpha
096: * Border alpha.
097: * @param openSides
098: * The sides specified in this set will not be painted. Can be
099: * <code>null</code> or empty.
100: * @param colorScheme1
101: * The first color scheme.
102: * @param colorScheme2
103: * The second color scheme.
104: * @param cyclePos
105: * Cycle position. Is used for rollover and pulsation effects.
106: * Must be in 0..10 range.
107: */
108: public static void paintHighlight(Graphics g, Component c,
109: Rectangle rect, float borderAlpha, Set<Side> openSides,
110: ColorScheme colorScheme1, ColorScheme colorScheme2,
111: float cyclePos) {
112: // fix for bug 65
113: if ((rect.width <= 0) || (rect.height <= 0))
114: return;
115:
116: SubstanceHighlightPainter highlightPainter = SubstanceLookAndFeel
117: .getCurrentHighlightPainter();
118: Graphics2D g2d = (Graphics2D) g.create(rect.x, rect.y,
119: rect.width, rect.height);
120:
121: highlightPainter.paintHighlight(g2d, c, rect.width,
122: rect.height, borderAlpha, openSides, colorScheme1,
123: colorScheme2, cyclePos);
124: g2d.dispose();
125: }
126: }
|