IDEA-17650 Splash screen is too agressive on Linux
[fedora-idea.git] / platform / platform-impl / src / com / intellij / ui / Splash.java
blob8d3ab2ef66be08addd60626f6860d4b74deec55b
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 JDialog {
26 private final Icon myImage;
27 private final JLabel myLabel;
29 public Splash(String imageName, final Color textColor) {
30 setUndecorated(true);
31 setResizable(false);
32 setModal(false);
34 Icon originalImage = IconLoader.getIcon(imageName);
35 myImage = new MyIcon(originalImage, textColor);
36 myLabel = new JLabel(myImage);
37 Container contentPane = getContentPane();
38 contentPane.setLayout(new BorderLayout());
39 contentPane.add(myLabel, BorderLayout.CENTER);
40 Dimension size = getPreferredSize();
41 setSize(size);
42 pack();
43 setLocationRelativeTo(null);
46 public void show() {
47 super.show();
48 toFront();
49 myLabel.paintImmediately(0, 0, myImage.getIconWidth(), myImage.getIconHeight());
52 public static boolean showLicenseeInfo(Graphics g, int x, int y, final int height, final Color textColor) {
53 if (ApplicationInfoImpl.getShadowInstance().showLicenseeInfo()) {
54 g.setFont(new Font(UIUtil.ARIAL_FONT_NAME, Font.BOLD, 11));
55 g.setColor(textColor);
56 LicenseeInfoProvider provider = LicenseeInfoProvider.getInstance();
57 if (provider != null) {
58 g.drawString(provider.getLicensedToMessage(), x + 20, y + height - 52);
59 g.drawString(provider.getLicenseRestrictionsMessage(), x + 20, y + height - 32);
61 return true;
63 return false;
66 private static final class MyIcon implements Icon {
67 private final Icon myOriginalIcon;
68 private final Color myTextColor;
70 public MyIcon(Icon originalIcon, Color textColor) {
71 myOriginalIcon = originalIcon;
72 myTextColor = textColor;
75 public void paintIcon(Component c, Graphics g, int x, int y) {
76 yeild();
77 myOriginalIcon.paintIcon(c, g, x, y);
79 showLicenseeInfo(g, x, y, getIconHeight(), myTextColor);
82 private static void yeild() {
83 try {
84 Thread.sleep(10);
86 catch (InterruptedException e) {
90 public int getIconWidth() {
91 return myOriginalIcon.getIconWidth();
94 public int getIconHeight() {
95 return myOriginalIcon.getIconHeight();