Crossfire JXClient, Trunk
FaceImagesUtils.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff
19  * Copyright (C) 2006-2017,2019-2023 Andreas Kirschbaum
20  * Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21  */
22 
23 package com.realtime.crossfire.jxclient.faces;
24 
25 import java.awt.GraphicsConfiguration;
26 import java.awt.GraphicsDevice;
27 import java.awt.GraphicsEnvironment;
28 import java.awt.Transparency;
29 import javax.swing.ImageIcon;
30 import org.jetbrains.annotations.NotNull;
31 
36 public class FaceImagesUtils {
37 
41  private FaceImagesUtils() {
42  }
43 
50  @NotNull
51  public static FaceImages newFaceImages(@NotNull final ImageIcon originalImageIcon) {
52  final ImageIcon scaledImageIcon = new ImageScale2x(originalImageIcon).getScaledImage();
53  final ImageIcon magicMapImageIcon = new ImageScale8d(originalImageIcon).getScaledImage();
54  return new FaceImages(originalImageIcon, scaledImageIcon, magicMapImageIcon);
55  }
56 
61  @NotNull
62  public static FaceImages newEmptyFaceImages() {
63  final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
64  final GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
65  final GraphicsConfiguration graphicsConfiguration = graphicsDevice.getDefaultConfiguration();
66 
67  final ImageIcon emptyOriginalImageIcon = new ImageIcon(graphicsConfiguration.createCompatibleImage(Face.SQUARE_SIZE, Face.SQUARE_SIZE, Transparency.OPAQUE));
68  final ImageIcon emptyScaledImageIcon = new ImageIcon(graphicsConfiguration.createCompatibleImage(Face.SQUARE_SIZE*2, Face.SQUARE_SIZE*2, Transparency.OPAQUE));
69  final ImageIcon emptyMagicMapImageIcon = new ImageIcon(graphicsConfiguration.createCompatibleImage(Face.SQUARE_SIZE/8, Face.SQUARE_SIZE/8, Transparency.OPAQUE));
70  return new FaceImages(emptyOriginalImageIcon, emptyScaledImageIcon, emptyMagicMapImageIcon);
71  }
72 
73 }
com.realtime.crossfire.jxclient.faces.FaceImagesUtils.newFaceImages
static FaceImages newFaceImages(@NotNull final ImageIcon originalImageIcon)
Definition: FaceImagesUtils.java:51
com.realtime.crossfire.jxclient.faces.FaceImagesUtils.newEmptyFaceImages
static FaceImages newEmptyFaceImages()
Definition: FaceImagesUtils.java:62
com.realtime.crossfire.jxclient.faces.ImageScale8d.getScaledImage
ImageIcon getScaledImage()
Definition: ImageScale8d.java:71
com.realtime.crossfire.jxclient.faces.FaceImagesUtils.FaceImagesUtils
FaceImagesUtils()
Definition: FaceImagesUtils.java:41
com.realtime.crossfire.jxclient.faces.ImageScale2x
Definition: ImageScale2x.java:34
com.realtime.crossfire.jxclient.faces.Face.SQUARE_SIZE
static final int SQUARE_SIZE
Definition: Face.java:42
com.realtime.crossfire.jxclient.faces.ImageScale2x.getScaledImage
ImageIcon getScaledImage()
Definition: ImageScale2x.java:71
com.realtime.crossfire.jxclient.faces.ImageScale8d
Definition: ImageScale8d.java:34
com.realtime.crossfire.jxclient.faces.FaceImagesUtils
Definition: FaceImagesUtils.java:36
com.realtime.crossfire.jxclient.faces.Face
Definition: Face.java:37
com.realtime.crossfire.jxclient.faces.FaceImages
Definition: FaceImages.java:32