1717 *******************************************************************************/
1818package org .jzy3d .chart .factories ;
1919
20- import org .jzy3d .chart .Chart ;
2120import org .jzy3d .chart .IAnimator ;
2221import org .jzy3d .chart .PanamaGLAnimator ;
23- import org .jzy3d .chart .controllers .keyboard .camera .AWTCameraKeyController ;
24- import org .jzy3d .chart .controllers .keyboard .camera .ICameraKeyController ;
25- import org .jzy3d .chart .controllers .keyboard .screenshot .AWTScreenshotKeyController ;
26- import org .jzy3d .chart .controllers .keyboard .screenshot .IScreenshotKeyController ;
27- import org .jzy3d .chart .controllers .mouse .camera .AWTCameraMouseController ;
28- import org .jzy3d .chart .controllers .mouse .camera .ICameraMouseController ;
29- import org .jzy3d .chart .controllers .mouse .picking .IMousePickingController ;
3022import org .jzy3d .maths .Dimension ;
3123import org .jzy3d .maths .Rectangle ;
3224import org .jzy3d .painters .IPainter ;
3527import org .jzy3d .plot3d .primitives .symbols .SymbolHandler ;
3628import org .jzy3d .plot3d .rendering .canvas .ICanvas ;
3729import org .jzy3d .plot3d .rendering .canvas .IScreenCanvas ;
38- import org .jzy3d .plot3d .rendering .canvas .PanamaGLCanvas ;
39- import org .jzy3d .plot3d .rendering .canvas .Quality ;
4030import org .jzy3d .plot3d .rendering .image .IImageWrapper ;
41- import org .jzy3d .plot3d .rendering .scene .Scene ;
4231import org .jzy3d .plot3d .rendering .view .IViewOverlay ;
4332import org .jzy3d .plot3d .rendering .view .layout .IViewportLayout ;
4433import org .jzy3d .plot3d .rendering .view .layout .PanamaGLViewAndColorbarsLayout ;
45- import panamagl .canvas .GLCanvasSwing ;
4634import panamagl .factory .PanamaGLFactory ;
47- import panamagl .opengl .GLContext ;
4835
49- public class PanamaGLPainterFactory implements IPainterFactory {
36+ /**
37+ * Toolkit-agnostic base for PanamaGL painter factories.
38+ *
39+ * Concrete subclasses (Swing/JavaFX/SWT) must provide the toolkit-dependent
40+ * pieces: canvas, frame, mouse/keyboard controllers, screenshot controller,
41+ * and mouse picking controller.
42+ */
43+ public abstract class APanamaGLPainterFactory implements IPainterFactory {
44+
5045 protected PanamaGLFactory panamaGLFactory = PanamaGLFactory .select ();
5146
5247 protected IChartFactory chartFactory ;
5348 protected boolean offscreen = false ;
5449 protected int width ;
5550 protected int height ;
56-
51+
5752 public PanamaGLFactory getPanamaGLFactory () {
5853 return panamaGLFactory ;
5954 }
@@ -62,33 +57,13 @@ public void setPanamaGLFactory(PanamaGLFactory panamaGLFactory) {
6257 this .panamaGLFactory = panamaGLFactory ;
6358 }
6459
65-
6660 @ Override
6761 public IPainter newPainter () {
6862 PanamaGLPainter p = new PanamaGLPainter ();
6963 p .setGL (panamaGLFactory .newGL ());
70-
71-
7264 return p ;
7365 }
7466
75-
76- @ Override
77- public ICanvas newCanvas (IChartFactory factory , Scene scene , Quality quality ) {
78- GLCanvasSwing glCanvas = new GLCanvasSwing (panamaGLFactory );
79- GLContext context = glCanvas .getContext ();
80-
81-
82- PanamaGLCanvas icanvas = new PanamaGLCanvas (factory , scene , quality , glCanvas );
83-
84- // Update painter with context
85-
86- //System.out.println();
87- ((PanamaGLPainter )icanvas .getView ().getPainter ()).setContext (context );
88- return icanvas ;
89- }
90-
91-
9267 @ Override
9368 public IViewOverlay newViewOverlay () {
9469 return null ;
@@ -101,7 +76,6 @@ public IViewportLayout newViewportLayout() {
10176
10277 @ Override
10378 public SymbolHandler newSymbolHandler (IImageWrapper image ) {
104- // TODO Auto-generated method stub
10579 return null ;
10680 }
10781
@@ -110,41 +84,6 @@ public IAnimator newAnimator(ICanvas canvas) {
11084 return new PanamaGLAnimator ((IScreenCanvas ) canvas );
11185 }
11286
113- @ Override
114- public ICameraMouseController newMouseCameraController (Chart chart ) {
115- return new AWTCameraMouseController (chart );
116- }
117-
118- @ Override
119- public IMousePickingController newMousePickingController (Chart chart , int clickWidth ) {
120- //return new AWTMousePickingController(chart, clickWidth);
121- throw new RuntimeException ("Not implemented" );
122- }
123-
124- @ Override
125- public ICameraKeyController newKeyboardCameraController (Chart chart ) {
126- return new AWTCameraKeyController (chart );
127- }
128-
129- @ Override
130- public IScreenshotKeyController newKeyboardScreenshotController (Chart chart ) {
131- return new AWTScreenshotKeyController (chart , "target/out.png" );
132- }
133-
134- @ Override
135- public IFrame newFrame (Chart chart ) {
136- return newFrame (chart , new Rectangle (0 , 0 , 800 , 600 ), "PanamaGL" );
137- }
138-
139- @ Override
140- public IFrame newFrame (Chart chart , Rectangle bounds , String title ) {
141- FrameSwing f = new FrameSwing ();
142- f .initialize (chart , bounds , title );
143-
144- return f ;
145- }
146-
147-
14887 @ Override
14988 public IChartFactory getChartFactory () {
15089 return chartFactory ;
@@ -182,21 +121,13 @@ public Dimension getOffscreenDimension() {
182121 return new Dimension (width , height );
183122 }
184123
185-
186124 @ Override
187125 public boolean isDebugGL () {
188126 return false ;
189127 }
190128
191- /**
192- * If true, will let GL trigger {@link GLException} if an error occur in OpenGL which ease
193- * debugging. Default is false.
194- */
195129 @ Override
196130 public void setDebugGL (boolean debugGL ) {
197131 throw new NotImplementedException ();
198132 }
199-
200-
201-
202133}
0 commit comments