JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.swing
Class JCIconCreator

java.lang.Object
  |
  +--com.klg.jclass.util.swing.JCIconCreator

public class JCIconCreator
extends Object

JCIconCreator creates image icons from String arrays. The format is similar to XPixMap (XPM) format files. For example:

     JCIconCreator im = new JCIconCreator(3, 2);
     im.setColor('G', Color.green);
     im.setColor('x', Color.orange);
     String[] pixels = { " .G", "G x" };
     im.setPixels(pixels);
     ImageIcon icon = im.getIcon();
 


Field Summary
protected  int[] colorMap
           
protected  int curRow
           
protected  int height
           
protected  ImageIcon icon
           
protected  int[] pixels
           
protected  int width
           
 
Constructor Summary
JCIconCreator()
          Creates an empty instance.
JCIconCreator(int w, int h)
          Creates an empty instance using the specified width and height.
 
Method Summary
 void clear()
          Clears the data.
 ImageIcon getIcon()
          Gets the Icon created by this instance of JCIconCreator.
static ImageIcon getIcon(byte[] bytes)
          This method takes a passed-in byte array (as might be obtained from a database's image field) and attempts to convert it into an Image.
 void setColor(char ch, Color color)
          Sets the color corresponding to a character.
 void setColor(char ch, int rgb)
          Sets the color (as an RGB int) corresponding to a character.
 void setPixels(int row, String string)
          Sets the pixel data at the specified row.
 void setPixels(String[] string)
          Sets the pixel data for all rows.
 void setSize(int w, int h)
          Sets the size of the image to be created.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

icon

protected ImageIcon icon

curRow

protected int curRow

width

protected int width

height

protected int height

colorMap

protected int[] colorMap

pixels

protected int[] pixels
Constructor Detail

JCIconCreator

public JCIconCreator(int w,
                     int h)
Creates an empty instance using the specified width and height.

Parameters:
w - the initial image width
h - the initial image height
See Also:
Component.createImage(java.awt.image.ImageProducer)

JCIconCreator

public JCIconCreator()
Creates an empty instance.

See Also:
Component.createImage(java.awt.image.ImageProducer)
Method Detail

clear

public void clear()
Clears the data.


getIcon

public ImageIcon getIcon()
Gets the Icon created by this instance of JCIconCreator. If the icon does not exist, uses pixels and the colorMap arrays to create it.

Returns:
The icon created by this instance of JCIconCreator
See Also:
setPixels(java.lang.String[])

setColor

public void setColor(char ch,
                     int rgb)
Sets the color (as an RGB int) corresponding to a character. Spaces are transparent by default.

Parameters:
ch - The character which represents the color
rgb - The rgb value of the color

setColor

public void setColor(char ch,
                     Color color)
Sets the color corresponding to a character. Spaces are transparent by default.

Parameters:
ch - The character which represents the color
color - The color object

setSize

public void setSize(int w,
                    int h)
Sets the size of the image to be created.

Parameters:
w - The new width
h - The new height

setPixels

public void setPixels(String[] string)
Sets the pixel data for all rows.

Parameters:
string - A list of strings representing pixel data for all rows

setPixels

public void setPixels(int row,
                      String string)
Sets the pixel data at the specified row.

Parameters:
row - The row index
string - The new pixel data at that row

getIcon

public static ImageIcon getIcon(byte[] bytes)
This method takes a passed-in byte array (as might be obtained from a database's image field) and attempts to convert it into an Image.

Parameters:
bytes -
Returns:

Copyright © 2004 Quest Software Inc..
All rights reserved.