锘??xml version="1.0" encoding="utf-8" standalone="yes"?> GEF緙栬緫鍣ㄦ槸鏋勬灦鍦―raw2D鐨凢igureCanvas涓婄殑,鑰孎igureCanvas鏄痵wt涓瑿anvas鐨勫瓙綾? 褰撳緱鍒癋igureCanvas涔嬪悗,灝卞彲浠ュ緱鍒癎EF緙栬緫鍣ㄧ殑鍖哄煙鍜孏EF緙栬緫鍣ㄥ唴閮ㄧ敾甯冪殑澶у皬: 緙栬緫鍣ㄥ尯鍩熷ぇ灝?FigureCanvas.getBounds(); 鐢誨竷澶у皬:FigureCanvas.getContents.getBounds(); 鑻ヨ瑙﹀彂GEF緙栬緫鍣ㄧ殑婊氬姩鏉℃搷浣?浠呴渶璋冪敤FigureCanvas鐨剆crollToX(int hOffset)鍜宻crollToY(int vOffset)鍗沖彲. 鑾峰彇FigureCanvas鐨勬柟娉曚篃姣旇緝綆鍗?閫氳繃EditPart.getViewer()鑾峰緱EditPartViewer,涓鑸儏鍐典笅EditPartViewer鐨凜ontrol灝辨槸FigureCanvas. 鍒楀嚭浠g爜濡備笅:
榪欐槸榪愮敤浜咶igureCanvas鏄疌anvas瀛愮被鐨勭壒鐐?璋冪敤SWT鐨凜anvas鐨刧etBounds()鏂規硶,鍗寵皟鐢–ontrol鐨刧etBounds()鏂規硶.
榪欐槸榪愮敤浜咺Figure鐨刧etBounds()鏂規硶, 榪欎袱涓尯鍩熺煩褰笉鍙販娣?
canvas.scrollToX(
500
);
canvas.scrollToY(
600
);
System.out.println(canvas.getBounds());
System.out.println(canvas.getContents().getBounds());
]]>
1.浣跨敤Image(Device device, InputStream stream)鏋勯犲嚱鏁?紺轟緥浠g爜濡備笅, path涓哄浘鍍忕浉瀵硅礬寰?private聽Image聽getImage(String聽path)
{
聽聽return聽new聽Image(Display.getCurrent(),聽getClass().getResourceAsStream(path));
}
2.浣跨敤ImageDescriptor鐨刢reateImage()鏂規硶,紺轟緥浠g爜濡備笅,path涓哄浘鍍忕浉瀵硅礬寰?聽private聽Image聽getImage(String聽path)
{
聽聽URL聽url聽=聽null;
聽聽try
{
聽聽聽url聽=聽new聽URL(Activator.getDefault().getDescriptor().getInstallURL(),聽path);
聽聽}catch(MalformedURLException聽e)
{
聽聽聽e.printStackTrace();
聽聽}
聽聽ImageDescriptor聽imageDescriptor聽=聽ImageDescriptor.createFromURL(url);
聽聽return聽imageDescriptor.createImage();
聽}
鎴栬?private聽Image聽getImage(String聽path)
{
聽聽聽ImageDescriptor聽desc聽=聽AbstractUIPlugin.imageDescriptorFromPlugin(ID,聽path);
聽聽聽return聽desc.createImage();
}
]]>
渚嬪,鍦‥clipse Editor瑙嗗浘涓姞鍏igure,闇瑕佽綆楀嚭鐩稿浜嶩ostFigure鐨勫潗鏍?鎵嶈兘姝g‘灝唂igure鏀懼湪榧犳爣鐐瑰嚮鐨勪綅緗?鍙互濡備笅榪欐牱鍋?
鍦╣etCreateCommand(CreateRequest request)鏂規硶涓?鍔犲叆濡備笅璇彞:
Point location = request.getLocation().getCopy();
getHostFigure().translateToRelative(location);
濡傛鑾峰緱鐨刲ocation灝辨槸鐩稿浜嶩ostFigure鐨勫潗鏍?
鑳藉鑾峰緱褰撳墠鍏夋爣緇濆鍧愭爣鐨勬柟娉曟槸:
Display.getDefault().getCursorLocation()
鍒鋒柊璧勬簮綆$悊鍣ㄨ皟鐢ㄦ柟娉?
RefreshLocal
public void refreshLocal(int depth, IProgressMonitor monitor)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 throws CoreException
Refreshes the resource hierarchy from this resource and its children (to the specified depth) relative to the local file system. Creations, deletions, and changes detected in the local file system will be reflected in the workspace's resource tree. This resource need not exist or be local.
This method may discover changes to resources; any such changes will be reported in a subsequent resource change event.
If a new file or directory is discovered in the local file system at or below the location of this resource, any parent folders required to contain the new resource in the workspace will also be created automatically as required.
This method is long-running; progress and cancellation are provided by the given progress monitor.
Parameters:
depth - valid values are DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
CoreException - if this method fails. Reasons include:
Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
OperationCanceledException - if the operation is canceled. Cancelation can occur even if no progress monitor is provided.
See Also:
DEPTH_ZERO, DEPTH_ONE, DEPTH_INFINITE, IResourceRuleFactory.refreshRule(IResource)
璇ユ柟娉曚綅浜巓rg.eclipse.core.resources.IResource
鎴戠殑璋冪敤鏂規硶鏄?
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor);
絳旀鏄彲浠ョ殑.
濡傛灉浣犳墍鍐欑殑Property View綾葷戶鎵胯嚜PropertySheet,閭d箞瀹冨氨鏄墿灞曞嚭鐨勬柊property view. 浣犲悓鏍峰彲浠ュ鍏惰繘琛屽畾鍒?涓嶄細騫叉壈鍒板師鏈夌殑property鐨勬甯告樉紺?
渚嬪,浣犲彲浠ヨ浣犵殑property view 涓嶇洃鍚煇涓猉YZView涓殑浜嬩歡,鍙渶瑕佽鐩栨帀isImportant鏂規硶灝卞彲浠ヤ簡.