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 test;
031:
032: import java.awt.*;
033:
034: import javax.swing.JFrame;
035: import javax.swing.JPanel;
036:
037: import org.jvnet.substance.color.AquaColorScheme;
038: import org.jvnet.substance.color.PurpleColorScheme;
039:
040: /**
041: * Image creator demo.
042: *
043: * @author Kirill Grouchnikov
044: */
045: public class JaxbwIconDemo {
046:
047: public static final int COLOR_CELL = 30;
048:
049: public static final int NAME_CELL = 120;
050:
051: private static final class IconFrame extends JFrame {
052: /**
053: * Simple constructor. Creates all the icons.
054: */
055: public IconFrame() {
056:
057: this .setLayout(new BorderLayout());
058: this .add(new IconPanel(), BorderLayout.CENTER);
059:
060: }
061: }
062:
063: /**
064: * Demo frame.
065: *
066: * @author Kirill Grouchnikov
067: */
068: private static final class IconPanel extends JPanel {
069: /**
070: * Simple constructor. Creates all the icons.
071: */
072: public IconPanel() {
073: int width = 50;
074: int height = 50;
075: Dimension dim = new Dimension(width, height);
076: this .setPreferredSize(dim);
077: this .setMinimumSize(dim);
078: this .setSize(dim);
079: }
080:
081: /*
082: * (non-Javadoc)
083: *
084: * @see java.awt.Component#paint(java.awt.Graphics)
085: */
086: public final void paint(Graphics g) {
087: Graphics2D g2 = (Graphics2D) g.create();
088: g2.setColor(Color.white);
089: g2.translate(15, 15);
090:
091: // g2.drawImage(SubstanceImageCreator.getRoundedBackground(16, 16,
092: // 2,
093: // ColorSchemeEnum.LIGHT_AQUA, 0, null), 0, 0, null);
094:
095: g2.setColor(new AquaColorScheme().getDarkColor());
096: g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
097: RenderingHints.VALUE_ANTIALIAS_ON);
098: g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
099: RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
100:
101: g2.setColor(new PurpleColorScheme().getDarkColor());
102: g2.setFont(new Font("Tahoma", Font.BOLD, 17));
103: g2.drawString("J", 6.0f, 14.0f);
104: g2.setColor(Color.BLACK);
105: g2.setFont(new Font("Tahoma", Font.BOLD, 11));
106: g2.drawString("w", 2.0f, 11.0f);
107:
108: // Stroke stroke = new BasicStroke(1.8f, BasicStroke.CAP_ROUND,
109: // BasicStroke.JOIN_ROUND);
110: // g2.setStroke(stroke);
111: // GeneralPath path1 = new GeneralPath();
112: // path1.moveTo(5.0f, 4.0f);
113: // path1.quadTo(3.0f, 4.0f, 3.0f, 8.0f);
114: // path1.quadTo(3.0f, 12.0f, 8.0f, 11.0f);
115: // path1.moveTo(10.0f, 12.0f);
116: // path1.quadTo(12.0f, 12.0f, 12.0f, 8.0f);
117: // path1.quadTo(12.0f, 4.0f, 7.0f, 5.0f);
118: // path1.lineTo(8.0f, 11.0f);
119: // // path1.moveTo(8.0f, 8.0f);
120: // g2.draw(path1);
121:
122: // g2.setColor(Color.BLACK);
123: // g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
124: // RenderingHints.VALUE_ANTIALIAS_OFF);
125: // g2.drawRect(-1, -1, 18, 18);
126: // Stroke stroke2 = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
127: // BasicStroke.JOIN_ROUND);
128: // g2.setStroke(stroke2);
129: }
130: }
131:
132: /**
133: * Main function for running <code>this</code> demo.
134: *
135: * @param args
136: */
137: public static void main(String[] args) {
138: IconFrame icf = new IconFrame();
139: icf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
140: icf.pack();
141: icf.setVisible(true);
142: }
143: }
|