The Pomodoro Technique

One of my favorite time management methods is the Pomodoro Technique. The method is basically as follows:

  1. Pick a task.
  2. Work on it for 25 minutes. This is called a Pomodoro.
  3. Take a 5 minute break. Do something totally unrelated to your work.
  4. Work for another Pomodoro, or 25 minutes. This can be on the same task, or a new one if the previous one is finished.
  5. After 4 Pomodoros, take a longer break of 15 to 30 minutes.

Because of the breaks, your mind gets just enough rest to stay focussed. Also, because you’re supposed to work on one task, and one task only during your Pomodoro, the quality of your work can go up.

Ofcourse, the technique is completely customizable. Do you think 25 minutes is too short (or too long)? Try 45 minutes (or 10 minutes). Do you need a long break sooner? Do it every 3 Pomodoros.

No I’ve made my own Pomodoro tracker. It’s written in Java 8, and it’s open source. You can find the source here . A runnable version can be found here.

This is still work in progress, and I mainly made it as a challenge to myself. If you like it, do whatever you want with it.

The pomodoro is running!
The pomodoro is running!

When the screen and the tray icon are red, a pomodoro is running. Right clicking the tray icon will bring up a menu.

Pomodoro break.
Pomodoro break.

When the screen and the tray icon are green, you are on a break.

Waiting for the next Pomodoro to be started.
Waiting for the next Pomodoro to be started.

When the screen and the tray icon are blue, the program is waiting.

Changing the settings
Changing the settings

The settings allow you to specify the location of the program, the times and the number of Pomodoros between long breaks.

JFreeChart

JFreeChart is an open source Java library for creating charts. The project started in February 2000, and is currently the most widely used Java charting library. It offers a large number of charts, examples of which can be found here.

To get started with JFreeChart in your maven project, add the following to your pom.xml

<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.17</version>
</dependency>

First, you need to create a Dataset to display in your chart. One of the most used Datasets by the library is the CategoryDataset, so let’s focus on that one.

DefaultCategoryDataset set = new DefaultCategoryDataset();
for (int i = 0; i < records.size(); i++){
Record record = records.get(i);
set.addValue(record.getCorrect(), // y-value
record.getStage(), // dataset
Integer.valueOf(i)); // x-value
}

The parameters for the addValue method are as follows:

  1. The actual value of this record
  2. The row key. When adding multiple sets to the same chart, so you can compare them, use different values for this parameter
  3. The column key, or the column at which this value will appear. Since this must implement the Comparable interface, it will be sorted.

Once you have the dataset, you can use it to createĀ  the chart itself.

JFreeChart chart = ChartFactory
.createLineChart("Score progress over time", // title
"Iteration", // category axis label
"Score", // value axis label
set); // dataset

With this dataset, you can create a number of charts. In this case, a line chart will be created, but you can also create an area chart, a bar chart, a stacked area / bar chart, and a 3D line / bar chart.

The library provides components to display the chart on screen, and to write it to file. The latter option involves only a couple of lines of code.

File output = new File(WORK_DIR, "chart.png");
try {
ChartUtilities.saveChartAsJPEG(output, // file
chart, // chart
800, // width
600); // height
} catch (IOException e) {
e.printStackTrace();
}

And when everything is ok, you’ll end up with something like this:chart