Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » display diagram on a stand-alone application
display diagram on a stand-alone application [message #158377] Mon, 05 November 2007 17:48 Go to next message
hoang_vu is currently offline hoang_vuFriend
Messages: 11
Registered: July 2009
Junior Member
I am building a java project which will show the diagram from gmf model.
My application takes 2 file as input: the diagram file and the model file
( may be placed any where in the file system, not only in the workspace)
and output is display the diagram on the Tab panel. I spent weeks with
many solutions : export to a image file and read it back, read the diagram
directly, and the main problem is that I can get the diagram from a
diagram file ( probably because some example I got always try to read a
diagram file inside a workspace)

Does anyone have solution or some snippet code which fit my requirement?
Thanks,
Hoang
Re: display diagram on a stand-alone application [message #158440 is a reply to message #158377] Tue, 06 November 2007 09:05 Go to previous message
hoang_vu is currently offline hoang_vuFriend
Messages: 11
Registered: July 2009
Junior Member
below is my code which try to save the diagram in a file as a gif file.
the problem happen since the resource content always be null.

public class _test_ {
public static void main(String argv[])
{
CopyToImage();
}
public static void CopyToImage()
{
String outputFileName = "E:\\wheel.gif";
String inputFileName = "E:\\wheel.saveccm";
File output = new File(outputFileName);
//JFileChooser fc = new JFileChooser();
URI uri = URI.createFileURI(inputFileName);
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(uri);
if(resource instanceof XMIResourceImpl){
Object object = resource.getContents().get(0);
CopyToImageUtil copyToImageUtil = new CopyToImageUtil();
try {
copyToImageUtil.copyToImage((Diagram)
object, Path.fromOSString(output.getAbsolutePath()),
ImageFileFormat.GIF, null, PreferencesHint.USE_DEFAULTS);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

}
}
Previous Topic:Plans for gmf 2.1?
Next Topic:Problems with loading a diagram_file
Goto Forum:
  


Current Time: Fri Aug 16 07:31:58 GMT 2024

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

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

Back to the top