mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-03 22:46:14 +00:00
Added javadoc to the gui elements
This commit is contained in:
@@ -36,6 +36,10 @@ import com.limelight.input.gamepad.GamepadMapping;
|
||||
import com.limelight.input.gamepad.GamepadMapping.Mapping;
|
||||
import com.limelight.settings.GamepadSettingsManager;
|
||||
|
||||
/**
|
||||
* A frame used to configure the gamepad mappings.
|
||||
* @author Diego Waxemberg
|
||||
*/
|
||||
public class GamepadConfigFrame extends JFrame {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -46,6 +50,10 @@ public class GamepadConfigFrame extends JFrame {
|
||||
private GamepadMapping config;
|
||||
private HashMap<Box, Mapping> componentMap;
|
||||
|
||||
/**
|
||||
* Constructs a new config frame. The frame is initially invisible and will <br>
|
||||
* be made visible after all components are built by calling <code>build()</code>
|
||||
*/
|
||||
public GamepadConfigFrame() {
|
||||
super("Gamepad Settings");
|
||||
System.out.println("Creating Settings Frame");
|
||||
@@ -56,6 +64,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds all components of the config frame and sets the frame visible.
|
||||
*/
|
||||
public void build() {
|
||||
componentMap = new HashMap<Box, Mapping>();
|
||||
|
||||
@@ -90,6 +101,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the box that holds the button and checkboxes
|
||||
*/
|
||||
private Box createComponentBox(Mapping mapping) {
|
||||
Box componentBox = Box.createHorizontalBox();
|
||||
|
||||
@@ -127,6 +141,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
}
|
||||
|
||||
//TODO: make createInvertListener() and createTriggerListener() one method. TOO MUCH COPY PASTA!
|
||||
/*
|
||||
* Creates the listener for the invert checkbox
|
||||
*/
|
||||
private ItemListener createInvertListener() {
|
||||
return new ItemListener() {
|
||||
@Override
|
||||
@@ -139,6 +156,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the listener for the trigger checkbox
|
||||
*/
|
||||
private ItemListener createTriggerListener() {
|
||||
return new ItemListener() {
|
||||
@Override
|
||||
@@ -152,6 +172,10 @@ public class GamepadConfigFrame extends JFrame {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Creates the listener for the window.
|
||||
* It will save configs on exit and restart controller threads
|
||||
*/
|
||||
private WindowListener createWindowListener() {
|
||||
return new WindowAdapter() {
|
||||
@Override
|
||||
@@ -171,6 +195,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the listener for the map button
|
||||
*/
|
||||
private ActionListener createMapListener() {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
@@ -189,6 +216,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Maps a gamepad component to the clicked component
|
||||
*/
|
||||
private void map(final Box toMap, final Gamepad pad) {
|
||||
if (mappingThread == null || !mappingThread.isAlive()) {
|
||||
|
||||
@@ -239,6 +269,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Waits until the user chooses what to map to the clicked component
|
||||
*/
|
||||
private Component waitForNewMapping(Gamepad pad) {
|
||||
Component newMapping = null;
|
||||
|
||||
@@ -266,6 +299,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
return newMapping;
|
||||
}
|
||||
|
||||
/*
|
||||
* Consumes any events left in the queue after the mapping has been made
|
||||
*/
|
||||
private void consumeEvents(final Gamepad pad) {
|
||||
// start a new thread to go through all of the remaining events
|
||||
Thread consumeEvents = new Thread(new Runnable() {
|
||||
@@ -287,6 +323,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
consumeEvents.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper method to get the box component that contains the given a mapping
|
||||
*/
|
||||
private Box getBox(Mapping mapping) {
|
||||
for (Entry<Box, Mapping> entry : componentMap.entrySet()) {
|
||||
if (entry.getValue() == mapping) {
|
||||
@@ -296,6 +335,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper method to get the button out of the box component
|
||||
*/
|
||||
private JButton getButton(Box componentBox) {
|
||||
for (java.awt.Component comp : componentBox.getComponents()) {
|
||||
if (comp instanceof JButton)
|
||||
@@ -304,6 +346,9 @@ public class GamepadConfigFrame extends JFrame {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes the current cofig to the configs on disk.
|
||||
*/
|
||||
private void updateConfigs() {
|
||||
GamepadSettingsManager.writeSettings(config);
|
||||
}
|
||||
|
||||
@@ -34,16 +34,28 @@ import com.limelight.nvstream.http.NvHTTP;
|
||||
import com.limelight.settings.PreferencesManager;
|
||||
import com.limelight.settings.PreferencesManager.Preferences;
|
||||
|
||||
/**
|
||||
* The main frame of Limelight that allows the user to specify the host and begin the stream.
|
||||
* @author Diego Waxemberg
|
||||
* <br>Cameron Gutman
|
||||
*/
|
||||
public class MainFrame {
|
||||
private JTextField hostField;
|
||||
private JButton pair;
|
||||
private JButton stream;
|
||||
private JFrame limeFrame;
|
||||
|
||||
/**
|
||||
* Gets the actual JFrame this class creates
|
||||
* @return the JFrame that is the main frame
|
||||
*/
|
||||
public JFrame getLimeFrame() {
|
||||
return limeFrame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds all components of the frame, including the frame itself and displays it to the user.
|
||||
*/
|
||||
public void build() {
|
||||
limeFrame = new JFrame("Limelight");
|
||||
limeFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
@@ -116,6 +128,9 @@ public class MainFrame {
|
||||
limeFrame.setVisible(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the menu bar for the user to go to preferences, mappings, etc.
|
||||
*/
|
||||
private JMenuBar createMenuBar() {
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
JMenu optionsMenu = new JMenu("Options");
|
||||
@@ -144,6 +159,9 @@ public class MainFrame {
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the listener for the stream button- starts the stream process
|
||||
*/
|
||||
private ActionListener createStreamButtonListener() {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
@@ -159,6 +177,9 @@ public class MainFrame {
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the listener for the pair button- requests a pairing with the specified host
|
||||
*/
|
||||
private ActionListener createPairButtonListener() {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
|
||||
@@ -16,12 +16,20 @@ import com.limelight.settings.PreferencesManager;
|
||||
import com.limelight.settings.PreferencesManager.Preferences;
|
||||
import com.limelight.settings.PreferencesManager.Preferences.Resolution;
|
||||
|
||||
/**
|
||||
* A frame that holds user preferences such as streaming resolution
|
||||
* @author Diego Waxemberg
|
||||
*/
|
||||
public class PreferencesFrame extends JFrame {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JComboBox resolution;
|
||||
private JCheckBox fullscreen;
|
||||
private Preferences prefs;
|
||||
|
||||
/**
|
||||
* Construcs a new frame and loads the saved preferences.
|
||||
* <br>The frame is not made visible until a call to <br>build()</br> is made.
|
||||
*/
|
||||
public PreferencesFrame() {
|
||||
super("Preferences");
|
||||
this.setSize(200, 100);
|
||||
@@ -30,6 +38,9 @@ public class PreferencesFrame extends JFrame {
|
||||
prefs = PreferencesManager.getPreferences();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs all components of the frame and makes the frame visible to the user.
|
||||
*/
|
||||
public void build() {
|
||||
|
||||
JPanel mainPanel = new JPanel();
|
||||
@@ -80,11 +91,17 @@ public class PreferencesFrame extends JFrame {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if the preferences have changed from the cached preferences.
|
||||
*/
|
||||
private boolean prefsChanged() {
|
||||
return (prefs.getResolution() != resolution.getSelectedItem()) ||
|
||||
(prefs.getFullscreen() != fullscreen.isSelected());
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes the preferences to the disk.
|
||||
*/
|
||||
private void writePreferences() {
|
||||
prefs.setFullscreen(fullscreen.isSelected());
|
||||
prefs.setResolution((Resolution)resolution.getSelectedItem());
|
||||
|
||||
@@ -28,6 +28,12 @@ import com.limelight.nvstream.NvConnection;
|
||||
import com.limelight.nvstream.NvConnectionListener.Stage;
|
||||
import com.limelight.nvstream.StreamConfiguration;
|
||||
|
||||
/**
|
||||
* The frame to which the video is rendered
|
||||
* @author Diego Waxemberg
|
||||
* <br>Cameron Gutman
|
||||
*
|
||||
*/
|
||||
public class StreamFrame extends JFrame {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -37,17 +43,29 @@ public class StreamFrame extends JFrame {
|
||||
private JLabel spinnerLabel;
|
||||
private Cursor noCursor;
|
||||
private NvConnection conn;
|
||||
|
||||
|
||||
/**
|
||||
* Frees the mouse ie. makes it visible and allowed to move outside the frame.
|
||||
*/
|
||||
public void freeMouse() {
|
||||
mouse.free();
|
||||
showCursor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Captures the mouse ie. makes it invisible and not allowed to leave the frame
|
||||
*/
|
||||
public void captureMouse() {
|
||||
mouse.capture();
|
||||
hideCursor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the components of this frame with the specified configurations.
|
||||
* @param conn the connection this frame belongs to
|
||||
* @param streamConfig the configurations for this frame
|
||||
* @param fullscreen if the frame should be made fullscreen
|
||||
*/
|
||||
public void build(NvConnection conn, StreamConfiguration streamConfig, boolean fullscreen) {
|
||||
this.conn = conn;
|
||||
|
||||
@@ -74,6 +92,9 @@ public class StreamFrame extends JFrame {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets the best display mode for the system and desired configuration
|
||||
*/
|
||||
private DisplayMode getBestDisplay(DisplayMode[] configs) {
|
||||
Arrays.sort(configs, new Comparator<DisplayMode>() {
|
||||
@Override
|
||||
@@ -99,6 +120,9 @@ public class StreamFrame extends JFrame {
|
||||
return bestConfig;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tries to make the frame fullscreen
|
||||
*/
|
||||
private void makeFullScreen() {
|
||||
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
||||
if (gd.isFullScreenSupported()) {
|
||||
@@ -125,7 +149,10 @@ public class StreamFrame extends JFrame {
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes the mouse cursor invisible
|
||||
*/
|
||||
public void hideCursor() {
|
||||
if (noCursor == null) {
|
||||
// Transparent 16 x 16 pixel cursor image.
|
||||
@@ -140,11 +167,19 @@ public class StreamFrame extends JFrame {
|
||||
this.getContentPane().setCursor(noCursor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the mouse cursor visible
|
||||
*/
|
||||
public void showCursor() {
|
||||
this.setCursor(Cursor.getDefaultCursor());
|
||||
this.getContentPane().setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a progress bar with a label underneath that tells the user what
|
||||
* loading stage the stream is at.
|
||||
* @param stage the currently loading stage
|
||||
*/
|
||||
public void showSpinner(Stage stage) {
|
||||
|
||||
if (spinner == null) {
|
||||
@@ -182,11 +217,17 @@ public class StreamFrame extends JFrame {
|
||||
spinnerLabel.setText("Starting " + stage.getName() + "...");
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the spinner and the label
|
||||
*/
|
||||
public void hideSpinner() {
|
||||
spinner.setVisible(false);
|
||||
spinnerLabel.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the stream and destroys the frame
|
||||
*/
|
||||
public void close() {
|
||||
dispose();
|
||||
conn.stop();
|
||||
|
||||
Reference in New Issue
Block a user