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;
031:
032: import java.awt.Color;
033:
034: import org.jvnet.substance.color.ColorScheme;
035: import org.jvnet.substance.utils.SubstanceColorUtilities;
036:
037: /**
038: * Gradient painter that returns images with flat appearance. This class is
039: * <b>for internal use only</b>.
040: *
041: * @author Kirill Grouchnikov
042: */
043: public class FlatGradientPainter extends StandardGradientPainter {
044: /**
045: * Creates a new flat gradient painter.
046: */
047: public FlatGradientPainter() {
048: }
049:
050: /*
051: * (non-Javadoc)
052: *
053: * @see org.jvnet.substance.painter.StandardGradientPainter#getDisplayName()
054: */
055: @Override
056: public String getDisplayName() {
057: return "Flat";
058: }
059:
060: /*
061: * (non-Javadoc)
062: *
063: * @see org.jvnet.substance.painter.StandardGradientPainter#getMidFillColorTop(org.jvnet.substance.color.ColorScheme,
064: * org.jvnet.substance.color.ColorScheme, double, boolean)
065: */
066: @Override
067: public Color getMidFillColorTop(ColorScheme interpolationScheme1,
068: ColorScheme interpolationScheme2, double cycleCoef,
069: boolean useCyclePosAsInterpolation) {
070: if (!useCyclePosAsInterpolation) {
071: return SubstanceColorUtilities.getInterpolatedColor(
072: interpolationScheme1.getDarkColor(),
073: interpolationScheme2.getMidColor(), cycleCoef);
074: } else {
075: return SubstanceColorUtilities.getInterpolatedColor(
076: interpolationScheme1.getDarkColor(),
077: interpolationScheme2.getDarkColor(), cycleCoef);
078: }
079: }
080:
081: /*
082: * (non-Javadoc)
083: *
084: * @see org.jvnet.substance.painter.StandardGradientPainter#getTopFillColor(org.jvnet.substance.color.ColorScheme,
085: * org.jvnet.substance.color.ColorScheme, double, boolean)
086: */
087: @Override
088: public Color getTopFillColor(ColorScheme interpolationScheme1,
089: ColorScheme interpolationScheme2, double cycleCoef,
090: boolean useCyclePosAsInterpolation) {
091: return this .getMidFillColorTop(interpolationScheme1,
092: interpolationScheme2, cycleCoef,
093: useCyclePosAsInterpolation);
094: }
095:
096: /*
097: * (non-Javadoc)
098: *
099: * @see org.jvnet.substance.painter.StandardGradientPainter#getMidFillColorBottom(org.jvnet.substance.color.ColorScheme,
100: * org.jvnet.substance.color.ColorScheme, double, boolean)
101: */
102: @Override
103: public Color getMidFillColorBottom(
104: ColorScheme interpolationScheme1,
105: ColorScheme interpolationScheme2, double cycleCoef,
106: boolean useCyclePosAsInterpolation) {
107: return this .getMidFillColorTop(interpolationScheme1,
108: interpolationScheme2, cycleCoef,
109: useCyclePosAsInterpolation);
110: }
111:
112: /*
113: * (non-Javadoc)
114: *
115: * @see org.jvnet.substance.painter.StandardGradientPainter#getBottomFillColor(org.jvnet.substance.color.ColorScheme,
116: * org.jvnet.substance.color.ColorScheme, double, boolean)
117: */
118: @Override
119: public Color getBottomFillColor(ColorScheme interpolationScheme1,
120: ColorScheme interpolationScheme2, double cycleCoef,
121: boolean useCyclePosAsInterpolation) {
122: return this .getMidFillColorTop(interpolationScheme1,
123: interpolationScheme2, cycleCoef,
124: useCyclePosAsInterpolation);
125: }
126:
127: /*
128: * (non-Javadoc)
129: *
130: * @see org.jvnet.substance.painter.StandardGradientPainter#getTopShineColor(org.jvnet.substance.color.ColorScheme,
131: * org.jvnet.substance.color.ColorScheme, double, boolean)
132: */
133: @Override
134: public Color getTopShineColor(ColorScheme interpolationScheme1,
135: ColorScheme interpolationScheme2, double cycleCoef,
136: boolean useCyclePosAsInterpolation) {
137: return null;
138: }
139:
140: /*
141: * (non-Javadoc)
142: *
143: * @see org.jvnet.substance.painter.StandardGradientPainter#getBottomShineColor(org.jvnet.substance.color.ColorScheme,
144: * org.jvnet.substance.color.ColorScheme, double, boolean)
145: */
146: @Override
147: public Color getBottomShineColor(ColorScheme interpolationScheme1,
148: ColorScheme interpolationScheme2, double cycleCoef,
149: boolean useCyclePosAsInterpolation) {
150: return null;
151: }
152:
153: // @Override
154: // public Color getMidBorderColor(ColorScheme interpolationScheme1,
155: // ColorScheme interpolationScheme2, double cycleCoef,
156: // boolean useCyclePosAsInterpolation) {
157: // return super.getTopBorderColor(interpolationScheme1,
158: // interpolationScheme2, cycleCoef, useCyclePosAsInterpolation);
159: // }
160: //
161: // @Override
162: // public Color getBottomBorderColor(ColorScheme interpolationScheme1,
163: // ColorScheme interpolationScheme2, double cycleCoef,
164: // boolean useCyclePosAsInterpolation) {
165: // return super.getTopBorderColor(interpolationScheme1,
166: // interpolationScheme2, cycleCoef, useCyclePosAsInterpolation);
167: // }
168: //
169: }
|