📄 treejuxtaposer.java
字号:
} } } void seedRestOfQueue(AccordionTreeDrawerFinal atd) { int min = 0; int max = atd.tree.getLeafCount()-1; RangeList fakeRangeList = new RangeList(99); fakeRangeList.addRange(min, max, atd); // start with every leaf node Vector drawQueue = atd.getToDrawQ(); Iterator iter = drawQueue.iterator(); while (iter.hasNext()) { // remove interactionbox from rest of complete range // leave marked objects alone Object nextObj = iter.next(); if (nextObj instanceof RangeInTree) { RangeInTree currRange = (RangeInTree)nextObj; fakeRangeList.cutRange(currRange); } } Iterator rangeIter = fakeRangeList.getRanges().iterator(); while (rangeIter.hasNext()) // add ranges to drawing queue { RangeInTree currRange = (RangeInTree)rangeIter.next(); drawQueue.add(currRange); } //atd.addRangeToDrawQueue(new RangeInTree(atd.tree.getLeaf(i).key, atd.tree.getLeaf(i+stepSize-1).key, atd)); } // // seed paths all the way up to the root// void seedQueue(AccordionTreeDrawerFinal atd, boolean drawSpecial) {//// atd.clearQueue();// Tree t = atd.getTree();// InteractionBox bbox = atd.getBaseBox();// int stepSize = t.getLeafCount()/100;// if (stepSize < 2) stepSize = 2; // at least 2 since 2 splitLines surround a single cell// // // int min = 0, max = 0;// // seed in the ranges (active one first) before seeding the interaction box// seedGroups(atd);// //// int activeGroup = atd.getActionGroup();//// int flickerThreshold = 20;// // seed the interaction box// if (bbox != null && !bbox.moveStuck())// {// min = atd.tree.getLeaf(bbox.getMinLine(AccordionDrawer.Y)+1).key;// max = atd.tree.getLeaf(bbox.getMaxLine(AccordionDrawer.Y)).key;// atd.addToDrawQueue(new RangeInTree(min, max, atd));// // }// seedRestOfQueue(atd);// double pixelSize = atd.getPixelSize(AccordionDrawer.Y);//// atd.splitRanges(stepSize);// atd.splitRanges(pixelSize);// } void seedQueue(AccordionTreeDrawerFinal atd) { atd.clearQueue(); InteractionBox bbox = atd.baseBox; int firstRange[] = {bbox == null ? -1 : bbox.getMinLine(AccordionDrawer.Y), bbox == null ? -1 : bbox.getMaxLine(AccordionDrawer.Y)};// RangeList seedRangeList = asd.returnSeedingQueue(); seedGroups(atd); Vector drawQueue = atd.getToDrawQ(); int numSeededGroups = drawQueue.size(); Iterator iter = atd.getListOfLeaves().iterator(); while (iter.hasNext()) { SplitCell sc = (SplitCell)iter.next(); if (sc.max > firstRange[0] && sc.min < firstRange[1]) drawQueue.add(numSeededGroups, new RangeInTree(sc.min, sc.max, atd)); // higher priority else drawQueue.add(new RangeInTree(sc.min, sc.max, atd)); }// System.out.println("seeded: " + drawQueue.size() + " frame: " + atd.getFrameNum()); if (atd.basePass || atd.groupPass) // reverse queue, linear but only for taking pictures { Vector temp = new Vector(drawQueue); drawQueue.clear(); while (temp.size() > 0) drawQueue.add(temp.remove(temp.size()-1)); } }//t.getLeafCount()-1 // built-in group precedence ordering determines which group color // wins out. just stop when you find the first one, because order // matters. ArrayList getColorsForRange(int objMin, int objMax, AccordionTreeDrawer callingTreeDrawer) { ArrayList returnList = new ArrayList(); //System.out.println("getting colors: " + objMin + " " + objMax); Tree callingTree = callingTreeDrawer.getTree(); // System.out.println("TOP objmin " + objMin + " objmax " + objMax + " callingtree " + callingTree.getKey()); RangeInTree fakeRange = new RangeInTree(objMin+1, objMax-1, callingTreeDrawer); RangeList foundGroup = null; Iterator GroupIter = groups.iterator(); RangeList.returnObject = true; while (GroupIter.hasNext()) { // && returnList.size() < 1) { RangeList group = (RangeList) GroupIter.next(); if (true == group.getEnabled() && group.getRanges().contains(fakeRange)) { RangeInTree foundRange = RangeList.matchRange; if (foundRange != null && group.getColor() != null) returnList.add(group.getColor()); } } RangeList.returnObject = false;// System.out.println("got colors: " + objMin + " " + objMax + " " + returnList); return returnList; } /** * Acts as a toggle on group members: turn off old ones, turn on * new ones, do lightweight frontbuffer drawing per item not whole * screen redraw * * @author Tamara Munzner * @see AccordionDrawer.Tree * @see AccordionDrawer.TreeNode * @see TreeJuxtaposer.RangeList * */ void doFlashGeom(CellGeom flashGeom, int group, AccordionTreeDrawerFinal thisTree, int x, int y, boolean all) { //System.out.println("doFlashGeom: " + x + " " + y); RangeList theGroup = getGroup(group); TreeNode flashNode; //System.out.println("fg "+flashGeom+" fgo "+flashGeomOld); if (null == flashGeom) { // if (null != flashGeomOld) { if (true) { // the first time flashGeom goes null, we need to call // setFlash with a null geometry to make sure the // highlight is turned off. flashNode = null; } else return; } else { // flashGeom is an edge. get its associated node instead. flashNode = thisTree.getNodeByKey(flashGeom.getKey()); // System.out.println("flash normal"); } //System.out.println("fn "+flashNode+" fgo "+flashGeomOld); if (flashNode == flashGeomOld) return; // we're still doing the group book-keeping so that we know // which tree the item is attached to. we just don't want to // enable the group, since then we're left with yellow boxes // that aren't easy to clean up with this frontbuffer trick! clearGroup(group); if (null != flashNode) addNodesToGroup(flashNode.getKey(), flashNode.getKey(), group, thisTree); Iterator tdIter = treeDrawers.iterator(); while (tdIter.hasNext()) { AccordionTreeDrawer atd = (AccordionTreeDrawer)tdIter.next(); // we're assuming flashGeom is a TreeNode, since we only put nodes in above (not edges) TreeNode bcn = (null == flashNode) ? null : TPs.getBestCorrNode(thisTree.tree, flashNode, atd.tree, edgeweightLevelUsed); boolean sametree = thisTree.tree == atd.tree; if (!sametree) atd.setFlash((CellGeom)bcn,theGroup.getColor(), -1, -1, sametree); else atd.setFlash((CellGeom)bcn,theGroup.getColor(), x, y, sametree); if (null == flashNode) { // tell it to turn off atd.setFlash(null,theGroup.getColor(), x, y, sametree); } } //System.out.println("TJ set fgo "+flashNode); flashGeomOld = flashNode; } void doSelectGeoms(ArrayList attachedGeoms, boolean selectSubtree, int group, AccordionTreeDrawer thisTree) { clearGroup(group); if (null != attachedGeoms) { Iterator geomIter = attachedGeoms.iterator(); while (geomIter.hasNext()) { CellGeom cg = (CellGeom) geomIter.next(); doSelectGeom(cg, selectSubtree, group, thisTree); System.out.println("this tree node key " + cg.getKey() + " min " + cg.getMin() + " max " + cg.getMax() + " thistree " + thisTree.getKey()); } } requestRedrawAll(); } void doSelectGeom(CellGeom g, boolean selectSubtree, int group, AccordionTreeDrawer thisTree) { System.out.println("key to select: "+g.getKey()); int which = (true == selectSubtree) ? g.getMax() : g.getKey(); addNodesToGroup(g.getKey(), which, group, thisTree); changedMarks(); RangeList r = getGroup(group);// r.setColorTree(new ColorTree(r)); //System.out.println("range tree for selected group " + group + " is: " + r.getColorTree()); } void doLCAGeom(int group, AccordionTreeDrawer thisTree) { if (true) return; clearGroup(group); if(lcaNode.size()<2) { System.out.println("need 2 or more nodes to have a LCA"); return; } Iterator it = lcaNode.iterator(); TreeNode tn1; tn1= (TreeNode)lcaNode.get(0); TreeNode lca = tn1; while(it.hasNext()) lca = lca.lca((TreeNode)it.next()); for(int i=0; i<lcaNode.size(); i++) { TreeNode current = (TreeNode)lcaNode.get(i); while(current != null && current.getKey() != lca.getKey()) { addNodesToGroup(current.getKey(), current.getKey(), group, thisTree); current=current.parent; } } addNodesToGroup(lca.getKey(), lca.getKey(), group, thisTree); changedMarks(); RangeList r = getGroup(group);// r.setColorTree(new ColorTree(r)); } /** * Compute perfectly matched nodes between two trees * * A node X is perfectly matched by a node Y if they have exactly * the same leaf set. * * @see AccordionDrawer.Tree * @see AccordionDrawer.TreeNode * @see TreeJuxtaposer.TreePairs **/ void doStructuralDiff(AccordionTreeDrawer atd1, AccordionTreeDrawer atd2, int group) { Tree t1 = atd1.getTree(); Tree t2 = atd2.getTree(); RangeList groupList = getGroup(group); for(int i = 0; i < t1.nodes.size(); i++) { TreeNode n = (TreeNode)t1.nodes.get(i); float score = TPs.getBestCorrNodeScore(t1, n, t2, edgeweightLevelUsed); n.setBcnScore(score); if (score < getBcnScore()) { // System.out.println("adding node to diffs: " + n); groupList.addRange(n.getKey(), n.getKey(), atd1);// addNodesToGroup(n.getKey(), n.getKey(), group, atd1); } } RangeList diffGroupRangeList = getGroup(diffGroup);// diffGroupRangeList.setColorTree(new ColorTree(diffGroupRangeList)); } void setFocus(CellGeom g, AccordionTreeDrawer atd) { Iterator i = treeDrawers.iterator(); while (i.hasNext()) { AccordionTreeDrawer thisTree = (AccordionTreeDrawer)i.next(); TreeNode n = atd.tree.getNodeByKey(g.getKey()); if (thisTree != atd) { n = TPs.getBestCorrNode(atd.tree, n, thisTree.tree, edgeweightLevelUsed); if (n != null) thisTree.setFocusCell(n.getCell()); else System.out.println("bad focus");; } else { thisTree.setFocusCell(n.getCell()); } } } public String getLabelByFQName(String FQName) { String returnValue = null; TreeNode n; Tree t; Iterator i = treeDrawers.iterator(); while (i.hasNext()) { t = ((AccordionTreeDrawer)i.next()).getTree(); if ((n = t.getNodeByName(FQName)) != null) { returnValue = n.label; } } return returnValue; } public void setBigGrid(boolean on) { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).setBigGrid(on); } public void toggleBigGrid() { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).toggleBigGrid(); } public void setCacheRange(boolean on) { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).setCacheRange(on); } public void toggleCacheRange() { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).toggleCacheRange(); } public void setCheckTime(boolean on) { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).setCheckTime(on); } public void toggleCheckTime() { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).toggleCheckTime(); } public void setColorGrid(boolean on) { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).setColorGrid(on); } public void toggleColorGrid() { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).toggleColorGrid(); } public void setDimBrite(boolean on) { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).setDimBrite(on); } public void toggleDimBrite() { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).toggleDimBrite(); } public boolean getDimBrite() { if (treeDrawers.size() > 0) return ((AccordionTreeDrawer)treeDrawers.get(0)).dimbrite; return false; } public void setDimColors(boolean on) { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).setDimColors(on); } public void toggleDimColors() { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).toggleDimColors(); } public boolean getDimColors() { if (treeDrawers.size() > 0) return ((AccordionTreeDrawer)treeDrawers.get(0)).dimcolors; return false; } public void setDrawLabels(boolean on) { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).setDrawLabels(on); } public void toggleDrawLabels() { Iterator i = treeDrawers.iterator(); while (i.hasNext()) ((AccordionTreeDrawer)i.next()).toggleDrawLabels(); } public boolean getDrawLabels() { if (treeDrawers.size() > 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -