com.realtime.crossfire.jxclient.gui.item
Class ItemPainter

java.lang.Object
  extended by com.realtime.crossfire.jxclient.gui.item.ItemPainter

public class ItemPainter
extends java.lang.Object

Paints Crossfire item images.


Field Summary
private  java.awt.Color appliedColor
          The background color for applied objects.
private  java.awt.image.BufferedImage appliedImage
          The overlay image for applied objects.
private  java.awt.Color blessedColor
          The background color for blessed objects.
private  java.awt.image.BufferedImage blessedImage
          The overlay image for blessed objects.
private  java.awt.Color cursedColor
          The background color for cursed objects.
private  java.awt.image.BufferedImage cursedImage
          The overlay image for cursed objects.
private  java.awt.Color damnedColor
          The background color for damned objects.
private  java.awt.image.BufferedImage damnedImage
          The overlay image for damned objects.
private  java.awt.Font font
          The font for the "nrof" text.
private  int h
          The item's height in pixel.
private  java.awt.Color lockedColor
          The background color for locked objects.
private  java.awt.image.BufferedImage lockedImage
          The overlay image for locked objects.
private  java.awt.Color magicColor
          The background color for magical objects.
private  java.awt.image.BufferedImage magicImage
          The overlay image for magical objects.
private  java.awt.Color nrofColor
          The color for the "nrof" text.
private  java.awt.Color selectorColor
          The background color for selected objects.
private  java.awt.image.BufferedImage selectorImage
          The overlay image for selected objects.
private static int TEXT_OFFSET
          The indentation of the item's text from the icon.
private  java.awt.Color unidentifiedColor
          The background color for unidentified objects.
private  java.awt.image.BufferedImage unidentifiedImage
          The overlay image for unidentified objects.
private  java.awt.Color unpaidColor
          The background color for unpaid objects.
private  java.awt.image.BufferedImage unpaidImage
          The overlay image for unpaid objects.
private  int w
          The item's width in pixel.
 
Constructor Summary
ItemPainter(java.awt.image.BufferedImage cursedImage, java.awt.image.BufferedImage damnedImage, java.awt.image.BufferedImage magicImage, java.awt.image.BufferedImage blessedImage, java.awt.image.BufferedImage appliedImage, java.awt.image.BufferedImage unidentifiedImage, java.awt.image.BufferedImage selectorImage, java.awt.image.BufferedImage lockedImage, java.awt.image.BufferedImage unpaidImage, java.awt.Color cursedColor, java.awt.Color damnedColor, java.awt.Color magicColor, java.awt.Color blessedColor, java.awt.Color appliedColor, java.awt.Color unidentifiedColor, java.awt.Color selectorColor, java.awt.Color lockedColor, java.awt.Color unpaidColor, java.awt.Font font, java.awt.Color nrofColor, int w, int h)
          Creates a new instance.
 
Method Summary
 ItemPainter newItemPainter(int w, int h)
          Creates a new instance having the same parameters as this instance except for the item's size.
 void paint(java.awt.Graphics2D g, CfItem item, boolean selected, java.awt.Image face)
          Paints an CfItem.
private  void paintColor(java.awt.Graphics g, java.awt.Color color, boolean isActive)
          Conditionally paints the background with a solid color.
private static void paintImage(java.awt.Graphics g, java.awt.Image image, boolean isActive)
          Conditionally paints an image.
private  void renderText(java.awt.Graphics2D g, int dx, int dy, int height, java.lang.String text)
          Renders a text string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

appliedColor

@Nullable
private final java.awt.Color appliedColor
The background color for applied objects.


appliedImage

@Nullable
private final java.awt.image.BufferedImage appliedImage
The overlay image for applied objects.


blessedColor

@Nullable
private final java.awt.Color blessedColor
The background color for blessed objects.


blessedImage

@Nullable
private final java.awt.image.BufferedImage blessedImage
The overlay image for blessed objects.


cursedColor

@Nullable
private final java.awt.Color cursedColor
The background color for cursed objects.


cursedImage

@Nullable
private final java.awt.image.BufferedImage cursedImage
The overlay image for cursed objects.


damnedColor

@Nullable
private final java.awt.Color damnedColor
The background color for damned objects.


damnedImage

@Nullable
private final java.awt.image.BufferedImage damnedImage
The overlay image for damned objects.


font

@NotNull
private final java.awt.Font font
The font for the "nrof" text.


h

private final int h
The item's height in pixel.


lockedColor

@Nullable
private final java.awt.Color lockedColor
The background color for locked objects.


lockedImage

@Nullable
private final java.awt.image.BufferedImage lockedImage
The overlay image for locked objects.


magicColor

@Nullable
private final java.awt.Color magicColor
The background color for magical objects.


magicImage

@Nullable
private final java.awt.image.BufferedImage magicImage
The overlay image for magical objects.


