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