MenuButton.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package model.objects;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics2D;
  5. import java.awt.geom.GeneralPath;
  6. import java.util.ArrayList;
  7. import audio.Song;
  8. public class MenuButton {
  9. private ArrayList<Color> colors;
  10. private int x, y;
  11. private boolean selected;
  12. private Song song;
  13. Color color;
  14. public MenuButton(int x, int y, Color color, Song song){
  15. this.x = x;
  16. this.y = y;
  17. this.color = color;
  18. setSong(song);
  19. }
  20. public void draw(Graphics2D g2d){
  21. if(selected){
  22. g2d.setColor(color);
  23. GeneralPath path = new GeneralPath();
  24. path.moveTo(320, 540);
  25. path.lineTo(320, 590);
  26. path.lineTo(385, 565);
  27. path.closePath();
  28. g2d.fill(path);
  29. g2d.setColor(Color.BLACK);
  30. g2d.draw(path);
  31. g2d.setColor(color.darker().darker().darker().darker());
  32. g2d.fillRect(x-10, y-10,900,90);
  33. }
  34. g2d.setColor(color.darker().darker());
  35. g2d.fillRect(x-5, y-5,890,80);
  36. g2d.setColor(color);
  37. g2d.fillRect(x,y,880,70);
  38. if(selected){
  39. g2d.setColor(Color.BLACK);
  40. g2d.drawRect(x-10, y-10, 900, 90);
  41. g2d.drawRect(x-5, y-5, 890, 80);
  42. g2d.drawRect(x, y, 880, 70);
  43. }
  44. //draw text
  45. g2d.setColor(Color.BLACK);
  46. Font textFont = new Font("OCR A Extended", Font.BOLD,60);
  47. g2d.setFont(textFont);
  48. g2d.drawString(song.getTitle(), x+50, y+57);
  49. }
  50. public void setSelected(boolean selected) {
  51. this.selected = selected;
  52. }
  53. public boolean isSelected(){
  54. return selected;
  55. }
  56. public void setX(int x){
  57. this.x = x;
  58. }
  59. public int getX() {
  60. return x;
  61. }
  62. public Song getSong() {
  63. return song;
  64. }
  65. public void setSong(Song song) {
  66. this.song = song;
  67. }
  68. }