1. /*
  2. * @(#)DefaultHSBChooserPanel.java 1.7 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing.colorchooser;
  11. import javax.swing.*;
  12. import java.awt.*;
  13. import java.awt.event.*;
  14. import javax.swing.event.*;
  15. import javax.swing.text.*;
  16. import javax.swing.border.*;
  17. import java.awt.image.*;
  18. /**
  19. * Implements the default HSB Color chooser
  20. *
  21. * @version 1.7 02/02/00
  22. * @author Tom Santos
  23. * @author Steve Wilson
  24. */
  25. class DefaultHSBChooserPanel extends AbstractColorChooserPanel {
  26. float[] hsb = new float[ 3 ];
  27. AbstractHSBImage palette;
  28. AbstractHSBImage sliderPalette;
  29. JSlider slider;
  30. JIntegerTextField hField;
  31. JIntegerTextField sField;
  32. JIntegerTextField bField;
  33. JTextField redField;
  34. JTextField greenField;
  35. JTextField blueField;
  36. boolean isAdjusting = false;
  37. boolean isUpdatingOften = false;
  38. Point paletteSelection = new Point();
  39. JLabel paletteLabel;
  40. JLabel sliderPaletteLabel;
  41. JRadioButton hRadio;
  42. JRadioButton sRadio;
  43. JRadioButton bRadio;
  44. Image paletteImage;
  45. Image sliderImage;
  46. static final int PALETTE_DIMENSION = 200;
  47. static final int MAX_HUE_VALUE = 359;
  48. static final int MAX_SATURATION_VALUE = 99;
  49. static final int MAX_BRIGHTNESS_VALUE = 99;
  50. int sliderType = HUE_SLIDER;
  51. static final int HUE_SLIDER = 0;
  52. static final int SATURATION_SLIDER = 1;
  53. static final int BRIGHTNESS_SLIDER = 2;
  54. public DefaultHSBChooserPanel() {
  55. super();
  56. }
  57. protected void repaintPaletteSelection() {
  58. paletteLabel.repaint();
  59. }
  60. protected void addPaletteListeners() {
  61. paletteLabel.addMouseListener( new MouseAdapter(){
  62. public void mousePressed( MouseEvent e ){
  63. palette.getHSBForLocation( e.getX(), e.getY(), hsb );
  64. updateHSB( hsb[0], hsb[1], hsb[2] );}});
  65. paletteLabel.addMouseMotionListener( new MouseMotionAdapter(){
  66. public void mouseDragged( MouseEvent e ){
  67. int labelWidth = paletteLabel.getWidth();
  68. int labelHeight = paletteLabel.getHeight();
  69. int x = e.getX();
  70. int y = e.getY();
  71. if ( x >= labelWidth ){
  72. x = labelWidth - 1;}
  73. if ( y >= labelHeight ){
  74. y = labelHeight - 1;}
  75. if ( x < 0 ){
  76. x = 0;}
  77. if ( y < 0 ){
  78. y = 0;}
  79. //System.out.println(palette);
  80. palette.getHSBForLocation( x, y, hsb );
  81. updateHSB( hsb[0], hsb[1], hsb[2] );}});
  82. }
  83. protected void addSliderListeners() {
  84. slider.addChangeListener( new ChangeListener(){
  85. public void stateChanged( ChangeEvent e ){
  86. boolean modelIsAdjusting = slider.getModel().getValueIsAdjusting();
  87. if ( (modelIsAdjusting && isUpdatingOften) || !modelIsAdjusting ){
  88. int sliderValue = slider.getValue();
  89. int sliderRange = slider.getMaximum() + 1;
  90. float value = (float)sliderValue / (float)sliderRange;
  91. int x = paletteSelection.x;
  92. int y = paletteSelection.y;
  93. palette.getHSBForLocation( x, y, hsb );
  94. switch ( sliderType ){case HUE_SLIDER:
  95. updateHSB( value, hsb[1], hsb[2] );
  96. break;case SATURATION_SLIDER:
  97. updateHSB( hsb[0], value, hsb[2] );
  98. break;case BRIGHTNESS_SLIDER:
  99. updateHSB( hsb[0], hsb[1], value );
  100. break;}}}});
  101. }
  102. protected void updatePalette( float h, float s, float b ) {
  103. int x = 0;
  104. int y = 0;
  105. switch ( sliderType ) {
  106. case HUE_SLIDER:
  107. if ( h != palette.getHue() ) {
  108. palette.setHue( h );
  109. palette.nextFrame( 0 );
  110. }
  111. x = PALETTE_DIMENSION - (int)(s * PALETTE_DIMENSION);
  112. y = PALETTE_DIMENSION - (int)(b * PALETTE_DIMENSION);
  113. break;
  114. case SATURATION_SLIDER:
  115. if ( s != palette.getSaturation() ) {
  116. palette.setSaturation( s );
  117. palette.nextFrame( 0 );
  118. }
  119. x = (int)(h * PALETTE_DIMENSION);
  120. y = PALETTE_DIMENSION - (int)(b * PALETTE_DIMENSION);
  121. break;
  122. case BRIGHTNESS_SLIDER:
  123. if ( b != palette.getBrightness() ) {
  124. palette.setBrightness( b );
  125. palette.nextFrame( 0 );
  126. }
  127. x = (int)(h * PALETTE_DIMENSION);
  128. y = PALETTE_DIMENSION - (int)(s * PALETTE_DIMENSION);
  129. break;
  130. }
  131. paletteSelection.setLocation( x, y );
  132. repaintPaletteSelection();
  133. }
  134. protected void updateSliderPalette( float h, float s, float b ) {
  135. if ( sliderType != HUE_SLIDER && h != sliderPalette.getHue() ) {
  136. sliderPalette.setHue( h );
  137. sliderPalette.nextFrame( 0 );
  138. }
  139. }
  140. protected void updateSlider( float h, float s, float b ) {
  141. float value = 0f;
  142. switch ( sliderType ) {
  143. case HUE_SLIDER:
  144. value = h;
  145. break;
  146. case SATURATION_SLIDER:
  147. value = s;
  148. break;
  149. case BRIGHTNESS_SLIDER:
  150. value = b;
  151. break;
  152. }
  153. slider.setValue( Math.round(value * (slider.getMaximum()+1)) );
  154. }
  155. protected void updateHSBTextFields( float hue, float saturation, float brightness ) {
  156. int h = Math.round(hue * 359);
  157. int s = Math.round(saturation * 100);
  158. int b = Math.round(brightness * 100);
  159. if ( hField.getIntegerValue() != h ) {
  160. hField.setText( String.valueOf( h ) );
  161. }
  162. if ( sField.getIntegerValue() != s ) {
  163. sField.setText( String.valueOf( s ) );
  164. }
  165. if ( bField.getIntegerValue() != b ) {
  166. bField.setText( String.valueOf( b ) );
  167. }
  168. }
  169. protected void updateRGBTextFields( Color color ) {
  170. redField.setText(String.valueOf(color.getRed()));
  171. greenField.setText(String.valueOf(color.getGreen()));
  172. blueField.setText(String.valueOf(color.getBlue()));
  173. }
  174. protected void updateHSB( float h, float s, float b ) {
  175. if ( !isAdjusting ) {
  176. isAdjusting = true;
  177. updatePalette( h, s, b );
  178. updateSliderPalette( h, s, b );
  179. updateSlider( h, s, b );
  180. updateHSBTextFields( h, s, b );
  181. Color color = new Color( palette.getRGBForLocation( paletteSelection.x, paletteSelection.y ) );
  182. updateRGBTextFields( color );
  183. getColorSelectionModel().setSelectedColor( color );
  184. isAdjusting = false;
  185. }
  186. }
  187. public void updateChooser() {
  188. if ( !isAdjusting ) {
  189. Color color = getColorFromModel();
  190. Color.RGBtoHSB( color.getRed(), color.getGreen(), color.getBlue(), hsb );
  191. updateHSB( hsb[0], hsb[1], hsb[2] );
  192. }
  193. }
  194. protected void buildChooser() {
  195. Color color = getColorFromModel();
  196. Color.RGBtoHSB( color.getRed(), color.getGreen(), color.getBlue(), hsb );
  197. setLayout(new BorderLayout());
  198. JComponent spp = buildSliderPalettePanel();
  199. add(spp, BorderLayout.WEST);
  200. JPanel controlHolder = new JPanel(new SmartGridLayout(1,3));
  201. JComponent hsbControls = buildHSBControls();
  202. controlHolder.add(hsbControls);
  203. controlHolder.add(new JLabel(" ")); // spacer
  204. JComponent rgbControls = buildRGBControls();
  205. controlHolder.add(rgbControls);
  206. controlHolder.setBorder(new EmptyBorder( 10, 5, 10, 5));
  207. add( controlHolder, BorderLayout.CENTER);
  208. }
  209. protected JComponent buildRGBControls() {
  210. JPanel panel = new JPanel(new SmartGridLayout(2,3));
  211. Color color = getColorFromModel();
  212. redField = new JTextField( String.valueOf(color.getRed()) );
  213. redField.setEditable(false);
  214. greenField = new JTextField(String.valueOf(color.getGreen()) );
  215. greenField.setEditable(false);
  216. blueField = new JTextField( String.valueOf(color.getBlue()) );
  217. blueField.setEditable(false);
  218. String redString = UIManager.getString("ColorChooser.hsbRedText");
  219. String greenString = UIManager.getString("ColorChooser.hsbGreenText");
  220. String blueString = UIManager.getString("ColorChooser.hsbBlueText");
  221. panel.add( new JLabel(redString) );
  222. panel.add( redField );
  223. panel.add( new JLabel(greenString) );
  224. panel.add( greenField );
  225. panel.add( new JLabel(blueString) );
  226. panel.add( blueField );
  227. return panel;
  228. }
  229. protected JComponent buildHSBControls() {
  230. String hueString = UIManager.getString("ColorChooser.hsbHueText");
  231. String saturationString = UIManager.getString("ColorChooser.hsbSaturationText");
  232. String brightnessString = UIManager.getString("ColorChooser.hsbBrightnessText");
  233. JPanel panel = new JPanel( new SmartGridLayout(2, 3) );
  234. hField = new JIntegerTextField( 0, 359, (int)(hsb[0] * 359) );
  235. sField = new JIntegerTextField( 0, 100, (int)(hsb[1] * 100 ) );
  236. bField = new JIntegerTextField( 0, 100, (int)(hsb[2] * 100 ) );
  237. ButtonGroup group = new ButtonGroup();
  238. hRadio = new JRadioButton(hueString);
  239. group.add(hRadio);
  240. hRadio.addActionListener( new ActionListener() {
  241. public void actionPerformed (ActionEvent e) {
  242. setHueMode();
  243. }} );
  244. sRadio = new JRadioButton(saturationString);
  245. group.add(sRadio);
  246. sRadio.addActionListener( new ActionListener() {
  247. public void actionPerformed (ActionEvent e) {
  248. setSaturationMode();
  249. }} );
  250. bRadio = new JRadioButton(brightnessString);
  251. group.add(bRadio);
  252. bRadio.addActionListener( new ActionListener() {
  253. public void actionPerformed (ActionEvent e) {
  254. setBrightnessMode();
  255. }} );
  256. hRadio.setSelected(true);
  257. NumberListener fieldListener = new NumberListener();
  258. hField.getDocument().addDocumentListener( fieldListener );
  259. sField.getDocument().addDocumentListener( fieldListener );
  260. bField.getDocument().addDocumentListener( fieldListener );
  261. panel.add(hRadio);
  262. panel.add(hField);
  263. panel.add(sRadio);
  264. panel.add(sField);
  265. panel.add(bRadio);
  266. panel.add(bField);
  267. return panel;
  268. }
  269. protected void setHueMode() {
  270. sliderType = HUE_SLIDER;
  271. slider.setInverted( true );
  272. slider.setMaximum( MAX_HUE_VALUE );
  273. palette = new SaturationBrightnessImage( PALETTE_DIMENSION, PALETTE_DIMENSION, hsb[ 0 ] );
  274. sliderPalette = new HueImage( 16, PALETTE_DIMENSION );
  275. paletteImage.flush();
  276. sliderImage.flush();
  277. paletteImage = Toolkit.getDefaultToolkit().createImage( palette );
  278. sliderImage = Toolkit.getDefaultToolkit().createImage( sliderPalette );
  279. paletteLabel.setIcon( new ImageIcon( paletteImage ) );
  280. sliderPaletteLabel.setIcon( new ImageIcon( sliderImage ) );
  281. updateHSB(hsb[0], hsb[1], hsb[2]);
  282. repaint();
  283. }
  284. protected void setSaturationMode() {
  285. sliderType = SATURATION_SLIDER;
  286. slider.setInverted( false );
  287. slider.setMaximum( MAX_SATURATION_VALUE );
  288. palette = new HueBrightnessImage( PALETTE_DIMENSION, PALETTE_DIMENSION, hsb[0], hsb[1] );
  289. sliderPalette = new SaturationImage( 16, PALETTE_DIMENSION, hsb[0] );
  290. paletteImage.flush();
  291. sliderImage.flush();
  292. paletteImage = Toolkit.getDefaultToolkit().createImage( palette );
  293. sliderImage = Toolkit.getDefaultToolkit().createImage( sliderPalette );
  294. paletteLabel.setIcon( new ImageIcon( paletteImage ) );
  295. sliderPaletteLabel.setIcon( new ImageIcon( sliderImage ) );
  296. updateHSB(hsb[0], hsb[1], hsb[2]);
  297. repaint();
  298. }
  299. protected void setBrightnessMode() {
  300. sliderType = BRIGHTNESS_SLIDER;
  301. slider.setInverted( false );
  302. slider.setMaximum( MAX_BRIGHTNESS_VALUE );
  303. palette = new HueSaturationImage( PALETTE_DIMENSION, PALETTE_DIMENSION, hsb[0], hsb[2] );
  304. sliderPalette = new BrightnessImage( 16, PALETTE_DIMENSION, hsb[0] );
  305. paletteImage.flush();
  306. sliderImage.flush();
  307. paletteImage = Toolkit.getDefaultToolkit().createImage( palette );
  308. sliderImage = Toolkit.getDefaultToolkit().createImage( sliderPalette );
  309. paletteLabel.setIcon( new ImageIcon( paletteImage ) );
  310. sliderPaletteLabel.setIcon( new ImageIcon( sliderImage ) );
  311. updateHSB(hsb[0], hsb[1], hsb[2]);
  312. repaint();
  313. }
  314. protected JComponent buildSliderPalettePanel() {
  315. JPanel panel = new JPanel();
  316. palette = new SaturationBrightnessImage( PALETTE_DIMENSION, PALETTE_DIMENSION, hsb[ 0 ] );
  317. // palette = new HueBrightnessImage( PALETTE_DIMENSION, PALETTE_DIMENSION, hsb[0], hsb[1] );
  318. //palette = new HueSaturationImage( PALETTE_DIMENSION, PALETTE_DIMENSION, hsb[0], hsb[2] );
  319. sliderPalette = new HueImage( 16, PALETTE_DIMENSION );
  320. //sliderPalette = new SaturationImage( 16, PALETTE_DIMENSION, hsb[0] );
  321. //sliderPalette = new BrightnessImage( 16, PALETTE_DIMENSION, hsb[0] );
  322. // This slider has to have a minimum of 0. A lot of math in this file is simplified due to this.
  323. slider = new JSlider( JSlider.VERTICAL, 0, MAX_HUE_VALUE, 0 );
  324. slider.setPaintTrack( false );
  325. Dimension prefSize = slider.getPreferredSize();
  326. slider.setPreferredSize( new Dimension( prefSize.width, PALETTE_DIMENSION + 15 ) );
  327. slider.setInverted( true );
  328. addSliderListeners();
  329. paletteLabel = createPaletteLabel();
  330. paletteImage = Toolkit.getDefaultToolkit().createImage( palette );
  331. paletteLabel.setIcon( new ImageIcon( paletteImage ) );
  332. addPaletteListeners();
  333. panel.add( paletteLabel );
  334. panel.add( slider );
  335. sliderPaletteLabel = new JLabel();
  336. sliderImage = Toolkit.getDefaultToolkit().createImage( sliderPalette );
  337. sliderPaletteLabel.setIcon( new ImageIcon( sliderImage ) );
  338. panel.add( sliderPaletteLabel );
  339. return panel;
  340. }
  341. protected JLabel createPaletteLabel() {
  342. return new JLabel() {
  343. protected void paintComponent( Graphics g ) {
  344. super.paintComponent( g );
  345. g.setColor( Color.white );
  346. g.drawOval( paletteSelection.x - 4, paletteSelection.y - 4, 8, 8 );
  347. }
  348. };
  349. }
  350. public String getDisplayName() {
  351. return UIManager.getString("ColorChooser.hsbNameText");
  352. }
  353. public Icon getSmallDisplayIcon() {
  354. return null;
  355. }
  356. public Icon getLargeDisplayIcon() {
  357. return null;
  358. }
  359. class NumberListener implements DocumentListener {
  360. public void insertUpdate(DocumentEvent e) {updatePanel(e);}
  361. public void removeUpdate(DocumentEvent e) {updatePanel(e);}
  362. public void changedUpdate(DocumentEvent e) {}
  363. private void updatePanel(DocumentEvent e) {
  364. float hue = (float)hField.getIntegerValue() / 359f;
  365. float saturation = (float)sField.getIntegerValue() / 100f;
  366. float brightness = (float)bField.getIntegerValue() / 100f;
  367. updateHSB( hue, saturation, brightness );
  368. }
  369. }
  370. abstract class AbstractHSBImage extends SyntheticImage {
  371. protected float h = .0f;
  372. protected float s = .0f;
  373. protected float b = .0f;
  374. protected float[] hsb = new float[3];
  375. protected boolean isDirty = true;
  376. protected AbstractHSBImage( int width, int height, float h, float s, float b ) {
  377. super( width, height );
  378. setHSB( h, s, b );
  379. }
  380. public void setHSB( float h, float s, float b ) {
  381. setHue( h );
  382. setSaturation( s );
  383. setBrightness( b );
  384. }
  385. public final void setHue( float hue ) {
  386. h = hue;
  387. }
  388. public final void setSaturation( float saturation ) {
  389. s = saturation;
  390. }
  391. public final void setBrightness( float brightness ) {
  392. b = brightness;
  393. }
  394. public final float getHue() {
  395. return h;
  396. }
  397. public final float getSaturation() {
  398. return s;
  399. }
  400. public final float getBrightness() {
  401. return b;
  402. }
  403. protected boolean isStatic() {
  404. return false;
  405. }
  406. public synchronized void nextFrame( int param ) {
  407. isDirty = true;
  408. notifyAll();
  409. }
  410. public int getRGBForMouseEvent( MouseEvent e ) {
  411. return getRGBForLocation( e.getX(), e.getY() );
  412. }
  413. public int getRGBForLocation( int x, int y ) {
  414. getHSBForLocation( x, y, hsb );
  415. return HSBtoRGB( hsb[0], hsb[1], hsb[2] );
  416. }
  417. public abstract void getHSBForLocation( int x, int y, float[] hsbArray );
  418. public synchronized void addConsumer(ImageConsumer ic){
  419. isDirty = true;
  420. super.addConsumer( ic );
  421. }
  422. protected void computeRow( int y, int[] row ) {
  423. if ( y == 0 ) {
  424. synchronized ( this ) {
  425. try {
  426. while ( !isDirty ) {
  427. wait();
  428. }
  429. } catch ( Exception e ) {System.out.println( e );}
  430. isDirty = false;
  431. }
  432. }
  433. for ( int i = 0; i < row.length; ++i ) {
  434. row[i] = getRGBForLocation( i, y );
  435. }
  436. }
  437. // An optimized version of Color.HSBtoRGB
  438. protected int HSBtoRGB( float hue, float saturation, float brightness) {
  439. int r = 0, g = 0, b = 0;
  440. if (saturation == 0) {
  441. r = g = b = (int) (brightness * 255);
  442. } else {
  443. double scaledBrightness = brightness*255.0;
  444. int iScaledBrightness = (int) scaledBrightness;
  445. double h = hue>=0 ? (hue - (int)hue) : (hue - Math.floor(hue));
  446. h *= 6.0;
  447. int ih = (int) h; // floor not necessary because h>=0
  448. double f = h - ih;
  449. int p = (int)(scaledBrightness * (1.0 - saturation));
  450. int q = (int)(scaledBrightness * (1.0 - saturation * f));
  451. int t = (int)(scaledBrightness * (1.0 - (saturation * (1.0 - f))));
  452. switch (ih) {
  453. case 0:
  454. r = iScaledBrightness;
  455. g = t;
  456. b = p;
  457. break;
  458. case 1:
  459. r = q;
  460. g = iScaledBrightness;
  461. b = p;
  462. break;
  463. case 2:
  464. r = p;
  465. g = iScaledBrightness;
  466. b = t;
  467. break;
  468. case 3:
  469. r = p;
  470. g = q;
  471. b = iScaledBrightness;
  472. break;
  473. case 4:
  474. r = t;
  475. g = p;
  476. b = iScaledBrightness;
  477. break;
  478. case 5:
  479. r = iScaledBrightness;
  480. g = p;
  481. b = q;
  482. break;
  483. }
  484. }
  485. return 0xff000000 | (r << 16) | (g << 8) | (b << 0);
  486. }
  487. }
  488. // Square for H
  489. class SaturationBrightnessImage extends AbstractHSBImage {
  490. public SaturationBrightnessImage( int width, int height, float hue ) {
  491. super( width, height, hue, 1.0f, 1.0f );
  492. }
  493. public void getHSBForLocation( int x, int y, float[] hsbArray ) {
  494. float saturationStep = ((float)x) / width;
  495. float brightnessStep = ((float)y) / height;
  496. hsbArray[0] = h;
  497. hsbArray[1] = s - saturationStep;
  498. hsbArray[2] = b - brightnessStep;
  499. }
  500. }
  501. // Square for S
  502. class HueBrightnessImage extends AbstractHSBImage {
  503. public HueBrightnessImage( int width, int height, float h, float s ) {
  504. super( width, height, h, s, 1.0f );
  505. }
  506. public void getHSBForLocation( int x, int y, float[] hsbArray ) {
  507. float brightnessStep = ((float)y) / height;
  508. float step = 1.0f / ((float)width);
  509. hsbArray[0] = x * step;
  510. hsbArray[1] = s;
  511. hsbArray[2] = 1.0f - brightnessStep;
  512. }
  513. }
  514. // Square for B
  515. class HueSaturationImage extends AbstractHSBImage {
  516. public HueSaturationImage( int width, int height, float h, float b ) {
  517. super( width, height, h, 1.0f, b );
  518. }
  519. public void getHSBForLocation( int x, int y, float[] hsbArray ) {
  520. float saturationStep = ((float)y) / height;
  521. float step = 1.0f / ((float)width);
  522. hsbArray[0] = x * step;
  523. hsbArray[1] = 1.0f - saturationStep;
  524. hsbArray[2] = b;
  525. }
  526. }
  527. // Slider for B
  528. class BrightnessImage extends AbstractHSBImage {
  529. protected int cachedY = -1;
  530. protected int cachedColor = 0;
  531. public BrightnessImage( int width, int height, float hue ) {
  532. super( width, height, hue, 1.0f, 1.0f );
  533. }
  534. public int getRGBForLocation( int x, int y ) {
  535. if ( y == cachedY ) {
  536. } else {
  537. cachedY = y;
  538. cachedColor = super.getRGBForLocation( x, y );
  539. }
  540. return cachedColor;
  541. }
  542. public void getHSBForLocation( int x, int y, float[] hsbArray ) {
  543. float brightnessStep = ((float)y) / height;
  544. hsbArray[0] = h;
  545. hsbArray[1] = s;
  546. hsbArray[2] = b - brightnessStep;
  547. }
  548. }
  549. // Slider for S
  550. class SaturationImage extends AbstractHSBImage {
  551. protected int cachedY = -1;
  552. protected int cachedColor = 0;
  553. public SaturationImage( int width, int height, float hue ) {
  554. super( width, height, hue, 1.0f, 1.0f );
  555. }
  556. public int getRGBForLocation( int x, int y ) {
  557. if ( y == cachedY ) {
  558. } else {
  559. cachedY = y;
  560. cachedColor = super.getRGBForLocation( x, y );
  561. }
  562. return cachedColor;
  563. }
  564. public void getHSBForLocation( int x, int y, float[] hsbArray ) {
  565. float saturationStep = ((float)y) / height;
  566. hsbArray[0] = h;
  567. hsbArray[1] = s - saturationStep;
  568. hsbArray[2] = b;
  569. }
  570. }
  571. // Slider for H
  572. class HueImage extends AbstractHSBImage {
  573. public HueImage( int width, int height ) {
  574. super( width, height, 0f, 1.0f, 1.0f );
  575. }
  576. protected boolean isStatic() {
  577. return true;
  578. }
  579. public void getHSBForLocation( int x, int y, float[] hsbArray ) {
  580. float step = 1.0f / ((float)height);
  581. hsbArray[0] = y * step;
  582. hsbArray[1] = s;
  583. hsbArray[2] = b;
  584. }
  585. }
  586. }