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.watermark;
031:
032: import java.awt.*;
033:
034: import org.jvnet.substance.utils.SubstanceColorUtilities;
035:
036: /**
037: * Implementation of {@link SubstanceWatermark} that paints a translucent fill
038: * (with no pattern). This class is part of officially supported API.
039: *
040: * @author Kirill Grouchnikov
041: * @author Chris Hall
042: */
043: public class SubstanceNullWatermark implements SubstanceWatermark {
044: /**
045: * The current color.
046: */
047: protected Color color;
048:
049: /**
050: * Simple constructor.
051: */
052: public SubstanceNullWatermark() {
053: this .color = SubstanceColorUtilities
054: .getWatermarkLightColor(0.2f);
055: }
056:
057: /*
058: * (non-Javadoc)
059: *
060: * @see org.jvnet.substance.watermark.SubstanceWatermark#drawWatermarkImage(java.awt.Graphics,
061: * int, int, int, int)
062: */
063: public void drawWatermarkImage(Graphics graphics, Component c,
064: int x, int y, int width, int height) {
065: graphics.setColor(this .color);
066: graphics.fillRect(x, y, width, height);
067: }
068:
069: /*
070: * (non-Javadoc)
071: *
072: * @see org.jvnet.substance.watermark.SubstanceWatermark#previewWatermark(java.awt.Graphics,
073: * int, int, int, int)
074: */
075: public void previewWatermark(Graphics g, int x, int y, int width,
076: int height) {
077: }
078:
079: /*
080: * (non-Javadoc)
081: *
082: * @see org.jvnet.substance.watermark.SubstanceWatermark#updateWatermarkImage()
083: */
084: public boolean updateWatermarkImage() {
085: this .color = SubstanceColorUtilities
086: .getWatermarkLightColor(0.2f);
087: return true;
088: }
089:
090: /*
091: * (non-Javadoc)
092: *
093: * @see org.jvnet.substance.watermark.SubstanceWatermark#getDisplayName()
094: */
095: public String getDisplayName() {
096: return SubstanceNullWatermark.getName();
097: }
098:
099: /**
100: * Returns the name of all watermarks of <code>this</code> class.
101: *
102: * @return The name of all watermarks of <code>this</code> class.
103: */
104: public static String getName() {
105: return "Null";
106: }
107:
108: /*
109: * (non-Javadoc)
110: *
111: * @see org.jvnet.substance.watermark.SubstanceWatermark#isDependingOnTheme()
112: */
113: public boolean isDependingOnTheme() {
114: return true;
115: }
116:
117: /*
118: * (non-Javadoc)
119: *
120: * @see org.jvnet.substance.watermark.SubstanceWatermark#dispose()
121: */
122: public void dispose() {
123: this.color = null;
124: }
125: }
|