package com.swtdesigner;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
/**
* Utility class for managing OS resources associated with SWT controls such as colors, fonts, images, etc.
* <p>
* !!! 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)
* <p>
* This class may be freely distributed as part of any application or plugin.
* <p>
* @author scheglov_ke
* @author Dan Rubel
*/
public class SWTResourceManager {
////////////////////////////////////////////////////////////////////////////
//
// Color
//
////////////////////////////////////////////////////////////////////////////
private static Map<RGB, Color> m_colorMap = new HashMap<RGB, Color>();
/**
* Returns the system {@link Color} matching the specific ID.
*
* @param systemColorID
* the ID value for the color
* @return the system {@link Color} matching the specific ID
*/
public static Color getColor(int systemColorID) {
Display display = Display.getCurrent();
return display.getSystemColor(systemColorID);
}
/**
* Returns a {@link Color} given its red, green and blue component values.
*
* @param r
* the red component of the color
* @param g
* the green component of the color
* @param b
* the blue component of the color
* @return the {@link Color} matching the given red, green and blue component values
*/
public static Color getColor(int r, int g, int b) {
return getColor(new RGB(r, g, b));
}
/**
* Returns a {@link Color} given its RGB value.
*
* @param rgb
* the {@link RGB} value of the color
* @return the {@link 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 {@link Color}'s.
*/
public static void disposeColors() {
for (Color color : m_colorMap.values()) {
color.dispose();
}
m_colorMap.clear();
}
////////////////////////////////////////////////////////////////////////////
//
// Image
//
////////////////////////////////////////////////////////////////////////////
/**
* Maps image paths to images.
*/
private static Map<String, Image> m_imageMap = new HashMap<String, Image>();
/**
* Returns an {@link Image} encoded by the specified {@link InputStream}.
*
* @param stream
* the {@link InputStream} encoding the image data
* @return the {@link Image} encoded by the specified input stream
*/
protected static Image getImage(InputStream stream) throws IOException {
try {
Display display = Display.getCurrent();
ImageData data = new ImageData(stream);
if (data.transparentPixel > 0) {
return new Image(display, data, data.getTransparencyMask());
}
return new Image(display, data);
} finally {
stream.close();
}
}
/**
* Returns an {@link Image} stored in the file at the specified path.
*
* @param path
* the path to the image file
* @return the {@link Image} stored in the file at the specified path
*/
public static Image getImage(String path) {
Image image = m_imageMap.get(path);
if (image == null) {
try {
image = getImage(new FileInputStream(path));
m_imageMap.put(path, image);
} catch (Exception e) {
image = getMissingImage();
m_imageMap.put(path, image);
}
}
return image;
}
/**
* Returns an {@link Image} stored in the file at the specified path relative to the specified class.
*
* @param clazz
* the {@link Class} relative to which to find the image
* @param path
* the path to the image file, if starts with <code>'/'</code>
* @return the {@link 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_imageMap.get(key);
if (image == null) {
try {
image = getImage(clazz.getResourceAsStream(path));
m_imageMap.put(key, image);
} catch (Exception e) {
image = getMissingImage();
m_imageMap.put(key, image);
}
}
return image;
}
private static final int MISSING_IMAGE_SIZE = 10;
/**
* @return the small {@link Image} that can be used as placeholder for missing image.
*/
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;
/**
* Internal value.
*/
protected static final int LAST_CORNER_KEY = 5;
/**
* Maps images to decorated images.
*/
@SuppressWarnings("unchecked")
private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
/**
* Returns an {@link Image} composed of a base image decorated by another image.
*
* @param baseImage
* the base {@link Image} that should be decorated
* @param decorator
* the {@link Image} to decorate the base image
* @return {@link Image} The resulting decorated image
*/
public static Image decorateImage(Image baseImage, Image decorator) {
return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
}
/**
* Returns an {@link Image} composed of a base image decorated by another image.
*
* @param baseImage
* the base {@link Image} that should be decorated
* @param decorator
* the {@link Image} to decorate the base image
* @param corner
* the corner to place decorator image
* @return the resulting decorated {@link Image}
*/
public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
if (corner <= 0 || corner >= LAST_CORNER_KEY) {
throw new IllegalArgumentException("Wrong decorate corner");
}
Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[corner];
if (cornerDecoratedImageMap == null) {
cornerDecoratedImageMap = new HashMap<Image, Map<Image, Image>>();
m_decoratedImageMap[corner] = cornerDecoratedImageMap;
}
Map<Image, Image> decoratedMap = cornerDecoratedImageMap.get(baseImage);
if (decoratedMap == null) {
decoratedMap = new HashMap<Image, Image>();
cornerDecoratedImageMap.put(baseImage, decoratedMap);
}
//
Image result = decoratedMap.get(decorator);
if (result == null) {
Rectangle bib = baseImage.getBounds();
Rectangle dib = decorator.getBounds();
//
result = new Image(Display.getCurrent(), bib.width, bib.height);
//
GC gc = new GC(result);
gc.draw
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java版课程进度管理系统,使用富客户端开发。 软件目的:对学校课程及进度进行管理,并且将学生合理安排到某个教室,通过本软件,可以将课程进度及教师,教室直观体现。 1. 教师管理:教师信息添加,修改,删除,查询。 a) 拓展:教师可教授阶段(一,二,三,四) 2. 教室管理:教室信息添加,修改,删除,查询,需要体现教室容纳人数,是否占用,占用期限(XX到XX) a) 拓展:该教室授课教师,授课阶段。 3. 阶段管理:阶段信息管理。开始一个阶段(需要教师,教室,阶段信息),转入下阶段(阶段信息,教师,教室情况),最后一阶段完毕后,结业。 4. 课程管理:每阶段课程管理。需要包括课程名,课时数。 5. 阶段信息总揽:可以通过教师,查看该教师所教的阶段情况。通过教室查看阶段情况,直接通过某阶段查看。 选做: 1. 某阶段如果某天有情况,则进度可以推迟。 2. 某阶段学生情况。 3. 某阶段根据上课时间计算课时数,以此计算,该阶段当前讲课进度。 附上源码与数据库(SQL Server2005).第一次做,难免有不足,仅供参考。
资源推荐
资源详情
资源评论
收起资源包目录
java+SQL Server2005 课程进度管理系统(eclipse+富客户端) (2576个子文件)
SWTResourceManager.class 11KB
ResourceManager.class 9KB
ClassroomManage.class 9KB
CourseManage.class 9KB
Teacherchange.class 9KB
ClassManage.class 9KB
AddClass.class 8KB
TeacherMessage.class 6KB
AddTeacher$1.class 6KB
ManageTree.class 6KB
NestStage.class 6KB
TeacherManage.class 5KB
AddCourse.class 5KB
Teacherchange$1.class 5KB
ClassManage$2.class 5KB
CourseChange.class 5KB
AddTeacher.class 5KB
AddClass$3.class 4KB
AddClassroom$1.class 4KB
ClassroomChange.class 4KB
NestStage$2.class 4KB
CourseChange$1.class 4KB
Vacation.class 4KB
AddClassroom.class 4KB
AddClassNC$2.class 3KB
AddClassNC.class 3KB
ClassManage$1.class 3KB
AddCourse$1.class 3KB
AddClassNC$1.class 3KB
Login.class 3KB
CourseManage$2.class 3KB
ClassroomChange$1.class 3KB
Vacation$1.class 3KB
ManageTree$7.class 3KB
TeacherManage$3.class 2KB
ClassroomManage$3.class 2KB
Login$1.class 2KB
CourseManage$6.class 2KB
Teacher.class 2KB
Today.class 2KB
CourseManage$5.class 2KB
AddCourse$2.class 2KB
TeacherManage$1.class 2KB
TeacherManage$2.class 2KB
ConnectSql.class 2KB
InputFactory.class 2KB
ClassroomManage$2.class 2KB
Application.class 2KB
AddClass$2.class 2KB
AddClass$1.class 2KB
ResourceManager$1.class 2KB
ApplicationWorkbenchAdvisor.class 2KB
CourseManage$4.class 2KB
CourseManage$3.class 1KB
AddClass$4.class 1KB
ManageTree$4.class 1KB
ManageTree$2.class 1KB
ManageTree$3.class 1KB
ManageTree$6.class 1KB
ManageTree$8.class 1KB
ManageTree$1.class 1KB
ManageTree$5.class 1KB
CourseManage$8.class 1KB
ApplicationWorkbenchWindowAdvisor.class 1KB
CourseManage$9.class 1KB
CourseManage$7.class 1KB
CourseManage$1.class 1KB
NestStage$1.class 1KB
Activator.class 1KB
BaseInput.class 1KB
Teacherchange$3.class 1018B
Teacherchange$5.class 1018B
Teacherchange$4.class 1014B
Teacherchange$2.class 1014B
MyInput.class 947B
ClassroomManage$1.class 921B
Application$1.class 915B
TeacherManage$4.class 902B
ClassManage$3.class 893B
ApplicationActionBarAdvisor.class 819B
Perspective.class 683B
ResourceManager$PluginResourceProvider.class 317B
StudentAddInput.class 281B
.classpath 513B
Thumbs.db 21KB
alt_about.gif 9KB
debug_wiz.gif 4KB
debug_wiz.gif 4KB
jarToPlugin_wiz.gif 4KB
jarToPlugin_wiz.gif 4KB
profile_wiz.gif 3KB
profile_wiz.gif 3KB
newint_wiz(2).gif 3KB
newint_wiz(2).gif 3KB
packrefact_wiz.gif 3KB
packrefact_wiz.gif 3KB
target_wiz.gif 3KB
target_wiz.gif 3KB
newenum_wiz(2).gif 3KB
newenum_wiz(2).gif 3KB
共 2576 条
- 1
- 2
- 3
- 4
- 5
- 6
- 26
资源评论
- wuyounyoun2012-08-30运行不出来!
- u0126000822013-10-29还行 能用 但是bug太多了
- rr2436344732014-06-09这个不能用的啊
- ccggkko2012-06-27为什么一点击登录窗口就消失了?
沙子
- 粉丝: 8
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 操作简单的Mongodb网页web管理工具,基于Spring Boot2.0支持mongodb集群.zip
- tms-mongodb-web,提供访问mongodb数据的REST API和可灵活扩展的mongodb web 客户端.zip
- SpringBoot整合mongodb学习MongoTemplate和MongoRepository两种方式CRUD使用.zip
- SpringBoot整合MongoDB实现对数据库的CRUD小demo.zip
- Python操作MongoDB数据库的基本一些操作 .zip
- NOSQL数据库监控工具,目前实现了对Redis、MongoDB的监控功能 .zip
- mongoDB数据库的增删改查,以及所需要的配置.zip
- mongodb数据库idea测试.zip
- koa 分别 连接 mysql、mongodb数据库操作.zip
- 基于pytorch实现的人体部件分割源码+模型.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功