Community
Participate
Working Groups
The rotate method of PrinterGraphics does not work properly. For example, in PrintFigureOperation.printPages(), add graphics.rotate(90); right before figure.paint(graphics); You will see this error in the log !MESSAGE The class: class org.eclipse.draw2d.PrinterGraphics has not implemented this new graphics function !STACK 0 java.lang.RuntimeException: The class: class org.eclipse.draw2d.PrinterGraphics has not implemented this new graphics function at org.eclipse.draw2d.Graphics.subclassFunctionMission (Graphics.java:897) at org.eclipse.draw2d.Graphics.rotate(Graphics.java:702) at org.eclipse.gef.examples.logicdesigner.actions.RotatePrintGraphicalViewerOperati on.printPages(RotatePrintGraphicalViewerOperation.java) at org.eclipse.draw2d.PrintOperation.run(PrintOperation.java:155) at org.eclipse.gef.examples.logicdesigner.actions.LogicPrintAction.run (LogicPrintAction.java) at org.eclipse.ui.internal.PluginAction.runWithEvent (PluginAction.java:246) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:538) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:400) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:844) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3070) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2703) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:163) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948)
rotate is a new function and it doesn't work for ScaledGraphics and its subclasses. You could try applying a Transform to SWT's GC prior to handing it off to the draw2d graphics.
Hi Randy, I tried your suggestion but it doesn't seem to work. I just get blank pages. Is PrinterGraphics never going to support rotate()?
Maybe you rotated everything in to the negative Y coordinates. You probably need to rotate about the bottom left corner of the page and not the origin. Can't the user just switch between landscape and portrait orientation?
Hi Randy, actually, setting even the default transform into the GC and then passing it into the Graphics results in a distorted image. gc.setTransform(new Transform(device)); Graphics g = new SWTGraphics(gc); The scaling and clipping performed on the graphics is completely off. So, unfortunately, this suggestion doesn't seem to work. The user can switch between landscape and orientation, but this is what we were trying to avoid! :)
If the identity transform doesn't work then you can imagine that rotating is not going to be very successful either. Both trigger the use of GDI+ on win32. We have tried printing with GDI+ and it works in some scenarios and with some printer drivers. I think bidi doesn't work though.
This defect has been open for 5 years now, are there any plans to fix this issue ?
There is no target milestone, so I guess there is no plan to fix it yet. My guess is it would be fixed for 3.7. If you can provide a patch that'd be great.