Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Saving figure Image - connections are cut short in image if scroll bars
Saving figure Image - connections are cut short in image if scroll bars [message #528281] Mon, 19 April 2010 22:31 Go to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
Hi,

I have a GEF Editor where if I save the figure to an image some of the
connections are cut short in the saved image if the diagram is bigger
than the viewport and scroll bars are needed.

I save as follows:

GraphicalViewer diagramViewer;
File file;
....
ScalableFreeformRootEditPart rootEditPart =
(ScalableFreeformRootEditPart)diagramViewer.getRootEditPart( );

IFigure figure = rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS);
Rectangle rectangle = figure.getBounds();

Image image = new Image(Display.getDefault(), rectangle.width + 50,
rectangle.height + 50);

GC gc = new GC(image);
SWTGraphics graphics = new SWTGraphics(gc);
figure.paint(graphics);

ImageLoader loader = new ImageLoader();
loader.data = new ImageData[]{image.getImageData()};

loader.save(file, SWT.IMAGE_PNG);
....

Anyone come across this?

PB
Re: Saving figure Image - connections are cut short in image if scroll bars [message #528286 is a reply to message #528281] Mon, 19 April 2010 22:55 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
On 19/04/2010 23:31, Phillipus wrote:
> Hi,
>
> I have a GEF Editor where if I save the figure to an image some of the
> connections are cut short in the saved image if the diagram is bigger
> than the viewport and scroll bars are needed.
>
> I save as follows:
>
> GraphicalViewer diagramViewer;
> File file;
> ...
> ScalableFreeformRootEditPart rootEditPart =
> (ScalableFreeformRootEditPart)diagramViewer.getRootEditPart( );
>
> IFigure figure = rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS);
> Rectangle rectangle = figure.getBounds();
>
> Image image = new Image(Display.getDefault(), rectangle.width + 50,
> rectangle.height + 50);
>
> GC gc = new GC(image);
> SWTGraphics graphics = new SWTGraphics(gc);
> figure.paint(graphics);
>
> ImageLoader loader = new ImageLoader();
> loader.data = new ImageData[]{image.getImageData()};
>
> loader.save(file, SWT.IMAGE_PNG);
> ...
>
> Anyone come across this?
>
> PB

Now I know why this is - because I'm using GEF 3.6 and in GEF 3.6 in the
ConnectionLayer.java class they added a ClippingStrategy "which takes
into account nested view ports and truncates those parts of connections
which reach outside."

Great.
Re: Saving figure Image - connections are cut short in image if scroll bars [message #528287 is a reply to message #528286] Mon, 19 April 2010 23:11 Go to previous message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
On 19/04/2010 23:55, Phillipus wrote:
> On 19/04/2010 23:31, Phillipus wrote:
>> Hi,
>>
>> I have a GEF Editor where if I save the figure to an image some of the
>> connections are cut short in the saved image if the diagram is bigger
>> than the viewport and scroll bars are needed.
>>
>> I save as follows:
>>
>> GraphicalViewer diagramViewer;
>> File file;
>> ...
>> ScalableFreeformRootEditPart rootEditPart =
>> (ScalableFreeformRootEditPart)diagramViewer.getRootEditPart( );
>>
>> IFigure figure = rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS);
>> Rectangle rectangle = figure.getBounds();
>>
>> Image image = new Image(Display.getDefault(), rectangle.width + 50,
>> rectangle.height + 50);
>>
>> GC gc = new GC(image);
>> SWTGraphics graphics = new SWTGraphics(gc);
>> figure.paint(graphics);
>>
>> ImageLoader loader = new ImageLoader();
>> loader.data = new ImageData[]{image.getImageData()};
>>
>> loader.save(file, SWT.IMAGE_PNG);
>> ...
>>
>> Anyone come across this?
>>
>> PB
>
> Now I know why this is - because I'm using GEF 3.6 and in GEF 3.6 in the
> ConnectionLayer.java class they added a ClippingStrategy "which takes
> into account nested view ports and truncates those parts of connections
> which reach outside."
>
> Great.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=309749
Previous Topic:NullPointer Exception During initializeGraphicalViewer
Next Topic:Add a new TextContainer
Goto Forum:
  


Current Time: Mon Nov 24 07:03:52 GMT 2014

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

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