Browse Source

Minor changes

Merge
master
Sogomn 9 years ago
parent
commit
9c5b83917e
  1. 30
      Ratty/src/de/sogomn/rat/Ratty.java
  2. 4
      Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java
  3. 20
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

30
Ratty/src/de/sogomn/rat/Ratty.java

@ -1,11 +1,17 @@
package de.sogomn.rat;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import de.sogomn.engine.util.FileUtils;
import de.sogomn.rat.server.ActiveServer;
@ -38,6 +44,23 @@ public final class Ratty {
//...
}
private static void setLookAndFeel() {
final NimbusLookAndFeel nimbus = new NimbusLookAndFeel();
final UIDefaults defaults = nimbus.getDefaults();
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
defaults.put("nimbusBase", Color.LIGHT_GRAY);
defaults.put("cotrol", Color.LIGHT_GRAY);
try {
UIManager.setLookAndFeel(nimbus);
} catch (final Exception ex) {
ex.printStackTrace();
}
}
private static void readConnectionData() throws ArrayIndexOutOfBoundsException, NumberFormatException {
final String[] lines = FileUtils.readInternalLines(CONNECTION_DATA_FILE_NAME);
final String addressString = lines[0].trim();
@ -110,6 +133,7 @@ public final class Ratty {
}
public static void main(final String[] args) {
setLookAndFeel();
readConnectionData();
if (DEBUG) {
@ -131,12 +155,10 @@ public final class Ratty {
} else {
final int port = getPortInput();
if (port == -1) {
return;
}
if (port != -1) {
startServer(port);
}
}
}
}

4
Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java

@ -34,8 +34,8 @@ public final class DisplayPanel extends AbstractListenerContainer<IGuiController
//...
}
private Screen createScreen(final int width, final int height) {
final Screen screen = new Screen(width, height);
private Screen createScreen(final int screenWidth, final int screenHeight) {
final Screen screen = new Screen(screenWidth, screenHeight);
screen.setResizeBehavior(ResizeBehavior.KEEP_ASPECT_RATIO);
screen.setTitle(title);

20
Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

@ -1,5 +1,7 @@
package de.sogomn.rat.server.gui;
import java.awt.image.BufferedImage;
import de.sogomn.rat.ActiveConnection;
import de.sogomn.rat.packet.ClipboardPacket;
import de.sogomn.rat.packet.CommandPacket;
@ -30,6 +32,12 @@ public final class RattyGuiController extends AbstractRattyController implements
* ==================================================
*/
private void showScreenshot(final ServerClient client, final ScreenshotPacket packet) {
final BufferedImage image = packet.getImage();
client.displayPanel.showImage(image);
}
private PopupPacket createPopupPacket() {
final String input = gui.getInput();
@ -70,7 +78,7 @@ public final class RattyGuiController extends AbstractRattyController implements
//...
}
private IPacket getPacket(final String command, final ServerClient client) {
private IPacket getPacket(final ServerClient client, final String command) {
IPacket packet = null;
if (command == RattyGui.FREE) {
@ -94,6 +102,14 @@ public final class RattyGuiController extends AbstractRattyController implements
@Override
protected boolean handlePacket(final ServerClient client, final IPacket packet) {
final Class<? extends IPacket> clazz = packet.getClass();
if (clazz == ScreenshotPacket.class) {
final ScreenshotPacket screenshot = (ScreenshotPacket)packet;
showScreenshot(client, screenshot);
}
return false;
}
@ -129,7 +145,7 @@ public final class RattyGuiController extends AbstractRattyController implements
@Override
public void userInput(final String command) {
final ServerClient client = gui.getLastServerClientClicked();
final IPacket packet = getPacket(command, client);
final IPacket packet = getPacket(client, command);
handleCommand(client, command);

Loading…
Cancel
Save