MenuButton.java 1.4 KB

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