/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.examples.imageanalyzer;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.printing.*;
import org.eclipse.swt.custom.*;
import java.util.*;
import java.net.*;
import java.io.*;
import java.text.MessageFormat;
public class ImageAnalyzer {
static ResourceBundle bundle = ResourceBundle.getBundle("examples_images");
Display display;
Shell shell;
Canvas imageCanvas, paletteCanvas;
Label typeLabel, sizeLabel, depthLabel, transparentPixelLabel,
timeToLoadLabel, screenSizeLabel, backgroundPixelLabel,
locationLabel, disposalMethodLabel, delayTimeLabel,
repeatCountLabel, paletteLabel, dataLabel, statusLabel;
Combo backgroundCombo, scaleXCombo, scaleYCombo, alphaCombo;
Button incrementalCheck, transparentCheck, maskCheck, backgroundCheck;
Button previousButton, nextButton, animateButton;
StyledText dataText;
Sash sash;
Color whiteColor, blackColor, redColor, greenColor, blueColor, canvasBackground;
Font fixedWidthFont;
Cursor crossCursor;
GC imageCanvasGC;
int paletteWidth = 140; // recalculated and used as a width hint
int ix = 0, iy = 0, py = 0; // used to scroll the image and palette
float xscale = 1, yscale = 1; // used to scale the image
int alpha = 255; // used to modify the alpha value of the image
boolean incremental = false; // used to incrementally display an image
boolean transparent = true; // used to display an image with transparency
boolean showMask = false; // used to display an icon mask or transparent image mask
boolean showBackground = false; // used to display the background of an animated image
boolean animate = false; // used to animate a multi-image file
Thread animateThread; // draws animated images
Thread incrementalThread; // draws incremental images
String lastPath; // used to seed the file dialog
String currentName; // the current image file or URL name
String fileName; // the current image file
ImageLoader loader; // the loader for the current image file
ImageData[] imageDataArray; // all image data read from the current file
int imageDataIndex; // the index of the current image data
ImageData imageData; // the currently-displayed image data
Image image; // the currently-displayed image
Vector incrementalEvents; // incremental image events
long loadTime = 0; // the time it took to load the current image
static final int INDEX_DIGITS = 4;
static final int ALPHA_CHARS = 5;
static final int ALPHA_CONSTANT = 0;
static final int ALPHA_X = 1;
static final int ALPHA_Y = 2;
static final String[] OPEN_FILTER_EXTENSIONS = new String[] {
"*.bmp; *.gif; *.ico; *.jfif; *.jpeg; *.jpg; *.png; *.tif; *.tiff",
"*.bmp", "*.gif", "*.ico", "*.jpg; *.jpeg; *.jfif", "*.png", "*.tif; *.tiff" };
static final String[] OPEN_FILTER_NAMES = new String[] {
bundle.getString("All_images") + " (bmp, gif, ico, jfif, jpeg, jpg, png, tif, tiff)",
"BMP (*.bmp)", "GIF (*.gif)", "ICO (*.ico)", "JPEG (*.jpg, *.jpeg, *.jfif)",
"PNG (*.png)", "TIFF (*.tif, *.tiff)" };
static final String[] SAVE_FILTER_EXTENSIONS = new String[] {
"*.bmp", "*.gif", "*.ico", "*.jpg", "*.png", "*.tif" };
static final String[] SAVE_FILTER_NAMES = new String[] {
"BMP (*.bmp)", "GIF (*.gif)", "ICO (*.ico)", "JPEG (*.jpg)",
"PNG (*.png)", "TIFF (*.tif)" };
class TextPrompter extends Dialog {
String message = "";
String result = null;
Shell dialog;
Text text;
public TextPrompter (Shell parent, int style) {
super (parent, style);
}
public TextPrompter (Shell parent) {
this (parent, SWT.APPLICATION_MODAL);
}
public String getMessage () {
return message;
}
public void setMessage (String string) {
message = string;
}
public String open () {
dialog = new Shell(getParent(), getStyle());
dialog.setText(getText());
dialog.setLayout(new GridLayout());
Label label = new Label(dialog, SWT.NONE);
label.setText(message);
label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text = new Text(dialog, SWT.SINGLE | SWT.BORDER);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = 300;
text.setLayoutData(data);
Composite buttons = new Composite(dialog, SWT.NONE);
GridLayout grid = new GridLayout();
grid.numColumns = 2;
buttons.setLayout(grid);
buttons.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
Button ok = new Button(buttons, SWT.PUSH);
ok.setText(bundle.getString("OK"));
data = new GridData();
data.widthHint = 75;
ok.setLayoutData(data);
ok.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
result = text.getText();
dialog.dispose();
}
});
Button cancel = new Button(buttons, SWT.PUSH);
cancel.setText(bundle.getString("Cancel"));
data = new GridData();
data.widthHint = 75;
cancel.setLayoutData(data);
cancel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
dialog.dispose();
}
});
dialog.setDefaultButton(ok);
dialog.pack();
dialog.open();
while (!dialog.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
return result;
}
}
public static void main(String [] args) {
Display display = new Display();
ImageAnalyzer imageAnalyzer = new ImageAnalyzer();
Shell shell = imageAnalyzer.open(display);
while (!shell.isDisposed())
if (!display.readAndDispatch()) display.sleep();
display.dispose();
}
public Shell open(Display dpy) {
// Create a window and set its title.
this.display = dpy;
shell = new Shell(display);
shell.setText(bundle.getString("Image_analyzer"));
// Hook resize and dispose listeners.
shell.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
resizeShell(event);
}
});
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
animate = false; // stop any animation in progress
if (animateThread != null) {
// wait for the thread to die before disposing the shell.
while (animateThread.isAlive()) {
if (!display.readAndDispatch()) display.sleep();
}
}
e.doit = true;
}
});
shell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
// Clean up.
if (image != null)
image.dispose();
whiteColor.dispose();
blackColor.dispose();
redColor.dispose();
greenColor.dispose();
blueColor.dispose();
fixedWidthFont.dispose();
crossCursor.dispose();
}
});
// Create colors and fonts.
whiteColor = new Color(display, 255, 255, 255);
blackColor = new Color(display, 0, 0, 0);
redColor = new Color(display, 255, 0, 0);
greenColor = new Color(display, 0, 255, 0);
blueColor = new Color(display, 0, 0, 255);
fixedWidthFont = new Font(display, "courier", 10, 0);
crossCursor = new Cursor(display, SWT.CURSOR_CROSS);
// Add a menu bar and widgets.
createMenuBar();
createWidgets();
shell.pack();
// Create a GC for drawing, and hook the listener to dispose it.
imageCanvasGC = new GC(imageCanvas);
imageCanvas.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
imageCanvasGC.dispose();
}
});
// Open the window
shell.open();
return shell;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Eclipse 插件开发官方示例 (528个子文件)
eclipse12.bmp 7KB
eclipse09.bmp 7KB
eclipse03.bmp 7KB
eclipse01.bmp 7KB
eclipse06.bmp 7KB
eclipse10.bmp 7KB
eclipse05.bmp 7KB
eclipse08.bmp 7KB
eclipse11.bmp 7KB
eclipse04.bmp 7KB
eclipse02.bmp 7KB
eclipse07.bmp 7KB
underline_mask.bmp 1KB
strikeout.bmp 1KB
italic_mask.bmp 1KB
strikeout_mask.bmp 1KB
italic.bmp 1KB
underline.bmp 1KB
strikeout.bmp 630B
underline_mask.bmp 630B
strikeout_mask.bmp 630B
underline.bmp 630B
erase.bmp 334B
blue.bmp 334B
green.bmp 334B
red.bmp 334B
yellow.bmp 214B
red.bmp 214B
blue_mask.bmp 134B
red_mask.bmp 134B
erase_mask.bmp 134B
bold_mask.bmp 134B
bold.bmp 134B
green_mask.bmp 134B
red_mask.bmp 110B
italic_mask.bmp 110B
yellow_mask.bmp 110B
bold.bmp 110B
bold_mask.bmp 110B
italic.bmp 110B
style.css 2KB
style.css 2KB
style.css 2KB
style.css 2KB
.eclipseextension 0B
org.eclipse.swt.examples.launcher.launchItems.exsd 7KB
Back640x440.gif 123KB
Back640x440.gif 123KB
Back640x440.gif 123KB
texture_cells.gif 65KB
texture_cells.gif 65KB
texture_cells.gif 65KB
EditCopy.gif 49KB
PreferencePage.gif 20KB
CreateNewIDMapButton.gif 14KB
IDMap_NewMapping_PreferencePage.gif 7KB
IDMap_NewIDMapScheme.gif 6KB
Ordered_NewOrderedEntry_PreferencePage.gif 5KB
Ordered_NewIDMapScheme.gif 5KB
IDMapContextMenu.gif 5KB
IDMap_SelectMyPlugin.gif 4KB
IDMap_MyPlugin.gif 3KB
Ordered_MyANT.gif 3KB
IDMap_NewMapping_ContextMenu.gif 3KB
Ordered_NewOrderedEntry_ContextMenu.gif 3KB
Ordered_UnorderedScheme.gif 3KB
IDMap_GeneralMatching.gif 3KB
newreadme_wiz.gif 2KB
black_chip.gif 2KB
white_chip.gif 2KB
wall_chip.gif 2KB
wall_people.gif 2KB
wall_pawn.gif 2KB
black_pawn.gif 2KB
white_pawn.gif 2KB
blue_people.gif 2KB
gold_people.gif 2KB
black.gif 1KB
wall.gif 1KB
sample.gif 983B
resolver.gif 983B
prj_obj.gif 956B
editor.gif 932B
home_nav.gif 928B
target.gif 917B
white.gif 910B
closedFolder.gif 906B
tool_airbrush.gif 890B
forward_nav.gif 883B
backward_nav.gif 881B
linestyle_dashdot.gif 880B
linestyle_dash.gif 880B
tool_polyline.gif 879B
linestyle_dot.gif 879B
tool_text.gif 875B
tool_pencil.gif 874B
fill_outline.gif 872B
tool_ellipse.gif 872B
tool_roundedrectangle.gif 871B
linestyle_solid.gif 871B
共 528 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- lgqjeson1262018-12-28比较有用,所需积分是统一设置的吗
zjf_1103
- 粉丝: 18
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功