/** Create a new quaternary venn example. */ public QuaternaryVennExample() { super(); canvas = new PCanvas(); canvas.setDefaultRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING); canvas.setAnimatingRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING); canvas.setInteractingRenderQuality(PPaintContext.HIGH_QUALITY_RENDERING); Set<String> set0 = read("the_pioneers.txt"); Set<String> set1 = read("the_deerslayer.txt"); Set<String> set2 = read("the_pathfinder.txt"); Set<String> set3 = read("last_of_the_mohicans.txt"); vennNode = new QuaternaryVennNode<String>( "The Pioneers", set0, "The Deerslayer", set1, "The Pathfinder", set2, "Last of the \nMohicans", set3); vennNode.offset(40.0d, 235.0d); detailsLabel = new PText("Refining label layout..."); detailsLabel.offset(20.0d, 540.0d); canvas.getLayer().addChild(vennNode); canvas.getLayer().addChild(detailsLabel); Timer t = new Timer( 35000, new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { updateDetails(); } }); t.setRepeats(false); t.start(); setLayout(new BorderLayout()); add("Center", canvas); }
/** Update details label, install double-click listener. */ private void updateDetails() { detailsLabel.setText( "Left mouse click to pan, right mouse click to zoom, double-click for details"); canvas.addInputEventListener( new PBasicInputEventHandler() { @Override public void mousePressed(final PInputEvent event) { if (event.getClickCount() == 2) { showDetails(); } } }); Timer t = new Timer( 25000, new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { detailsLabel.animateToTransparency(0.0f, 2000); } }); t.setRepeats(false); t.start(); }