/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t C S ( E x t e n s i o n ) 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h e   N y A R T o o l k i t C S   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 > 
 
   *   
 
   * / 
 
 u s i n g   S y s t e m ; 
 
 u s i n g   S y s t e m . D i a g n o s t i c s ;   
 
 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00000000;uP0<h
}Y00000000g0Y00
 
           *   Y00000Q0000n0!Nek0[_W0~0Y00
 
           * / 
 
         p u b l i c   c l a s s   N y A R G r a y s c a l e R a s t e r   :   I N y A R G r a y s c a l e R a s t e r 
 
         { 
 
                 p r o t e c t e d   N y A R I n t S i z e   _ s i z e ; 
 
                 p r o t e c t e d   i n t   _ b u f f e r _ t y p e ; 
 
                 / * * 
 
                   *   S0n0peo00000n0E^0ԏW0~0Y00
 
                   * / 
 
                 p u b l i c   i n t   g e t W i d t h ( ) 
 
                 { 
 
                         r e t u r n   t h i s . _ s i z e . w ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000n0ؚU00ԏW0~0Y00
 
                   * / 
 
                 p u b l i c   i n t   g e t H e i g h t ( ) 
 
                 { 
 
                         r e t u r n   t h i s . _ s i z e . h ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000n00000<h
}W0_00000000ԏW0~0Y00
 
                   * / 
 
                 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 . _ s i z e ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000n00000x0n0Sgq$P0ԏW0~0Y00
 
                   *   0000n0b__o000000000k0c[W0_0b__h0TX0g0Y00
 
                   * / 
 
                 p u b l i c   i n t   g e t B u f f e r T y p e ( ) 
 
                 { 
 
                         r e t u r n   _ b u f f e r _ t y p e ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000n0E^0ԏW0~0Y00
 
                   * / 
 
                 p u b l i c   b o o l   i s E q u a l B u f f e r T y p e ( i n t   i _ t y p e _ v a l u e ) 
 
                 { 
 
                         r e t u r n   t h i s . _ b u f f e r _ t y p e   = =   i _ t y p e _ v a l u e ; 
 
                 } 
 
                 p u b l i c   I N y A R G s P i x e l D r i v e r   g e t G s P i x e l D r i v e r ( ) 
 
                 { 
 
                         r e t u r n   t h i s . _ p i x d r v ; 
 
                 } 
 
 
 
                 / * *   0000000000* / 
 
                 p r o t e c t e d   o b j e c t   _ b u f ; 
 
                 / * *   0000000000L00000U00f0D00p0t r u e * / 
 
                 p r o t e c t e d   b o o l   _ i s _ a t t a c h e d _ b u f f e r ; 
 
                 p r o t e c t e d   I N y A R G s P i x e l D r i v e r   _ p i x d r v ; 
 
 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   *   QSgqn00000{ @ l i n k   N y A R B u f f e r T y p e # I N T 1 D _ G R A Y _ 8 } b__	0cd00000000ubW0~0Y00
 
                   *   @ p a r a m   i _ w i d t h 
 
                   *   000n0000
 
                   *   @ p a r a m   i _ h e i g h t 
 
                   *   000n0000
 
                   *   @ 
 
                   * / 
 
                 p u b l i c   N y A R G r a y s c a l e R a s t e r ( i n t   i _ w i d t h ,   i n t   i _ h e i g h t ) 
 
                 { 
 
                         t h i s . _ s i z e   =   n e w   N y A R I n t S i z e ( i _ w i d t h ,   i _ h e i g h t ) ; 
 
                         t h i s . _ 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 ; 
 
                         i n i t I n s t a n c e ( t h i s . _ s i z 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 ,   t r u e ) ; 
 
                 } 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   *   ;uPn000000000h00000Sgqe_0c[W0f000000000ubW0~0Y00
 
                   *   0000n0b__o00{ @ l i n k   N y A R B u f f e r T y p e # I N T 1 D _ G R A Y _ 8 } g0Y00
 
                   *   @ p a r a m   i _ w i d t h 
 
                   *   000n0000
 
                   *   @ p a r a m   i _ h e i g h t 
 
                   *   000n0000
 
                   *   @ p a r a m   i _ i s _ a l l o c 
 
                   *   00000YSgqk0Y00K0n0000$P0
 
                   *   t r u e j00Q00000f a l s e j00Y00000O(uW0~0Y00
 
                   *   f a l s e n04XT0Rgn00000o0n u l l k0j00~0Y000000000ubW0_0n0a0k00{ @ l i n k   # w r a p B u f f e r } 0Oc0f0rR0S_f0f0O0`0U0D00
 
                   *   @ 
 
                   * / 
 
                 p u b l i c   N y A R G r a y s c a l e R a s t e r ( i n t   i _ w i d t h ,   i n t   i _ h e i g h t ,   b o o l   i _ i s _ a l l o c ) 
 
                 { 
 
                         t h i s . _ s i z e   =   n e w   N y A R I n t S i z e ( i _ w i d t h ,   i _ h e i g h t ) ; 
 
                         t h i s . _ 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 ; 
 
                         i n i t I n s t a n c e ( t h i s . _ s i z 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 ,   i _ i s _ a l l o c ) ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   *   ;uPn000000000h00000b__0c[W0f000000000ubW0~0Y00
 
                   *   @ p a r a m   i _ w i d t h 
 
                   *   000n0000
 
                   *   @ p a r a m   i _ h e i g h t 
 
                   *   000n0000
 
                   *   @ p a r a m   i _ r a s t e r _ t y p e 
 
                   *   000n00000b__0
 
                   *   { @ l i n k   N y A R B u f f e r T y p e } k0[U00_0[pe$P0c[W0f0O0`0U0D00c[g0M00$Po00NNn00g0Y00
 
                   *   < u l > 
 
                   *   < l i > { @ l i n k   N y A R B u f f e r T y p e # I N T 1 D _ G R A Y _ 8 } 
 
                   *   < u l > 
 
                   *   @ p a r a m   i _ i s _ a l l o c 
 
                   *   00000YSgqk0Y00K0n0000$P0
 
                   *   t r u e j00Q00000f a l s e j00Y00000O(uW0~0Y00
 
                   *   f a l s e n04XT0Rgn00000o0n u l l k0j00~0Y000000000ubW0_0n0a0k00{ @ l i n k   # w r a p B u f f e r } 0Oc0f0rR0S_f0f0O0`0U0D00
 
                   *   @ 
 
                   * / 
 
                 p u b l i c   N y A R G r a y s c a l e R a s t e r ( i n t   i _ w i d t h ,   i n t   i _ h e i g h t ,   i n t   i _ r a s t e r _ t y p e ,   b o o l   i _ i s _ a l l o c ) 
 
                 { 
 
                         t h i s . _ s i z e   =   n e w   N y A R I n t S i z e ( i _ w i d t h ,   i _ h e i g h t ) ; 
 
                         t h i s . _ b u f f e r _ t y p e   =   i _ r a s t e r _ t y p e ; 
 
                         i n i t I n s t a n c e ( t h i s . _ s i z e ,   i _ r a s t e r _ t y p e ,   i _ i s _ a l l o c ) ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   S0n0000n0RgS00000g0Y000000000K00|Ts0QW0~0Y00RgSk01YWeY00h00OY0zvuW0~0Y00
 
                   *   @ p a r a m   i _ s i z e 
 
                   *   000000
 
                   *   @ p a r a m   i _ r a s t e r _ t y p e 
 
                   *   0000b__
 
                   *   @ p a r a m   i _ i s _ a l l o c 
 
                   *   0000Sgqel$P
 
                   *   @   
 
                   * / 
 
                 p r o t e c t e d   v i r t u a l   v o i d   i n i t I n s t a n c e ( N y A R I n t S i z e   i _ s i z e ,   i n t   i _ r a s t e r _ t y p e ,   b o o l   i _ i s _ a l l o c ) 
 
                 { 
 
                         s w i t c h   ( i _ r a s t 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 : 
 
                                         t h i s . _ b u f   =   i _ i s _ a l l o c   ?   n e w   i n t [ i _ s i z e . w   *   i _ s i z e . h ]   :   n u l l ; 
 
                                         b r e a k ; 
 
                                 d e f a u l t : 
 
                                         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 . _ i s _ a t t a c h e d _ b u f f e r   =   i _ i s _ a l l o c ; 
 
                         / / 00000000n0ub
 
                         t h i s . _ p i x d r v   =   N y A R G s P i x e l D r i v e r F a c t o r y . c r e a t e D r i v e r ( t h i s ) ; 
 
                 } 
 
                 p u b l i c   v i r t u a l   o b j e c t   c r e a t e I n t e r f a c e ( T y p e   i _ i i d ) 
 
                 { 
 
                         i f   ( i _ i i d   = =   t y p e o f ( N y A R L a b e l i n g _ R l e . I R a s t e r D r i v e r ) ) 
 
                         { 
 
                                 r e t u r n   N y A R L a b e l i n g _ R l e . R a s t e r D r i v e r F a c t o r y . c r e a t e D r i v e r ( t h i s ) ; 
 
                         } 
 
                         i f   ( i _ i i d   = = t y p e o f ( N y A R C o n t o u r P i c k u p . I R a s t e r D r i v e r ) ) 
 
                         { 
 
                                 r e t u r n   N y A R C o n t o u r P i c k u p . I m a g e D r i v e r F a c t o r y . c r e a t e D r i v e r ( t h i s ) ; 
 
                         } 
 
                         i f   ( i _ i i d   = =   t y p e o f ( I N y A R H i s t o g r a m F r o m R a s t e r ) ) 
 
                         { 
 
                                 r e t u r n   N y A R H i s t o g r a m F r o m R a s t e r F a c t o r y . c r e a t e I n s t a n c e ( t h i s ) ; 
 
                         } 
 
                         t h r o w   n e w   N y A R E x c e p t i o n ( ) ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000n00000x0n0Sgq$P0ԏW0~0Y00
 
                   *   0000n0b__o000000000k0c[W0_0b__h0TX0g0Y00
 
                   * / 
 
                 p u b l i c   o b j e c t   g e t B u f f e r ( ) 
 
                 { 
 
                         r e t u r n   t h i s . _ b u f ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   S0n0peo00000000L000000@b	gY00K00ԏW0~0Y00
 
                   *   QSgq0000n04XTo008^k0t r u e g0Y00
 
                   *   YSgq0000n04XTo000000k00000Y00MRk00S0n000000xW0f0O0`0U0D00
 
                   * / 
 
                 p u b l i c   b o o l   h a s B u f f e r ( ) 
 
                 { 
 
                         r e t u r n   t h i s . _ b u f   ! =   n u l l ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000k0YSgq00000000W0~0Y00
 
                   *   YSgq00000cd0000000g0n00O(ug0M0~0Y00QSgq00000cd0000000g0o0O(ug0M0~0[000
 
                   * / 
 
                 p u b l i c   v o i d   w r a p B u f f e r ( o b j e c t   i _ r e f _ b u f ) 
 
                 { 
 
                         D e b u g . A s s e r t ( ! t h i s . _ i s _ a t t a c h e d _ b u f f e r ) ; / /   0000L00000U00f0D0_00_jW0j0D00
 
                         / / 000n0b__o0weu0
 
                         t h i s . _ p i x d r v . s w i t c h R a s t e r ( t h i s ) ; 
 
                         t h i s . _ b u f   =   i _ r e f _ b u f ; 
 
                 } 
 
 
 
         } 
 
 } 