Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » save diagram as jpg
save diagram as jpg [message #157468] Mon, 29 October 2007 09:49
Eclipse UserFriend
Originally posted by: giuseppeloprete.gmail.com

Hi, I need to save a file ".example_diagram" as a jpg. I wrote the follow
code but I have "invalid thread access exception" when I call the method
copyToImageUtil. Could you help me?
Thanks


CODE:

Resource diagramResource = loadResource(filePathName + "_diagram");
Iterator diagramResourceIte = diagramResource.getContents()
.iterator();
Diagram diagram = (Diagram) diagramResourceIte.next();
if (diagram != null) {
final CopyToImageUtil copyToImageUtil = new
CopyToImageUtil();
Resource modelResource = loadResource(filePathName);

Iterator modelResourceIte = modelResource.getContents()
.iterator();
Object objModel = modelResourceIte.next();
IPath pathParent = Path.fromOSString(filePathName)
.removeLastSegments(1);

String jpegExt = "jpg";
path= new Path("C:\\");
if (path != null) {
path = path.addFileExtension(jpegExt);
try {
copyToImageUtil
.copyToImage(
diagram,
path,
ImageFileFormat.JPG,
new
NullProgressMonitor(),

SuiteDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
} catch (CoreException e) {
e.printStackTrace();
}
}
Previous Topic:translation of the diagram as scroll horizontally
Next Topic:mac os X, gmf editor
Goto Forum:
  


Current Time: Sat Jul 27 17:18:08 GMT 2024

Powered by FUDForum. Page generated in 0.03068 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top