Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » PrintGraphicalViewerOperation does not print Connections with Style 'Graphics.LINE_DASH'
PrintGraphicalViewerOperation does not print Connections with Style 'Graphics.LINE_DASH' [message #493837] Wed, 28 October 2009 08:17 Go to next message
Alexander Haag is currently offline Alexander HaagFriend
Messages: 119
Registered: July 2009
Senior Member
Hi there,

I've got a subclass of PrintGraphicalViewerOperation to print the
content of ma graphical Viewer with pagebreaks and footer on every page.

The printoperation does work without complaints.
The only thing that does not work as desined is that my
ConnectionEditParts having lineStyle LINE_DASH are printed as if they
where LINE_SOLID.

Does anybody know what I must do in order to get the correct linestyle
printed?

I added a snippet with the overriden method in
PrintGraphicalViewerOperation below.

Additional Info:
I did set the linestyle of my Connection using
((PolylineConnection) connection).setLineStyle( Graphics.LINE_DASH );
in the createFigure()-Method of my EditPart.
The Connections are routed using ManhattenRouter.
OS: Windows XP
Eclipse Galileo(Build id: 20090619-0625) with
'org.eclipse.gef_3.5.0.v20090528-1511.jar'

Thanks for all your help and advices
Alex



------->> Snippet <<------
/**
* {@inheritDoc}
*
* @see org.eclipse.draw2d.PrintFigureOperation#printPages()
*/
@Override
protected void printPages()
{
Graphics graphics = getFreshPrinterGraphics();

IFigure figure = getPrintSource();
PrinterData prnData = getPrinter().getPrinterData();
int startPageNumber = prnData.startPage;
int endPageNumber = prnData.endPage;

setupPrinterGraphicsFor( graphics, figure );
Rectangle bounds = figure.getBounds();
int x = bounds.x, y = bounds.y;

// compute pagesizes for all pages
Rectangle clipRect = new Rectangle();
graphics.getClip( clipRect );

// save original pagesize for later use
m_OriginalPageSizeHeight = clipRect.height;
m_OriginalPageSizeWidth = clipRect.width;

computePageSizeForEditorGraphicsPrint();

int currentPageNumber = 1;

while ( y < bounds.y + bounds.height )
{
while ( x < bounds.x + bounds.width )
{
graphics.pushState();
graphics.translate( -x, -y );
graphics.getClip( clipRect );
clipRect.setSize( m_PrintablePageSizeWidth,
m_PrintablePageSizeHeight );
graphics.clipRect( clipRect );

/*
* check if all pages are to be printed (scope ==
PrinterData.ALL_PAGES) or just some
* (startpage>= curPage >= endPage)
*/
if ( prnData.scope == PrinterData.ALL_PAGES
|| (currentPageNumber <= endPageNumber &&
currentPageNumber >= startPageNumber) )
{
getPrinter().startPage();
figure.paint( graphics );

// draw page header with m_HeaderString
graphics.drawText( m_HeaderString, clipRect.width /
2 + clipRect.x, clipRect.y );

// draw page footer with currentPageNumber
graphics.drawText( " " + currentPageNumber,
clipRect.width / 2 + clipRect.x,
clipRect.height + clipRect.y - 12 );

getPrinter().endPage();
}
graphics.popState();

// incrementiere die bereits gedruckte seitenbreite
x += clipRect.width;
// incrementiere die currentPageNumber
currentPageNumber++;
}
// reset x
x = bounds.x;
// incrementiere die bereits gedruckte seitenhoehe
y += clipRect.height;
}
}
private void computePageSizeForEditorGraphicsPrint()
{
// compute static print-size of a page
int widthOffset = (m_OriginalPageSizeWidth -
GraphicalControlLayoutManager.INIT_GAP) %
GraphicalControlLayoutManager.COLUMN_WIDTH;
int heightOffset = (m_OriginalPageSizeHeight -
GraphicalControlLayoutManager.INIT_GAP) %
GraphicalControlLayoutManager.ROW_HEIGHT;
m_PrintablePageSizeWidth = m_OriginalPageSizeWidth - widthOffset;
m_PrintablePageSizeHeight = m_OriginalPageSizeHeight -
heightOffset;
}
Re: PrintGraphicalViewerOperation does not print Connections with Style 'Graphics.LINE_DASH' [message #496202 is a reply to message #493837] Mon, 09 November 2009 10:45 Go to previous message
Alexander Haag is currently offline Alexander HaagFriend
Messages: 119
Registered: July 2009
Senior Member
Hi again,

has anybody ever tried to print a PolylineConnection which did NOT have
LineStyle 'LINE_SOLID', but 'LINE_DASH' or 'LINE_DASHDOT' or anything else?

Any help or hints welcome

Greets Alex
Previous Topic:[Zest] Auto Srolling
Next Topic:[draw2d] ColorConstants return disposed color...
Goto Forum:
  


Current Time: Thu Apr 18 22:05:15 GMT 2024

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

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

Back to the top