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.JLabel
albumArtLabel
The label storing the album art.private static javax.swing.JPanel
albumArtPanel
The panel storing the album art.private static int
albumArtSize
The size of the album art display square.private static javax.swing.JLabel
artistNameLabel
The label displaying the artist name.private static java.awt.Color
barColor
The color of the progress and volume bars in the overlay.private static int
barOffset
The offset by which to move the progress bar to the right of the album art.private static int
buttonSize
The size of the previous, pause, play, and skip buttons.private static javax.swing.JPanel
contentPanel
The content panel managing the layout of the overlay.private static java.awt.image.BufferedImage
currentArt
The current album art of the user's currently playing track.private static se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlayingContext
currentInfo
The context of the user's currently playing track.private static se.michaelthelin.spotify.model_objects.miscellaneous.CurrentlyPlaying
currentlyPlaying
The CurrentlyPlaying of the user's currently playing track.private static se.michaelthelin.spotify.model_objects.specification.Track
currentTrack
The current Track object the user is playing.private static javax.swing.JFrame
frame
The overlay frame.private static int
height
The height of the overlay.private static boolean
isPlaying
Value storing the status of the user's playback.private static int
MARGIN
The amount of pixel displacement from the corner the overlay will go through.private static javax.swing.JButton
nextButton
The button to go to the next track.private static javax.swing.JButton
pauseButton
The button to pause/resume playback.private static java.lang.String
positionString
The String storing the position of the overlay.private static javax.swing.JButton
previousButton
The button to go to the previous track.private static javax.swing.JSlider
progressBar
The progress bar object.private static int
progressHeight
The width of the progress bar.private static javax.swing.event.ChangeListener
progressListener
The listener that is used to track user movements of the progress slider.private static javax.swing.plaf.basic.BasicSliderUI
progressSliderUI
The UI that the progress bar will use.private static int
progressWidth
The width of the progress bar.private static java.awt.Dimension
screenSize
The size of the user's screen.private static javax.swing.JLabel
songNameLabel
The label displaying the song name.private static int
TRACK_CHANGE_UPDATE_INTERVAL
The interval in which the track changes will be checked in milliseconds.private static int
TRACK_PLAYING_UPDATE_INTERVAL
The interval in which the track playing/pausing status will be checked.private static int
TRACK_PROGRESS_CHANGE_UPDATE_INTERVAL
The interval in which the track progress will be checked.private static java.util.concurrent.ScheduledExecutorService
TrackChangeExecutor
The executor of the track change checker Thread.private static java.util.concurrent.ScheduledExecutorService
TrackPlayingExecutor
The executor of the Track Playing/Pausing checker thread.private static java.util.concurrent.ScheduledExecutorService
TrackProgressChangeExecutor
The executor of the Track Progress checker Thread.private static int
VOLUME_INIT
The initial value for the volume slider.private static int
VOLUME_MAX
The maximum value for the volume slider.private static int
VOLUME_MIN
The minimum value for the volume slider.private static int
volumeHeight
The height of the volume bar.private static int
volumeOffset
The offset by which to move the volume bar to the right of the buttons.private static javax.swing.JSlider
volumeSlider
The slider to change the volume on Spotify.private static javax.swing.plaf.basic.BasicSliderUI
volumeSliderUI
The UI that the volume bar will use.private static int
volumeWidth
The width of the volume bar.private static int
width
The width of the overlay.private static int
x
The X coordinate the overlay will be placed in.private static int
y
The Y coordinate the overlay will be placed in. -
Constructor Summary
Constructors Constructor Description OverlayWindow()
-
Method Summary
Modifier and Type Method Description static int
getHeight()
Getter for the height of the overlaystatic java.lang.String
getPositionString()
Getter for the String describing the position of the overlay.static java.awt.Dimension
getScreenSize()
Getter for the screen size of the desktop.static int
getWidth()
Getter for the width of the overlay.static void
setAlbumArt(java.awt.image.BufferedImage image)
Setter for the album art corresponding to the current playing track displayed in the overlay.static void
setArtistName(java.lang.String name)
The setter for the artist name text field in the overlay.static void
setPositionString(java.lang.String string)
Setter for the string describing the position of the overlay.static void
setProgress(int progress)
The setter for the progress bar, indicating how long a track has been playing.static void
setProgressMax(int max)
The setter for the maximum of the progress bar, namely the length of a song in milliseconds.static void
setSongName(java.lang.String name)
The setter for the track name text field in the overlay.static void
setVolume(int volume)
The setter for the value of the volume slider.static void
setWindowOpacity(float newOpacity)
Sets the overlay's opacity to the desired number.static void
setWindowPosition(int newX, int newY)
Sets the overlay's position to the specified coordinates on the screen.static void
setWindowSize(java.lang.String size)
Sets the overlay's size to the desired set size
Namely, Small, Medium, or Largestatic void
showOverlay()
Displays the overlay and whatever track information it can receive upon starting.static void
startTrackChangeUpdateExecutor()
Starts the async thread to listen for track changes.private static void
startTrackPlayingExecutor()
Starts the async thread to listen for track playing/pausing changes.private static void
startTrackProgressExecutor()
Starts the async thread to listen for track progress changes.private static void
stopExecutorServices()
Stops all async executors gracefully.private static void
updateTrackChange()
The method that the TrackChangeExecutor executes at intervals.private static void
updateTrackPlaying()
The method that the TrackPlayingExecutor executes at intervals.private static void
updateTrackProgress()
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.
-