001: package tide.greeting;
002:
003: import snow.utils.gui.Icons;
004: import tide.editor.MainEditorFrame;
005: import snow.utils.StringUtils;
006: import java.awt.font.*;
007: import java.awt.*;
008: import java.awt.Graphics;
009: import javax.swing.*;
010: import javax.swing.event.*;
011: import java.awt.event.*;
012:
013: public final class GreetingOutline extends JPanel {
014: // java.util.Timer timer;
015: public GreetingOutline() {
016: //setBackground(Color.WHITE);
017: /* timer = new java.util.Timer();
018: timer.scheduleAtFixedRate(new TimerTask()
019: {
020: public void run() {
021: if(!isVisible()) return;
022: repaint();
023: }
024: }, 1000,30 );*/
025:
026: }
027:
028: public void terminate() {
029:
030: //timer.cancel();
031: }
032:
033: int repaints = 0;
034: GlyphVector gv = null;
035:
036: int shiftX = 20, shiftY = 110;
037:
038: @Override
039: public void paintComponent(Graphics g) {
040: repaints++;
041: // if(repaints>2500) timer.cancel();
042:
043: //fills back
044: super .paintComponent(g);
045:
046: Icon ic = new Icons.StartIcon(56, 56, true);
047: ic.paintIcon(this , g, 45, 59);
048:
049: Font f = new Font("Lucida", Font.PLAIN, 64);
050: Font f2 = new Font("Lucida", Font.PLAIN, 10);
051: Graphics2D g2 = (Graphics2D) g;
052:
053: g2.setComposite(AlphaComposite.Src);
054: g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
055: RenderingHints.VALUE_ANTIALIAS_ON);
056: g2.setRenderingHint(RenderingHints.KEY_RENDERING,
057: RenderingHints.VALUE_RENDER_QUALITY);
058: if (gv == null) {
059: gv = f
060: .createGlyphVector(g2.getFontRenderContext(),
061: "tI E");
062: }
063: Shape out = gv.getOutline(shiftX, shiftY);
064:
065: int width = getWidth();
066: int height = getHeight();
067:
068: int xgr = (int) (Math.sin(repaints / 40.0) * width);
069:
070: g2.setPaint(new GradientPaint(xgr, 0, Color.BLUE.brighter(),
071: xgr + 150, height, Color.white));
072: //g2.fillRect(0, 0, width, height);
073:
074: /*g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
075: g2.setPaint(new GradientPaint(xgr, 0, Color.orange.brighter(), xgr+150, height, Color.white));
076: */
077: for (int i = 0; i < gv.getNumGlyphs(); i++) {
078: //int dx = (int)(Math.sin(i*Math.PI/2.0+repaints/25.0)*15.0);
079: //dx = (int)(Math.exp(-repaints/720.0)*dx);
080: drawGlyph(g2, gv.getGlyphOutline(i, shiftX, shiftY), false);
081: }
082:
083: g2.setFont(f2);
084: g2.setColor(Color.darkGray);
085:
086: g2.drawString("Ver "
087: + StringUtils.extractFromFirstToNext_Excluded(
088: MainEditorFrame._VERSION, "tIDE ", "]") + "]",
089: shiftX, shiftY + 22);
090: /*
091: g2.setPaint(new GradientPaint(0, 0, Color.darkGray, 0, height, Color.YELLOW));
092: g2.fill(out);
093:
094:
095: g2.setPaint(new GradientPaint(0, 0, Color.ORANGE, 0, height, Color.YELLOW));
096: g2.translate(2,2);
097: g2.fill(out);
098: g2.translate(-2,-2);
099:
100: int gn = repaints/10 % 4;
101: gn = gv.getNumGlyphs()-4+gn;
102:
103: g2.setColor(Color.ORANGE.darker());
104: g2.fill( gv.getGlyphOutline(gn,shiftX,shiftY));*/
105:
106: }
107:
108: private void drawGlyph(Graphics2D g2, Shape out, boolean emph) {
109: int width = getWidth();
110: int height = getHeight();
111:
112: /* int xgr=100;
113: g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
114: g2.setPaint(new GradientPaint(xgr, 0, Color.orange.brighter(), xgr+150, height, Color.white));
115: //g2.draw(out);*/
116:
117: g2.setPaint(new GradientPaint(0, 0, Color.darkGray, 0, height,
118: Color.YELLOW));
119: g2.fill(out);
120:
121: g2.setPaint(new GradientPaint(0, 0, Color.ORANGE, 0, height,
122: Color.YELLOW));
123: g2.translate(2, 2);
124: g2.fill(out);
125: g2.translate(-2, -2);
126:
127: if (emph) {
128: g2.setColor(Color.ORANGE.darker());
129: g2.fill(out);
130: }
131: }
132:
133: /*test
134: public static void main(String[] args)
135: {
136: JFrame f = new JFrame();
137: f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
138: GreetingOutline g = new GreetingOutline();
139: f.setContentPane(g);
140: f.setSize(160,350);
141: f.setLocationRelativeTo(null);
142: f.setVisible(true);
143: }*/
144:
145: }
|