/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t ( E x t e n s i o n ) 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h e   N y A R T o o l k i t   i s   J a v a   e d i t i o n   A R T o o l K i t   c l a s s   l i b r a r y . 
 
   *   C o p y r i g h t   ( C ) 2 0 0 8 - 2 0 1 2   R y o   I i z u k a 
 
   * 
 
   *   T h i s   p r o g r a m   i s   f r e e   s o f t w a r e :   y o u   c a n   r e d i s t r i b u t e   i t   a n d / o r   m o d i f y 
 
   *   i t   u n d e r   t h e   t e r m s   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e   a s   p u b l i s h e d   b y 
 
   *   t h e   F r e e   S o f t w a r e   F o u n d a t i o n ,   e i t h e r   v e r s i o n   3   o f   t h e   L i c e n s e ,   o r 
 
   *   ( a t   y o u r   o p t i o n )   a n y   l a t e r   v e r s i o n . 
 
   *   
 
   *   T h i s   p r o g r a m   i s   d i s t r i b u t e d   i n   t h e   h o p e   t h a t   i t   w i l l   b e   u s e f u l , 
 
   *   b u t   W I T H O U T   A N Y   W A R R A N T Y ;   w i t h o u t   e v e n   t h e   i m p l i e d   w a r r a n t y   o f 
 
   *   M E R C H A N T A B I L I T Y   o r   F I T N E S S   F O R   A   P A R T I C U L A R   P U R P O S E .     S e e   t h e 
 
   *   G N U   G e n e r a l   P u b l i c   L i c e n s e   f o r   m o r e   d e t a i l s . 
 
   * 
 
   *   Y o u   s h o u l d   h a v e   r e c e i v e d   a   c o p y   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e 
 
   *   a l o n g   w i t h   t h i s   p r o g r a m .     I f   n o t ,   s e e   < h t t p : / / w w w . g n u . o r g / l i c e n s e s / > . 
 
   *   
 
   *   F o r   f u r t h e r   i n f o r m a t i o n   p l e a s e   c o n t a c t . 
 
   * 	 h t t p : / / n y a t l a . j p / n y a t o o l k i t / 
 
   * 	 < a i r m a i l ( a t ) e b o n y . p l a l a . o r . j p >   o r   < n y a t l a ( a t ) n y a t l a . j p > 
 
   *   
 
   * / 
 
 n a m e s p a c e   j p . n y a t l a . n y a r t o o l k i t . c s . c o r e 
 
 { 
 
 
 
         / * * 
 
           *   S0n0000o00I N y A R G s P i x e l D r i v e r 00000000cd00000000i{Y00Kbk0cOW0~0Y00
 
           * / 
 
         p u b l i c   c l a s s   N y A R G s P i x e l D r i v e r F a c t o r y 
 
         { 
 
                 / * * 
 
                   *   000K00;u }00000i{W0~0Y00i{W0_00000000k0o00i _ r e f _ r a s t e r 0000W0~0Y00
 
                   *   @ p a r a m   i _ r e f _ r a s t e r 
 
                   *   @ r e t u r n 
 
                   *   @ 
 
                   * / 
 
                 p u b l i c   s t a t i c   I N y A R G s P i x e l D r i v e r   c r e a t e D r i v e r ( I N y A R G r a y s c a l e R a s t e r   i _ r e f _ r a s t e r ) 
 
                 { 
 
                         I N y A R G s P i x e l D r i v e r   r e t ; 
 
                         s w i t c h   ( i _ r e f _ r a s t e r . g e t B u f f e r T y p e ( ) ) 
 
                         { 
 
                                 c a s e   N y A R B u f f e r T y p e . I N T 1 D _ G R A Y _ 8 : 
 
                                 c a s e   N y A R B u f f e r T y p e . I N T 1 D _ B I N _ 8 : 
 
                                         r e t   =   n e w   N y A R G s P i x e l D r i v e r _ I N T 1 D _ G R A Y _ 8 ( ) ; 
 
                                         b r e a k ; 
 
                                 d e f a u l t : 
 
                                         / / R G B R a s t e r 0000000L0B004XT
 
                                         i f   ( i _ r e f _ r a s t e r   i s   I N y A R R g b R a s t e r ) 
 
                                         { 
 
                                                 r e t   =   n e w   N y A R G s P i x e l D r i v e r _ R G B X ( ( I N y A R R g b R a s t e r ) i _ r e f _ r a s t e r ) ; 
 
                                                 b r e a k ; 
 
                                         } 
 
                                         t h r o w   n e w   N y A R E x c e p t i o n ( ) ; 
 
                         } 
 
                         r e t . s w i t c h R a s t e r ( i _ r e f _ r a s t e r ) ; 
 
                         r e t u r n   r e t ; 
 
                 } 
 
                 p u b l i c   s t a t i c   I N y A R G s P i x e l D r i v e r   c r e a t e D r i v e r ( I N y A R R g b R a s t e r   i _ r e f _ r a s t e r ) 
 
                 { 
 
                         / / R G B R a s t e r 0000000L0B004XT
 
                         r e t u r n   n e w   N y A R G s P i x e l D r i v e r _ R G B X ( i _ r e f _ r a s t e r ) ; 
 
                 } 
 
         } 
 
         / / 
 
         / / 	 00000000n0[
 
         / / 
 
 
 
 
 
 
 
         / * * 
 
           *   I N T 1 D _ G R A Y _ 8 n00000g0Y00
 
           * / 
 
         c l a s s   N y A R G s P i x e l D r i v e r _ I N T 1 D _ G R A Y _ 8   :   I N y A R G s P i x e l D r i v e r 
 
         { 
 
                 p r o t e c t e d   i n t [ ]   _ r e f _ b u f ; 
 
                 p r i v a t e   N y A R I n t S i z e   _ r e f _ s i z e ; 
 
                 p u b l i c   N y A R I n t S i z e   g e t S i z e ( ) 
 
                 { 
 
                         r e t u r n   t h i s . _ r e f _ s i z e ; 
 
                 } 
 
                 p u b l i c   v o i d   g e t P i x e l S e t ( i n t [ ]   i _ x ,   i n t [ ]   i _ y ,   i n t   i _ n ,   i n t [ ]   o _ b u f ,   i n t   i _ s t _ b u f ) 
 
                 { 
 
                         i n t   b p ; 
 
                         i n t   w   =   t h i s . _ r e f _ s i z e . w ; 
 
                         i n t [ ]   b   =   t h i s . _ r e f _ b u f ; 
 
                         f o r   ( i n t   i   =   i _ n   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 b p   =   ( i _ x [ i ]   +   i _ y [ i ]   *   w ) ; 
 
                                 o _ b u f [ i _ s t _ b u f   +   i ]   =   ( b [ b p ] ) ; 
 
                         } 
 
                         r e t u r n ; 
 
                 } 
 
                 p u b l i c   i n t   g e t P i x e l ( i n t   i _ x ,   i n t   i _ y ) 
 
                 { 
 
                         i n t [ ]   r e f _ b u f   =   t h i s . _ r e f _ b u f ; 
 
                         r e t u r n   r e f _ b u f [ ( i _ x   +   i _ y   *   t h i s . _ r e f _ s i z e . w ) ] ; 
 
                 } 
 
                 p u b l i c   v o i d   s e t P i x e l ( i n t   i _ x ,   i n t   i _ y ,   i n t   i _ g s ) 
 
                 { 
 
                         t h i s . _ r e f _ b u f [ ( i _ x   +   i _ y   *   t h i s . _ r e f _ s i z e . w ) ]   =   i _ g s ; 
 
                 } 
 
                 p u b l i c   v o i d   s e t P i x e l s ( i n t [ ]   i _ x ,   i n t [ ]   i _ y ,   i n t   i _ n u m ,   i n t [ ]   i _ i n t g s ) 
 
                 { 
 
                         i n t   w   =   t h i s . _ r e f _ s i z e . w ; 
 
                         i n t [ ]   r   =   t h i s . _ r e f _ b u f ; 
 
                         f o r   ( i n t   i   =   i _ n u m   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 r [ ( i _ x [ i ]   +   i _ y [ i ]   *   w ) ]   =   i _ i n t g s [ i ] ; 
 
                         } 
 
                 } 
 
                 p u b l i c   v o i d   s w i t c h R a s t e r ( I N y A R R a s t e r   i _ r e f _ r a s t e r ) 
 
                 { 
 
                         t h i s . _ r e f _ b u f   =   ( i n t [ ] ) i _ r e f _ r a s t e r . g e t B u f f e r ( ) ; 
 
                         t h i s . _ r e f _ s i z e   =   i _ r e f _ r a s t e r . g e t S i z e ( ) ; 
 
                 } 
 
                 p u b l i c   b o o l   i s C o m p a t i b l e R a s t e r ( I N y A R R a s t e r   i _ r a s t e r ) 
 
                 { 
 
                         r e t u r n   i _ r a s t e r . i s E q u a l B u f f e r T y p e ( N y A R B u f f e r T y p e . I N T 1 D _ G R A Y _ 8 ) ; 
 
                 } 
 
         } 
 
         / * * 
 
           *   NO0000g0Y00^L0_j04XTo00;u }00000fO0S0h00
 
           * / 
 
         c l a s s   N y A R G s P i x e l D r i v e r _ R G B X   :   I N y A R G s P i x e l D r i v e r 
 
         { 
 
                 p r i v a t e   I N y A R R g b P i x e l D r i v e r   _ r g b d ; 
 
                 p r i v a t e   i n t [ ]   _ t m p   =   n e w   i n t [ 3 ] ; 
 
                 p u b l i c   N y A R G s P i x e l D r i v e r _ R G B X ( I N y A R R g b R a s t e r   i _ r a s t e r ) 
 
                 { 
 
                         t h i s . _ r g b d   =   i _ r a s t e r . g e t R g b P i x e l D r i v e r ( ) ; 
 
                 } 
 
                 p u b l i c   N y A R I n t S i z e   g e t S i z e ( ) 
 
                 { 
 
                         r e t u r n   t h i s . _ r g b d . g e t S i z e ( ) ; 
 
                 } 
 
                 p u b l i c   v o i d   g e t P i x e l S e t ( i n t [ ]   i _ x ,   i n t [ ]   i _ y ,   i n t   i _ n ,   i n t [ ]   o _ b u f ,   i n t   i _ s t _ b u f ) 
 
                 { 
 
                         I N y A R R g b P i x e l D r i v e r   r   =   t h i s . _ r g b d ; 
 
                         i n t [ ]   t m p   =   t h i s . _ t m p ; 
 
                         f o r   ( i n t   i   =   i _ n   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 r . g e t P i x e l ( i _ x [ i ] ,   i _ y [ i ] ,   t m p ) ; 
 
                                 o _ b u f [ i _ s t _ b u f   +   i ]   =   ( t m p [ 0 ]   +   t m p [ 1 ]   +   t m p [ 2 ] )   /   3 ; 
 
                         } 
 
                         r e t u r n ; 
 
                 } 
 
                 p u b l i c   i n t   g e t P i x e l ( i n t   i _ x ,   i n t   i _ y ) 
 
                 { 
 
                         i n t [ ]   t m p   =   t h i s . _ t m p ; 
 
                         t h i s . _ r g b d . g e t P i x e l ( i _ x ,   i _ y ,   t m p ) ; 
 
                         r e t u r n   ( t m p [ 0 ]   +   t m p [ 1 ]   +   t m p [ 2 ] )   /   3 ; 
 
                 } 
 
                 p u b l i c   v o i d   s e t P i x e l ( i n t   i _ x ,   i n t   i _ y ,   i n t   i _ g s ) 
 
                 { 
 
                         t h i s . _ r g b d . s e t P i x e l ( i _ x ,   i _ y ,   i _ g s ,   i _ g s ,   i _ g s ) ; 
 
                 } 
 
                 p u b l i c   v o i d   s e t P i x e l s ( i n t [ ]   i _ x ,   i n t [ ]   i _ y ,   i n t   i _ n u m ,   i n t [ ]   i _ i n t g s ) 
 
                 { 
 
                         I N y A R R g b P i x e l D r i v e r   r   =   t h i s . _ r g b d ; 
 
                         f o r   ( i n t   i   =   i _ n u m   -   1 ;   i   > =   0 ;   i - - ) 
 
                         { 
 
                                 i n t   g s   =   i _ i n t g s [ i ] ; 
 
                                 r . s e t P i x e l ( i _ x [ i ] ,   i _ y [ i ] ,   g s ,   g s ,   g s ) ; 
 
                         } 
 
                 } 
 
                 p u b l i c   v o i d   s w i t c h R a s t e r ( I N y A R R a s t e r   i _ r e f _ r a s t e r ) 
 
                 { 
 
                         i f   ( ! ( i _ r e f _ r a s t e r   i s   I N y A R R g b R a s t e r ) ) 
 
                         { 
 
                                 t h r o w   n e w   N y A R E x c e p t i o n ( ) ; 
 
                         } 
 
                         t h i s . _ r g b d   =   ( ( I N y A R R g b R a s t e r ) i _ r e f _ r a s t e r ) . g e t R g b P i x e l D r i v e r ( ) ; 
 
                 } 
 
                 p u b l i c   b o o l   i s C o m p a t i b l e R a s t e r ( I N y A R R a s t e r   i _ r a s t e r ) 
 
                 { 
 
                         r e t u r n   ( i _ r a s t e r   i s   I N y A R R g b R a s t e r ) ; 
 
                 } 
 
         } 
 
 } 