Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-27-2010, 11:42 AM
Member
 
Join Date: Jan 2010
Posts: 1
Rep Power: 0
graj83 is on a distinguished road
Default how to save view to .jpg in RCP
hi..

i want to save my view as JPG image iam useing folling code

ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart)gViewer.getEditPartRegistry(). get(LayerManager.ID);
IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LA YERS);
Rectangle rootFigureBounds = rootFigure.getBounds();
Control figureCanvas = gViewer.getControl();
GC figureCanvasGC = new GC(figureCanvas);

Image img = new Image(null, rootFigureBounds.width, rootFigureBounds.height);
GC imageGC = new GC(img);

imageGC.setBackground(figureCanvasGC.getBackground ());
imageGC.setForeground(figureCanvasGC.getForeground ());
imageGC.setFont(figureCanvasGC.getFont());
imageGC.setLineStyle(figureCanvasGC.getLineStyle() );
imageGC.setLineWidth(figureCanvasGC.getLineWidth() );
imageGC.setXORMode(figureCanvasGC.getXORMode());


Graphics imgGraphics = new SWTGraphics(imageGC);
rootFigure.paint(imgGraphics);
ImageData[] imgData = new ImageData[1];
imgData[0] = img.getImageData();
ImageLoader imgLoader = new ImageLoader();
imgLoader.data = imgData;
imgLoader.save("c:/View.jpg", SWT.IMAGE_JPEG);

figureCanvasGC.dispose();
imageGC.dispose();
img.dispose();

my view gViewer contains - x and - y values...
i am able to save the image from (0,0) cordinates can any one tell me the how to get - ve x and y coordinate data

Thanks
Raj
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A view to help hervey Reviews / Advertising 1 10-29-2008 07:37 AM
Updating a view using actions in a seperate view xcallmejudasx Eclipse 0 10-24-2008 09:24 PM
MVC - View Example JavaForums Java Blogs 0 02-13-2008 12:30 PM
MVC - View JavaForums Java Blogs 0 02-13-2008 12:20 AM
How can i save the data Internally(auto save) Rama Koti Reddy AWT / Swing 0 12-10-2007 01:46 PM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 09:23 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org