手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>Java技术>列表

Java WS和二进制数据传送

来源:互联网 作者:west263.com 时间:2008-02-23
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

w.open();
}

public void showImage(String fn) {
IImage_Stub stub = (IImage_Stub) createProxy();
IImage hello = (IImage) stub;

ImageData idata = null;
try {
idata = new ImageData(hello.fetchImg(fn).getInputStream());
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ImageDescriptor id = ImageDescriptor.createFromImageData(idata);
if (image != null)
image.dispose();
image = id.createImage();
// label.setImage(id.createImage());
// canvas.setData(image);
canvas.setImage(image);
}

public Object getFileInfo() {
IImage_Stub stub = (IImage_Stub) createProxy();
IImage hello = (IImage) stub;
ArrayList al = null;
try {
al = hello.fetchFileList();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return al;
}

private Stub createProxy() {
return (Stub) (new BinaryService_Impl().getIImagePort());
}
}


ImageLabelProvider标签类,能滚动图象的组件.

package swtui;

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.*;

public class ImageLabelProvider extends Canvas {
ScrollBar hBar = null;

ScrollBar VBar = null;

private Image image;

public Image getImage() {
return image;
}

public void setImage(Image image) {
this.image = image;
setData(image);
}

public ImageLabelProvider() {
this(null, SWT.CENTER);
// TODO Auto-generated constructor stub
}

public ImageLabelProvider(Composite arg0, int arg1) {
super(arg0, arg1);
hBar = getHorizontalBar();
vBar = getVerticalBar();
setListener();
// TODO Auto-generated constructor stub
}

public void adjustSize() {
if(image==null)
return;
final Point origin = new Point(0, 0);
Rectangle rect = image.getBounds();
Rectangle client = getClientArea();
hBar.setMaximum(rect.width);
vBar.setMaximum(rect.height);
hBar.setThumb(Math.min(rect.width, client.width));
vBar.setThumb(Math.min(rect.height, client.height));
int hPage = rect.width - client.width;
int vPage = rect.height - client.height;
int hSelection = hBar.getSelection();
int vSelection = vBar.getSelection();
if (hSelection >= hPage) {
if (hPage <= 0)
hSelection = 0;
origin.x = -hSelection;
}
if (vSelection >= vPage) {
if (vPage <= 0)
vSelection = 0;
origin.y = -vSelection;
}
redraw();
}

private void setListener() {
final Point origin = new Point(0, 0);

hBar.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
int hSelection = hBar.getSelection();
int destX = -hSelection - origin.x;
Rectangle rect = image.getBounds();
scroll(destX, 0, 0, 0, rect.width, rect.height, false);
origin.x = -hSelection;
}
});
vBar.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
int vSelection = vBar.getSelection();
int destY = -vSelection - origin.y;
Rectangle rect = getBounds();
scroll(0, destY, 0, 0, rect.width, rect.height, false);
origin.y = -vSelection;
}
});
addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
Rectangle rect = image.getBounds();
Rectangle client = getClientArea();
hBar.setMaximum(rect.width);
vBar.setMaximum(rect.height);
hBar.setThumb(Math.min(rect.width, client.width));
vBar.setThumb(Math.min(rect.height, client.height));
int hPage = rect.width - client.width;
int vPage = rect.height - client.height;
int hSelection = hBar.getSelection();
int vSelection = vBar.getSelection();
if (hSelection >= hPage) {
if (hPage <= 0)
hSelection = 0;
origin.x = -hSelection;
}
if (vSelection >= vPage) {
if (vPage <= 0)
vSelection = 0;
origin.y = -vSelection;
}
redraw();
}
});
addListener(SWT.Paint, new Listener() {
public void handleEvent(Event e) {
GC gc = e.gc;
gc.drawImage(image, origin.x, origin.y);
Rectangle rect = image.getBounds();
Rectangle client = getClientArea();
int marginWidth = client.width - rect.width;
if (marginWidth > 0) {

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!