Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
hvvka committed Jun 20, 2018
1 parent b538ee9 commit a85e7f9
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 27 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# barely-total-commander

The graphic files browser that enables navigation on files system.

In a separate thread image previews are loaded and stored in **weak references**.

There are also plugins implementing simple image transformation and loaded in runtime (ClassLoader):

- no plugin
![no_plugin](img/no_plugin.png)

- increase saturation
![increased_saturation](img/increased_saturation.png)

- gray scale
![gray_scale](img/gray_scale.png)

- black & white
![black_white](img/black_white.png)

- negative
![negative](img/negative.png)
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ task fatJar(type: Jar) {
'Implementation-Version': version,
'Main-Class': 'com.hania.Runner'
}
baseName = project.name + '-all'
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
Binary file added img/black_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/gray_scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/increased_saturation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/negative.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/no_plugin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/java/com/hania/FileRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private ConcurrentMap.Entry<String, WeakReference<CachedImage>> getRecord(
}
}

public JList<Object> getList() {
JList<Object> getList() {
return list;
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/hania/ImageFileChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/
public class ImageFileChooser extends JFileChooser {

//todo directory from resources
private static final String DIRECTORY_PATH = "/Users/hg/Desktop/images";
private static final String DIRECTORY_PATH = "/";

public ImageFileChooser() {
super(DIRECTORY_PATH);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/hania/PluginGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* @author <a href="mailto:[email protected]">Hanna Grodzicka</a>
*/
public class PluginGenerator {
class PluginGenerator {

private static final Logger LOG = LoggerFactory.getLogger(PluginGenerator.class);

Expand All @@ -29,12 +29,12 @@ public class PluginGenerator {
this.pluginClassLoader = new PluginClassLoader();
}

public Object getPlugin(PluginType pluginType) {
Object getPlugin(PluginType pluginType) {
loadPlugin(pluginType);
return pluginObject;
}

public BufferedImage invokeConvertIconMethod(Object pluginObject, String path) {
BufferedImage invokeConvertIconMethod(Object pluginObject, String path) {
Method[] methods = pluginObject.getClass().getMethods();
int argumentIndex = 0;
int numberOfArguments = methods[argumentIndex].getParameterCount();
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/com/hania/controller/MainFrameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ private void initListeners() {
addPluginListeners();
}

private void addChooseDirectoryListener() {
chooseDirectoryMenuItem.addActionListener(e -> {
imageFileChooser = new ImageFileChooser();
int returnVal = imageFileChooser.showOpenDialog(imageFileChooser);

if (returnVal == JFileChooser.APPROVE_OPTION) {
String path = imageFileChooser.getSelectedFile().getAbsolutePath();
mainFrame.setTitle(path);
}
attachDirectory();
});
}

private void attachDirectory() {
SwingUtilities.invokeLater(() -> {
fileRecordLoader = new FileRecordLoader(imageFileChooser, PluginType.NO_PLUGIN);
refreshRecordList();
});
}

private void addPluginListeners() {
noPluginMenuItem.addActionListener(e -> attachPluginToAttachedDirectory(PluginType.NO_PLUGIN));
negativePluginMenuItem.addActionListener(e -> attachPluginToAttachedDirectory(PluginType.NEGATIVE));
Expand All @@ -62,13 +82,6 @@ private void attachPlugin(PluginType pluginType) {
refreshRecordList();
}

private void attachDirectory() {
SwingUtilities.invokeLater(() -> {
fileRecordLoader = new FileRecordLoader(imageFileChooser, PluginType.NO_PLUGIN);
refreshRecordList();
});
}

private void refreshRecordList() {
fileRecordList = fileRecordLoader.getFileRecordList();
contentPane.remove(scrollPane);
Expand All @@ -78,19 +91,6 @@ private void refreshRecordList() {
contentPane.repaint();
}

private void addChooseDirectoryListener() {
chooseDirectoryMenuItem.addActionListener(e -> {
imageFileChooser = new ImageFileChooser();
int returnVal = imageFileChooser.showOpenDialog(imageFileChooser);

if (returnVal == JFileChooser.APPROVE_OPTION) {
String path = imageFileChooser.getSelectedFile().getAbsolutePath();
mainFrame.setTitle(path);
}
attachDirectory();
});
}

private void initComponents() {
mainFrame.setVisible(true);
initContentPane();
Expand Down

0 comments on commit a85e7f9

Please sign in to comment.