Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds PDF export #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Ignore unneeded files.
.DS_Store
data/
pdfs/
46 changes: 44 additions & 2 deletions MovesMapper_1_0.pde
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// - - - - - - - - - - - - - - - - - - - - - - -
// MOVES MAPPER v1.0
// Nicholas Felton — September 3, 2013
Expand All @@ -9,7 +10,7 @@
// - - - - - - - - - - - - - - - - - - - - - - -
import controlP5.*;
import java.util.Map;

import processing.pdf.*;

// - - - - - - - - - - - - - - - - - - - - - - -
// GLOBAL VARIABLES
Expand All @@ -36,11 +37,16 @@ StringDict placesDrawn = new StringDict();
int margin = 30;
int top_margin = margin + 50;

// for PDF export
Boolean record = false;

// GUI
ControlP5 cp5;
DropdownList d1, d2;
CheckBox checkbox;
Button labels, walk, run, cycle, transportation;
Button labels, walk, run, cycle, transportation, exportPDF;
Textfield input;

String[] monthNames = {
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
};
Expand Down Expand Up @@ -143,6 +149,22 @@ void setup() {
// reposition the Label for controller 'slider'
cp5.getController("TimeOfDay").getValueLabel().setText(TimeString).align(ControlP5.LEFT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);
cp5.getController("TimeOfDay").getCaptionLabel().align(ControlP5.RIGHT, ControlP5.BOTTOM_OUTSIDE).setPaddingX(0);

// PDF export
exportPDF = cp5.addButton("exportPDF", 0, width-250, height-40, 75, 20)
.setColorForeground(color(190))
.setColorBackground(color(60))
.setColorActive(color(255, 128));

input = cp5.addTextfield("")
.setValue("filename.pdf")
.setPosition(width-250, height-70)
.setSize(100, 20)
.setColorForeground(color(190))
.setColorBackground(color(60))
.setColorActive(color(255, 128))
.setFocus(true);

}


Expand All @@ -156,6 +178,10 @@ void draw() {
placesDrawn.clear();
timeLabel();

if(record) {
beginRecord(PDF, "pdfs/"+input.getText());
}

// Draw Moves
for (int i=0; i<movesDates.length; i++) {
try {
Expand All @@ -164,4 +190,20 @@ void draw() {
catch (Exception e) {
}
}

if(record) {
record = false;
println("Saving PDF file to pdfs/"+input.getText()+"...");
endRecord();
}
}


// - - - - - - - - - - - - - - - - - - - - - - -
// PDF EXPORT
// - - - - - - - - - - - - - - - - - - - - - - -

public void exportPDF() {
record = true;
}