Merge pull request #4276 from JayDi85/chrismas-logo

Christmas logo
This commit is contained in:
Oleg Agafonov 2017-12-23 21:19:59 +04:00 committed by GitHub
commit 40760bf0ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View file

@ -429,17 +429,41 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
} }
private boolean isChrismasTime(){
// from december 15 to january 15
Calendar cal = Calendar.getInstance();
int currentYear = cal.get(Calendar.YEAR);
Date currentTime = cal.getTime();
Date chrisFrom = new GregorianCalendar(currentYear, Calendar.DECEMBER, 15).getTime();
Date chrisTo = new GregorianCalendar(currentYear + 1, Calendar.JANUARY, 15 + 1).getTime();
return currentTime.after(chrisFrom) && currentTime.before(chrisTo);
}
private void addMageLabel() { private void addMageLabel() {
if (liteMode || grayMode) { if (liteMode || grayMode) {
return; return;
} }
String filename = "/label-xmage.png";
String filename;
float ratio;
if (isChrismasTime()){
// chrismass logo
LOGGER.info("Yo Ho Ho, Merry Christmas and a Happy New Year");
filename = "/label-xmage-christmas.png";
ratio = 539.0f / 318.0f;
}else{
// standard logo
filename = "/label-xmage.png";
ratio = 509.0f / 288.0f;
}
try { try {
InputStream is = this.getClass().getResourceAsStream(filename); InputStream is = this.getClass().getResourceAsStream(filename);
float ratio = 1179.0f / 678.0f;
titleRectangle = new Rectangle(540, (int) (640 / ratio));
if (is != null) { if (is != null) {
titleRectangle = new Rectangle(540, (int) (640 / ratio));
BufferedImage image = ImageIO.read(is); BufferedImage image = ImageIO.read(is);
//ImageIcon resized = new ImageIcon(image.getScaledInstance(titleRectangle.width, titleRectangle.height, java.awt.Image.SCALE_SMOOTH)); //ImageIcon resized = new ImageIcon(image.getScaledInstance(titleRectangle.width, titleRectangle.height, java.awt.Image.SCALE_SMOOTH));
title = new JLabel(); title = new JLabel();

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB