📄 splittransition.java
字号:
/* Copyright (c) 2002 Compaq Computer Corporation SOFTWARE RELEASE Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the names of Compaq Research, Compaq Computer Corporation nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL COMPAQ COMPUTER CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/package AccordionDrawer;/** * A class that helps compute coordinates for smooth animated transitions * * * @author Tamara Munzner, Serdar Tasiran, Li Zhang, Yunhong Zhou * * @see AccordionDrawer.GridCell */public class SplitTransition implements Comparable { private SplitLine splitLine; private int index; // index of split in splitLine private int curStep; private int maxStep;// private double increment; private double endPos; private double startPos; private AccordionDrawer ad; public SplitTransition(SplitLine splitLine, int index, double endPos, int numSteps) { this.splitLine = splitLine; this.index = index; this.endPos = (double)endPos; this.ad = splitLine.ad; startPos = splitLine.splitCells[index].splitValue; curStep = 0; maxStep = numSteps; if (endPos > 1 || endPos < 0) { System.out.println("end position is too much for a split transition increment: " + endPos); }// increment = (double)(endPos - splitLine.splitValues[index])/numSteps; } public void incr() { curStep++; } public boolean done() { return curStep > maxStep; } // ends this transition public void end() {// System.out.println("Ending transition: " + this); splitLine.splitCells[index].splitValue = endPos; } public void move() { splitLine.splitCells[index].splitValue = (double)curStep/(double)maxStep * (endPos - startPos) + startPos;// if (curStep <= maxStep)// splitLine.splitValues[index] += increment;// else// splitLine.splitValues[index] = endPos; if (splitLine.splitCells[index].splitValue < 0 || splitLine.splitCells[index].splitValue > 1) System.out.println("bad split line set in move: " + splitLine.splitCells[index].splitValue); } // public void incr() {// curStep++;// double howfar = ((double)curStep)/maxStep;// aCurValue = aNewValue*howfar + aOldValue*(1.0-howfar);// bCurValue = bNewValue*howfar + bOldValue*(1.0-howfar);// } public String toString() { return "(" +(splitLine.horizontal?"X":"Y")+ " " + index + "@"+ splitLine.splitCells[index].splitValue + " -> " + index + "@"+ endPos+", " + curStep + "/" + maxStep+")"; } /* (non-Javadoc) * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(Object arg0) { if (!(arg0 instanceof SplitTransition)) return -1; SplitTransition target = (SplitTransition)arg0; if (equals(target)) return 0; if (splitLine.isHorizontal() && !target.splitLine.isHorizontal()) // horizontal > vertical return 1; else if (target.splitLine.isHorizontal() && !splitLine.isHorizontal()) // horizontal > vertical return -1; else if (target.index < index) // index > target.index => this > target return 1; return -1; } public boolean equals(Object arg0) { if (!(arg0 instanceof SplitTransition)) return false; SplitTransition target = (SplitTransition)arg0; return target.splitLine.isHorizontal() == splitLine.isHorizontal() && target.index == index; } public Integer getIndex() { return new Integer(index); } public Integer getHashKey() { return new Integer((index + 1) * (splitLine.horizontal ? 1 : -1)); } /** * @return */ public AccordionDrawer getDrawer() { return ad; }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -