public ConcordanceTree() { super(new Visualization()); m_display_self = this; m_label = NAME; tree = new Tree(); Table ntable = tree.getNodeTable(); ntable.addColumn(NAME, String.class); ntable.addColumn(NODECOUNT, int.class); ntable.addColumn(ROWCOUNT, int.class); resetTree(); m_vis.add(TREE, tree); // m_vis.add(TREE, t, new WordCountPredicate()); m_nodeRenderer = new LabelRenderer(m_label); m_nodeRenderer.setRenderType(AbstractShapeRenderer.RENDER_TYPE_FILL); m_nodeRenderer.setHorizontalAlignment(Constants.LEFT); m_nodeRenderer.setRoundedCorner(8, 8); m_edgeRenderer = new EdgeRenderer(Constants.EDGE_TYPE_CURVE); DefaultRendererFactory rf = new DefaultRendererFactory(m_nodeRenderer); rf.add(new InGroupPredicate(TREEEDGES), m_edgeRenderer); m_vis.setRendererFactory(rf); // colors ItemAction nodeColor = new NodeColorAction(TREENODES); ItemAction textColor = new ColorAction(TREENODES, VisualItem.TEXTCOLOR, ColorLib.rgb(0, 0, 0)); m_vis.putAction("textColor", textColor); ItemAction edgeColor = new ColorAction(TREEEDGES, VisualItem.STROKECOLOR, ColorLib.rgb(255, 155, 155)); // quick repaint ActionList repaint = new ActionList(); repaint.add(nodeColor); // WordSizeAction wsaction = new WordSizeAction(TREEEDGES); repaint.add(new RepaintAction()); m_vis.putAction("repaint", repaint); // full paint ActionList fullPaint = new ActionList(); fullPaint.add(nodeColor); m_vis.putAction("fullPaint", fullPaint); // animate paint change ActionList animatePaint = new ActionList(400); animatePaint.add(new ColorAnimator(TREENODES)); animatePaint.add(new RepaintAction()); m_vis.putAction("animatePaint", animatePaint); // create the tree layout action NodeLinkTreeLayout treeLayout = new NodeLinkTreeLayout(TREE, m_orientation, 10, 0, 0); Point2D anchor = new Point2D.Double(25, HEIGHT / 2); treeLayout.setLayoutAnchor(anchor); m_vis.putAction("treeLayout", treeLayout); CollapsedSubtreeLayout subLayout = new CollapsedSubtreeLayout(TREE, m_orientation); m_vis.putAction("subLayout", subLayout); AutoPanAction autoPan = new AutoPanAction(); AutoCenterAction autocenter = new AutoCenterAction(); AutoFitAction autofit = new AutoFitAction(); ActionList positioning = new ActionList(); positioning.add(autofit); m_vis.putAction("positioning", positioning); ActionList fna = new ActionList(); fna.add(new WordFontAction(TREENODES, defaultTreeFont)); // fna.add(new EdgeWidthAction(TREEEDGES)); // fna.add(new WordSizeAction(TREEEDGES)); m_vis.putAction("fontnodeaction", fna); // create the filtering and layout ActionList filter = new ActionList(); filter.add(fna); filter.add(fisheyetreefilter); // VisibilityFilter visibfilter = new VisibilityFilter(new WordCountPredicate()); // filter.add(visibfilter); filter.add(treeLayout); filter.add(subLayout); filter.add(textColor); filter.add(nodeColor); filter.add(edgeColor); m_vis.putAction("filter", filter); // This doesn't quite work as expected; the layout is calculated // for the entire tree and low freq nodes are simply not shown, // leaving gaps in the layout // // setPredicate(new WordCountPredicate()); // animated transition ActionList animate = new ActionList(1000); animate.setPacingFunction(new SlowInSlowOutPacer()); // animate.add(autoPan); animate.add(new QualityControlAnimator()); animate.add(new VisibilityAnimator(TREE)); animate.add(new LocationAnimator(TREENODES)); animate.add(new ColorAnimator(TREENODES)); animate.add(new RepaintAction()); m_vis.putAction("animate", animate); m_vis.alwaysRunAfter("filter", "animate"); // create animator for orientation changes ActionList orient = new ActionList(2000); orient.setPacingFunction(new SlowInSlowOutPacer()); // orient.add(autoPan); // orient.add(autocenter); orient.add(new QualityControlAnimator()); orient.add(new LocationAnimator(TREENODES)); orient.add(new RepaintAction()); // orient.add(autofit); m_vis.putAction("orient", orient); // ------------------------------------------------ // initialize the display setSize(WIDTH, HEIGHT); setItemSorter(new TreeDepthItemSorter()); addControlListener(new ZoomToFitControl()); addControlListener(new ZoomControl()); addControlListener(new WheelZoomControl()); addControlListener(new PanControl()); addControlListener(new FocusControl(1, "filter")); addControlListener(new ToolTipControl(NODECOUNT)); registerKeyboardAction( new OrientAction(Constants.ORIENT_LEFT_RIGHT), "left-to-right", KeyStroke.getKeyStroke("ctrl 1"), WHEN_IN_FOCUSED_WINDOW); registerKeyboardAction( new OrientAction(Constants.ORIENT_TOP_BOTTOM), "top-to-bottom", KeyStroke.getKeyStroke("ctrl 2"), WHEN_IN_FOCUSED_WINDOW); registerKeyboardAction( new OrientAction(Constants.ORIENT_RIGHT_LEFT), "right-to-left", KeyStroke.getKeyStroke("ctrl 3"), WHEN_IN_FOCUSED_WINDOW); registerKeyboardAction( new OrientAction(Constants.ORIENT_BOTTOM_TOP), "bottom-to-top", KeyStroke.getKeyStroke("ctrl 4"), WHEN_IN_FOCUSED_WINDOW); registerKeyboardAction( new FisheyeExpandAction(-1), "collapse-one", KeyStroke.getKeyStroke("ctrl 5"), WHEN_IN_FOCUSED_WINDOW); registerKeyboardAction( new FisheyeExpandAction(+1), "expand-one", KeyStroke.getKeyStroke("ctrl 6"), WHEN_IN_FOCUSED_WINDOW); // ------------------------------------------------ // filter graph and perform layout setOrientation(m_orientation); m_vis.run("filter"); /* TupleSet search = new PrefixSearchTupleSet(); m_vis.addFocusGroup(Visualization.SEARCH_ITEMS, search); search.addTupleSetListener(new TupleSetListener() { public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) { m_vis.cancel("animatePaint"); m_vis.run("fullPaint"); m_vis.run("animatePaint"); } }); */ }
public trial(int st, String n) { // setup a visualisation super(new Visualization()); System.out.println(st + " " + n); // generate a graph initGraph(n, st); // standard labelRenderer for the given label LabelRenderer nodeRenderer = new LabelRenderer(LABEL); // rendererFactory for the visualization items DefaultRendererFactory rendererFactory = new DefaultRendererFactory(); // set the labelRenderer rendererFactory.setDefaultRenderer(nodeRenderer); m_vis.setRendererFactory(rendererFactory); // Color Actions ColorAction nodeText = new ColorAction(NODES, VisualItem.TEXTCOLOR); nodeText.setDefaultColor(ColorLib.gray(0)); ColorAction nodeStroke = new ColorAction(NODES, VisualItem.STROKECOLOR); nodeStroke.setDefaultColor(ColorLib.gray(100)); ColorAction nodeFill = new ColorAction(NODES, VisualItem.FILLCOLOR); nodeFill.setDefaultColor(ColorLib.gray(255)); ColorAction edgeStrokes = new ColorAction(EDGES, VisualItem.STROKECOLOR); edgeStrokes.setDefaultColor(ColorLib.gray(100)); // ColorAction fill = new ColorAction(NODES, VisualItem.FILLCOLOR, ColorLib.rgb(200, 200, 255); // fill.add(VisualItem.FIXED, ColorLib.rgb(255,100,100)); // fill.add(VisualItem.HIGHLIGHT, ColorLib.rgb(255,200,125)); // bundle the color actions ActionList draw = new ActionList(); // draw.add(fill); draw.add(new ColorAction(NODES, VisualItem.STROKECOLOR, 0)); draw.add(new ColorAction(NODES, VisualItem.TEXTCOLOR, ColorLib.rgb(0, 0, 0))); draw.add(new ColorAction(EDGES, VisualItem.FILLCOLOR, ColorLib.gray(200))); draw.add(new ColorAction(EDGES, VisualItem.STROKECOLOR, ColorLib.gray(200))); draw.add(nodeText); draw.add(nodeStroke); draw.add(nodeFill); draw.add(edgeStrokes); ActionList animate = new ActionList(Activity.INFINITY); // animate.add(fill); animate.add(new RepaintAction()); m_nodeRenderer = new LabelRenderer(m_label); m_nodeRenderer.setRenderType(AbstractShapeRenderer.RENDER_TYPE_FILL); m_nodeRenderer.setHorizontalAlignment(Constants.LEFT); m_nodeRenderer.setRoundedCorner(8, 8); m_edgeRenderer = new EdgeRenderer(Constants.EDGE_TYPE_CURVE); DefaultRendererFactory rf = new DefaultRendererFactory(m_nodeRenderer); m_vis.setRendererFactory(rf); // DataSizeAction DataSizeAction nodeDataSizeAction = new DataSizeAction(NODES, SIZE); draw.add(nodeDataSizeAction); m_vis.putAction("draw", draw); m_vis.putAction("layout", animate); m_vis.runAfter("draw", "layout"); // create the layout action for the graph NodeLinkTreeLayout treeLayout = new NodeLinkTreeLayout(GRAPH, m_orientation, 80, 5, 10); treeLayout.setLayoutAnchor(new Point2D.Double(250, -150)); m_vis.putAction("treeLayout", treeLayout); m_vis.addFocusGroup("selected"); CollapsedSubtreeLayout subLayout = new CollapsedSubtreeLayout(GRAPH, m_orientation); m_vis.putAction("subLayout", subLayout); m_vis.run("treeLayout"); m_vis.run("draw"); pan(250, 250); setHighQuality(true); addControlListener(new ZoomControl()); addControlListener(new PanControl()); addControlListener(new DragControl(true)); addControlListener(new NodeClicked()); addControlListener(new FocusControl()); registerKeyboardAction( new OrientAction(Constants.ORIENT_LEFT_RIGHT), "left-to-right", KeyStroke.getKeyStroke("ctrl 1"), WHEN_FOCUSED); registerKeyboardAction( new OrientAction(Constants.ORIENT_TOP_BOTTOM), "top-to-bottom", KeyStroke.getKeyStroke("ctrl 2"), WHEN_FOCUSED); registerKeyboardAction( new OrientAction(Constants.ORIENT_RIGHT_LEFT), "right-to-left", KeyStroke.getKeyStroke("ctrl 3"), WHEN_FOCUSED); registerKeyboardAction( new OrientAction(Constants.ORIENT_BOTTOM_TOP), "bottom-to-top", KeyStroke.getKeyStroke("ctrl 4"), WHEN_FOCUSED); TupleSet search = new PrefixSearchTupleSet(); m_vis.addFocusGroup(Visualization.SEARCH_ITEMS, search); search.addTupleSetListener( new TupleSetListener() { public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) { m_vis.cancel("animatePaint"); m_vis.run("fullPaint"); m_vis.run("animatePaint"); } }); }
public PhysioMapRadialGraphView( SemGenSettings sets, Graph g, String label, SemSimModel semsimmodel) { super(new Visualization()); this.semsimmodel = semsimmodel; // -- set up visualization -- m_vis.add(tree, g); m_vis.setInteractive(treeEdges, null, false); // -- set up renderers -- LabelRenderer m_nodeRenderer = new LabelRenderer(label); m_nodeRenderer.setRenderType(AbstractShapeRenderer.RENDER_TYPE_DRAW_AND_FILL); m_nodeRenderer.setHorizontalAlignment(Constants.CENTER); m_nodeRenderer.setRoundedCorner(8, 8); EdgeRenderer m_edgeRenderer = new EdgeRenderer(Constants.EDGE_TYPE_LINE, prefuse.Constants.EDGE_ARROW_REVERSE); m_edgeRenderer.setArrowType(prefuse.Constants.EDGE_ARROW_REVERSE); m_edgeRenderer.setArrowHeadSize(8, 8); // MAYBE HERE? DefaultRendererFactory rf = new DefaultRendererFactory(m_nodeRenderer); rf.add(new InGroupPredicate(treeEdges), m_edgeRenderer); m_vis.setRendererFactory(rf); // m_vis. // -- set up processing actions -- // colors ItemAction nodeColor = new NodeColorAction(treeNodes); ItemAction borderColor = new BorderColorAction(treeNodes); m_vis.putAction("borderColor", borderColor); ItemAction textColor = new TextColorAction(treeNodes); m_vis.putAction("textColor", textColor); ItemAction edgeColor = new ColorAction(treeEdges, VisualItem.STROKECOLOR, ColorLib.rgb(0, 0, 0)); ItemAction arrowColor = new ArrowColorAction(treeEdges); m_vis.putAction("arrowColor", arrowColor); FontAction fonts = new FontAction(treeNodes, FontLib.getFont("Verdana", 12)); fonts.add("ingroup('_focus_')", FontLib.getFont("Verdana", 12)); // recolor // When recolor, do these actions ActionList recolor = new ActionList(); recolor.add(nodeColor); recolor.add(borderColor); recolor.add(textColor); recolor.add(arrowColor); m_vis.putAction("recolor", recolor); // repaint ActionList repaint = new ActionList(); repaint.add(recolor); repaint.add(new RepaintAction()); m_vis.putAction("repaint", repaint); // animate paint change ActionList animatePaint = new ActionList(400); animatePaint.add(new ColorAnimator(treeNodes)); animatePaint.add(new RepaintAction()); m_vis.putAction("animatePaint", animatePaint); // create the tree layout action RadialTreeLayout treeLayout = new RadialTreeLayout(tree); treeLayout.setAutoScale(true); m_vis.putAction("treeLayout", treeLayout); CollapsedSubtreeLayout subLayout = new CollapsedSubtreeLayout(tree); m_vis.putAction("subLayout", subLayout); // create the filtering and layout ActionList filter = new ActionList(); filter.add(new TreeRootAction(tree)); filter.add(fonts); filter.add(treeLayout); filter.add(borderColor); filter.add(subLayout); filter.add(textColor); filter.add(nodeColor); filter.add(edgeColor); filter.add(arrowColor); m_vis.putAction("filter", filter); // animated transition ActionList animate = new ActionList(700); animate.setPacingFunction(new SlowInSlowOutPacer()); animate.add(new QualityControlAnimator()); animate.add(new VisibilityAnimator(tree)); animate.add(new PolarLocationAnimator(treeNodes, linear)); animate.add(new ColorAnimator(treeNodes)); animate.add(new RepaintAction()); m_vis.putAction("animate", animate); m_vis.alwaysRunAfter("filter", "animate"); // ------------------------------------------------ // initialize the display setSize(sets.getAppWidth() - ExtractorTab.leftpanewidth - 50, sets.getAppHeight() - 235); setItemSorter(new TreeDepthItemSorter()); addControlListener(new DragControl()); addControlListener(new ZoomToFitControl()); addControlListener(new ZoomControl()); addControlListener(new PanControl()); addControlListener(new FocusControl(1, "filter")); addControlListener(new HoverActionControl("repaint")); // ------------------------------------------------ // filter graph and perform layout m_vis.run("filter"); // maintain a set of items that should be interpolated linearly // this isn't absolutely necessary, but makes the animations nicer // the PolarLocationAnimator should read this set and act accordingly m_vis.addFocusGroup(linear, new DefaultTupleSet()); m_vis .getGroup(Visualization.FOCUS_ITEMS) .addTupleSetListener( new TupleSetListener() { public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) { TupleSet linearInterp = m_vis.getGroup(linear); if (add.length < 1) return; linearInterp.clear(); for (Node n = (Node) add[0]; n != null; n = n.getParent()) linearInterp.addTuple(n); } }); SearchTupleSet search = new PrefixSearchTupleSet(); m_vis.addFocusGroup(Visualization.SEARCH_ITEMS, search); search.addTupleSetListener( new TupleSetListener() { public void tupleSetChanged(TupleSet t, Tuple[] add, Tuple[] rem) { m_vis.cancel("animatePaint"); m_vis.run("recolor"); m_vis.run("animatePaint"); } }); }