@@ -425,6 +425,7 @@ static public class RendererChangeException extends RuntimeException { }
425
425
426
426
427
427
/** Called with the activity is first created. */
428
+ @ SuppressWarnings ("unchecked" )
428
429
@ Override
429
430
public void onCreate (Bundle savedInstanceState ) {
430
431
super .onCreate (savedInstanceState );
@@ -467,31 +468,30 @@ public void onCreate(Bundle savedInstanceState) {
467
468
int sw = sketchWidth ();
468
469
int sh = sketchHeight ();
469
470
470
- //get renderer name anc class
471
- String renderer_name = sketchRenderer ();
472
- Class <?> renderer_class = null ;
471
+ // Get renderer name and class
472
+ String rendererName = sketchRenderer ();
473
+ Class <?> rendererClass = null ;
473
474
try {
474
- renderer_class = Class .forName (renderer_name );
475
+ rendererClass = Class .forName (rendererName );
475
476
} catch (ClassNotFoundException exception ) {
476
- //what to throw here?
477
477
String message = String .format (
478
- "Error: Could not resolve renderer class name: %s" , renderer_name );
478
+ "Error: Could not resolve renderer class name: %s" , rendererName );
479
479
throw new RuntimeException (message , exception );
480
480
}
481
481
482
- //java2d renderer
483
- if (renderer_name .equals (JAVA2D )) {
482
+ // JAVA2D renderer
483
+ if (rendererName .equals (JAVA2D )) {
484
484
surfaceView = new SketchSurfaceView (this , sw , sh );
485
485
}
486
- //P2D, P3D, and any other PGraphicsOpenGL-based renderer
487
- else if (PGraphicsOpenGL .class .isAssignableFrom (renderer_class )){
486
+ // P2D, P3D, and any other PGraphicsOpenGL-based renderer
487
+ else if (PGraphicsOpenGL .class .isAssignableFrom (rendererClass )){
488
488
surfaceView = new SketchSurfaceViewGL (this , sw , sh ,
489
- (Class <? extends PGraphicsOpenGL >) renderer_class );
489
+ (Class <? extends PGraphicsOpenGL >) rendererClass );
490
490
}
491
- //anything else
491
+ // Anything else
492
492
else {
493
493
String message = String .format (
494
- "Error: Unsupported renderer class: %s" , renderer_name )
494
+ "Error: Unsupported renderer class: %s" , rendererName );
495
495
throw new RuntimeException (message );
496
496
}
497
497
@@ -809,7 +809,7 @@ public class SketchSurfaceViewGL extends GLSurfaceView /*implements SketchSurfac
809
809
810
810
public SketchSurfaceViewGL (
811
811
Context context , int wide , int high ,
812
- Class <? extends PGraphicsOpenGL > renderer_class ){
812
+ Class <? extends PGraphicsOpenGL > clazz ){
813
813
super (context );
814
814
815
815
// Check if the system supports OpenGL ES 2.0.
@@ -832,19 +832,19 @@ public SketchSurfaceViewGL(
832
832
// before surfaceChanged() is ever called.
833
833
834
834
//P2D
835
- if (renderer_class .equals ( PGraphics2D .class )) {
835
+ if (clazz .equals (PGraphics2D .class )) {
836
836
g3 = new PGraphics2D ();
837
837
}
838
838
//P3D
839
- else if (renderer_class .equals ( PGraphics3D .class )) {
839
+ else if (clazz .equals (PGraphics3D .class )) {
840
840
g3 = new PGraphics3D ();
841
841
}
842
842
//something that extends P2D, P3D, or PGraphicsOpenGL
843
843
else {
844
844
try {
845
845
//dang java generics
846
846
Constructor <? extends PGraphicsOpenGL > constructor =
847
- renderer_class .getConstructor ();
847
+ clazz .getConstructor ();
848
848
g3 = constructor .newInstance ();
849
849
} catch (Exception exception ) {
850
850
throw new RuntimeException (
0 commit comments