|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mailster.gui.SWTHelper
public class SWTHelper
---
Mailster (C) 2007-2009 De Oliveira Edouard
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
See Mailster
Web Site
---
SWTHelper.java - A helper class that handles all the OS associated resources.
Resources are cached and the helper provides a disposeAll() method
that allows to free all system resources acquired till there. The class also
register a JVM shutdown hook to ensure it won't be forgotten.
| Field Summary | |
|---|---|
static java.lang.String |
DESC_IMAGES_DIRECTORY
The directory in which images and icons are stored. |
static java.lang.String |
GRAY_IMAGE_SUFFIX
The suffix added to the key name of the gray version of a image. |
static java.lang.String |
IMAGES_DIRECTORY
|
private static java.util.Map<org.eclipse.swt.graphics.Image,java.util.HashMap<org.eclipse.swt.graphics.Image,org.eclipse.swt.graphics.Image>> |
imageToDecoratorMap
Images decorator map. |
private static org.slf4j.Logger |
log
|
private static java.util.Map<java.lang.String,org.eclipse.swt.graphics.Resource> |
resourceTracker
The resource tracker. |
static org.eclipse.swt.graphics.Font |
SYSTEM_FONT
The system font. |
static org.eclipse.swt.graphics.Font |
SYSTEM_FONT_BOLD
The system font in bold style. |
private static java.lang.String |
tempDir
The temporary directory path. |
| Constructor Summary | |
|---|---|
SWTHelper()
|
|
| Method Summary | |
|---|---|
static void |
collapseAll(org.eclipse.swt.widgets.Tree tree)
|
static org.eclipse.swt.graphics.Color |
createColor(int r,
int g,
int b)
Creates a Color object and register in the resource tracker for later disposal. |
static org.eclipse.swt.graphics.Font |
createFont(org.eclipse.swt.graphics.FontData data)
Creates a font that is registered in the resource tracker. |
static org.eclipse.swt.graphics.Font |
createFont(org.eclipse.swt.graphics.FontData[] data)
Creates a font that is registered in the resource tracker. |
static org.eclipse.swt.widgets.ToolItem |
createToolItem(org.eclipse.swt.widgets.ToolBar parent,
int type,
java.lang.String text,
java.lang.String toolTipText,
java.lang.String imageName,
boolean createHotImage)
Helper function to create a tool item. |
static org.eclipse.swt.graphics.Image |
decorateImage(org.eclipse.swt.graphics.Image baseImage,
org.eclipse.swt.graphics.Image decorator,
int corner)
Returns an image composed of a base image decorated by another image. |
static org.eclipse.swt.graphics.Image |
decorateImage(java.lang.String baseImage,
java.lang.String decorator,
int corner)
Returns an image composed of a base image decorated by another image. |
static void |
disposeAll()
Dispose all registered OS resources. |
static void |
expandAll(org.eclipse.swt.widgets.Tree tree)
|
static org.eclipse.swt.widgets.Display |
getDisplay()
Try to return the current display. |
static org.eclipse.swt.graphics.Color[] |
getGradientColors(int steps,
org.eclipse.swt.graphics.Color start,
org.eclipse.swt.graphics.Color end)
Computes the gradient between two colors. |
static org.eclipse.jface.resource.ImageDescriptor |
getImageDescriptor(java.lang.String fileName)
Returns an ImageDescriptor from the application's
image directory but DOES NOT register it with the resource
tracker. |
static java.lang.String |
getImageURL(java.lang.String fileName)
Returns the file URL of the image on the local temporary directory. |
static java.io.InputStream |
getResourceAsStream(java.lang.String fileName)
Loads an image from the application's image directory and register it with a resource tracker for later disposal by the disposeAll() function. |
static org.eclipse.swt.graphics.Image |
loadGrayImage(java.lang.String fileName)
Loads an image from the application's image directory, then computes the correszponding gray image and finally register the grayed image with a resource tracker for later disposal by the disposeAll()
function. |
static org.eclipse.swt.graphics.Image |
loadImage(java.lang.String fileName)
Loads an image from the application's image directory and register it with a resource tracker for later disposal by the disposeAll() function. |
protected static org.eclipse.swt.graphics.Image |
loadImage(java.lang.String fileName,
boolean register)
Loads an image from the application's image directory and register it with a resource tracker for later disposal by the disposeAll() function if the register parameter
is set to true. |
static org.eclipse.swt.graphics.Font |
makeBoldFont(org.eclipse.swt.graphics.Font sourceFont)
Turns the specified Font bold. |
private static void |
setNodesExpandedState(org.eclipse.swt.widgets.TreeItem current,
boolean expand)
|
private static boolean |
writeImageToTempDirectory(java.lang.String fileName)
Writes the resource image to the temporary directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final org.slf4j.Logger log
public static final java.lang.String DESC_IMAGES_DIRECTORY
public static final java.lang.String IMAGES_DIRECTORY
public static final java.lang.String GRAY_IMAGE_SUFFIX
private static final java.lang.String tempDir
private static java.util.Map<java.lang.String,org.eclipse.swt.graphics.Resource> resourceTracker
public static final org.eclipse.swt.graphics.Font SYSTEM_FONT
public static final org.eclipse.swt.graphics.Font SYSTEM_FONT_BOLD
private static java.util.Map<org.eclipse.swt.graphics.Image,java.util.HashMap<org.eclipse.swt.graphics.Image,org.eclipse.swt.graphics.Image>> imageToDecoratorMap
| Constructor Detail |
|---|
public SWTHelper()
| Method Detail |
|---|
public static org.eclipse.swt.graphics.Font makeBoldFont(org.eclipse.swt.graphics.Font sourceFont)
Font bold.
sourceFont - the source Font object
Font in Boldpublic static org.eclipse.swt.graphics.Font createFont(org.eclipse.swt.graphics.FontData data)
data - the FontData to create the font
public static org.eclipse.swt.graphics.Font createFont(org.eclipse.swt.graphics.FontData[] data)
data - the FontData to create the font
public static org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String fileName)
ImageDescriptor from the application's
image directory but DOES NOT register it with the resource
tracker.
fileName - the image file name
public static org.eclipse.swt.graphics.Image loadImage(java.lang.String fileName)
disposeAll() function.
fileName - the image file name
public static java.io.InputStream getResourceAsStream(java.lang.String fileName)
disposeAll() function.
fileName - the image file name
InputStream
protected static org.eclipse.swt.graphics.Image loadImage(java.lang.String fileName,
boolean register)
disposeAll() function if the register parameter
is set to true.
fileName - the image file nameregister - if true image is registered in the resource tracker
public static org.eclipse.swt.graphics.Image loadGrayImage(java.lang.String fileName)
disposeAll()
function.
fileName - the image file name
public static void disposeAll()
public static org.eclipse.swt.widgets.ToolItem createToolItem(org.eclipse.swt.widgets.ToolBar parent,
int type,
java.lang.String text,
java.lang.String toolTipText,
java.lang.String imageName,
boolean createHotImage)
public static org.eclipse.swt.graphics.Color[] getGradientColors(int steps,
org.eclipse.swt.graphics.Color start,
org.eclipse.swt.graphics.Color end)
steps - the number of steps for the color transition in the gradientstart - the color at the start of the gradientend - the color at the end of the gradient
public static org.eclipse.swt.graphics.Color createColor(int r,
int g,
int b)
r - the red composant of the colorg - the green composant of the colorb - the blue composant of the color
public static java.lang.String getImageURL(java.lang.String fileName)
fileName - the image file name
private static boolean writeImageToTempDirectory(java.lang.String fileName)
fileName - the image file name
public static org.eclipse.swt.widgets.Display getDisplay()
public static org.eclipse.swt.graphics.Image decorateImage(java.lang.String baseImage,
java.lang.String decorator,
int corner)
baseImage - The filename of the base image that should be decorateddecorator - The filename of the image used to decorate the base imagecorner - The corner to place decorator image
public static org.eclipse.swt.graphics.Image decorateImage(org.eclipse.swt.graphics.Image baseImage,
org.eclipse.swt.graphics.Image decorator,
int corner)
baseImage - Image The base image that should be decorateddecorator - Image The image used to decorate the base imagecorner - The corner to place decorator image
public static void expandAll(org.eclipse.swt.widgets.Tree tree)
public static void collapseAll(org.eclipse.swt.widgets.Tree tree)
private static void setNodesExpandedState(org.eclipse.swt.widgets.TreeItem current,
boolean expand)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||