/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
*/
/**
* This class is used as a cache containing the icons that are used by the
* BrowserController to update the nodes. It keeps some icons associated with
* some entry types, to suffixes, to the root node, etc.
*/
public class IconPool {
/**
* Mask for the leaf node.
*/
/**
* Mask for the referral node.
*/
/**
* Mask for the node that has an error.
*/
/**
* The path that contains the icons.
*/
"person", "ds-user.png",
"organization", "ds-folder.png",
"organizationalunit", "ds-ou.png",
"groupofuniquenames", "ds-group.png",
"groupofurls", "ds-group.png",
"ds-virtual-static-group", "ds-group.png",
"passwordpolicy", "ds-ppol.png"
};
"organizationalunit",
"ds-virtual-static-group",
};
/**
* The default constructor.
*
*/
public IconPool() {
// Recopy ICON_PATH in pathTable for fast access
}
}
}
/**
* If objectClass is null, a default icon is used.
* @param objectClasses the objectclass values of the entry for which we want
* an icon.
* @param modifiers the modifiers associated with the entry (if there was
* an error, if it is a referral, etc.).
* @return the icon corresponding to the provided object classes and
* modifiers.
*/
}
return result;
}
/**
* Creates an icon for a given path.
* @param path the path of the icon.
* @param description the description of the icon
* @return the associated ImageIcon.
*/
{
if (description != null)
{
}
return icon;
}
/**
* Returns the icon associated with a leaf node.
* @return the icon associated with a leaf node.
*/
if (defaultLeafIcon == null) {
}
return defaultLeafIcon;
}
/**
* Returns the icon associated with a container node.
* @return the icon associated with a container node.
*/
if (defaultContainerIcon == null) {
"Folder entry");
}
return defaultContainerIcon;
}
/**
* Returns the icon associated with a suffix node.
* @return the icon associated with a suffix node.
*/
if (suffixIcon == null) {
"Suffix entry");
}
return suffixIcon;
}
/**
* Returns the icon associated with a root node.
* @return the icon associated with a root node.
*/
if (rootNodeIcon == null) {
"Root entry");
}
return rootNodeIcon;
}
/**
* Returns the icon associated with a node for which an error occurred.
* @return the icon associated with a node for which an error occurred.
*/
}
return errorIcon;
}
/**
* Returns the icon associated with the error mask icon.
* @return the icon associated with the error mask icon.
*/
if (errorMaskIcon == null) {
}
return errorMaskIcon;
}
/**
* Returns the icon associated with the referral mask icon.
* @return the icon associated with the referral mask icon.
*/
if (referralMaskIcon == null) {
"Referral mask");
}
return referralMaskIcon;
}
/**
* Returns an icon for a given objectclass applying some modifiers.
* @param objectClasses the objectclasses of the entry
* @param modifiers the modifiers of the icon (if the entry is inactivated,
* if it is a referral...).
* @return an icon for a given objectclass applying some modifiers.
*/
// Find the icon associated to the object class
}
else {
{
{
break;
}
}
result = getDefaultLeafIcon();
}
else {
}
}
else {
{
if (description != null)
{
break;
}
}
if (description == null)
{
}
}
}
// Alter this icon according the modifiers
}
result = getErrorMaskIcon();
}
return result;
}
// TODO: verify the performance of IconPool.makeKey()
}
}
/**
* Returns a RemoteImage corresponding to the superposition of the icon
* Image and the mask Image.
*
* @param icon the RemoteImage that we want to bar.
* @param mask the ImageIcond to be used as mask.
* @return a RemoteImage corresponding to the superposition of the icon
* Image and the mask Image.
*/
int h = icon.getIconHeight();
int w = icon.getIconWidth();
return null;
}
return null;
}
int[] iconPixels = new int[w * h];
try {
pg.grabPixels();
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
int[] filterPixels = new int[w * h];
try {
pgf.grabPixels();
return fReturn;
}
} catch (Exception e) {
e.printStackTrace();
return fReturn;
}
int[] newPixels = new int[w * h];
for( int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (filterPixels[j + i*w] != TRANSPARENT) {
newPixels[j + i*w] = filterPixels[j + i*w];
} else {
newPixels[j + i*w] = iconPixels[j + i*w];
}
new MemoryImageSource(
return fReturn;
}
}