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

Main class of Emrick Designer. Contains all GUI elements and logic for light show design and Emrick board interaction
See Also:
  • Field Details

  • Constructor Details

    • MediaEditorGUI

      public MediaEditorGUI(String file)
      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

      public static void main(String[] args)
      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

      private boolean deleteDirectory(File directoryToBeDeleted)
      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

      private JButton 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

      public SerialTransmitter comPortPrompt(String type)
      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

      private void runServer(String path, boolean lightBoard)
      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

      private void loadProject(File path)
      Loads a new .emrick file to the viewport to be edited.
      Parameters:
      path - Path pointing to the intended .emrick file
    • concatenateProject

      private void concatenateProject(File path)
    • 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

      public void onMultiSelect(HashSet<Integer> labels, HashSet<String> symbols)
      Specified by:
      onMultiSelect in interface SelectListener
    • onGroupSelection

      public void onGroupSelection(LEDStrip[] ledStrips)
      Specified by:
      onGroupSelection in interface SelectListener
    • ctrlGroupSelection

      public void ctrlGroupSelection(LEDStrip[] ledStrips)
      Specified by:
      ctrlGroupSelection in interface SelectListener
    • onSaveGroup

      public LEDStrip[] onSaveGroup()
      Specified by:
      onSaveGroup in interface SelectListener
    • onUpdateGroup

      public void onUpdateGroup()
      Specified by:
      onUpdateGroup in interface SelectListener
    • exportCsvFileForPerformerDeviceIDs

      private void exportCsvFileForPerformerDeviceIDs(File selectedFile)
      Builds and exports a csv file containing configuration data for led strips and performers

      Format:

      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

      private void parseCsvFileForPerformerDeviceIDs(File inputFile)
      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 interface ImportListener
    • onImport

      public void onImport()
      Specified by:
      onImport in interface ImportListener
    • onFileSelect

      public void onFileSelect(ArrayList<File> archivePaths, File csvFile)
      Specified by:
      onFileSelect in interface ImportListener
    • onAudioImport

      public void onAudioImport(ArrayList<File> audioFiles)
      Specified by:
      onAudioImport in interface ImportListener
    • onConcatAudioImport

      public void onConcatAudioImport(ArrayList<File> audioFiles)
      Specified by:
      onConcatAudioImport in interface ImportListener
    • onDrillImport

      public void onDrillImport(String drill)
      Specified by:
      onDrillImport in interface ImportListener
    • rebuildPageTabCounts

      private void rebuildPageTabCounts()
      Rebuilds the map of set labels to set start counts that is used in ScrubBarGUI.
    • onSync

      public void onSync(ArrayList<SyncTimeGUI.Pair> times, float startDelay)
      Specified by:
      onSync in interface SyncListener
    • setupEffectView

      private void setupEffectView(ArrayList<Integer> ids)
      Initializes the effect panel and its dependencies
      Parameters:
      ids - List of effect ids
    • onPlay

      public boolean onPlay()
      Specified by:
      onPlay in interface ScrubBarListener
    • onPause

      public boolean onPause()
      Specified by:
      onPause in interface ScrubBarListener
    • onScrub

      public long onScrub()
      Specified by:
      onScrub in interface ScrubBarListener
    • onTimeChange

      public void onTimeChange(long time)
      Specified by:
      onTimeChange in interface ScrubBarListener
    • onSetChange

      public void onSetChange(int setIndex)
      Specified by:
      onSetChange in interface ScrubBarListener
    • 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 interface ScrubBarListener
    • onUserLoggedIn

      public void onUserLoggedIn(String username)
      Specified by:
      onUserLoggedIn in interface UserAuthListener
    • showEffectBeforeFirstTriggerError

      private void showEffectBeforeFirstTriggerError()
      Display an error message to the user that indicates an RF Trigger has not been placed yet.
    • onCreateEffect

      public void onCreateEffect(Effect effect)
      Specified by:
      onCreateEffect in interface EffectListener
    • onUpdateEffect

      public void onUpdateEffect(Effect oldEffect, Effect newEffect)
      Specified by:
      onUpdateEffect in interface EffectListener
    • onDeleteEffect

      public void onDeleteEffect(Effect effect)
      Specified by:
      onDeleteEffect in interface EffectListener
    • onUpdateEffectPanel

      public void onUpdateEffectPanel(Effect effect, boolean isNew, int index)
      Specified by:
      onUpdateEffectPanel in interface EffectListener
    • onChangeSelectionMode

      public void onChangeSelectionMode(boolean isInnerSelect, HashSet<LEDStrip> strips)
      Specified by:
      onChangeSelectionMode in interface EffectListener
    • onInnerSelectionRequired

      public HashSet<LEDStrip> onInnerSelectionRequired()
      Specified by:
      onInnerSelectionRequired in interface EffectListener
    • onSelectionRequired

      public HashSet<LEDStrip> onSelectionRequired()
      Specified by:
      onSelectionRequired in interface EffectListener
    • onTimeRequired

      public TimeManager onTimeRequired()
      Specified by:
      onTimeRequired in interface EffectListener
    • onPerformerSelect

      public void onPerformerSelect()
      Specified by:
      onPerformerSelect in interface FootballFieldListener
    • onPerformerDeselect

      public void onPerformerDeselect()
      Specified by:
      onPerformerDeselect in interface FootballFieldListener
    • onCreateRFTrigger

      public void onCreateRFTrigger(RFTrigger rfTrigger)
      Specified by:
      onCreateRFTrigger in interface RFTriggerListener
    • onUpdateRFTrigger

      public void onUpdateRFTrigger(RFTrigger rfTrigger, int count)
      Specified by:
      onUpdateRFTrigger in interface RFTriggerListener
    • onDeleteRFTrigger

      public void onDeleteRFTrigger(int count)
      Specified by:
      onDeleteRFTrigger in interface RFTriggerListener
    • onPressRFTrigger

      public void onPressRFTrigger(RFTrigger rfTrigger)
      Specified by:
      onPressRFTrigger in interface RFTriggerListener
    • onResizeBackground

      public void onResizeBackground()
      Specified by:
      onResizeBackground in interface FootballFieldListener
    • getFrameRate

      public double getFrameRate()
      Specified by:
      getFrameRate in interface FootballFieldListener
    • isPlaying

      public boolean isPlaying()
      Specified by:
      isPlaying in interface FootballFieldListener
    • onPressEffect

      public void onPressEffect(Effect effect)
      Specified by:
      onPressEffect in interface EffectListener
    • updateEffectViewPanel

      private void updateEffectViewPanel(EffectList effectType)
      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

      private void saveProject(File path, ArrayList<File> archivePaths)
      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

      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.
      Parameters:
      index - Current RF Trigger index
      e - Effect to find the time before
      effects - List of effects on the relevant led strip
      timesMS - 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

      private 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.
      Parameters:
      index - Current RF Trigger index
      e - Effect to find the time before
      effects - List of effects on the relevant led strip
      timesMS - 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

      private int getEffectTriggerIndex(Effect e, Long[] timesMS)
      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

      private void exportPackets(File path)
      Multithreaded export of firmware-readable packet data to a .pkt file.
      Parameters:
      path - Location to write .pkt file.
    • writeSysMsg

      private void writeSysMsg(String msg)
      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 interface RFSignalListener
    • onRequestComplete

      public void onRequestComplete(int id)
      Specified by:
      onRequestComplete in interface RequestCompleteListener
    • onExitConfig

      public void onExitConfig()
      Specified by:
      onExitConfig in interface LEDConfigListener
    • onNewFileSelect

      public boolean onNewFileSelect(File drill, File archive)
      Specified by:
      onNewFileSelect in interface ReplaceFilesListener
    • getAudioPlayers

      public ArrayList<AudioPlayer> getAudioPlayers()
      Get audio player
      Returns:
      AudioPlayer object