use of javax.swing.filechooser.FileSystemView in project processing by processing.
the class MovieMaker method createMovie.
private void createMovie(final File movieFile) {
createMovieButton.setEnabled(false);
// ---------------------------------
// Check input
// ---------------------------------
final File soundFile = soundFileField.getText().trim().length() == 0 ? null : new File(soundFileField.getText().trim());
final File imageFolder = imageFolderField.getText().trim().length() == 0 ? null : new File(imageFolderField.getText().trim());
//final String streaming = prefs.get("movie.streaming", "fastStartCompressed");
final String streaming = "fastStartCompressed";
if (soundFile == null && imageFolder == null) {
JOptionPane.showMessageDialog(this, Language.text("movie_maker.error.need_input"));
return;
}
final double fps;
try {
width = Integer.parseInt(widthField.getText());
height = Integer.parseInt(heightField.getText());
fps = Double.parseDouble(fpsField.getText());
} catch (Throwable t) {
JOptionPane.showMessageDialog(this, Language.text("movie_maker.error.badnumbers"));
return;
}
if (width < 1 || height < 1 || fps < 1) {
JOptionPane.showMessageDialog(this, Language.text("movie_maker.error.badnumbers"));
return;
}
final QuickTimeWriter.VideoFormat videoFormat;
switch(compressionBox.getSelectedIndex()) {
// break;
case //1:
0:
videoFormat = QuickTimeWriter.VideoFormat.RLE;
break;
case //2:
1:
videoFormat = QuickTimeWriter.VideoFormat.JPG;
break;
//3:
case 2:
default:
videoFormat = QuickTimeWriter.VideoFormat.PNG;
break;
}
// ---------------------------------
// Update Preferences
// ---------------------------------
prefs.put("movie.imageFolder", imageFolderField.getText());
prefs.put("movie.soundFile", soundFileField.getText());
prefs.putInt("movie.width", width);
prefs.putInt("movie.height", height);
prefs.putDouble("movie.fps", fps);
prefs.putInt("movie.compression", compressionBox.getSelectedIndex());
prefs.putBoolean("movie.originalSize", originalSizeCheckBox.isSelected());
final boolean originalSize = originalSizeCheckBox.isSelected();
// ---------------------------------
// Create the QuickTime movie
// ---------------------------------
new SwingWorker<Throwable, Object>() {
@Override
protected Throwable doInBackground() {
try {
// Read image files
File[] imgFiles = null;
if (imageFolder != null) {
imgFiles = imageFolder.listFiles(new FileFilter() {
FileSystemView fsv = FileSystemView.getFileSystemView();
public boolean accept(File f) {
return f.isFile() && !fsv.isHiddenFile(f) && !f.getName().equals("Thumbs.db");
}
});
if (imgFiles == null || imgFiles.length == 0) {
return new RuntimeException(Language.text("movie_maker.error.no_images_found"));
}
Arrays.sort(imgFiles);
}
// Get the width and height if we're preserving size.
if (originalSize) {
Dimension d = findSize(imgFiles);
if (d == null) {
// No images at all? No video then.
throw new RuntimeException(Language.text("movie_maker.error.no_images_found"));
}
width = d.width;
height = d.height;
}
// Delete movie file if it already exists.
if (movieFile.exists()) {
movieFile.delete();
}
if (imageFolder != null && soundFile != null) {
writeVideoAndAudio(movieFile, imgFiles, soundFile, width, height, fps, videoFormat, /*passThrough,*/
streaming);
} else if (imageFolder != null) {
writeVideoOnlyVFR(movieFile, imgFiles, width, height, fps, videoFormat, /*passThrough,*/
streaming);
} else {
writeAudioOnly(movieFile, soundFile, streaming);
}
return null;
} catch (Throwable t) {
return t;
}
}
Dimension findSize(File[] imgFiles) {
for (int i = 0; i < imgFiles.length; i++) {
BufferedImage temp = readImage(imgFiles[i]);
if (temp != null) {
return new Dimension(temp.getWidth(), temp.getHeight());
} else {
// Nullify bad Files so we don't get errors twice.
imgFiles[i] = null;
}
}
return null;
}
@Override
protected void done() {
Throwable t;
try {
t = get();
} catch (Exception ex) {
t = ex;
}
t.printStackTrace();
JOptionPane.showMessageDialog(MovieMaker.this, Language.text("movie_maker.error.movie_failed") + "\n" + (t.getMessage() == null ? t.toString() : t.getMessage()), Language.text("movie_maker.error.sorry"), JOptionPane.ERROR_MESSAGE);
createMovieButton.setEnabled(true);
}
}.execute();
}
use of javax.swing.filechooser.FileSystemView in project jdk8u_jdk by JetBrains.
the class bug6688203 method main.
public static void main(String[] args) {
// Create an instance of FileSystemView
FileSystemView.getFileSystemView();
int startCount = UIManager.getPropertyChangeListeners().length;
for (int i = 0; i < 100; i++) {
FileSystemView.getFileSystemView();
}
if (startCount != UIManager.getPropertyChangeListeners().length) {
throw new RuntimeException("New listeners were added into UIManager");
}
FileSystemView fileSystemView = FileSystemView.getFileSystemView();
File file = new File("Some file");
for (UIManager.LookAndFeelInfo lafInfo : UIManager.getInstalledLookAndFeels()) {
try {
UIManager.setLookAndFeel(lafInfo.getClassName());
} catch (Exception e) {
// Ignore such errors
System.out.println("Cannot set LAF " + lafInfo.getName());
continue;
}
fileSystemView.getSystemDisplayName(file);
try {
Field field = FileSystemView.class.getDeclaredField("useSystemExtensionHiding");
field.setAccessible(true);
Boolean value = field.getBoolean(fileSystemView);
if (value != UIManager.getDefaults().getBoolean("FileChooser.useSystemExtensionHiding")) {
throw new RuntimeException("Invalid cached value of the FileSystemView.useSystemExtensionHiding field");
}
} catch (Exception e) {
throw new RuntimeException("Cannot read the FileSystemView.useSystemExtensionHiding field", e);
}
}
}
use of javax.swing.filechooser.FileSystemView in project Gargoyle by callakrsos.
the class FxUtil method createImageIconView.
/**
* 파일로부터 이미지를 그리기 위한 뷰를 반환한다.
*
* @Date 2015. 10. 14.
* @param file
* @return
* @User KYJ
*/
public static ImageView createImageIconView(File file) {
Image fxImage = null;
if (file.exists()) {
FileSystemView fileSystemView = FileSystemView.getFileSystemView();
Icon icon = fileSystemView.getSystemIcon(file);
BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(null, bufferedImage.getGraphics(), 0, 0);
fxImage = SwingFXUtils.toFXImage(bufferedImage, null);
} else {
return new ImageView();
}
return new ImageView(fxImage);
}
use of javax.swing.filechooser.FileSystemView in project SKMCLauncher by SKCraft.
the class LauncherStub method getFileChooseDefaultDir.
private static File getFileChooseDefaultDir() {
JFileChooser chooser = new JFileChooser();
FileSystemView fsv = chooser.getFileSystemView();
return fsv.getDefaultDirectory();
}
use of javax.swing.filechooser.FileSystemView in project processing by processing.
the class PApplet method desktopFile.
/** Not a supported function. For testing use only. */
public static File desktopFile(String what) {
if (desktopFolder == null) {
// Should work on Linux and OS X (on OS X, even with the localized version).
desktopFolder = new File(System.getProperty("user.home"), "Desktop");
if (!desktopFolder.exists()) {
if (platform == WINDOWS) {
FileSystemView filesys = FileSystemView.getFileSystemView();
desktopFolder = filesys.getHomeDirectory();
} else {
throw new UnsupportedOperationException("Could not find a suitable desktop foldder");
}
}
}
return new File(desktopFolder, what);
}
Aggregations