Skip to content

Commit

Permalink
Allow specifying delays for capturing and animated GIFs in 1/10-th of
Browse files Browse the repository at this point in the history
seconds instead of whole seconds.
  • Loading branch information
mvmn committed Sep 18, 2013
1 parent 43ac114 commit 55cd74a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/x/mvmn/jscrcap/gui/swing/ControlWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class ControlWindow extends JFrame implements WindowListener {

private static final long serialVersionUID = -2200911929118097957L;

public static final int MAX_DELAY_VALUE = 6000;

private final JButton btnToggleViewCaptureRect = new JButton("Show capture rect");
private final JButton btnResetCaptureRect = new JButton("Reset capture rect");
private final CaptureRectFrame captureRectFrame = new CaptureRectFrame();
Expand All @@ -58,7 +60,7 @@ public class ControlWindow extends JFrame implements WindowListener {
private final JButton btnSaveOne = new JButton("Save image");
private final JButton btnExport = new JButton("Export animated GIF");
private final JSlider sliderOpacity = new JSlider(JSlider.HORIZONTAL, 0, 100, 55);
private final JSlider sliderDelay = new JSlider(JSlider.HORIZONTAL, 1, 600, 5);
private final JSlider sliderDelay = new JSlider(JSlider.HORIZONTAL, 1, MAX_DELAY_VALUE, 10);
private final JTextField fldDelay = new JTextField("5");
private final JCheckBox cbLoopGif = new JCheckBox("Loop GIF");
private final JComboBox<String> cbxImageFormat;
Expand Down Expand Up @@ -185,8 +187,8 @@ public void keyTyped(KeyEvent e) {
if (validIntVal < 0) {
validIntVal = -validIntVal;
}
if (validIntVal > 600) {
validIntVal = 600;
if (validIntVal > MAX_DELAY_VALUE) {
validIntVal = MAX_DELAY_VALUE;
}
sliderDelay.setValue(validIntVal);
if (intVal != validIntVal) {
Expand Down Expand Up @@ -258,7 +260,6 @@ public void actionPerformed(ActionEvent actEvent) {
JOptionPane.OK_CANCEL_OPTION));
}
if (sizesOkToExport) {

JFileChooser fileChooser = new JFileChooser();
if (fileChooser.showSaveDialog(ControlWindow.this) == JFileChooser.APPROVE_OPTION) {
ExportProgressDialog progressDialog = new ExportProgressDialog(ControlWindow.this, images.length, fileChooser.getSelectedFile()
Expand All @@ -279,7 +280,7 @@ public void actionPerformed(ActionEvent actEvent) {

JPanel controlsForDelayPanel = new JPanel(new BorderLayout());
controlsForDelayPanel.add(sliderDelay, BorderLayout.CENTER);
controlsForDelayPanel.add(new JLabel("Delay (seconds)"), BorderLayout.WEST);
controlsForDelayPanel.add(new JLabel("Delay (1/10 of second)"), BorderLayout.WEST);
controlsForDelayPanel.add(fldDelay, BorderLayout.EAST);
fldDelay.setPreferredSize(new Dimension(fldDelay.getFont().getSize() * 6, fldDelay.getPreferredSize().height));

Expand Down
8 changes: 4 additions & 4 deletions src/x/mvmn/jscrcap/util/GifExportThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ public class GifExportThread extends Thread {

private final CapturedImage[] captures;
private final Component parentComponent;
private final int delayBetweenFramesInSeconds;
private final int delayBetweenFramesInTenthOfSeconds;
private final File outputFile;
private final boolean loopContinuously;
private final ExportProgressDialog progressDialog;
private volatile boolean stopRequested = false;

public GifExportThread(final Component parentComponent, final ExportProgressDialog progressDialog, final CapturedImage[] captures,
final int delayBetweenFramesInSeconds, final File outputFile, final boolean loopContinuously) {
final int delayBetweenFramesInTenthOfSeconds, final File outputFile, final boolean loopContinuously) {
this.progressDialog = progressDialog;
this.captures = captures;
this.parentComponent = parentComponent;
this.delayBetweenFramesInSeconds = delayBetweenFramesInSeconds;
this.delayBetweenFramesInTenthOfSeconds = delayBetweenFramesInTenthOfSeconds;
this.outputFile = outputFile;
this.loopContinuously = loopContinuously;
progressDialog.setExportThread(this);
Expand Down Expand Up @@ -75,7 +75,7 @@ public void run() {
graphicsControlExtensionNode.setAttribute("disposalMethod", "none");
graphicsControlExtensionNode.setAttribute("userInputFlag", "FALSE");
graphicsControlExtensionNode.setAttribute("transparentColorFlag", "FALSE");
graphicsControlExtensionNode.setAttribute("delayTime", Integer.toString(delayBetweenFramesInSeconds * 100));
graphicsControlExtensionNode.setAttribute("delayTime", Integer.toString(delayBetweenFramesInTenthOfSeconds * 10));
graphicsControlExtensionNode.setAttribute("transparentColorIndex", "0");

IIOMetadataNode commentsNode = getNode(root, "CommentExtensions");
Expand Down
2 changes: 1 addition & 1 deletion src/x/mvmn/jscrcap/util/SequenceCaptureThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SequenceCaptureThread extends Thread {
private final CapturesTableModel capturesTableModel;

public SequenceCaptureThread(final CapturesTableModel capturesTableModel, final Rectangle captureArea, final int captureInterval) {
this.captureInterval = captureInterval * 1000;
this.captureInterval = captureInterval * 100;
this.capturesTableModel = capturesTableModel;
this.captureArea = captureArea;
}
Expand Down

0 comments on commit 55cd74a

Please sign in to comment.