Crossfire JXClient, Trunk  R20561
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-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.faces;
23 
24 import java.awt.GraphicsConfiguration;
25 import java.awt.GraphicsDevice;
26 import java.awt.GraphicsEnvironment;
27 import java.awt.Transparency;
28 import javax.swing.ImageIcon;
29 import org.jetbrains.annotations.NotNull;
30 
35 public class FaceImagesUtils {
36 
40  private FaceImagesUtils() {
41  }
42 
49  @NotNull
50  public static FaceImages newFaceImages(@NotNull final ImageIcon originalImageIcon) {
51  final ImageIcon scaledImageIcon = new ImageScale2x(originalImageIcon).getScaledImage();
52  final ImageIcon magicMapImageIcon = new ImageScale8d(originalImageIcon).getScaledImage();
53  return new FaceImages(originalImageIcon, scaledImageIcon, magicMapImageIcon);
54  }
55 
60  @NotNull
61  public static FaceImages newEmptyFaceImages() {
62  final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
63  final GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();
64  final GraphicsConfiguration graphicsConfiguration = graphicsDevice.getDefaultConfiguration();
65 
66  final ImageIcon emptyOriginalImageIcon = new ImageIcon(graphicsConfiguration.createCompatibleImage(Face.SQUARE_SIZE, Face.SQUARE_SIZE, Transparency.OPAQUE));
67  final ImageIcon emptyScaledImageIcon = new ImageIcon(graphicsConfiguration.createCompatibleImage(Face.SQUARE_SIZE*2, Face.SQUARE_SIZE*2, Transparency.OPAQUE));
68  final ImageIcon emptyMagicMapImageIcon = new ImageIcon(graphicsConfiguration.createCompatibleImage(Face.SQUARE_SIZE/8, Face.SQUARE_SIZE/8, Transparency.OPAQUE));
69  return new FaceImages(emptyOriginalImageIcon, emptyScaledImageIcon, emptyMagicMapImageIcon);
70  }
71 
72 }
static FaceImages newFaceImages(@NotNull final ImageIcon originalImageIcon)
Creates a new FaceImages instance from an "original" face; the "scaled" and "magic map" sized images ...
static final int SQUARE_SIZE
The size of one square in pixels.
Definition: Face.java:41
Utility class for creating FaceImages instances.
Consists of three ImageIcons representing a Face.
Definition: FaceImages.java:31
static FaceImages newEmptyFaceImages()
Creates a new FaceImages instance consisting of empty images.
A utility to scale down an image by 8 in both dimensions.
ImageIcon getScaledImage()
Retrieves the scaled image.
ImageIcon getScaledImage()
Returns the scaled image.
A utility to perform the scale2x algorithm on a Java Image.
FaceImagesUtils()
Private constructor to prevent instantiation.