22 package com.realtime.crossfire.jxclient.commands;
27 import java.awt.Color;
28 import java.awt.Graphics;
29 import java.awt.image.BufferedImage;
31 import java.io.IOException;
32 import javax.imageio.ImageIO;
33 import org.jetbrains.annotations.NotNull;
62 super(
"screenshot", crossfireServerConnection);
79 public void execute(@NotNull
final String args) {
83 file = screenshotFiles.
getFile();
84 }
catch (
final IOException ex) {
85 drawInfoError(
"Failed to create screenshot filename: "+ex.getMessage());
89 file =
new File(args);
93 final Graphics g = image.createGraphics();
95 g.setColor(Color.black);
102 ImageIO.write(image,
"png", file);
103 }
catch (
final IOException ex) {
104 drawInfoError(
"Cannot write screenshot "+file.getPath()+
": "+ex.getMessage());
106 }
catch (
final NullPointerException ignored) {
111 drawInfo(
"Saved screenshot to "+file.getPath());
Abstract base class for Command implementations.
boolean allArguments()
Returns whether all remaining commands should be included as arguments.whether all remaining commands...
void drawInfoError(@NotNull final String message)
Displays an error message.
File getFile()
Returns a File for the next screenshot file.
final CrossfireServerConnection crossfireServerConnection
The connection instance.
final ScreenshotFiles screenshotFiles
The ScreenshotFiles instance for creating screenshot file names.
int getWindowHeight()
Returns the height of the client area.
Helper class for creating file names for screenshot files.
Renders a Gui instance into a Frame.
void redraw(@NotNull final Graphics g)
Paints the view into the given graphics instance.
Implements the "screenshot" command.
ScreenshotCommand(@NotNull final JXCWindowRenderer windowRenderer, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final ScreenshotFiles screenshotFiles)
Creates a new instance.
final JXCWindowRenderer windowRenderer
The renderer to use.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
int getWindowWidth()
Returns the width of the client area.
void drawInfo(@NotNull final String message)
Displays a regular output message.
void execute(@NotNull final String args)
Executes the command with the given arguments.the command arguments