6a575d7a42a3bf35cb93f095506d947b9c1ed3af
[fedora-idea.git] / platform / platform-impl / src / com / intellij / ui / Splash.java
blob6a575d7a42a3bf35cb93f095506d947b9c1ed3af
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.ui;
18 import com.intellij.openapi.application.impl.ApplicationInfoImpl;
19 import com.intellij.openapi.util.IconLoader;
20 import com.intellij.util.ui.UIUtil;
22 import javax.swing.*;
23 import java.awt.*;
25 public class Splash extends JWindow {
26 private final Icon myImage;
27 private final JLabel myLabel;
29 public Splash(String imageName, final Color textColor) {
30 Icon originalImage = IconLoader.getIcon(imageName);
31 myImage = new MyIcon(originalImage, textColor);
32 myLabel = new JLabel(myImage);
33 Container contentPane = getContentPane();
34 contentPane.setLayout(new BorderLayout());
35 contentPane.add(myLabel, BorderLayout.CENTER);
36 Dimension size = getPreferredSize();
37 setSize(size);
38 pack();
39 setLocationRelativeTo(null);
42 public void show() {
43 super.show();
44 myLabel.paintImmediately(0, 0, myImage.getIconWidth(), myImage.getIconHeight());
47 public static boolean showLicenseeInfo(Graphics g, int x, int y, final int height, final Color textColor) {
48 if (ApplicationInfoImpl.getShadowInstance().showLicenseeInfo()) {
49 g.setFont(new Font(UIUtil.ARIAL_FONT_NAME, Font.BOLD, 11));
50 g.setColor(textColor);
51 LicenseeInfoProvider provider = LicenseeInfoProvider.getInstance();
52 if (provider != null) {
53 g.drawString(provider.getLicensedToMessage(), x + 20, y + height - 52);
54 g.drawString(provider.getLicenseRestrictionsMessage(), x + 20, y + height - 32);
56 return true;
58 return false;
61 private static final class MyIcon implements Icon {
62 private final Icon myOriginalIcon;
63 private final Color myTextColor;
65 public MyIcon(Icon originalIcon, Color textColor) {
66 myOriginalIcon = originalIcon;
67 myTextColor = textColor;
70 public void paintIcon(Component c, Graphics g, int x, int y) {
71 yeild();
72 myOriginalIcon.paintIcon(c, g, x, y);
74 showLicenseeInfo(g, x, y, getIconHeight(), myTextColor);
77 private static void yeild() {
78 try {
79 Thread.sleep(10);
81 catch (InterruptedException e) {
85 public int getIconWidth() {
86 return myOriginalIcon.getIconWidth();
89 public int getIconHeight() {
90 return myOriginalIcon.getIconHeight();