From 27371a5fd183ad5eac50ab5dd1b30113452e5467 Mon Sep 17 00:00:00 2001 From: GoToLoop Date: Sat, 9 Jul 2016 08:47:43 -0300 Subject: [PATCH] Update ControllerGroup.java --- src/controlP5/ControllerGroup.java | 37 ++++++++---------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/controlP5/ControllerGroup.java b/src/controlP5/ControllerGroup.java index 5f8ed0f..6c16441 100755 --- a/src/controlP5/ControllerGroup.java +++ b/src/controlP5/ControllerGroup.java @@ -1,5 +1,3 @@ -package controlP5; - /** * controlP5 is a processing gui library. * @@ -25,6 +23,8 @@ package controlP5; * */ +package controlP5; + import java.util.ArrayList; import java.util.List; @@ -43,7 +43,7 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , protected final float[] positionBuffer = new float[ 2 ]; protected final float[] absolutePosition = new float[ 2 ]; protected final ControllerList controllers = new ControllerList( ); - protected final List< ControlListener > _myControlListener = new ArrayList< ControlListener >( ); + protected final List< ControlListener > _myControlListener = new ArrayList< >( ); // protected ControlWindow _myControlWindow; protected ControlP5 cp5; protected ControllerGroup< ? > _myParent; @@ -66,7 +66,7 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , protected int _myWidth = 99; protected int _myHeight = 9; protected boolean isUpdate; - protected final List< Canvas > _myCanvas = new ArrayList< Canvas >( ); + protected final List< Canvas > _myCanvas = new ArrayList< >( ); protected float _myValue; protected String _myStringValue; protected float[] _myArrayValue; @@ -90,14 +90,9 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , public ControllerGroup( ControlP5 theControlP5 , ControllerGroup< ? > theParent , String theName , float theX , float theY ) { set( position , theX , theY ); - //position = new float[] { theX , theY }; cp5 = theControlP5; - //me = ( T ) this; color.set( theParent == null ? cp5.color : theParent.color ); _myName = theName; - //controllers = new ControllerList( ); - //_myCanvas = new ArrayList< Canvas >( ); - //_myControlListener = new ArrayList< ControlListener >( ); _myLabel = new Label( cp5 , _myName ); _myLabel.setText( _myName ).setColor( color.getCaptionLabel( ) ).align( LEFT , TOP ); setParent( theParent == null ? this : theParent ); @@ -105,10 +100,6 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , protected ControllerGroup( int theX , int theY ) { set( position , theX , theY ); - //position = new float[] { theX , theY }; - //me = ( T ) this; - //controllers = new ControllerList( ); - //_myCanvas = new ArrayList< Canvas >( ); } @ControlP5.Invisible @Override public void init( ) { @@ -193,12 +184,8 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , } @Override public Tab getTab( ) { - if ( this instanceof Tab ) { - return ( Tab ) this; - } - if ( _myParent instanceof Tab ) { - return ( Tab ) _myParent; - } + if ( this instanceof Tab ) return ( Tab ) this; + if ( _myParent instanceof Tab ) return ( Tab ) _myParent; return _myParent.getTab( ); } @@ -246,9 +233,8 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , final float y = y( position ) + y( _myParent.getAbsolutePosition( ) ); set( absolutePosition , x , y ); if ( controllers.size( ) != 0 ) synchronized ( controllers.get( ) ) { - for ( final ControllerInterface< ? > ci : controllers.get( ) ) { + for ( final ControllerInterface< ? > ci : controllers.get( ) ) ci.updateAbsolutePosition( ); - } } return me; } @@ -408,7 +394,7 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , * Removes a canvas from a controller group. */ public T removeCanvas( final Canvas theCanvas ) { - if ( !_myCanvas.isEmpty( ) ) synchronized (_myCanvas) { + if ( !_myCanvas.isEmpty( ) ) synchronized (_myCanvas) { _myCanvas.remove( theCanvas ); } return me; @@ -485,9 +471,7 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , } @Override public T setAddress( String theAddress ) { - if ( _myAddress.length( ) == 0 ) { - _myAddress = theAddress; - } + if ( _myAddress.length( ) == 0 ) _myAddress = theAddress; return me; } @@ -497,9 +481,8 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , @ControlP5.Invisible @Override public void keyEvent( final KeyEvent theEvent ) { if ( controllers.size( ) != 0 ) synchronized ( controllers.get( ) ) { - for ( final ControllerInterface< ? > ci : controllers.get( ) ) { + for ( final ControllerInterface< ? > ci : controllers.get( ) ) ci.keyEvent( theEvent ); - } } }