Class OverlayWindow
java.lang.Object
az.araezarzosa.spotifyoverlay.spotify_in_game_overlay.OverlayWindow
public class OverlayWindow
extends java.lang.Object
Stores information and methods related to the display of the overlay.
- Author:
- Arae
-
Field Summary
Fields Modifier and Type Field Description private static javax.swing.JLabelalbumArtLabelThe label storing the album art.private static javax.swing.JPanelalbumArtPanelThe panel storing the album art.private static intalbumArtSizeThe size of the album art display square.private static javax.swing.JLabelartistNameLabelThe label displaying the artist name.private static java.awt.ColorbarColorThe color of the progress and volume bars in the overlay.private static intbarOffsetThe offset by which to move the progress bar to the right of the album art.private static intbuttonSizeThe size of the previous, pause, play, and skip buttons.private static javax.swing.JPanelcontentPanelThe content panel managing the layout of the overlay.private static java.awt.image.BufferedImagecurrentArtThe current album art of the user's currently playing track.private static se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlayingContextcurrentInfoThe context of the user's currently playing track.private static se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlayingcurrentlyPlayingThe CurrentlyPlaying of the user's currently playing track.private static se.michaelthelin.spotify.model_objects.specification.TrackcurrentTrackThe current Track object the user is playing.private static javax.swing.JFrameframeThe overlay frame.private static intheightThe height of the overlay.private static booleanisPlayingValue storing the status of the user's playback.private static intMARGINThe amount of pixel displacement from the corner the overlay will go through.private static javax.swing.JButtonnextButtonThe button to go to the next track.private static javax.swing.JButtonpauseButtonThe button to pause/resume playback.private static java.lang.StringpositionStringThe String storing the position of the overlay.private static javax.swing.JButtonpreviousButtonThe button to go to the previous track.private static javax.swing.JSliderprogressBarThe progress bar object.private static intprogressHeightThe width of the progress bar.private static javax.swing.event.ChangeListenerprogressListenerThe listener that is used to track user movements of the progress slider.private static javax.swing.plaf.basic.BasicSliderUIprogressSliderUIThe UI that the progress bar will use.private static intprogressWidthThe width of the progress bar.private static java.awt.DimensionscreenSizeThe size of the user's screen.private static javax.swing.JLabelsongNameLabelThe label displaying the song name.private static intTRACK_CHANGE_UPDATE_INTERVALThe interval in which the track changes will be checked in milliseconds.private static intTRACK_PLAYING_UPDATE_INTERVALThe interval in which the track playing/pausing status will be checked.private static intTRACK_PROGRESS_CHANGE_UPDATE_INTERVALThe interval in which the track progress will be checked.private static java.util.concurrent.ScheduledExecutorServiceTrackChangeExecutorThe executor of the track change checker Thread.private static java.util.concurrent.ScheduledExecutorServiceTrackPlayingExecutorThe executor of the Track Playing/Pausing checker thread.private static java.util.concurrent.ScheduledExecutorServiceTrackProgressChangeExecutorThe executor of the Track Progress checker Thread.private static intVOLUME_INITThe initial value for the volume slider.private static intVOLUME_MAXThe maximum value for the volume slider.private static intVOLUME_MINThe minimum value for the volume slider.private static intvolumeHeightThe height of the volume bar.private static intvolumeOffsetThe offset by which to move the volume bar to the right of the buttons.private static javax.swing.JSlidervolumeSliderThe slider to change the volume on Spotify.private static javax.swing.plaf.basic.BasicSliderUIvolumeSliderUIThe UI that the volume bar will use.private static intvolumeWidthThe width of the volume bar.private static intwidthThe width of the overlay.private static intxThe X coordinate the overlay will be placed in.private static intyThe Y coordinate the overlay will be placed in. -
Constructor Summary
Constructors Constructor Description OverlayWindow() -
Method Summary
Modifier and Type Method Description static intgetHeight()Getter for the height of the overlaystatic java.lang.StringgetPositionString()Getter for the String describing the position of the overlay.static java.awt.DimensiongetScreenSize()Getter for the screen size of the desktop.static intgetWidth()Getter for the width of the overlay.static voidsetAlbumArt(java.awt.image.BufferedImage image)Setter for the album art corresponding to the current playing track displayed in the overlay.static voidsetArtistName(java.lang.String name)The setter for the artist name text field in the overlay.static voidsetPositionString(java.lang.String string)Setter for the string describing the position of the overlay.static voidsetProgress(int progress)The setter for the progress bar, indicating how long a track has been playing.static voidsetProgressMax(int max)The setter for the maximum of the progress bar, namely the length of a song in milliseconds.static voidsetSongName(java.lang.String name)The setter for the track name text field in the overlay.static voidsetVolume(int volume)The setter for the value of the volume slider.static voidsetWindowOpacity(float newOpacity)Sets the overlay's opacity to the desired number.static voidsetWindowPosition(int newX, int newY)Sets the overlay's position to the specified coordinates on the screen.static voidsetWindowSize(java.lang.String size)Sets the overlay's size to the desired set size
Namely, Small, Medium, or Largestatic voidshowOverlay()Displays the overlay and whatever track information it can receive upon starting.static voidstartTrackChangeUpdateExecutor()Starts the async thread to listen for track changes.private static voidstartTrackPlayingExecutor()Starts the async thread to listen for track playing/pausing changes.private static voidstartTrackProgressExecutor()Starts the async thread to listen for track progress changes.private static voidstopExecutorServices()Stops all async executors gracefully.private static voidupdateTrackChange()The method that the TrackChangeExecutor executes at intervals.private static voidupdateTrackPlaying()The method that the TrackPlayingExecutor executes at intervals.private static voidupdateTrackProgress()The method that the TrackProgressChangeExecutor executes at intervals.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
MARGIN
private static final int MARGINThe amount of pixel displacement from the corner the overlay will go through.- See Also:
- Constant Field Values
-
frame
private static javax.swing.JFrame frameThe overlay frame. -
x
private static int xThe X coordinate the overlay will be placed in. -
y
private static int yThe Y coordinate the overlay will be placed in. -
screenSize
private static java.awt.Dimension screenSizeThe size of the user's screen. -
width
private static int widthThe width of the overlay. -
height
private static int heightThe height of the overlay. -
barColor
private static java.awt.Color barColorThe color of the progress and volume bars in the overlay. -
albumArtSize
private static int albumArtSizeThe size of the album art display square. -
progressWidth
private static int progressWidthThe width of the progress bar. -
progressHeight
private static int progressHeightThe width of the progress bar. -
volumeWidth
private static int volumeWidthThe width of the volume bar. -
volumeHeight
private static int volumeHeightThe height of the volume bar. -
buttonSize
private static int buttonSizeThe size of the previous, pause, play, and skip buttons. -
volumeOffset
private static int volumeOffsetThe offset by which to move the volume bar to the right of the buttons. -
barOffset
private static int barOffsetThe offset by which to move the progress bar to the right of the album art. -
contentPanel
private static javax.swing.JPanel contentPanelThe content panel managing the layout of the overlay. -
albumArtLabel
private static javax.swing.JLabel albumArtLabelThe label storing the album art. -
albumArtPanel
private static javax.swing.JPanel albumArtPanelThe panel storing the album art. -
songNameLabel
private static javax.swing.JLabel songNameLabelThe label displaying the song name. -
artistNameLabel
private static javax.swing.JLabel artistNameLabelThe label displaying the artist name. -
progressSliderUI
private static javax.swing.plaf.basic.BasicSliderUI progressSliderUIThe UI that the progress bar will use. -
volumeSliderUI
private static javax.swing.plaf.basic.BasicSliderUI volumeSliderUIThe UI that the volume bar will use. -
progressBar
private static javax.swing.JSlider progressBarThe progress bar object. -
previousButton
private static javax.swing.JButton previousButtonThe button to go to the previous track. -
pauseButton
private static javax.swing.JButton pauseButtonThe button to pause/resume playback. -
nextButton
private static javax.swing.JButton nextButtonThe button to go to the next track. -
volumeSlider
private static javax.swing.JSlider volumeSliderThe slider to change the volume on Spotify. -
positionString
private static java.lang.String positionStringThe String storing the position of the overlay. Starts by displaying the overlay at the Top Left. -
VOLUME_MIN
private static final int VOLUME_MINThe minimum value for the volume slider.- See Also:
- Constant Field Values
-
VOLUME_MAX
private static final int VOLUME_MAXThe maximum value for the volume slider.- See Also:
- Constant Field Values
-
VOLUME_INIT
private static final int VOLUME_INITThe initial value for the volume slider.- See Also:
- Constant Field Values
-
isPlaying
private static boolean isPlayingValue storing the status of the user's playback. -
currentTrack
private static se.michaelthelin.spotify.model_objects.specification.Track currentTrackThe current Track object the user is playing. -
currentlyPlaying
private static se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlaying currentlyPlayingThe CurrentlyPlaying of the user's currently playing track. -
currentInfo
private static se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlayingContext currentInfoThe context of the user's currently playing track. -
currentArt
private static java.awt.image.BufferedImage currentArtThe current album art of the user's currently playing track. -
TRACK_CHANGE_UPDATE_INTERVAL
private static final int TRACK_CHANGE_UPDATE_INTERVALThe interval in which the track changes will be checked in milliseconds.- See Also:
- Constant Field Values
-
TRACK_PLAYING_UPDATE_INTERVAL
private static final int TRACK_PLAYING_UPDATE_INTERVALThe interval in which the track playing/pausing status will be checked.- See Also:
- Constant Field Values
-
TRACK_PROGRESS_CHANGE_UPDATE_INTERVAL
private static final int TRACK_PROGRESS_CHANGE_UPDATE_INTERVALThe interval in which the track progress will be checked.- See Also:
- Constant Field Values
-
progressListener
private static javax.swing.event.ChangeListener progressListenerThe listener that is used to track user movements of the progress slider. -
TrackChangeExecutor
private static java.util.concurrent.ScheduledExecutorService TrackChangeExecutorThe executor of the track change checker Thread. -
TrackPlayingExecutor
private static java.util.concurrent.ScheduledExecutorService TrackPlayingExecutorThe executor of the Track Playing/Pausing checker thread. -
TrackProgressChangeExecutor
private static java.util.concurrent.ScheduledExecutorService TrackProgressChangeExecutorThe executor of the Track Progress checker Thread.
-
-
Constructor Details
-
OverlayWindow
public OverlayWindow()
-
-
Method Details
-
showOverlay
public static void showOverlay()Displays the overlay and whatever track information it can receive upon starting. -
setWindowOpacity
public static void setWindowOpacity(float newOpacity)Sets the overlay's opacity to the desired number.- Parameters:
newOpacity- Float value of the overlay's new opacity.
-
setWindowPosition
public static void setWindowPosition(int newX, int newY)Sets the overlay's position to the specified coordinates on the screen.- Parameters:
newX- X coordinate.newY- Y coordinate.
-
setWindowSize
public static void setWindowSize(java.lang.String size)Sets the overlay's size to the desired set size
Namely, Small, Medium, or Large- Parameters:
size- Desired overlay size.
-
getScreenSize
public static java.awt.Dimension getScreenSize()Getter for the screen size of the desktop.- Returns:
- Dimension object containing the desktop screen's size.
-
getWidth
public static int getWidth()Getter for the width of the overlay.- Returns:
- Overlay width.
-
getHeight
public static int getHeight()Getter for the height of the overlay- Returns:
- Overlay height.
-
getPositionString
public static java.lang.String getPositionString()Getter for the String describing the position of the overlay.- Returns:
- the String.
-
setPositionString
public static void setPositionString(java.lang.String string)Setter for the string describing the position of the overlay.- Parameters:
string- The new String for the overlay's position.
-
setAlbumArt
public static void setAlbumArt(java.awt.image.BufferedImage image)Setter for the album art corresponding to the current playing track displayed in the overlay.- Parameters:
image- The BufferedImage object to be displayed.
-
setSongName
public static void setSongName(java.lang.String name)The setter for the track name text field in the overlay.- Parameters:
name- The text to be used in the text field.
-
setArtistName
public static void setArtistName(java.lang.String name)The setter for the artist name text field in the overlay.- Parameters:
name- The text to be used in the text field.
-
setProgress
public static void setProgress(int progress)The setter for the progress bar, indicating how long a track has been playing.- Parameters:
progress- The number in milliseconds to set the progress bar to.
-
setProgressMax
public static void setProgressMax(int max)The setter for the maximum of the progress bar, namely the length of a song in milliseconds.- Parameters:
max- The new maximum amount of the progress bar.
-
setVolume
public static void setVolume(int volume)The setter for the value of the volume slider.- Parameters:
volume- The new value.
-
startTrackChangeUpdateExecutor
public static void startTrackChangeUpdateExecutor()Starts the async thread to listen for track changes. -
updateTrackChange
private static void updateTrackChange()The method that the TrackChangeExecutor executes at intervals. -
startTrackPlayingExecutor
private static void startTrackPlayingExecutor()Starts the async thread to listen for track playing/pausing changes. -
updateTrackPlaying
private static void updateTrackPlaying()The method that the TrackPlayingExecutor executes at intervals. -
startTrackProgressExecutor
private static void startTrackProgressExecutor()Starts the async thread to listen for track progress changes. -
updateTrackProgress
private static void updateTrackProgress()The method that the TrackProgressChangeExecutor executes at intervals. -
stopExecutorServices
private static void stopExecutorServices()Stops all async executors gracefully.
-