package com.swtdesigner;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
/**
* Utility class for managing OS resources associated with SWT controls such as
* colors, fonts, images, etc.
*
* !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code>
* method to release the operating system resources managed by cached objects
* when those objects and OS resources are no longer needed (e.g. on
* application shutdown)
*
* This class may be freely distributed as part of any application or plugin.
* <p>
* Copyright (c) 2003 - 2005, Instantiations, Inc. <br>All Rights Reserved
*
* @author scheglov_ke
* @author Dan Rubel
*/
public class SWTResourceManager {
/**
* Dispose of cached objects and their underlying OS resources. This should
* only be called when the cached objects are no longer needed (e.g. on
* application shutdown)
*/
public static void dispose() {
disposeColors();
disposeFonts();
disposeImages();
disposeCursors();
}
//////////////////////////////
// Color support
//////////////////////////////
/**
* Maps RGB values to colors
*/
private static HashMap<RGB, Color> m_ColorMap = new HashMap<RGB, Color>();
/**
* Returns the system color matching the specific ID
* @param systemColorID int The ID value for the color
* @return Color The system color matching the specific ID
*/
public static Color getColor(int systemColorID) {
Display display = Display.getCurrent();
return display.getSystemColor(systemColorID);
}
/**
* Returns a color given its red, green and blue component values
* @param r int The red component of the color
* @param g int The green component of the color
* @param b int The blue component of the color
* @return Color The color matching the given red, green and blue componet values
*/
public static Color getColor(int r, int g, int b) {
return getColor(new RGB(r, g, b));
}
/**
* Returns a color given its RGB value
* @param rgb RGB The RGB value of the color
* @return Color The color matching the RGB value
*/
public static Color getColor(RGB rgb) {
Color color = m_ColorMap.get(rgb);
if (color == null) {
Display display = Display.getCurrent();
color = new Color(display, rgb);
m_ColorMap.put(rgb, color);
}
return color;
}
/**
* Dispose of all the cached colors
*/
public static void disposeColors() {
for (Iterator<Color> iter = m_ColorMap.values().iterator(); iter.hasNext();)
iter.next().dispose();
m_ColorMap.clear();
}
//////////////////////////////
// Image support
//////////////////////////////
/**
* Maps image names to images
*/
private static HashMap<String, Image> m_ClassImageMap = new HashMap<String, Image>();
/**
* Maps images to image decorators
*/
private static HashMap<Image, HashMap<Image, Image>> m_ImageToDecoratorMap = new HashMap<Image, HashMap<Image, Image>>();
/**
* Returns an image encoded by the specified input stream
* @param is InputStream The input stream encoding the image data
* @return Image The image encoded by the specified input stream
*/
protected static Image getImage(InputStream is) {
Display display = Display.getCurrent();
ImageData data = new ImageData(is);
if (data.transparentPixel > 0)
return new Image(display, data, data.getTransparencyMask());
return new Image(display, data);
}
/**
* Returns an image stored in the file at the specified path
* @param path String The path to the image file
* @return Image The image stored in the file at the specified path
*/
public static Image getImage(String path) {
return getImage("default", path); //$NON-NLS-1$
}
/**
* Returns an image stored in the file at the specified path
* @param section The section to which belongs specified image
* @param path String The path to the image file
* @return Image The image stored in the file at the specified path
*/
public static Image getImage(String section, String path) {
String key = section + '|' + SWTResourceManager.class.getName() + '|' + path;
Image image = m_ClassImageMap.get(key);
if (image == null) {
try {
FileInputStream fis = new FileInputStream(path);
image = getImage(fis);
m_ClassImageMap.put(key, image);
fis.close();
} catch (Exception e) {
image = getMissingImage();
m_ClassImageMap.put(key, image);
}
}
return image;
}
/**
* Returns an image stored in the file at the specified path relative to the specified class
* @param clazz Class The class relative to which to find the image
* @param path String The path to the image file
* @return Image The image stored in the file at the specified path
*/
public static Image getImage(Class<?> clazz, String path) {
String key = clazz.getName() + '|' + path;
Image image = m_ClassImageMap.get(key);
if (image == null) {
try {
if (path.length() > 0 && path.charAt(0) == '/') {
String newPath = path.substring(1, path.length());
image = getImage(new BufferedInputStream(clazz.getClassLoader().getResourceAsStream(newPath)));
} else {
image = getImage(clazz.getResourceAsStream(path));
}
m_ClassImageMap.put(key, image);
} catch (Exception e) {
image = getMissingImage();
m_ClassImageMap.put(key, image);
}
}
return image;
}
private static final int MISSING_IMAGE_SIZE = 10;
private static Image getMissingImage() {
Image image = new Image(Display.getCurrent(), MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
//
GC gc = new GC(image);
gc.setBackground(getColor(SWT.COLOR_RED));
gc.fillRectangle(0, 0, MISSING_IMAGE_SIZE, MISSING_IMAGE_SIZE);
gc.dispose();
//
return image;
}
/**
* Style constant for placing decorator image in top left corner of base image.
*/
public static final int TOP_LEFT = 1;
/**
* Style constant for placing decorator image in top right corner of base image.
*/
public static final int TOP_RIGHT = 2;
/**
* Style constant for placing decorator image in bottom left corner of base image.
*/
public static final int BOTTOM_LEFT = 3;
/**
* Style constant for placing decorator image in bottom right corner of base image.
*/
public static final int BOTTOM_RIGHT = 4;
/**
* Returns an image composed of a base image decorated by another image
* @param baseImage Image The base image that should be decorated
* @param decorator Image The image to decorate the base image
* @return Image The resulting decorated image
*/
public static Image decorateImage(Image baseImage, Image decorator) {
return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
}
/**
* Returns an image composed of a base image decorated by another image
* @param baseImage Image The base image that should be decorated
* @param decorator Image The image to decorate the base image
* @param corner The corner to place decorator image
* @return Image The resulting decorated image
*/
public static Image decorateImage(Image baseImage, Image decorator, int corner) {
HashMap<Image, Image> decoratedMap = m_ImageToDecoratorMap.get(baseImage);
if (decoratedMap
没有合适的资源?快使用搜索试试~ 我知道了~
Java课程设计——报刊管理系统
共52个文件
class:34个
java:8个
prefs:1个
4星 · 超过85%的资源 需积分: 29 87 下载量 98 浏览量
2014-05-26
11:17:53
上传
评论 13
收藏 8.21MB RAR 举报
温馨提示
报刊订阅管理系统的设计与实现 通过对某企业的报刊订阅业务进行分析、调查,设计该企业的报刊订阅管理系统。主要实现以下功能: ①录入功能:录入订阅人员信息、报刊基本信息; ②订阅功能:订阅人员订阅报刊(并计算出其金额); ③查询功能:按人员查询、按报刊查询、按部门查询有关订阅信息,对查询结果能进行预览和打印; ④统计功能:按报刊统计、按人员统计、按部门统计,对统计结果能进行预览和打印; ⑤系统维护:如数据安全管理(含备份与恢复)、操作员管理、权限设置等; 要求:创建相关视图、存储过程、触发器; 建立数据库相关表之间的完整性约束
资源推荐
资源详情
资源评论
收起资源包目录
magazine.rar (52个子文件)
magazine
bin
com
swtdesigner
SWTResourceManager.class 13KB
SWTResourceManager$1.class 857B
magazine
Worker_admin$4.class 3KB
Worker_admin$3.class 1018B
Order_query$5.class 1KB
Order_query$3.class 798B
Main_admin$6.class 791B
Order_query$4.class 1KB
Magazine_admin.class 6KB
Magazine_admin$2.class 816B
Worker_admin$2.class 3KB
Magazine_admin$3.class 987B
Order_admin$1.class 798B
Order_tongji$1.class 804B
Worker_admin$1.class 2KB
Main_admin$7.class 792B
Main_admin$8.class 797B
Worker_admin.class 7KB
Order_query$2.class 1KB
Order_admin.class 7KB
Main_admin$2.class 803B
Order_tongji.class 6KB
Order_query$1.class 1KB
Main_admin$3.class 791B
Main_admin$4.class 788B
Department_admin$1.class 828B
Department_admin.class 5KB
Order_query.class 6KB
Worker_admin$6.class 1KB
Main_admin.class 4KB
Worker_admin$5.class 804B
Magazine_admin$1.class 987B
Main_admin$5.class 788B
Main_admin$1.class 797B
magazine manager_fat.jar 7.64MB
data
magazine.mdf 3MB
magazine_log.ldf 2MB
swt-win32-3235.dll 316KB
.settings
org.eclipse.jdt.core.prefs 598B
src
com
swtdesigner
SWTResourceManager.java 15KB
magazine
Main_admin.java 5KB
Department_admin.java 4KB
Worker_admin.java 11KB
Order_tongji.java 7KB
Magazine_admin.java 6KB
Order_admin.java 8KB
Order_query.java 7KB
.project 392B
.fatjar 304B
Thumbs.db 15KB
.classpath 295B
Manifest 123B
共 52 条
- 1
资源评论
- z6641306002014-07-16有错误啊 在研究
- fwen92002014-06-10别人做的挺好的只不过自己只能参考形式
Jerry-Yang
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 散斑结构光测试图像-对应博客:https://mp.csdn.net/mp-blog/creation/editor/13817
- 20220823-1000-ts.dat
- Galaxy10CNN实现星系图像分类项目深度学习环境配置
- DVB-S2:GCS组帧数据.dat
- 基于强化学习Q-Learning方法实现机器人走迷宫源码.zip
- numpy+pandas_basics.ipynb
- 网络安全-Diffie Hellman密钥协商
- 双H桥电机驱动L298N芯片AD集成库ALTIUM库(原理图库+PCB封装库)文件.zip
- 计算机组成原理实验;16位运算器ALU CPU设计
- 毕设绝技 - 4天玩乐完成商城系统完整资料day04
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功