display diagram on a stand-alone application [message #158377] |
Mon, 05 November 2007 12:48  |
Eclipse User |
|
|
|
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 04:05  |
Eclipse User |
|
|
|
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();
}
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04240 seconds