save diagram as jpg [message #157468] |
Mon, 29 October 2007 05:49 |
Eclipse User |
|
|
|
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();
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.05954 seconds