How to use basic Processing key event in Treemappa library

edited May 2015 in Library Questions

Hello, although I'm not good at both writing English sentence and developing, I have a question with my practical treemap code. I wondered that I have to post this question in 'Library' category, but this problem is related with basic Processing key events. I had copied the treemappa library from somewhere(my friend had given it to me), trying to make my code showing treemap when I press the 'a(A)' key. Here's my questions. How can I make a treemap with using key events interactivity? Where should I put pTreeMappa.getTreeMapPanel().updateLayout(); when I want to put interactions like this? I know that method provides a TreeMapPanel used to customise the appearance of the treemap and tried every position that method can be put. Sorry for the crappy English, again. Here's my code.

import org.gicentre.treemappa.gui.*; import org.gicentre.io.*; import org.gicentre.treemappa.*; import org.gicentre.utils.colour.*;

PTreeMappa pTreeMappa;

boolean drawTree = false;

void setup() { size(1200,600); smooth(); zoomer = new ZoomPan(this); noLoop();

textFont(createFont("sans-serif",40));

pTreeMappa = new PTreeMappa(this);

pTreeMappa.readData("life2.csv");

pTreeMappa.getTreeMapPanel().setBorders(0.6); pTreeMappa.getTreeMapPanel().setBorder(0,40); pTreeMappa.getTreeMapPanel().setBorderColour(255);

pTreeMappa.getTreeMapPanel().setShowBranchLabels(false); pTreeMappa.getTreeMapPanel().setBranchMaxTextSize(0,80); pTreeMappa.getTreeMapPanel().setBranchMaxTextSize(1,30); pTreeMappa.getTreeMapPanel().setLeafMaxTextSize(12); pTreeMappa.getTreeMapPanel().setAllowVerticalLabels(false); pTreeMappa.getTreeMapPanel().setBranchTextColours(0); pTreeMappa.getTreeMapPanel().setLeafTextColour(0); pTreeMappa.getTreeMapPanel().setColourTable(ColourTable.readFile(createInput("life.ctb")));

pTreeMappa.getTreeMapPanel().setLayouts("pivotSize");

pTreeMappa.getTreeMapPanel().updateLayout(); }

void draw() { background(255);

if (drawTree == true){

pTreeMappa.draw(); } pTreeMappa.getTreeMapPanel().updateLayout(); }

void keyPressed() { if ((key == 'a' )||(key == 'A')){ drawTree = true; }

}

Sign In or Register to comment.