Skip to content
This repository has been archived by the owner on Nov 20, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/1.3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
redwarp committed Sep 8, 2014
2 parents fdce14c + ead91f7 commit aadd332
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ As simple as drag and drop can get.

And here is the [changelog](https://github.com/redwarp/9-Patch-Resizer/wiki/Changelog)

Current version : *1.3.1*
Current version : *1.3.2*

You're using 9patch resizer for your apps ? Don't hesitate and leave me a message!

Expand Down
10 changes: 5 additions & 5 deletions launch4j_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>C:\Users\Redwarp\workspace\Resizer\Resizer_proguard.jar</jar>
<outfile>C:\Users\Redwarp\workspace\Resizer\Resizer_1.3.2.exe</outfile>
<outfile>C:\Users\Redwarp\workspace\Resizer\Resizer_1.3.3.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir></chdir>
Expand All @@ -26,12 +26,12 @@
<runtimeBits>64/32</runtimeBits>
</jre>
<versionInfo>
<fileVersion>1.3.2.0</fileVersion>
<txtFileVersion>1.3.2</txtFileVersion>
<fileVersion>1.3.3.0</fileVersion>
<txtFileVersion>1.3.3</txtFileVersion>
<fileDescription>9Patch Resizer</fileDescription>
<copyright>Redwarp - 2014</copyright>
<productVersion>1.3.2.0</productVersion>
<txtProductVersion>1.3.2</txtProductVersion>
<productVersion>1.3.3.0</productVersion>
<txtProductVersion>1.3.3</txtProductVersion>
<productName>9Patch Resizer</productName>
<companyName></companyName>
<internalName>Resizer</internalName>
Expand Down
2 changes: 1 addition & 1 deletion res/misc/preferences.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Created by JInto - www.guh-software.de
#Sun Oct 21 22:30:52 CEST 2012
version=1.3.2
version=1.3.3
58 changes: 58 additions & 0 deletions src/net/redwarp/tool/resizer/FileProcessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package net.redwarp.tool.resizer;

import java.io.File;

import net.redwarp.tool.resizer.table.Operation;
import net.redwarp.tool.resizer.table.OperationStatus;
import net.redwarp.tool.resizer.worker.ImageScaler;
import net.redwarp.tool.resizer.worker.ScreenDensity;

public class FileProcessor {

public interface FileProcessorStatusListener {
void onSuccess();

void onFailure(String msg);
}

private ImageScaler scaler;
FileProcessorStatusListener listener;
String fileName;

public FileProcessor(String name, FileProcessorStatusListener l) {
fileName = name;
listener = l;
if (name.endsWith(".png") || name.endsWith(".jpg")) {
Operation operation = new Operation(new File(name));

scaler = new ImageScaler(operation,
ScreenDensity.getDefaultInputDensity()) {
@Override
protected void process(java.util.List<Operation> chunks) {
for (Operation operation : chunks) {
OperationStatus status = operation.getStatus();
if (status == OperationStatus.FINISH) {
if (listener != null) {
listener.onSuccess();
}
} else if (status == OperationStatus.ERROR) {
listener.onFailure(operation.getMessage());
}
}
}
};
}
}

public void process() {
if (scaler != null) {
scaler.post();
} else {
if (listener != null) {
listener.onFailure("processor for argument:" + fileName
+ " is null");
}
}
}

}
84 changes: 64 additions & 20 deletions src/net/redwarp/tool/resizer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,74 @@
*/
package net.redwarp.tool.resizer;

import java.util.ArrayList;

import net.redwarp.tool.resizer.FileProcessor.FileProcessorStatusListener;
import net.redwarp.tool.resizer.misc.Localization;
import net.redwarp.tool.resizer.views.MainWindow;

import javax.swing.*;

public class Main {
public static void main(String[] args) {
// Apple only stuff
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name",
Localization.get("app_name"));

try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}

new MainWindow().setVisible(true);
}
static class StatusListener implements FileProcessorStatusListener {
int count = 0;
int current = 0;
int failureCount = 0;

public StatusListener(int count) {
this.count = count;
}

@Override
public void onSuccess() {
this.current++;
if (this.current == this.count) {
System.exit(failureCount);
}
}

@Override
public void onFailure(String msg) {
System.err.print(msg + "\n");
this.current++;
this.failureCount++;
if (this.current == this.count) {
System.exit(failureCount);
}
}
}

public static void main(String[] args) {
// Apple only stuff
System.setProperty("apple.laf.useScreenMenuBar", "true");
System.setProperty("com.apple.mrj.application.apple.menu.about.name",
Localization.get("app_name"));
if (args.length > 0) {
StatusListener l = new StatusListener(args.length);
ArrayList<FileProcessor> processors = new ArrayList<FileProcessor>();

for (String s : args) {
processors.add(new FileProcessor(s, l));
}
for (FileProcessor p : processors) {
p.process();
}
} else {

try {
UIManager.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}

new MainWindow().setVisible(true);
}
}
}

0 comments on commit aadd332

Please sign in to comment.