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

📄 accordiondrawer.java

📁 生物物种进化历程的演示
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/*   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;import java.awt.Color;import java.io.*;import java.util.*;import java.awt.event.*;import BitmapFont.BitmapFontsFamily;import gl4java.*;import gl4java.awt.*;import gl4java.utils.glut.*;import gl4java.utils.glut.fonts.*;/** * An abstract class representing a multi-scale rectangular grid on which  * shapes consisting of horizontal and vertical line segments (such as * trees and graphs) can be drawn *  *  * @author  Tamara Munzner, Serdar Tasiran * @version  * @see     AccordionDrawer.AccordionTreeDrawer * @see     TreeJuxtaposer.AccordionTreeDrawerFinal */public abstract class AccordionDrawer extends GLCanvas implements MouseListener, MouseMotionListener, KeyListener {//	protected SplitTree splitTree;	static String fontFile = "/OlduvaiFont";	static BitmapFontsFamily bff = new BitmapFontsFamily(fontFile);	static boolean fontInitialized = false;	public static int getDescent(int fontheight)	{		return bff.getDescent(fontheight);	}	public static int stringWidth(String name, int fontheight)	{		return bff.stringWidth(name, fontheight);	}	/**	 * Initialize variable font family for tree labels. fontFamily[i]	 * is the font should be used when there enough space for font	 * with size i+minFontSize. The reason this is stored in an array	 * is to speed up the look up time. 	 * 	 * @author Li Zhang	 * @see TreeNode.drawInCell	 */	private void initializeFont() {		// bitmap fonts		try {			bff.read();		} catch (IOException e) {			System.out.println("cannot produce fonts");			return;		}		System.out.println("bitmap fonts initialized" + " " + bff.nofonts);	}	    protected int count;    private static int getTimeOfDayCounter;    GLUTFunc glut;    public GLCapabilities glc;	// the 2 lines of splits in X and Y directions	protected SplitLine[] splitLine = new SplitLine[2];	protected Vector ToDrawQ;	public boolean flag = false;	public static boolean loaded = false; // don't draw until the data is loaded	protected boolean startFrame = false;	protected boolean continueFrame = false;		// never called	public void drawBackgroundBox(Color boxColor)	{		splitLine[X].drawBackground(boxColor, frameNum);		splitLine[Y].drawBackground(boxColor, frameNum);	}    /**    * Size of the window to draw the AccordionDrawer in    * winsize[0] = w(idth)    * winsize[0] = h(eight)    */     protected int winsize[] = new int[2];    protected int nameStuckVal;    protected long dynamicStart, continueStart;	protected long dynamicTime;	protected long now; 	protected int frameNum;    public int changedMarksFrame;	public boolean rendermode = false;		    Color backgroundColor;    Color labelColor;    Color labelBackColor;    Color labelHiColor;    Color labelBackHiColor;    protected Color rubberbandColor;    // make sure that highlighted stuff is always visible, even it    // might otherwise overlap with nonhighlighted stuff: always draw    // it in front.    float backplane;    public float hiliteplane;    float labelplane;    float labelbgplane;    protected float gridplane;    protected float objplane;    public float interactionplane;	public boolean drawBackground;    // cells    public GridCell focusCell;    public GridCell defaultFocusCell;	/**	 * The root GridCell that contains all others. It is at level (gridDepth-1).	 * rootCell = grids[gridDepth-1][0][0]	 */	// it's the top level root of all quad trees in a quad grid cell system	// it's the vertical binary tree root of all splitlines to choose a horizontal binary tree root in a binary cell system	public GridCell rootCell;		/**	 * store lens pixel	 */	protected double xlenspixels[][];	protected double ylenspixels[][];	protected double zoompixels[];	public Lens lens;	public Lens oldLens;	protected boolean doLensView;	protected boolean mouseChanged;	protected boolean justPressed;	protected boolean doZoom;	protected ArrayList drawnLabels = new ArrayList();    public int[] gridDepth;    /**     * How many cells there are in the bottom level of the quadtree,     * indexed by X and Y.      */    public int bottomSize[] = new int[2];    /**     * minContext is the percentage of screen area guaranteed for smooshed things */    public double minContextInside = .01;     public double minContextPeriphery = .01;     /**     * How much to shrink a cell-to-cell area if it is smaller than 2*inflateIncr;     */    protected double shrinkFactor = .5;     public final static int X=0;    public final static int Y=1;    public Hashtable toMove;    public final boolean doDoubleBuffer = true; // this is our intent to double buffer        public boolean ignoreProgressive = false;        protected boolean doublebuffer; // this gets set on/off with the gl state of the same name    public boolean keepDrawing;    public boolean keepMoving;        //  set before drawing, the next draw will only output to file    // file name is window title with incrementing counter, .eps)    public boolean takeSnapshot;    public final static String snapShotExtension = ".eps";    public static String snapshotName = "";    public BufferedWriter snapShotWriter = null;        public void newSnapshotName(String base)    {    	String directory = ".";    	try		{    		directory = new File(directory).getCanonicalPath();		}    	catch (IOException ioe)		{    		System.out.println("Error resolving canonical path for this current directory");    		return;		}//    	directory = directory.substring(0, directory.lastIndexOf('/'));//    	directory = directory.substring(0, directory.lastIndexOf('/'));//    	.substring(0, directory.lastIndexOf('/')).substring(0, directory.lastIndexOf('/'));    	//    	if (snapShotWriter != null)//    	{//    		try//			{//    			snapShotWriter.close();//			}//    		catch (IOException ioe)//			{//    			System.out.println("Error: IOException trying to close an open writer: " + snapShotWriter.toString());//			}//    	}    	base = base.replace(' ', '_').replace(':', '.');    	snapshotName = directory + "/" + base + snapShotExtension;    	boolean success = false;    	int incrementNumber = 0;    	BufferedReader br = null;    	while (!success)    	{    		try			{    			br = new BufferedReader( new FileReader( snapshotName ) );			}    		catch (FileNotFoundException fnfe)			{    			System.out.println("ok, found a file: " + snapshotName);    			success = true;			}    		if (!success)    		{    			try				{    				br.close();				}    			catch (IOException ioe)				{    				System.out.println("Error: IOException trying to close a known open file: " + snapshotName);				}    			snapshotName = directory + "/" + base + (incrementNumber++) + snapShotExtension;    		}    	}    	try		{    		FileWriter fw = new FileWriter(snapshotName);    		snapShotWriter = new BufferedWriter( fw );		}    	catch (IOException ioe)		{    		System.out.println("Error: IOException trying to open a file for writing: " + snapshotName);		}    	    }        protected float flashBoxWidth;    protected boolean doBox;    protected InteractionBox flashBox;    protected InteractionBox flashBoxOld;	public InteractionBox baseBox;    protected CellGeom flashGeom;    protected CellGeom flashGeomOld;    protected Color flashCol;    protected int flashX, flashY, flashXOld, flashYOld;    public boolean showalg;    public boolean colorgrid;    public boolean biggrid;    public boolean nogrid;    public boolean nogeoms;    public boolean noflash;    public int expandleaves;    public boolean showdiffs;    private int linethickness;    public boolean drawlabels;    public boolean labelposright;    public boolean labeldrawback;    public boolean labelpopup;    public boolean dimcolors;    public boolean dimbrite;    public boolean linkednav;    public boolean labeltransp;    public boolean cacherange;    public boolean checktime;    public boolean stoprendering;    public boolean dumpstats;    public boolean horiz; // if true, draw horizontal (like trees), false for sequences  :)	public boolean drawsplits;	    /**     * Order to draw elements in scene.      * BRUTEFORCE / 0: start from tree root, doesn't support highlighting     * 2: FROMFOCUSCELL / 2: start from focusCell, add attached objects parents/children to queue     */    public int draworder;    public static final int BRUTEFORCE = 0;    public static final int FROMFOCUSCELL = 1;    /**       Whether to guarantee visibility. Default true.    */    public boolean guarvis;    protected boolean mouseDragging;    public boolean transitionAnimating;    //boolean overlay;    protected boolean doingFlash;    int numAnimSteps; // in an animated transition    protected double inflateIncr;        // ST: Is this out of date?    // array of array lists, one for each column of the bottom level 0    // grid cells. the size of this array is equal to the depth of the    // tree. each arraylist in this array has the bottom cells for    // that column, which is a variable number since the grid is sparse.     //     // so we can access the hierarchical grid either from the top with    // the rootCell or from the bottom with the level 0 cells.     double minCellDims[] = new double[2];    int key;    protected PrintWriter stats;    int numCellsDrawnThisFrame;	public int drawDirection;//	public int upDown;//	public static final int LEFT = 0, RIGHT = 1, UP = 2, DOWN = 3;	public int[]  xInterval, yInterval;    	public static String[] stateMachine = {"GL_DEPTH_TEST"};	public static boolean[] stateMachineOn = {false};	    public AccordionDrawer(int w, int h) {    		super(w,h);	System.out.println("new accordion drawer: width: " + w +" height: " + h);	winsize[0] = w;	winsize[1] = h;		if (!fontInitialized) {		initializeFont();		fontInitialized = true;	}		//ToDrawQ = Collections.synchronizedSortedSet(new TreeSet());	ToDrawQ = new Vector();		frameNum = 0;	changedMarksFrame = 0;	minCellDims[X] = 1;	minCellDims[Y] = 1;//	setDoubleBuffer(doDoubleBuffer, true);	GLContext.gljNativeDebug = false;	GLContext.gljClassDebug = false;	GLContext.gljThreadDebug = false;	backgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.0f);	labelColor = new Color(0.0f, 1.0f, 0.0f, 0.0f);	labelBackColor = new Color(0.2f, 0.2f, 0.2f, 0.0f);	labelHiColor = new Color(0.2f, 0.2f, 0.2f, 0.0f);	labelBackHiColor = new Color(0.0f, 1.0f, 0.0f, 0.0f);	dynamicTime = 30;	addMouseListener(this);	addMouseMotionListener(this);	addKeyListener(this);

⌨️ 快捷键说明

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