nrofColor

@NotNull
private final java.awt.Color nrofColor
The color for the "nrof" text.


selectorColor

@Nullable
private final java.awt.Color selectorColor
The background color for selected objects.


selectorImage

@Nullable
private final java.awt.image.BufferedImage selectorImage
The overlay image for selected objects.


TEXT_OFFSET

private static final int TEXT_OFFSET
The indentation of the item's text from the icon.

See Also:
Constant Field Values

unidentifiedColor

@Nullable
private final java.awt.Color unidentifiedColor
The background color for unidentified objects.


unidentifiedImage

@Nullable
private final java.awt.image.BufferedImage unidentifiedImage
The overlay image for unidentified objects.


unpaidColor

@Nullable
private final java.awt.Color unpaidColor
The background color for unpaid objects.


unpaidImage

@Nullable
private final java.awt.image.BufferedImage unpaidImage
The overlay image for unpaid objects.


w

private final int w
The item's width in pixel.

Constructor Detail

ItemPainter

public ItemPainter(@Nullable
                   java.awt.image.BufferedImage cursedImage,
                   @Nullable
                   java.awt.image.BufferedImage damnedImage,
                   @Nullable
                   java.awt.image.BufferedImage magicImage,
                   @Nullable
                   java.awt.image.BufferedImage blessedImage,
                   @Nullable
                   java.awt.image.BufferedImage appliedImage,
                   @Nullable
                   java.awt.image.BufferedImage unidentifiedImage,
                   @Nullable
                   java.awt.image.BufferedImage selectorImage,
                   @Nullable
                   java.awt.image.BufferedImage lockedImage,
                   @Nullable
                   java.awt.image.BufferedImage unpaidImage,
                   @Nullable
                   java.awt.Color cursedColor,
                   @Nullable
                   java.awt.Color damnedColor,
                   @Nullable
                   java.awt.Color magicColor,
                   @Nullable
                   java.awt.Color blessedColor,
                   @Nullable
                   java.awt.Color appliedColor,
                   @Nullable
                   java.awt.Color unidentifiedColor,
                   @Nullable
                   java.awt.Color selectorColor,
                   @Nullable
                   java.awt.Color lockedColor,
                   @Nullable
                   java.awt.Color unpaidColor,
                   @NotNull
                   java.awt.Font font,
                   @NotNull
                   java.awt.Color nrofColor,
                   int w,
                   int h)
Creates a new instance.

Parameters:
cursedImage - the overlay image for cursed objects
damnedImage - the overlay image for damned objects
magicImage - the overlay image for magical objects
blessedImage - the overlay image for blessed objects
appliedImage - the overlay image for applied objects
unidentifiedImage - the overlay image for unidentified objects
selectorImage - the overlay image for selected objects
lockedImage - the overlay image for locked objects
unpaidImage - the overlay image for unpaid objects
cursedColor - the background color for cursed objects
damnedColor - the background color for damned objects
magicColor - the background color for magical objects
blessedColor - the background color for blessed objects
appliedColor - the background color for applied objects
unidentifiedColor - the background color for unidentified objects
selectorColor - the background color for selected objects
lockedColor - the background color for locked objects
unpaidColor - the background color for unpaid objects
font - the font for nrof information
nrofColor - the color for nrof information
w - the item's width in pixel
h - the item's height in pixel
Method Detail

newItemPainter

@NotNull
public ItemPainter newItemPainter(int w,
                                          int h)
Creates a new instance having the same parameters as this instance except for the item's size.

Parameters:
w - the item's width in pixel
h - the item's height in pixel
Returns:
the new instance

paint

public void paint(@NotNull
                  java.awt.Graphics2D g,
                  @NotNull
                  CfItem item,
                  boolean selected,
                  @NotNull
                  java.awt.Image face)
Paints an CfItem.

Parameters:
g - the graphics instance to paint into
item - the item
selected - whether the item is selected
face - the item's face

paintColor

private void paintColor(@NotNull
                        java.awt.Graphics g,
                        @Nullable
                        java.awt.Color color,
                        boolean isActive)
Conditionally paints the background with a solid color.

Parameters:
g - the context to paint into
color - the color to use
isActive - whether painting should be done at all

paintImage

private static void paintImage(@NotNull
                               java.awt.Graphics g,
                               @Nullable
                               java.awt.Image image,
                               boolean isActive)
Conditionally paints an image.

Parameters:
g - the context to paint into
image - the image to paint
isActive - whether painting should be done at all

renderText

private void renderText(@NotNull
                        java.awt.Graphics2D g,
                        int dx,
                        int dy,
                        int height,
                        @NotNull
                        java.lang.String text)
Renders a text string.

Parameters:
g - the graphics context to paint into
dx - the x-coordinate
dy - the y-coordinate
height - the text height
text - the text