Skip to content

Commit

Permalink
Added input file chooser
Browse files Browse the repository at this point in the history
  • Loading branch information
Georgy Litvinov committed Jul 7, 2017
1 parent 977a508 commit d38a1fa
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 9 deletions.
23 changes: 23 additions & 0 deletions src/main/java/ru/ras/iph/impose/FileChooser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ru.ras.iph.impose;

import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
public class FileChooser extends JFrame {
public static void main(String [] args){
chooseFile();
}
public static File chooseFile(){
File selected = null;
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(new File(System.getProperty("user.home")));
int result = fileChooser.showOpenDialog(null);
if (result == fileChooser.APPROVE_OPTION){
selected = fileChooser.getSelectedFile();
System.out.println("Selected file " + selected.getAbsolutePath());
}
return selected;

}

}
43 changes: 34 additions & 9 deletions src/main/java/ru/ras/iph/impose/ImposeonA3.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ public class ImposeonA3 {
public static void main(String[] args) throws IOException, DocumentException {
if (args.length != 1) {
System.err.println("Usage: java -jar impose.jar input_file.pdf");
System.exit(1);
}
String inputFileName = args[0];
File inputFile = new File(inputFileName);
if (!inputFile.exists()){
}
File inputFile = null;
if (args.length == 1){
String inputFileName = args[0];
inputFile = new File(inputFileName);
} else {
inputFile = FileChooser.chooseFile();
}

if (inputFile == null || !inputFile.exists()){
System.err.println("Input file not found!");
System.exit(1);
}
Expand Down Expand Up @@ -290,11 +295,17 @@ public static void main(String[] args) throws IOException, DocumentException {
document.close();
reader.close();
}
private static void drawSerifs(PdfContentByte canvas) {
/**
* @param canvas
*/
private static void drawSerifs(PdfContentByte canvas) {

canvas.stroke();
}
private static void drawFoldLines(PdfContentByte canvas) {
/**
* @param canvas
*/
private static void drawFoldLines(PdfContentByte canvas) {
canvas.moveTo(3,595.5);
canvas.lineTo(30,595.5);
canvas.moveTo(812,595.5);
Expand All @@ -306,7 +317,10 @@ private static void drawFoldLines(PdfContentByte canvas) {
canvas.stroke();

}
private static void drawRectangle2(PdfContentByte canvas){
/**
* @param canvas
*/
private static void drawRectangle2(PdfContentByte canvas){
int startX = 782;
int startY = 587;
canvas.moveTo(startX,startY);
Expand All @@ -317,7 +331,10 @@ private static void drawRectangle2(PdfContentByte canvas){
canvas.fillStroke();
canvas.stroke();
}
private static void drawRectangle4(PdfContentByte canvas){
/**
* @param canvas
*/
private static void drawRectangle4(PdfContentByte canvas){
int startX = 413;
int startY = 590;
canvas.moveTo(startX,startY);
Expand All @@ -329,6 +346,10 @@ private static void drawRectangle4(PdfContentByte canvas){
canvas.stroke();
}

/**
* @param canvas
* @param layout
*/
private static void drawSerifs4(PdfContentByte canvas, int layout) {
float xl = 413f;
float xr = 430f;
Expand All @@ -347,6 +368,10 @@ private static void drawSerifs4(PdfContentByte canvas, int layout) {

}

/**
* @param canvas
* @param layout
*/
private static void drawSerifs2(PdfContentByte canvas, int layout) {
float yt = 587f;
float yb = 604f;
Expand Down

0 comments on commit d38a1fa

Please sign in to comment.