⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 accordiondrawer.java

📁 生物物种进化历程的演示
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
//	setDoubleBuffer(!showalg, true, false); // only for a clear??	requestRedraw();//	setDoubleBuffer(originalDoubleBuffer, false);    }    public void toggleShowAlg() {setShowAlg(!showalg);}    public void reset() {//		boolean originalDoubleBuffer = getDoubleBuffer();//		setDoubleBuffer(doDoubleBuffer, true); // just to clear?  this is eventually done in requestRedraw	resetGridUniform();	focusCell = defaultFocusCell;	keepMoving = false;	requestRedraw();//	setDoubleBuffer(originalDoubleBuffer, false);    }	    public void changedMarks() {	changedMarksFrame = frameNum;    }    public void clearQueue() {	ToDrawQ.clear();    }    //    public void addCellToQueue(GridCell cell) { //	if (cell == null) return;//	ToDrawQ.add(cell); // adding uses the comparator function//	cell.enqueuedFrame = frameNum;//    }//    public GridCell findEnclosingCell(int arow, int acol, int brow, int bcol) {//	int i;//	int aShift[] = new int[2];//	int bShift[] = new int[2];//	aShift[0] = acol;//	aShift[1] = arow;//	bShift[0] = bcol;//	bShift[1] = brow;//	int depth = 0;//	while ( (aShift[0] != bShift[0]) || (aShift[1] != bShift[1])) {//	    for (i = 0; i < 2; i++) {//		aShift[i] = aShift[i]>>1; //		bShift[i] = bShift[i]>>1; //	    }//	    depth++;//	}//        return splitTree.getGridCell(depth, aShift[1], aShift[0]);//    }	public void resetGridUniform() {	for (int xy = 0; xy < 2; xy++) {		splitLine[xy].resetSplitValues();	}	toMove.clear(); // stop all animations	transitionAnimating = false;	}    /**    * Converts pixel coordinates into relative "fractional" coordinates in [0,1]    */ 	    public double s2w(int s, int xy) { return ((double)s)/winsize[xy];}    public double s2w(double s, int xy) { return ((double)s)/winsize[xy];}    /**    * Converts "fractional" coordinates in [0,1] into pixel coordinates    */     public int w2s(double w, int xy) { return (int) Math.floor(w*winsize[xy]);}    public int getWinMaxX() { return winsize[X]; }    public int getWinMaxY() { return winsize[Y]; }    public int getWinMax(int xy) { return winsize[xy]; }    public abstract CellGeom pickGeom(int x, int y);//	return rootCell.pickDescend(x, y);//    }    public void setCellHighlight(GridCell c, boolean on) {	c.setDrawBackground(on);    }    public void setColorGL(Color col) {		float thecol[] = new float[3];		col.getRGBColorComponents(thecol);		gl.glColor3f(thecol[0], thecol[1], thecol[2]);    }     public boolean drawStart(boolean swap) { //System.out.println("drawStart " + swap);    	boolean returnValue = glj.gljMakeCurrent();    	if (swap) glj.gljSwap();    	return returnValue;	}        public void drawEnd(boolean swap) {     	//System.out.println("drawEnd " + swap);	gl.glFlush();	if (swap) glj.gljSwap();//	glj.gljCheckGL(); // probably not necessary?	glj.gljFree();    }	    public abstract CellGeom pickAttached(int x, int y); // ArrayList of CellGeoms    public abstract void initCells();    public abstract ArrayList getColorsForGridCell(GridCell c, int objkey);    public abstract ArrayList getColorsForCellGeom(CellGeom c);    public abstract void doFlash();    public abstract void drawNextFancy(CellGeom g);    abstract protected void drawPreContFrame();    abstract protected void drawPreNewFrame();    abstract protected void drawPostFrame();    abstract protected void drawPostScene();    abstract protected void drawBruteForce();    abstract protected void seedQueue();    abstract public void subpixelDraw(GridCell c);    public abstract OlduvaiObject getOlduvaiObject();    public abstract void drawReferenceLine();    OlduvaiObject o;        abstract public int getBottomGrid( boolean horizontal );	/**	 * @return	 */	public double getMinCellDims(int xy) {		return minCellDims[xy];	}	/**	 * @param is	 */	public void setMinCellDims(int xy, double is) {		minCellDims[xy] = is;	}	/**	 * @return	 */	public double getObjplane() {		return objplane;	}	/**	 * @return	 */	public double getLabelplane() {		return labelplane;	}	/**	 * @return	 */	public boolean isDoingFlash() {		return doingFlash;	}	/**	 * @return	 */	public int getWinsize(int xy) {		return winsize[xy];	}		public void setDrawSplits(boolean on)	{		drawsplits = on;	}		public void toggleDrawSplits()	{		drawsplits = !drawsplits;	}	/**	 * @return	 */	public ArrayList getDrawnLabels() {		return drawnLabels;	}	protected static final int FAR_FROM_STUCK = -1;	protected static final int MIN_STUCK_X = 0;	protected static final int MIN_STUCK_Y = 1;	protected static final int MAX_STUCK_X = 2;	protected static final int MAX_STUCK_Y = 3;	// -1: not close to a stuck line	//  0: close to min stuck X	//  1: close to min stuck Y	//  2: close to max stuck X	//  3: close to max stuck Y	// create an interaction box on a stuck line to mark that a stuck line has been	//  chosen to move with the next drag	protected InteractionBox createBoxFromCells(int stuckType)	{//		System.out.println("Create box from cells with stuckType: " + stuckType);		if (stuckType == FAR_FROM_STUCK) return null;		int minSplit[] = {-1, -1};		int maxSplit[] = {splitLine[X].size, splitLine[Y].size};		if (stuckType == MIN_STUCK_X)			maxSplit[X] = -1;		else if (stuckType == MIN_STUCK_Y)			maxSplit[Y] = -1;		else if (stuckType == MAX_STUCK_X)			minSplit[X] = splitLine[X].size;		else if (stuckType == MAX_STUCK_Y)			minSplit[Y] = splitLine[Y].size;		return new InteractionBox(minSplit, maxSplit, null, this);	}	/**		 * Make an InteractionBox from the GridCells nearest to the box of the mousedrag.		 * Expects dragStart[X]/Y, dragEnd[X]/Y to be set. 		 * 		 * @author Francois Guimbretiere, Tamara Munzner */	protected InteractionBox createBoxFromCells(int[] dragStart, int[] dragEnd) {		// Convert from the start and end of a drag motion to absolute		// min/max coordinates so that computation can be carried out		// independent of the direction that the user chose to drag.		int min[] = new int[2];		int max[] = new int[2];		for (int xy = 0; xy < 2; xy++) {			if (dragStart[xy] < dragEnd[xy]) {				min[xy] = dragStart[xy];				max[xy] = dragEnd[xy];			} else {				min[xy] = dragEnd[xy];				max[xy] = dragStart[xy];			}		}		int[] minSplit = {splitLine[X].getMinIndexForPixelValue(min[X], frameNum), 				splitLine[Y].getMinIndexForPixelValue(min[Y], frameNum)};		int[] maxSplit = {splitLine[X].getMinIndexForPixelValue(max[X], frameNum)+1,				splitLine[Y].getMinIndexForPixelValue(max[Y], frameNum)+1};		return new InteractionBox(minSplit, maxSplit, null, this);//)minCell, maxCell, null, this));		}	/**		 * Make an InteractionBox from the GridCells nearest to the box of the mousedrag.		 * Expects dragStart[X]/Y, dragEnd[X]/Y to be set. 		 * 		 * @author Francois Guimbretiere, Tamara Munzner */	// baseBox.dragStart, dragEnd positions are in pixels; where mouse started and is now while dragging	// basebox is defined by 4 split lines (2 movable, 2 not) and is currently being resized		// CRFP: return 2 integers, pixel differences for baseBox movable lines in X and Y	protected int[] createRectFromPick(InteractionBox baseBox) {		// if they pick close enough to a corner, 		// use baseBox for the other corner//		System.out.println("interactions happen here, start to log them or something");		int[] returnArray = new int[2]; // x min, y min, x max, y max (-1 for unchanged values)		for (int xy = X; xy <= Y; xy++)		{			int pixelMinContextInside = w2s(minContextInside, xy);			int stuckPixelPosition = w2s(splitLine[xy].getAbsoluteValue(baseBox.stuckLineIndex[xy], frameNum), xy);			int dragLength = baseBox.dragStart[xy] - baseBox.dragEnd[xy];			returnArray[xy] = baseBox.originalMovePixelPosition[xy] - dragLength;			if (baseBox.moveLineIndex[xy] > baseBox.stuckLineIndex[xy] &&				returnArray[xy] < stuckPixelPosition + pixelMinContextInside)			{ // moveLine is bigger than stuck, max line is moving					returnArray[xy] = stuckPixelPosition + pixelMinContextInside;			}			else if (baseBox.moveLineIndex[xy] < baseBox.stuckLineIndex[xy] &&				returnArray[xy] > stuckPixelPosition - pixelMinContextInside)			{ // moveline is smaller than stuck, min line is moving				returnArray[xy] = stuckPixelPosition - pixelMinContextInside;			}		}		return returnArray;	}	// assert baseBox is not null	protected void moveStuckPosition(InteractionBox baseBox)	{		while (transitionAnimating)			endAllTransitions(); // end transitions		// CRFP: return 2 integers, pixel differences for baseBox movable lines in X and Y		int[] rectBox = createRectFromPick(baseBox);		double newPos;		int xy = X;		if (baseBox.getMinLine(X) != baseBox.getMaxLine(X))			xy = Y;		double stuckValue[] = {splitLine[xy].getMinStuckValue(), splitLine[xy].getMaxStuckValue()};				if (baseBox.getMinLine(xy) == -1) // minstuck moving		{			newPos = s2w(rectBox[xy], xy);			if (newPos > stuckValue[1] - minContextInside)				splitLine[xy].setMinStuckValue(stuckValue[1] - minContextInside);			else if (newPos < SplitLine.defaultMinStuckValue)				splitLine[xy].setMinStuckValue(SplitLine.defaultMinStuckValue); 			else				splitLine[xy].setMinStuckValue(newPos);		}		else // maxStuck moving		{			newPos = s2w(rectBox[xy], xy);			if (newPos < stuckValue[0] + minContextInside)				splitLine[xy].setMaxStuckValue(stuckValue[0] + minContextInside);			else if (newPos > SplitLine.defaultMaxStuckValue)				splitLine[xy].setMaxStuckValue(SplitLine.defaultMaxStuckValue);			else				splitLine[xy].setMaxStuckValue(newPos);		}//		System.out.println("newPos: " + newPos + " oldStuck: " + stuckValue[0] + " " + stuckValue[1]);					incrementFrameNumber(); // so compute place this frame will update, this can be moved to after transitions are created		keepMoving = true; // a user movement?		requestRedraw(); // redraw the frame, this will enact the movements in the move queue	}	/**	 * @return	 */	public Vector getToDrawQ() {		return ToDrawQ;	}		/**	 * @return	 */	public SplitLine getSplitLine(int xy) {		return splitLine[xy];	}		public void incrementFrameNumber()	{		frameNum++;	}		/**	 * @return	 */	public InteractionBox getFlashBox()	{		return flashBox;	}	/**	 * @return Returns the flashCol.	 */	public Color getFlashCol() {		return flashCol;	}		public void drawText(double x, double y, String name, int fontheight, Color col, double zplane,			Color outlineColor)	{//		if (outlineColor != null)//		{//			final int shadowDepth = 1;//			double delta[] = { s2w(shadowDepth, X), s2w(shadowDepth, Y)};//			for (int xc = -1; xc < 2; xc+=2)//				for (int yc = -1; yc < 2; yc+=2)//					drawText(x + xc * delta[X], y + yc * delta[Y], name, fontheight, outlineColor, zplane - 0.01, null);			//		}		if (takeSnapshot)		{			try			{				snapShotWriter.write("/Arial findfont " +					fontheight + " scalefont setfont " +					w2s(x, X) + " " + w2s(y, Y) + " moveto " +					"gsave 1 -1 scale (" + name + ") " +					col.getRed() / 255f	+ " " + 					col.getGreen() / 255f + " " + 					col.getBlue() / 255f + " setrgbcolor show grestore\n");			} catch (IOException ioe) {				System.out.println("Error: IOException while trying to write cell names to file: "					+ snapShotWriter.toString());			}		}		else		{			if (outlineColor != null)			{				final int shadowDepth = 1;				double delta[] = { s2w(shadowDepth, X), s2w(shadowDepth, Y)};				for (int xc = -1; xc < 2; xc+=2)					for (int yc = -1; yc < 2; yc+=2)						drawText(x + xc * delta[X], y + yc * delta[Y], name, fontheight, outlineColor, zplane - 0.01, null);						}			setColorGL(col);			gl.glRasterPos3d(x, y, zplane);			bff.drawString(gl, name, fontheight);		}	}	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -