Package org.emrick.project
Class MediaEditorGUI
java.lang.Object
java.awt.Component
org.emrick.project.MediaEditorGUI
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,EffectListener
,RFTriggerListener
,FootballFieldListener
,ImportListener
,LEDConfigListener
,ReplaceFilesListener
,RequestCompleteListener
,RFSignalListener
,ScrubBarListener
,SelectListener
,SyncListener
,UserAuthListener
public class MediaEditorGUI
extends Component
implements ImportListener, ScrubBarListener, SyncListener, FootballFieldListener, EffectListener, SelectListener, UserAuthListener, RFTriggerListener, RFSignalListener, RequestCompleteListener, LEDConfigListener, ReplaceFilesListener
Main class of Emrick Designer.
Contains all GUI elements and logic for light show design and Emrick board interaction
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
private class
Runnable object used to split the load of packet export.private class
Task used by the playback timer to repeatedly repaint the footballfieldpanel with new frames in fps mode.private class
Object used to track the progress of programming led strips using the web serverNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
final int
private final Timer
final int
private Effect
private File
private Effect
private int
int
final int
final int
final int
private EffectGUI
private EffectManager
private JPanel
private File
static final String
static final String
static final String
static final String
static final String
private JMenuItem
private FlowViewGUI
private JPanel
private FootballFieldBackground
private FootballFieldPanel
private final JFrame
private SelectionGroupGUI
private final com.google.gson.Gson
final int
private boolean
private LEDConfigurationGUI
private LEDStripViewGUI
final int
private JMenuItem
private boolean
private JPanel
private static int
private Timer
private String
private float
private Timer
private int
final int
private JProgressBar
private RFTriggerGUI
private JMenuItem
private JMenuItem
private JMenuItem
private ScrubBarGUI
private JPanel
private EffectList
private SerialTransmitter
private HttpServer
final int
private JCheckBoxMenuItem
private String
private float
private JMenuItem
private JMenuItem
private final JLabel
private TimelineGUI
private JPanel
private TimeManager
private ArrayList<SyncTimeGUI.Pair>
private int
final int
final int
private final Path
private boolean
private Color
final int
(package private) JFrame
private WindowListener
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Applies a default led configuration to all performersprivate void
Loads the ScrubBarGUI Panel if it has not been created, or refreshes it if it already exists.comPortPrompt
(String type) Used to get a Serial Transmitter object.private void
private void
concatenateProject
(File path) private void
Builds all major GUI elements and adds them to the main frame.void
ctrlGroupSelection
(LEDStrip[] ledStrips) private boolean
deleteDirectory
(File directoryToBeDeleted) Recursively empties and deletes the specified file/directory.private void
exportCsvFileForPerformerDeviceIDs
(File selectedFile) Builds and exports a csv file containing configuration data for led strips and performersprivate void
exportPackets
(File path) Multithreaded export of firmware-readable packet data to a .pkt file.Get audio playerprivate JButton
Initializes the Effect Options button and the effects popup menu and returns the Effect Options button.private int
getEffectTriggerIndex
(Effect e, Long[] timesMS) Calculates the index of the RF Trigger immediately before the relevant effect.double
private int
private long
Calculates and returns the frame length in millisecondslong
getPrevAudioPlayerDurations
(int index) boolean
private void
loadProject
(File path) Loads a new .emrick file to the viewport to be edited.static void
Main method of Emrick Designer.void
onAudioImport
(ArrayList<File> audioFiles) void
void
onChangeSelectionMode
(boolean isInnerSelect, HashSet<LEDStrip> strips) void
onConcatAudioImport
(ArrayList<File> audioFiles) void
onCreateEffect
(Effect effect) void
onCreateRFTrigger
(RFTrigger rfTrigger) void
onDeleteEffect
(Effect effect) void
onDeleteRFTrigger
(int count) void
onDrillImport
(String drill) void
void
onFileSelect
(ArrayList<File> archivePaths, File csvFile) void
onGroupSelection
(LEDStrip[] ledStrips) void
onImport()
void
onMultiSelect
(HashSet<Integer> labels, HashSet<String> symbols) boolean
onNewFileSelect
(File drill, File archive) boolean
onPause()
void
void
boolean
onPlay()
void
onPressEffect
(Effect effect) void
onPressRFTrigger
(RFTrigger rfTrigger) void
onRequestComplete
(int id) void
void
onRFSignal
(int i) LEDStrip[]
long
onScrub()
void
onSetChange
(int setIndex) void
onSpeedChange
(float playbackSpeed) void
onSync
(ArrayList<SyncTimeGUI.Pair> times, float startDelay) void
onTimeChange
(long time) void
onUpdateEffect
(Effect oldEffect, Effect newEffect) void
onUpdateEffectPanel
(Effect effect, boolean isNew, int index) void
void
onUpdateRFTrigger
(RFTrigger rfTrigger, int count) void
onUserLoggedIn
(String username) private void
Opens a prompt for the user to select a project to open.private void
parseCsvFileForPerformerDeviceIDs
(File inputFile) Imports a configuration csv file and applies the config to an open project.private void
Begin playing audio in sync with the drill playbackprivate void
Rebuilds the map of set labels to set start counts that is used in ScrubBarGUI.private void
Removes the flow viewer from the main content panel and restores the run menu to be used againprivate void
Prompts the user for information and then starts a web server using this informationprivate void
Prompts the user for a location to save the current project.private void
saveProject
(File path, ArrayList<File> archivePaths) Save the current project to a .emrick file.private void
Attempts to save the project to a file.private void
setupEffectView
(ArrayList<Integer> ids) Initializes the effect panel and its dependenciesprivate void
Display an error message to the user that indicates an RF Trigger has not been placed yet.private void
Stops the currently running web server, restores the run menu to be used again, and cleans the filesystem of any files created by the web serverprivate long
timeAfterEffect
(int index, Effect e, ArrayList<Effect> effects, Long[] timesMS) Calculates the time between the end of the current effect and the start of the next effect/RF Trigger.private long
timeBeforeEffect
(int index, Effect e, ArrayList<Effect> effects, Long[] timesMS) Calculates the time between the end of the previous effect/RF Trigger and the start of the current effect.private void
updateEffectViewPanel
(EffectList effectType) Update the effect panel to display the currently selected effectprivate void
Create a create/delete button depending on whether there is RF trigger at current count.private void
Update the timeline panel to show data relevant to the currently selected performers.private void
writeSysMsg
(String msg) Writes a system message in the top right of the screenMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
-
Field Details
-
FILE_MENU_CONCATENATE
- See Also:
-
FILE_MENU_NEW_PROJECT
- See Also:
-
FILE_MENU_OPEN_PROJECT
- See Also:
-
FILE_MENU_SAVE
- See Also:
-
FILE_MENU_SAVE_AS
- See Also:
-
frame
-
windowListener
-
mainContentPanel
-
footballField
-
footballFieldPanel
-
footballFieldBackground
-
ledConfigurationGUI
-
timelineGUI
-
effectGUI
-
groupsGUI
-
rfTriggerGUI
-
flowViewGUI
-
ledStripViewGUI
-
scrubBarGUI
-
scrubBarPanel
-
effectViewPanel
-
timelinePanel
-
sysMsg
-
clearSysMsg
-
gson
private final com.google.gson.Gson gson -
userHome
-
audioPlayers
-
currentAudioPlayer
-
canSeekAudio
private boolean canSeekAudio -
effectManager
-
currentEffect
-
copiedEffect
-
selectedEffectType
-
DEFAULT_FUNCTION
public final int DEFAULT_FUNCTION- See Also:
-
USE_DURATION
public final int USE_DURATION- See Also:
-
SET_TIMEOUT
public final int SET_TIMEOUT- See Also:
-
DO_DELAY
public final int DO_DELAY- See Also:
-
INSTANT_COLOR
public final int INSTANT_COLOR- See Also:
-
PROGRAMMING_MODE
public final int PROGRAMMING_MODE- See Also:
-
USE_COLORS
public final int USE_COLORS- See Also:
-
DIRECTION
public final int DIRECTION- See Also:
-
LIGHT_BOARD
public final int LIGHT_BOARD- See Also:
-
CONTINUOUS
public final int CONTINUOUS- See Also:
-
VERIFY
public final int VERIFY- See Also:
-
CHECK_LR
public final int CHECK_LR- See Also:
-
count2RFTrigger
-
timeManager
-
timeSync
-
useStartDelay
private boolean useStartDelay -
startDelay
private float startDelay -
playbackSpeed
private float playbackSpeed -
playbackTimer
-
currentMovement
public int currentMovement -
server
-
ssid
-
password
-
port
private int port -
currentID
private int currentID -
MAX_CONNECTIONS
private static int MAX_CONNECTIONS -
token
private int token -
verificationColor
-
noRequestTimer
-
requestIDs
-
runWebServer
-
runLightBoardWebServer
-
stopWebServer
-
programmingTracker
-
programmingProgressBar
-
lightBoardMode
private boolean lightBoardMode -
runShowItem
-
flowViewerItem
-
lightBoardFlowViewerItem
-
stopShowItem
-
isLightBoardMode
private boolean isLightBoardMode -
showIndividualView
-
archivePaths
-
emrickPath
-
csvFile
-
serialTransmitter
-
webServerFrame
JFrame webServerFrame
-
-
Constructor Details
-
MediaEditorGUI
Constructor for MediaEditorGUI- Parameters:
file
- - Used when starting the application via opening a file via an associated type. Otherwise, this can be left as an empty string.
-
-
Method Details
-
main
Main method of Emrick Designer.- Parameters:
args
- - Only used when opening the application via an associated file type rather than an executable
-
getPlaybackTimerTimeByCounts
private long getPlaybackTimerTimeByCounts()Calculates and returns the frame length in milliseconds- Returns:
- - Time in milliseconds the timer should wait between frames
-
createAndShowGUI
private void createAndShowGUI()Builds all major GUI elements and adds them to the main frame. This method should be called on startup and on project loading when another project is already loaded. -
deleteDirectory
Recursively empties and deletes the specified file/directory.- Parameters:
directoryToBeDeleted
- - File or directory that should be emptied and/or deleted- Returns:
- true - if the directory was deleted successfully. false - otherwise
-
getEffectOptionsButton
Initializes the Effect Options button and the effects popup menu and returns the Effect Options button.- Returns:
- JButton button that displays a popup menu with all the effect options when pressed
-
comPortPrompt
Used to get a Serial Transmitter object. If only 1 Emrick board of the desired type is connected, it will be found automatically. Otherwise, the user will be prompted with a menu to select the intended COM port- Parameters:
type
- The type of hardware that should be detected.- Returns:
- A SerialTransmitter object loaded with the specified COM port. If no COM ports are found, this method returns null.
-
removeFlowViewer
private void removeFlowViewer()Removes the flow viewer from the main content panel and restores the run menu to be used again -
stopServer
private void stopServer()Stops the currently running web server, restores the run menu to be used again, and cleans the filesystem of any files created by the web server -
runServer
Prompts the user for information and then starts a web server using this information- Parameters:
path
- A path to the .pkt file whose contents should be served by the web server.lightBoard
- true - Run the web server to serve light board packets false - Run the web server to serve show packets
-
loadProject
Loads a new .emrick file to the viewport to be edited.- Parameters:
path
- Path pointing to the intended .emrick file
-
concatenateProject
-
getMovementIndex
private int getMovementIndex() -
buildScrubBarPanel
private void buildScrubBarPanel()Loads the ScrubBarGUI Panel if it has not been created, or refreshes it if it already exists. -
onMultiSelect
- Specified by:
onMultiSelect
in interfaceSelectListener
-
onGroupSelection
- Specified by:
onGroupSelection
in interfaceSelectListener
-
ctrlGroupSelection
- Specified by:
ctrlGroupSelection
in interfaceSelectListener
-
onSaveGroup
- Specified by:
onSaveGroup
in interfaceSelectListener
-
onUpdateGroup
public void onUpdateGroup()- Specified by:
onUpdateGroup
in interfaceSelectListener
-
exportCsvFileForPerformerDeviceIDs
Builds and exports a csv file containing configuration data for led strips and performersFormat:
The first line contains headers and the last element contains the expected number of led strips.
A new performer starts on a new line where its label (Ex. "R31") is written as the first element
Below each performer label will be a list of all of this performer's led strips, each line beginning with an empty element. The led strips lines will contain their label, id, and a set of configuration data.
Ex. ",226,R31L,50,12,6,-6,-6"
- Parameters:
selectedFile
- The desired file location to write the csv file.
-
applyDefaultLEDConfiguration
private void applyDefaultLEDConfiguration()Applies a default led configuration to all performers -
parseCsvFileForPerformerDeviceIDs
Imports a configuration csv file and applies the config to an open project.- Parameters:
inputFile
- csv configuration file
-
openProjectDialog
private void openProjectDialog()Opens a prompt for the user to select a project to open. -
concatenateDialog
private void concatenateDialog() -
saveProjectDialog
private void saveProjectDialog()Attempts to save the project to a file. If the currently open project is a new project, the user will be prompted to specify a save location before the project is saved. -
saveAsProjectDialog
private void saveAsProjectDialog()Prompts the user for a location to save the current project. -
onBeginImport
public void onBeginImport()- Specified by:
onBeginImport
in interfaceImportListener
-
onImport
public void onImport()- Specified by:
onImport
in interfaceImportListener
-
onFileSelect
- Specified by:
onFileSelect
in interfaceImportListener
-
onAudioImport
- Specified by:
onAudioImport
in interfaceImportListener
-
onConcatAudioImport
- Specified by:
onConcatAudioImport
in interfaceImportListener
-
onDrillImport
- Specified by:
onDrillImport
in interfaceImportListener
-
rebuildPageTabCounts
private void rebuildPageTabCounts()Rebuilds the map of set labels to set start counts that is used in ScrubBarGUI. -
onSync
- Specified by:
onSync
in interfaceSyncListener
-
setupEffectView
Initializes the effect panel and its dependencies- Parameters:
ids
- List of effect ids
-
onPlay
public boolean onPlay()- Specified by:
onPlay
in interfaceScrubBarListener
-
onPause
public boolean onPause()- Specified by:
onPause
in interfaceScrubBarListener
-
onScrub
public long onScrub()- Specified by:
onScrub
in interfaceScrubBarListener
-
onTimeChange
public void onTimeChange(long time) - Specified by:
onTimeChange
in interfaceScrubBarListener
-
onSetChange
public void onSetChange(int setIndex) - Specified by:
onSetChange
in interfaceScrubBarListener
-
updateRFTriggerButton
private void updateRFTriggerButton()Create a create/delete button depending on whether there is RF trigger at current count. -
playAudioFromCorrectPosition
private void playAudioFromCorrectPosition()Begin playing audio in sync with the drill playback -
getPrevAudioPlayerDurations
public long getPrevAudioPlayerDurations(int index) -
onSpeedChange
public void onSpeedChange(float playbackSpeed) - Specified by:
onSpeedChange
in interfaceScrubBarListener
-
onUserLoggedIn
- Specified by:
onUserLoggedIn
in interfaceUserAuthListener
-
showEffectBeforeFirstTriggerError
private void showEffectBeforeFirstTriggerError()Display an error message to the user that indicates an RF Trigger has not been placed yet. -
onCreateEffect
- Specified by:
onCreateEffect
in interfaceEffectListener
-
onUpdateEffect
- Specified by:
onUpdateEffect
in interfaceEffectListener
-
onDeleteEffect
- Specified by:
onDeleteEffect
in interfaceEffectListener
-
onUpdateEffectPanel
- Specified by:
onUpdateEffectPanel
in interfaceEffectListener
-
onChangeSelectionMode
- Specified by:
onChangeSelectionMode
in interfaceEffectListener
-
onInnerSelectionRequired
- Specified by:
onInnerSelectionRequired
in interfaceEffectListener
-
onSelectionRequired
- Specified by:
onSelectionRequired
in interfaceEffectListener
-
onTimeRequired
- Specified by:
onTimeRequired
in interfaceEffectListener
-
onPerformerSelect
public void onPerformerSelect()- Specified by:
onPerformerSelect
in interfaceFootballFieldListener
-
onPerformerDeselect
public void onPerformerDeselect()- Specified by:
onPerformerDeselect
in interfaceFootballFieldListener
-
onCreateRFTrigger
- Specified by:
onCreateRFTrigger
in interfaceRFTriggerListener
-
onUpdateRFTrigger
- Specified by:
onUpdateRFTrigger
in interfaceRFTriggerListener
-
onDeleteRFTrigger
public void onDeleteRFTrigger(int count) - Specified by:
onDeleteRFTrigger
in interfaceRFTriggerListener
-
onPressRFTrigger
- Specified by:
onPressRFTrigger
in interfaceRFTriggerListener
-
onResizeBackground
public void onResizeBackground()- Specified by:
onResizeBackground
in interfaceFootballFieldListener
-
getFrameRate
public double getFrameRate()- Specified by:
getFrameRate
in interfaceFootballFieldListener
-
isPlaying
public boolean isPlaying()- Specified by:
isPlaying
in interfaceFootballFieldListener
-
onPressEffect
- Specified by:
onPressEffect
in interfaceEffectListener
-
updateEffectViewPanel
Update the effect panel to display the currently selected effect- Parameters:
effectType
- - The type of effect that is currently selected.
-
updateTimelinePanel
private void updateTimelinePanel()Update the timeline panel to show data relevant to the currently selected performers. -
saveProject
Save the current project to a .emrick file.- Parameters:
path
- The file location to save the project.archivePaths
- The locations of the .3dz files in user files when the project is loaded.
-
timeBeforeEffect
Calculates the time between the end of the previous effect/RF Trigger and the start of the current effect.- Parameters:
index
- Current RF Trigger indexe
- Effect to find the time beforeeffects
- List of effects on the relevant led striptimesMS
- A list of times in milliseconds that RF Triggers occur- Returns:
- The time in milliseconds between the current effect and the previous effect/RF Trigger.
-
timeAfterEffect
Calculates the time between the end of the current effect and the start of the next effect/RF Trigger.- Parameters:
index
- Current RF Trigger indexe
- Effect to find the time beforeeffects
- List of effects on the relevant led striptimesMS
- A list of times in milliseconds that RF Triggers occur- Returns:
- The time in milliseconds between the current effect and the next effect/RF Trigger.
-
getEffectTriggerIndex
Calculates the index of the RF Trigger immediately before the relevant effect.- Parameters:
e
- The relevant effect.timesMS
- A list of times in milliseconds that RF Triggers occur- Returns:
- The index of the RF Trigger immediately before the relevant effect.
-
exportPackets
Multithreaded export of firmware-readable packet data to a .pkt file.- Parameters:
path
- Location to write .pkt file.
-
writeSysMsg
Writes a system message in the top right of the screen- Parameters:
msg
- Message to be written
-
onRFSignal
public void onRFSignal(int i) - Specified by:
onRFSignal
in interfaceRFSignalListener
-
onRequestComplete
public void onRequestComplete(int id) - Specified by:
onRequestComplete
in interfaceRequestCompleteListener
-
onExitConfig
public void onExitConfig()- Specified by:
onExitConfig
in interfaceLEDConfigListener
-
onNewFileSelect
- Specified by:
onNewFileSelect
in interfaceReplaceFilesListener
-
getAudioPlayers
Get audio player- Returns:
- AudioPlayer object
-