Force little endian order for filetypes module.

Projects/Red Horizon - Filetypes/Java/redhorizon/utilities/ByteBufferOrdering.aj


remove field masking issues

remove field masking issues

/*
 * hashshmash - An aspect to record HashMap/Set allocations
 * Copyright 2013 MeBigFatGuy.com
 * Copyright 2013 Dave Brosius
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations
 * under the License.
 */
package com.mebigfatguy.hashshmash;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public aspect HashCollector {

    private static final Journaller journaller = new Journaller();

    after() returning (Map<?,?> m): call(HashMap.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashMapDetails details = new HashMapDetails(m, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    after() returning (Map<?,?> m): call(LinkedHashMap.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashMapDetails details = new LinkedHashMapDetails(m, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    after() returning (Map<?,?> m): call(ConcurrentHashMapMap.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashMapDetails details = new ConcurrentHashMapDetails(m, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    after() returning (Set<?> s): call(HashSet.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashSetDetails details = new HashSetDetails(s, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    after() returning (Set<?> s): call(LinkedHashSet.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashSetDetails details = new LinkedHashSetDetails(s, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    before(): execution(public static void *.main(String[])) {
        Class<?> c = HashCollector.class;
    }
}

final class Journaller implements Runnable {

    private static final int SLEEP_TIME = 5 * 1000;

    private Field tableField;
    private ConcurrentHashMap<HashDetails, HashDetails> hDetails = new ConcurrentHashMap<HashDetails, HashDetails>();
    private PrintWriter writer;
    private boolean operational = false;

    public Journaller() {
        try {
            System.out.println("*************************");
            System.out.println("HASHSHMASH ASPECT ENABLED");
            System.out.println("*************************");

            tableField = HashMap.class.getDeclaredField("table");
            tableField.setAccessible(true);

            File dir = new File(System.getProperty("user.home"), ".hashshmash");
            dir.mkdirs();

            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, new Date().toString() + ".txt")))));

            Thread t = new Thread(this);
            t.setDaemon(true);
            operational = true;
            t.start();
        } catch (Exception e) {
        }
    }

    public void add(HashDetails details) {
        if (operational)
            hDetails.put(details,  details);
    }

    public void run() {
        try {
            while (!Thread.interrupted()) {
                Thread.sleep(SLEEP_TIME);

                for (HashDetails details : hDetails.keySet()) {
                    try {
                        Map<?, ?> map = details.getMap();
                        if (map != null) {
                            int newSize = details.getMap().size();
                            if (newSize == details.size) {
                                Entry<?, ?>[] table = (Entry<?, ?>[])tableField.get(map);
                                details.totalSlots = table.length;
                                for (Entry<?, ?> e : table) {
                                    if (e != null) {
                                        details.usedSlots++;
                                    }
                                }
                                writer.println(details);
                                hDetails.remove(details);
                            } else
                                details.size = newSize;
                        } else {
                            hDetails.remove(details);
                        }
                    } catch (Exception e) {
                        //might get ConcurrentModificationException or such, just ignore
                    }
                }
                writer.flush();
            }
        } catch (InterruptedException ie) {
        }
    }
}

abstract class HashDetails {
    private static SimpleDateFormat FORMATTER = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss-SSS");

    public Date allocTime;
    public String caller;
    public int size;
    public int usedSlots;
    public int totalSlots;

    public abstract Map<?,?> getMap();

    public abstract String getDetailType();

    public String toString() {
        return getDetailType() + "\t" + FORMATTER.format(allocTime) + "\t" + caller + "\t" + getMap().size() + "\t" + totalSlots + "\t" + usedSlots;
    }
}

class HashMapDetails extends HashDetails {
    public Map<?, ?> map;

    public HashMapDetails(Map<?, ?> m, Date d, String c) {
        map = m;
        allocTime = d;
        caller = c;
        size = map.size();
    }

    public Map<?,?> getMap() {
        return map;
    }

    public String getDetailType() {
        return map.getClass().getSimpleName();
    }
}

class LinkedHashMapDetails extends HashMapDetails {

    public LinkedHashMapDetails(Map<?, ?> m, Date d, String c) {
       super(m, d, c);
    }

    public String getDetailType() {
        return map.getClass().getSimpleName();
    }
}

class ConcurrentHashMapDetails extends HashMapDetails {

    public ConcurrentHashMapDetails(Map<?, ?> m, Date d, String c) {
       super(m, d, c);
    }

    public String getDetailType() {
        return map.getClass().getSimpleName();
    }
}

class HashSetDetails extends HashDetails {
    private static Field MAP_FIELD;
    static {
        try {
            MAP_FIELD = HashSet.class.getDeclaredField("map");
            MAP_FIELD.setAccessible(true);
        } catch (Exception e) {
            MAP_FIELD = null;
        }
    }

    public Set<?> set;

    public HashSetDetails(Set<?> s, Date d, String c) {
        set = s;
        allocTime = d;
        caller = c;
        size = set.size();
    }

    public Map<?,?> getMap() {
        try {
            if (MAP_FIELD == null)
                return null;

            return (Map<?,?>) MAP_FIELD.get(set);
        } catch (Exception e) {
            return null;
        }
    }

    public String getDetailType() {
        return set.getClass().getSimpleName();
    }
}

class LinkedHashSetDetails extends HashSetDetails {
    public Map<?, ?> map;

    public LinkedHashSetDetails(Set<?> s, Date d, String c) {
       super(s, d, c);
    }

    public String getDetailType() {
        return map.getClass().getSimpleName();
    }
}

/*
 * hashshmash - An aspect to record HashMap/Set allocations
 * Copyright 2013 MeBigFatGuy.com
 * Copyright 2013 Dave Brosius
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations
 * under the License.
 */
package com.mebigfatguy.hashshmash;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public aspect HashCollector {

    private static final Journaller journaller = new Journaller();

    after() returning (Map<?,?> m): call(HashMap.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashMapDetails details = new HashMapDetails(m, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    after() returning (Map<?,?> m): call(LinkedHashMap.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashMapDetails details = new LinkedHashMapDetails(m, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    after() returning (Map<?,?> m): call(ConcurrentHashMapMap.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashMapDetails details = new ConcurrentHashMapDetails(m, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    after() returning (Set<?> s): call(HashSet.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashSetDetails details = new HashSetDetails(s, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    after() returning (Set<?> s): call(LinkedHashSet.new(..)) {
        String fileName = thisJoinPointStaticPart.getSourceLocation().getFileName();
        int line = thisJoinPointStaticPart.getSourceLocation().getLine();

        HashSetDetails details = new LinkedHashSetDetails(s, new Date(), fileName + ":" + line);
        journaller.add(details);
    }

    before(): execution(public static void *.main(String[])) {
        Class<?> c = HashCollector.class;
    }
}

final class Journaller implements Runnable {

    private static final int SLEEP_TIME = 5 * 1000;

    private Field tableField;
    private ConcurrentHashMap<HashDetails, HashDetails> hDetails = new ConcurrentHashMap<HashDetails, HashDetails>();
    private PrintWriter writer;
    private boolean operational = false;

    public Journaller() {
        try {
            System.out.println("*************************");
            System.out.println("HASHSHMASH ASPECT ENABLED");
            System.out.println("*************************");

            tableField = HashMap.class.getDeclaredField("table");
            tableField.setAccessible(true);

            File dir = new File(System.getProperty("user.home"), ".hashshmash");
            dir.mkdirs();

            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, new Date().toString() + ".txt")))));

            Thread t = new Thread(this);
            t.setDaemon(true);
            operational = true;
            t.start();
        } catch (Exception e) {
        }
    }

    public void add(HashDetails details) {
        if (operational)
            hDetails.put(details,  details);
    }

    public void run() {
        try {
            while (!Thread.interrupted()) {
                Thread.sleep(SLEEP_TIME);

                for (HashDetails details : hDetails.keySet()) {
                    try {
                        Map<?, ?> map = details.getMap();
                        if (map != null) {
                            int newSize = details.getMap().size();
                            if (newSize == details.size) {
                                Entry<?, ?>[] table = (Entry<?, ?>[])tableField.get(map);
                                details.totalSlots = table.length;
                                for (Entry<?, ?> e : table) {
                                    if (e != null) {
                                        details.usedSlots++;
                                    }
                                }
                                writer.println(details);
                                hDetails.remove(details);
                            } else
                                details.size = newSize;
                        } else {
                            hDetails.remove(details);
                        }
                    } catch (Exception e) {
                        //might get ConcurrentModificationException or such, just ignore
                    }
                }
                writer.flush();
            }
        } catch (InterruptedException ie) {
        }
    }
}

abstract class HashDetails {
    private static SimpleDateFormat FORMATTER = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss-SSS");

    public Date allocTime;
    public String caller;
    public int size;
    public int usedSlots;
    public int totalSlots;

    public abstract Map<?,?> getMap();

    public abstract String getDetailType();

    public String toString() {
        return getDetailType() + "\t" + FORMATTER.format(allocTime) + "\t" + caller + "\t" + getMap().size() + "\t" + totalSlots + "\t" + usedSlots;
    }
}

class HashMapDetails extends HashDetails {
    public Map<?, ?> map;

    public HashMapDetails(Map<?, ?> m, Date d, String c) {
        map = m;
        allocTime = d;
        caller = c;
        size = map.size();
    }

    public Map<?,?> getMap() {
        return map;
    }

    public String getDetailType() {
        return map.getClass().getSimpleName();
    }
}

class LinkedHashMapDetails extends HashMapDetails {
    public Map<?, ?> map;

    public LinkedHashMapDetails(Map<?, ?> m, Date d, String c) {
       super(m, d, c);
    }

    public String getDetailType() {
        return map.getClass().getSimpleName();
    }
}

class ConcurrentHashMapDetails extends HashMapDetails {
    public Map<?, ?> map;

        public ConcurrentHashMapDetails(Map<?, ?> m, Date d, String c) {
           super(m, d, c);
        }

        public String getDetailType() {
            return map.getClass().getSimpleName();
        }
}

class HashSetDetails extends HashDetails {
    private static Field MAP_FIELD;
    static {
        try {
            MAP_FIELD = HashSet.class.getDeclaredField("map");
            MAP_FIELD.setAccessible(true);
        } catch (Exception e) {
            MAP_FIELD = null;
        }
    }

    public Set<?> set;

    public HashSetDetails(Set<?> s, Date d, String c) {
        set = s;
        allocTime = d;
        caller = c;
        size = set.size();
    }

    public Map<?,?> getMap() {
        try {
            if (MAP_FIELD == null)
                return null;

            return (Map<?,?>) MAP_FIELD.get(set);
        } catch (Exception e) {
            return null;
        }
    }

    public String getDetailType() {
        return set.getClass().getSimpleName();
    }
}

class LinkedHashSetDetails extends HashSetDetails {
    public Map<?, ?> map;

    public LinkedHashSetDetails(Set<?> s, Date d, String c) {
       super(s, d, c);
    }

    public String getDetailType() {
        return map.getClass().getSimpleName();
    }
}


First version of the statistics export to pdf

import java.io.IOException;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
import org.apache.pdfbox.pdmodel.font.PDType1Font;

import view.GUI;

public privileged aspect StatisticsExport {

	private GUI gui;

    /**
     * catch constructor call, so that we have the correct gui, to refer to everywhere
     */
    after() returning(GUI gui): call(GUI.new(*)) {
        this.gui = gui;
    }

    /**
     * Catch the call on {@link PDFReportListener.drawTable(PDDocument)} to get the pdf
     * creator object.
     *
     * @param document
     * @throws IOException
     */
	void around(PDDocument document) throws IOException
		: execution (* PDFReportListener.drawTable(PDDocument))
		&& args(document) {
		PDPage page = new PDPage();
		document.addPage(page);
		PDPageContentStream contentStream = new PDPageContentStream(document, page);
		contentStream.setFont(PDType1Font.HELVETICA_BOLD, 10);
		contentStream.beginText();
		createContent(contentStream);
		contentStream.endText();
		contentStream.close();
	}

	/**
	 * Write statistics to given contentStream of a pdf page.
	 *
	 * @param contentStream The contentStream of the pdf page to write on.
	 * @throws IOException
	 */
	private void createContent(PDPageContentStream contentStream) throws IOException {
		OverallStatistics data = gui.model.gameDB.getOverallStatistics();

		int anzahlSpieleGesamt = data.getAnzahlSpieleGesamt();
        int anzahlSpieleGesamtGewonnen = data.getAnzahlSpieleGesamtGewonnen();
        int teuerstesRufspiel = data.getTeuerstesRufspiel();
        int teuerstesSolo = data.getTeuerstesSolo();
        int teuerstesSoloTout = data.getTeuerstesSoloTout();
        int teuerstesSoloSie = data.getTeuerstesSoloSie();
        int anzahlRufspiele = data.getAnzahlRufspiele();
        int anzahlSoli = data.getAnzahlSoli();
        int anzahlSoliTout = data.getAnzahlSoliTout();
        int anzahlSoliSie = data.getAnzahlSoliSie();
        int anzahlSoliGesamt = data.getAnzahlSoliGesamt();
        int anzahlGewonneneSoliGesamt = data.getAnzahlGewonneneSoliGesamt();
        int anzahlGewonneneRufspiele = data.getAnzahlGewonneneRufspiele();
        int anzahlGewonneneSoli = data.getAnzahlGewonneneSoli();
        int anzahlGewonneneSoliTout = data.getAnzahlGewonneneSoliTout();
        int anzahlGewonneneSoliSie = data.getAnzahlGewonneneSoliSie();
        int anzahlWeiter = data.getAnzahlWeiter();

        double sologesamtwin = (anzahlSoliGesamt) > 0 ? ((double) (anzahlGewonneneSoliGesamt) / (anzahlSoliGesamt))
                : 0;

        contentStream.moveTextPositionByAmount(50, 650);
        contentStream.drawString("#Spiele (ohne weiter): "
                + anzahlSpieleGesamt
                + " (gewonnen: "
                + String.format("%.2f",
                        (anzahlSpieleGesamt > 0 ? anzahlSpieleGesamtGewonnen
                                / ((double) anzahlSpieleGesamt) : 0) * 100)
                + "%)");

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("#Rufspiele: "
                + anzahlRufspiele
                + " (gewonnen: "
                + String.format("%.2f",
                        (anzahlRufspiele > 0 ? anzahlGewonneneRufspiele
                                / ((double) anzahlRufspiele) : 0) * 100)
                + "%)");

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("          -> teuerstes Rufspiel: "
                + teuerstesRufspiel);

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("#Soli gesamt: "
                + (anzahlSoli + anzahlSoliTout + anzahlSoliSie)
                + " (gewonnen: "
                + String.format("%.2f", sologesamtwin * 100)
                + "%)");

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("#Soli normal: "
                + anzahlSoli
                + " (gewonnen: "
                + String.format("%.2f", (anzahlSoli > 0 ? anzahlGewonneneSoli
                        / ((double) anzahlSoli) : 0) * 100)
                + "%)");

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("            -> teuerstes Solo: "
                + teuerstesSolo);

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("#Solo Tout: "
                + anzahlSoliTout
                + " (gewonnen: "
                + String.format("%.2f",
                        (anzahlSoliTout > 0 ? anzahlGewonneneSoliTout
                                / ((double) anzahlSoliTout) : 0) * 100)
                + "%)");

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("          -> teuerstes Solo Tout: "
                + teuerstesSoloTout);

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("#Solo Sie: "
                + anzahlSoliSie
                + " (gewonnen: "
                + String.format("%.2f",
                        (anzahlSoliSie > 0 ? anzahlGewonneneSoliSie
                                / ((double) anzahlSoliSie) : 0) * 100) + "%)");

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("         -> teuerstes Solo Sie: " + teuerstesSoloSie);

        contentStream.moveTextPositionByAmount(0, -20);
        contentStream.drawString("#Weiter: " + anzahlWeiter);
	}
}

public aspect StatisticsExport {
	// TODO Auto-generated aspect
}


remove debug output

remove debug output

import java.awt.GridLayout;
import java.util.Iterator;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;

import view.GUI;
import view.UIUpdater;
import model.db.GameData;
import model.SystemValues.Games;
import model.SystemValues.Players;
import model.SystemValues.WIN;
import model.db.DataObject;

public privileged aspect StatPlayerWiseTxt {
    declare precedence : StatPlayerWiseTxt, StatOverallGraph, StatOverallTxt;

    private static GUI gui;
    private static JPanel panel = new JPanel();
    private static JTextArea statText = new JTextArea();

    after() returning(GUI gui): call(GUI.new(*)) {
        StatPlayerWiseTxt.gui = gui;
    }

    after(JTabbedPane tabbedPane):
                        execution(public static void StatisticsHelper.StatisticsPaneCreated(JTabbedPane))
                        && args(tabbedPane) {
        statText.setEditable(false);
        panel.setLayout(new GridLayout(0, 1));
        panel.add(statText);
        ((JTabbedPane) tabbedPane).addTab("PlayerWiseText", panel);
    }

    after() : execution(* UIUpdater.run()) {
        statText.setText(gui.model.getGameData()
                .getPlayerWiseStatisticsString());
    }

    public String GameData.getPlayerWiseStatisticsString() {
        StringBuilder result = new StringBuilder();

        for (Players player : Players.values()) {
            result.append(player);
            result.append(":" + System.lineSeparator() + System.lineSeparator());

            int gamesPlayedTot = 0;
            int gamesWonTot = 0;
            int highestAcc = 0;
            int lowestAcc = 0;
            int highestWin = 0;
            int highestLoss = 0;

            int[] gamesPlayedPerType = new int[Games.values().length];
            int[] gamesWonPerType = new int[Games.values().length];

            Iterator<DataObject> it = data.iterator();
            DataObject lastObj = it.next();

            while (it.hasNext()) {
                DataObject dataObj = it.next();

                if (dataObj.getPlayer().equals(player.toString())) {
                    gamesPlayedTot++;
                    gamesPlayedPerType[dataObj.getGameKind().ordinal()]++;
                    if (dataObj.getGameWon() == WIN.PLAYER) {
                        gamesWonTot++;
                        gamesWonPerType[dataObj.getGameKind().ordinal()]++;
                    }
                }
                int gameVal = dataObj.getPlayerVal(player) - lastObj.getPlayerVal(player);
                if (gameVal > highestWin) {
                    highestWin = gameVal;
                } else if (gameVal < highestLoss) {
                    highestLoss = gameVal;
                }

                int accVal = dataObj.getPlayerVal(player);
                if (accVal > highestAcc) {
                    highestAcc = accVal;
                } else if (accVal < lowestAcc) {
                    lowestAcc = accVal;
                }

                lastObj = dataObj;
            }

            double gamesWonPerc = ((gamesPlayedTot + gamesWonTot) > 0 ? (double) gamesWonTot
                    / gamesPlayedTot
                    : 0.0) * 100;

            double gamesWonPerTypePerc[] = new double[Games.values().length];
            for (Games game : Games.values()) {
                int i = game.ordinal();
                gamesWonPerTypePerc[i] = ((gamesPlayedPerType[i] + gamesWonPerType[i]) > 0 ? (double) gamesWonPerType[i]
                        / gamesPlayedPerType[i]
                        : 0.0) * 100;
            }

            result.append(
                    "Gespielte Spiele:" + System.lineSeparator() + "\t"
                            + "- Gesamt: " + gamesPlayedTot)
                    .append(", davon gewonnen: " + gamesWonTot)
                    .append(" (" + String.format("%.2f", gamesWonPerc) + "%)"
                            + System.lineSeparator());

            for (Games game : Games.values()) {
                if (game != Games.WEITER) {
                    int i = game.ordinal();
                    result.append(
                            "\t- " + game.toString() + ": "
                                    + gamesPlayedPerType[i])
                            .append(", davon gewonnen: " + gamesWonPerType[i])
                            .append(" ("
                                    + String.format("%.2f",
                                            gamesWonPerTypePerc[i]) + "%)"
                                    + System.lineSeparator());
                }
            }

            result.append("Höchster Kontostand: " + highestAcc
                    + System.lineSeparator() + "Niedrigster Kontostand: "
                    + lowestAcc + System.lineSeparator());

            result.append("Größter Gewinn: " + highestWin
                    + System.lineSeparator());
            result.append("Größter Verlust: " + highestLoss
                    + System.lineSeparator());

            result.append(System.lineSeparator());
        }
        return result.toString();
    }
}

import java.awt.GridLayout;
import java.util.Iterator;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;

import view.GUI;
import view.UIUpdater;
import model.db.GameData;
import model.SystemValues.Games;
import model.SystemValues.Players;
import model.SystemValues.WIN;
import model.db.DataObject;

public privileged aspect StatPlayerWiseTxt {
    declare precedence : StatPlayerWiseTxt, StatOverallGraph, StatOverallTxt;

    private static GUI gui;
    private static JPanel panel = new JPanel();
    private static JTextArea statText = new JTextArea();

    after() returning(GUI gui): call(GUI.new(*)) {
        StatPlayerWiseTxt.gui = gui;
    }

    after(JTabbedPane tabbedPane):
                        execution(public static void StatisticsHelper.StatisticsPaneCreated(JTabbedPane))
                        && args(tabbedPane) {
        statText.setEditable(false);
        panel.setLayout(new GridLayout(0, 1));
        panel.add(statText);
        ((JTabbedPane) tabbedPane).addTab("PlayerWiseText", panel);
    }

    after() : execution(* UIUpdater.run()) {
        statText.setText(gui.model.getGameData()
                .getPlayerWiseStatisticsString());
    }

    public String GameData.getPlayerWiseStatisticsString() {
        StringBuilder result = new StringBuilder();

        for (Players player : Players.values()) {
            result.append(player);
            result.append(":" + System.lineSeparator() + System.lineSeparator());

            int gamesPlayedTot = 0;
            int gamesWonTot = 0;
            int highestAcc = 0;
            int lowestAcc = 0;
            int highestWin = 0;
            int highestLoss = 0;

            int[] gamesPlayedPerType = new int[Games.values().length];
            int[] gamesWonPerType = new int[Games.values().length];

            Iterator<DataObject> it = data.iterator();
            DataObject lastObj = it.next();

            while (it.hasNext()) {
                DataObject dataObj = it.next();

                if (dataObj.getPlayer().equals(player.toString())) {
                    gamesPlayedTot++;
                    gamesPlayedPerType[dataObj.getGameKind().ordinal()]++;
                    if (dataObj.getGameWon() == WIN.PLAYER) {
                        gamesWonTot++;
                        gamesWonPerType[dataObj.getGameKind().ordinal()]++;
                    }
                }
                int gameVal = dataObj.getPlayerVal(player) - lastObj.getPlayerVal(player);
                if (gameVal > highestWin) {
                    highestWin = gameVal;
                } else if (gameVal < highestLoss) {
                    highestLoss = gameVal;
                }

                int accVal = dataObj.getPlayerVal(player);
                System.out.println(player + ": " + accVal);
                if (accVal > highestAcc) {
                    highestAcc = accVal;
                } else if (accVal < lowestAcc) {
                    lowestAcc = accVal;
                }

                lastObj = dataObj;
            }

            double gamesWonPerc = ((gamesPlayedTot + gamesWonTot) > 0 ? (double) gamesWonTot
                    / gamesPlayedTot
                    : 0.0) * 100;

            double gamesWonPerTypePerc[] = new double[Games.values().length];
            for (Games game : Games.values()) {
                int i = game.ordinal();
                gamesWonPerTypePerc[i] = ((gamesPlayedPerType[i] + gamesWonPerType[i]) > 0 ? (double) gamesWonPerType[i]
                        / gamesPlayedPerType[i]
                        : 0.0) * 100;
            }

            result.append(
                    "Gespielte Spiele:" + System.lineSeparator() + "\t"
                            + "- Gesamt: " + gamesPlayedTot)
                    .append(", davon gewonnen: " + gamesWonTot)
                    .append(" (" + String.format("%.2f", gamesWonPerc) + "%)"
                            + System.lineSeparator());

            for (Games game : Games.values()) {
                if (game != Games.WEITER) {
                    int i = game.ordinal();
                    result.append(
                            "\t- " + game.toString() + ": "
                                    + gamesPlayedPerType[i])
                            .append(", davon gewonnen: " + gamesWonPerType[i])
                            .append(" ("
                                    + String.format("%.2f",
                                            gamesWonPerTypePerc[i]) + "%)"
                                    + System.lineSeparator());
                }
            }

            result.append("Höchster Kontostand: " + highestAcc
                    + System.lineSeparator() + "Niedrigster Kontostand: "
                    + lowestAcc + System.lineSeparator());

            result.append("Größter Gewinn: " + highestWin
                    + System.lineSeparator());
            result.append("Größter Verlust: " + highestLoss
                    + System.lineSeparator());

            result.append(System.lineSeparator());
        }
        return result.toString();
    }
}


Add the ProcessHelper in the Quart JobDataMap.

/*
 *     ParallelJ, framework for parallel computing
 *
 *     Copyright (C) 2010, 2011, 2012 Atos Worldline or third-party contributors as
 *     indicated by the @author tags or express copyright attribution
 *     statements applied by the authors.
 *
 *     This library is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU Lesser General Public
 *     License as published by the Free Software Foundation; either
 *     version 2.1 of the License.
 *
 *     This library is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *     Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public
 *     License along with this library; if not, write to the Free Software
 *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
package org.parallelj.launching.quartz;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.parallelj.Programs;
import org.parallelj.Programs.ProcessHelper;
import org.parallelj.internal.kernel.KProgram;
import org.parallelj.internal.reflect.ProgramAdapter.Adapter;
import org.parallelj.launching.LaunchingMessageKind;
import org.parallelj.launching.ProgramReturnCodes;
import org.parallelj.launching.internal.LaunchingObservable;
import org.parallelj.mirror.ProgramType;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * Implements the Job.execute(..) method
 *
 *
 */
privileged public aspect ProgramJobsAdapter {

	/*
	 * The Aspect JobsAdapter must be passed before this.
	 */
	declare precedence :
		org.parallelj.internal.kernel.Identifiers,
		org.parallelj.internal.reflect.ProgramAdapter,
		org.parallelj.internal.util.sm.impl.KStateMachines,
		org.parallelj.internal.util.sm.impl.KStateMachines.PerMachine,
		org.parallelj.Executables$PerExecutable,
		org.parallelj.internal.reflect.ProgramAdapter.PerProgram,
		org.parallelj.internal.log.Logs,
		org.parallelj.launching.quartz.JobsAdapter;

	/**
	 * Launch a Program and initialize the Result as a JobDataMap.
	 *
	 * @param self
	 * @param context
	 * @throws JobExecutionException
	 */
	void around(Job self, JobExecutionContext context)
			throws JobExecutionException :
		execution( public void  Job+.execute(..) throws JobExecutionException)
			&& (within(@org.parallelj.Program *) || within(JobsAdapter))
				&& args(context) && this(self) {
		JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
		context.setResult(jobDataMap);
		jobDataMap.put(QuartzUtils.RETURN_CODE, ProgramReturnCodes.SUCCESS);

		proceed(self, context);

		try {
			// Initialize an ExecutorService with the Capacity of the Program
			ProcessHelper<?> processHelper = Programs.as((Adapter) self);
			if (processHelper == null) {
				jobDataMap.put(QuartzUtils.RETURN_CODE, ProgramReturnCodes.NOTSTARTED);
				throw new JobExecutionException(LaunchingMessageKind.ELAUNCH0003.getFormatedMessage(self));
			}
			ProgramType programType = processHelper.getProcess().getProgram();

			LaunchingObservable observable = new LaunchingObservable();
			observable.prepareLaunching((Adapter) self, processHelper, context);

			/*
			 * ExecutorService
			 *
			 * If an executorService was specified, we use it
			 */
			ExecutorService service = null;
			if (context.getJobDetail().getJobDataMap().get(Launch.DEFAULT_EXECUTOR_KEY) != null) {
				service = (ExecutorService)context.getJobDetail().getJobDataMap().get(Launch.DEFAULT_EXECUTOR_KEY);
			} else
			if (programType instanceof KProgram) {
				// Initialize an ExecutorService with the Program Capacity
				short programCapacity = ((KProgram) programType)
						.getCapacity();
				service = (programCapacity == Short.MAX_VALUE) ? Executors
						.newCachedThreadPool() : Executors
						.newFixedThreadPool(programCapacity);
			} else {
				service = Executors
						.newCachedThreadPool();
			}

			/*
			 *  Launch the program with the initialized ExecutorService
			 */
			processHelper.execute(service).join();
			jobDataMap.put(QuartzUtils.CONTEXT, processHelper);

			observable.finalizeLaunching((Adapter) self, processHelper, context);
			service.shutdown();

		} catch (Exception e) {
			jobDataMap.put(QuartzUtils.RETURN_CODE, ProgramReturnCodes.FAILURE);
			throw new JobExecutionException(e);
		}
	}

}

/*
 *     ParallelJ, framework for parallel computing
 *
 *     Copyright (C) 2010, 2011, 2012 Atos Worldline or third-party contributors as
 *     indicated by the @author tags or express copyright attribution
 *     statements applied by the authors.
 *
 *     This library is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU Lesser General Public
 *     License as published by the Free Software Foundation; either
 *     version 2.1 of the License.
 *
 *     This library is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *     Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public
 *     License along with this library; if not, write to the Free Software
 *     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */
package org.parallelj.launching.quartz;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.parallelj.Programs;
import org.parallelj.Programs.ProcessHelper;
import org.parallelj.internal.kernel.KProgram;
import org.parallelj.internal.reflect.ProgramAdapter.Adapter;
import org.parallelj.launching.LaunchingMessageKind;
import org.parallelj.launching.ProgramReturnCodes;
import org.parallelj.launching.internal.LaunchingObservable;
import org.parallelj.mirror.ProgramType;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * Implements the Job.execute(..) method
 *
 *
 */
privileged public aspect ProgramJobsAdapter {

	/*
	 * The Aspect JobsAdapter must be passed before this.
	 */
	declare precedence :
		org.parallelj.internal.kernel.Identifiers,
		org.parallelj.internal.reflect.ProgramAdapter,
		org.parallelj.internal.util.sm.impl.KStateMachines,
		org.parallelj.internal.util.sm.impl.KStateMachines.PerMachine,
		org.parallelj.Executables$PerExecutable,
		org.parallelj.internal.reflect.ProgramAdapter.PerProgram,
		org.parallelj.internal.log.Logs,
		org.parallelj.launching.quartz.JobsAdapter;

	/**
	 * Launch a Program and initialize the Result as a JobDataMap.
	 *
	 * @param self
	 * @param context
	 * @throws JobExecutionException
	 */
	void around(Job self, JobExecutionContext context)
			throws JobExecutionException :
		execution( public void  Job+.execute(..) throws JobExecutionException)
			&& (within(@org.parallelj.Program *) || within(JobsAdapter))
				&& args(context) && this(self) {
		JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
		context.setResult(jobDataMap);
		jobDataMap.put(QuartzUtils.RETURN_CODE, ProgramReturnCodes.SUCCESS);

		proceed(self, context);

		try {
			// Initialize an ExecutorService with the Capacity of the Program
			ProcessHelper<?> processHelper = Programs.as((Adapter) self);
			if (processHelper == null) {
				jobDataMap.put(QuartzUtils.RETURN_CODE, ProgramReturnCodes.NOTSTARTED);
				throw new JobExecutionException(LaunchingMessageKind.ELAUNCH0003.getFormatedMessage(self));
			}
			ProgramType programType = processHelper.getProcess().getProgram();

			LaunchingObservable observable = new LaunchingObservable();
			observable.prepareLaunching((Adapter) self, processHelper, context);

			/*
			 * ExecutorService
			 *
			 * If an executorService was specified, we use it
			 */
			ExecutorService service = null;
			if (context.getJobDetail().getJobDataMap().get(Launch.DEFAULT_EXECUTOR_KEY) != null) {
				service = (ExecutorService)context.getJobDetail().getJobDataMap().get(Launch.DEFAULT_EXECUTOR_KEY);
			} else
			if (programType instanceof KProgram) {
				// Initialize an ExecutorService with the Program Capacity
				short programCapacity = ((KProgram) programType)
						.getCapacity();
				service = (programCapacity == Short.MAX_VALUE) ? Executors
						.newCachedThreadPool() : Executors
						.newFixedThreadPool(programCapacity);
			} else {
				service = Executors
						.newCachedThreadPool();
			}

			/*
			 *  Launch the program with the initialized ExecutorService
			 */
			processHelper.execute(service).join();
			jobDataMap.put(QuartzUtils.CONTEXT, self);

			observable.finalizeLaunching((Adapter) self, processHelper, context);

			service.shutdown();

		} catch (Exception e) {
			jobDataMap.put(QuartzUtils.RETURN_CODE, ProgramReturnCodes.FAILURE);
			throw new JobExecutionException(e);
		}
	}

}