亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? graph.java

?? 一個小公司要求給寫的很簡單的任務管理系統。
?? JAVA
字號:
/* * @(#)Graph.java	1.18 06/02/22 *  * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: *  * -Redistribution of source code must retain the above copyright notice, this *  list of conditions and the following disclaimer. *  * -Redistribution 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 name of Sun Microsystems, Inc. or the names of contributors may  * be used to endorse or promote products derived from this software without  * specific prior written permission. *  * This software is provided "AS IS," without a warranty of any kind. ALL  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST  * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,  * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY  * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. *  * You acknowledge that this software is not designed, licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. *//* * @(#)Graph.java	1.18 06/02/22 */import java.util.*;import java.awt.*;import java.applet.Applet;import java.awt.event.*;class Node {    double x;    double y;    double dx;    double dy;    boolean fixed;    String lbl;}class Edge {    int from;    int to;    double len;}class GraphPanel extends Panel    implements Runnable, MouseListener, MouseMotionListener {    Graph graph;    int nnodes;    Node nodes[] = new Node[100];    int nedges;    Edge edges[] = new Edge[200];    Thread relaxer;    boolean stress;    boolean random;    int numMouseButtonsDown = 0;    GraphPanel(Graph graph) {	this.graph = graph;	addMouseListener(this);    }    int findNode(String lbl) {	for (int i = 0 ; i < nnodes ; i++) {	    if (nodes[i].lbl.equals(lbl)) {		return i;	    }	}	return addNode(lbl);    }    int addNode(String lbl) {	Node n = new Node();	n.x = 10 + 380*Math.random();	n.y = 10 + 380*Math.random();	n.lbl = lbl;	nodes[nnodes] = n;	return nnodes++;    }    void addEdge(String from, String to, int len) {	Edge e = new Edge();	e.from = findNode(from);	e.to = findNode(to);	e.len = len;	edges[nedges++] = e;    }    public void run() {        Thread me = Thread.currentThread();	while (relaxer == me) {	    relax();	    if (random && (Math.random() < 0.03)) {		Node n = nodes[(int)(Math.random() * nnodes)];		if (!n.fixed) {		    n.x += 100*Math.random() - 50;		    n.y += 100*Math.random() - 50;		}		graph.play(graph.getCodeBase(), "audio/drip.au");	    }	    try {		Thread.sleep(100);	    } catch (InterruptedException e) {		break;	    }	}    }    synchronized void relax() {	for (int i = 0 ; i < nedges ; i++) {	    Edge e = edges[i];	    double vx = nodes[e.to].x - nodes[e.from].x;	    double vy = nodes[e.to].y - nodes[e.from].y;	    double len = Math.sqrt(vx * vx + vy * vy);            len = (len == 0) ? .0001 : len;	    double f = (edges[i].len - len) / (len * 3);	    double dx = f * vx;	    double dy = f * vy;	    nodes[e.to].dx += dx;	    nodes[e.to].dy += dy;	    nodes[e.from].dx += -dx;	    nodes[e.from].dy += -dy;	}	for (int i = 0 ; i < nnodes ; i++) {	    Node n1 = nodes[i];	    double dx = 0;	    double dy = 0;	    for (int j = 0 ; j < nnodes ; j++) {		if (i == j) {		    continue;		}		Node n2 = nodes[j];		double vx = n1.x - n2.x;		double vy = n1.y - n2.y;		double len = vx * vx + vy * vy;		if (len == 0) {		    dx += Math.random();		    dy += Math.random();		} else if (len < 100*100) {		    dx += vx / len;		    dy += vy / len;		}	    }	    double dlen = dx * dx + dy * dy;	    if (dlen > 0) {		dlen = Math.sqrt(dlen) / 2;		n1.dx += dx / dlen;		n1.dy += dy / dlen;	    }	}	Dimension d = getSize();	for (int i = 0 ; i < nnodes ; i++) {	    Node n = nodes[i];	    if (!n.fixed) {		n.x += Math.max(-5, Math.min(5, n.dx));		n.y += Math.max(-5, Math.min(5, n.dy));            }            if (n.x < 0) {                n.x = 0;            } else if (n.x > d.width) {                n.x = d.width;            }            if (n.y < 0) {                n.y = 0;            } else if (n.y > d.height) {                n.y = d.height;            }	    n.dx /= 2;	    n.dy /= 2;	}	repaint();    }    Node pick;    boolean pickfixed;    Image offscreen;    Dimension offscreensize;    Graphics offgraphics;    final Color fixedColor = Color.red;    final Color selectColor = Color.pink;    final Color edgeColor = Color.black;    final Color nodeColor = new Color(250, 220, 100);    final Color stressColor = Color.darkGray;    final Color arcColor1 = Color.black;    final Color arcColor2 = Color.pink;    final Color arcColor3 = Color.red;    public void paintNode(Graphics g, Node n, FontMetrics fm) {	int x = (int)n.x;	int y = (int)n.y;	g.setColor((n == pick) ? selectColor : (n.fixed ? fixedColor : nodeColor));	int w = fm.stringWidth(n.lbl) + 10;	int h = fm.getHeight() + 4;	g.fillRect(x - w/2, y - h / 2, w, h);	g.setColor(Color.black);	g.drawRect(x - w/2, y - h / 2, w-1, h-1);	g.drawString(n.lbl, x - (w-10)/2, (y - (h-4)/2) + fm.getAscent());    }    public synchronized void update(Graphics g) {	Dimension d = getSize();	if ((offscreen == null) || (d.width != offscreensize.width) || (d.height != offscreensize.height)) {	    offscreen = createImage(d.width, d.height);	    offscreensize = d;	    if (offgraphics != null) {	        offgraphics.dispose();	    }	    offgraphics = offscreen.getGraphics();	    offgraphics.setFont(getFont());	}	offgraphics.setColor(getBackground());	offgraphics.fillRect(0, 0, d.width, d.height);	for (int i = 0 ; i < nedges ; i++) {	    Edge e = edges[i];	    int x1 = (int)nodes[e.from].x;	    int y1 = (int)nodes[e.from].y;	    int x2 = (int)nodes[e.to].x;	    int y2 = (int)nodes[e.to].y;	    int len = (int)Math.abs(Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) - e.len);	    offgraphics.setColor((len < 10) ? arcColor1 : (len < 20 ? arcColor2 : arcColor3)) ;	    offgraphics.drawLine(x1, y1, x2, y2);	    if (stress) {		String lbl = String.valueOf(len);		offgraphics.setColor(stressColor);		offgraphics.drawString(lbl, x1 + (x2-x1)/2, y1 + (y2-y1)/2);		offgraphics.setColor(edgeColor);	    }	}	FontMetrics fm = offgraphics.getFontMetrics();	for (int i = 0 ; i < nnodes ; i++) {	    paintNode(offgraphics, nodes[i], fm);	}	g.drawImage(offscreen, 0, 0, null);    }    //1.1 event handling    public void mouseClicked(MouseEvent e) {    }    public void mousePressed(MouseEvent e) {        numMouseButtonsDown++;        addMouseMotionListener(this);	double bestdist = Double.MAX_VALUE;	int x = e.getX();	int y = e.getY();	for (int i = 0 ; i < nnodes ; i++) {	    Node n = nodes[i];	    double dist = (n.x - x) * (n.x - x) + (n.y - y) * (n.y - y);	    if (dist < bestdist) {		pick = n;		bestdist = dist;	    }	}	pickfixed = pick.fixed;	pick.fixed = true;	pick.x = x;	pick.y = y;	repaint();	e.consume();    }    public void mouseReleased(MouseEvent e) {        numMouseButtonsDown--;        removeMouseMotionListener(this);        pick.fixed = pickfixed;        pick.x = e.getX();        pick.y = e.getY();        if (numMouseButtonsDown == 0) {            pick = null;        }        repaint();        e.consume();    }    public void mouseEntered(MouseEvent e) {    }    public void mouseExited(MouseEvent e) {    }    public void mouseDragged(MouseEvent e) {	pick.x = e.getX();	pick.y = e.getY();	repaint();	e.consume();    }    public void mouseMoved(MouseEvent e) {    }    public void start() {	relaxer = new Thread(this);	relaxer.start();    }    public void stop() {	relaxer = null;    }}public class Graph extends Applet implements ActionListener, ItemListener {    GraphPanel panel;    Panel controlPanel;    Button scramble = new Button("Scramble");    Button shake = new Button("Shake");    Checkbox stress = new Checkbox("Stress");    Checkbox random = new Checkbox("Random");    public void init() {	setLayout(new BorderLayout());	panel = new GraphPanel(this);	add("Center", panel);	controlPanel = new Panel();	add("South", controlPanel);	controlPanel.add(scramble); scramble.addActionListener(this);	controlPanel.add(shake); shake.addActionListener(this);	controlPanel.add(stress); stress.addItemListener(this);	controlPanel.add(random); random.addItemListener(this);	String edges = getParameter("edges");	for (StringTokenizer t = new StringTokenizer(edges, ",") ; t.hasMoreTokens() ; ) {	    String str = t.nextToken();	    int i = str.indexOf('-');	    if (i > 0) {		int len = 50;		int j = str.indexOf('/');		if (j > 0) {		    len = Integer.valueOf(str.substring(j+1)).intValue();		    str = str.substring(0, j);		}		panel.addEdge(str.substring(0,i), str.substring(i+1), len);	    }	}	Dimension d = getSize();	String center = getParameter("center");	if (center != null){	    Node n = panel.nodes[panel.findNode(center)];	    n.x = d.width / 2;	    n.y = d.height / 2;	    n.fixed = true;	}    }    public void destroy() {        remove(panel);        remove(controlPanel);    }    public void start() {	panel.start();    }    public void stop() {	panel.stop();    }    public void actionPerformed(ActionEvent e) {	Object src = e.getSource();	if (src == scramble) {	    play(getCodeBase(), "audio/computer.au");	    Dimension d = getSize();	    for (int i = 0 ; i < panel.nnodes ; i++) {		Node n = panel.nodes[i];		if (!n.fixed) {		    n.x = 10 + (d.width-20)*Math.random();		    n.y = 10 + (d.height-20)*Math.random();		}	    }	    return;	}	if (src == shake) {	    play(getCodeBase(), "audio/gong.au");	    Dimension d = getSize();	    for (int i = 0 ; i < panel.nnodes ; i++) {		Node n = panel.nodes[i];		if (!n.fixed) {		    n.x += 80*Math.random() - 40;		    n.y += 80*Math.random() - 40;		}	    }	}    }    public void itemStateChanged(ItemEvent e) {	Object src = e.getSource();	boolean on = e.getStateChange() == ItemEvent.SELECTED;	if (src == stress) panel.stress = on;	else if (src == random) panel.random = on;    }    public String getAppletInfo() {	return "Title: GraphLayout \nAuthor: <unknown>";    }    public String[][] getParameterInfo() {	String[][] info = {	    {"edges", "delimited string", "A comma-delimited list of all the edges.  It takes the form of 'C-N1,C-N2,C-N3,C-NX,N1-N2/M12,N2-N3/M23,N3-NX/M3X,...' where C is the name of center node (see 'center' parameter) and NX is a node attached to the center node.  For the edges connecting nodes to each other (and not to the center node) you may (optionally) specify a length MXY separated from the edge name by a forward slash."},	    {"center", "string", "The name of the center node."}	};	return info;    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美视频一区| 成人免费视频在线观看| 欧洲色大大久久| 99久久夜色精品国产网站| 丁香婷婷综合色啪| 岛国精品一区二区| 99久久免费国产| 欧美亚洲动漫制服丝袜| 欧美美女直播网站| 欧美精品久久99久久在免费线| 欧美日精品一区视频| 8x福利精品第一导航| 91精品婷婷国产综合久久性色 | 日韩精品1区2区3区| 午夜av区久久| 久久99久久久欧美国产| 丰满少妇久久久久久久| 色综合天天性综合| 欧美军同video69gay| 欧美变态tickling挠脚心| 国产欧美日韩视频一区二区| 一区二区三区在线视频观看| 亚洲不卡一区二区三区| 精品一区二区三区视频| 9久草视频在线视频精品| 欧美性受xxxx黑人xyx| 欧美成人在线直播| 亚洲欧美综合另类在线卡通| 亚洲国产精品久久一线不卡| 国内一区二区视频| 欧洲一区二区三区在线| 精品国产乱码久久久久久夜甘婷婷| 久久久久久久久岛国免费| 自拍偷自拍亚洲精品播放| 丝袜诱惑制服诱惑色一区在线观看| 狠狠色丁香婷婷综合久久片| 日本韩国精品在线| 精品美女一区二区三区| 一区二区三区欧美亚洲| 国产毛片精品一区| 欧美视频一区二| 欧美激情一区在线观看| 日韩成人一级片| 99在线精品视频| 91精品国产91久久久久久一区二区 | 91精品国产色综合久久ai换脸| 久久久久亚洲综合| 天天综合天天综合色| 成人动漫中文字幕| 欧美成人一区二区三区片免费 | 日韩三级在线观看| 亚洲蜜臀av乱码久久精品蜜桃| 精久久久久久久久久久| 欧美久久一二三四区| 日韩理论片网站| 成人精品一区二区三区四区| 欧美午夜影院一区| 国产欧美精品区一区二区三区 | 激情综合色丁香一区二区| 欧美曰成人黄网| 18欧美亚洲精品| 粉嫩在线一区二区三区视频| 日韩免费高清视频| 日韩国产高清在线| 欧美精品日日鲁夜夜添| 亚洲不卡在线观看| 欧美精品tushy高清| 亚洲美女区一区| 91精彩视频在线| 亚洲激情在线播放| 在线观看不卡一区| 亚洲一区二区三区美女| 欧美亚洲免费在线一区| 亚洲综合av网| 欧美精品少妇一区二区三区| 亚洲va天堂va国产va久| 欧美日韩一区高清| 午夜精品久久久久| 日韩限制级电影在线观看| 美女视频黄免费的久久| 久久色在线观看| 成人午夜短视频| 玉足女爽爽91| 欧美日韩精品欧美日韩精品一 | 国产精品妹子av| 99精品国产视频| 一二三区精品福利视频| 在线视频国内自拍亚洲视频| 亚洲伊人伊色伊影伊综合网| 欧美三级在线看| 日韩va欧美va亚洲va久久| 欧美一区二区三区免费在线看| 九九在线精品视频| 国产欧美日韩精品在线| 色域天天综合网| 视频在线观看一区二区三区| 日韩精品影音先锋| 不卡影院免费观看| 亚洲超碰精品一区二区| 久久综合色播五月| 99视频超级精品| 日韩成人精品在线观看| 久久综合国产精品| 99久免费精品视频在线观看 | 欧美精品一区二区三区很污很色的| 国产成人午夜高潮毛片| 亚洲伊人色欲综合网| 欧美一级免费大片| www.色精品| 日本系列欧美系列| 国产精品黄色在线观看| 4438x成人网最大色成网站| 国产麻豆精品久久一二三| 亚洲三级在线免费观看| 日韩欧美一区二区在线视频| 成人激情综合网站| 视频在线在亚洲| 成人欧美一区二区三区视频网页 | 国产丝袜欧美中文另类| 欧美影片第一页| 国产成人综合网站| 三级在线观看一区二区| 国产精品天干天干在线综合| 欧美精品视频www在线观看| va亚洲va日韩不卡在线观看| 久久激情五月激情| 亚洲不卡一区二区三区| 中文字幕五月欧美| 欧美一区二区视频网站| 91麻豆高清视频| 国产一区二区三区黄视频 | 丁香另类激情小说| 美国十次综合导航| 亚洲一区电影777| 国产精品成人免费在线| 日韩一区二区在线播放| 欧美日韩高清在线| 色婷婷综合久久久中文字幕| 国产不卡视频一区二区三区| 精品一区二区久久久| 日韩经典中文字幕一区| 一区二区三区四区亚洲| 中文字幕一区二区三区不卡| 久久综合视频网| 欧美成人aa大片| 欧美一区二区三区免费视频| 欧美日韩精品三区| 欧美日韩国产在线播放网站| 在线免费观看视频一区| 色综合天天综合网天天狠天天| 成人午夜精品一区二区三区| 国产精品一二三四五| 国产精品综合二区| 国产sm精品调教视频网站| 黑人巨大精品欧美黑白配亚洲| 日本不卡123| 蜜桃精品在线观看| 加勒比av一区二区| 国产一区二区三区免费观看| 狠狠狠色丁香婷婷综合久久五月| 美国av一区二区| 国产一区二区看久久| 懂色av一区二区三区免费观看| 成人av网站在线观看| 成人av小说网| av不卡免费在线观看| 欧亚一区二区三区| 制服丝袜中文字幕一区| 精品久久久久99| 国产精品美女一区二区三区| 国产精品网站一区| 亚洲精品国产精华液| 日韩影视精彩在线| 国产激情视频一区二区在线观看| 99久久er热在这里只有精品66| 色94色欧美sute亚洲线路一久 | 91麻豆免费在线观看| 日本丰满少妇一区二区三区| 91精品国产免费| 中文字幕第一区第二区| 亚洲影院久久精品| 久久国产欧美日韩精品| 97精品超碰一区二区三区| 欧美美女一区二区| 久久久影院官网| 亚洲综合色丁香婷婷六月图片| 免费的成人av| 91论坛在线播放| 日韩欧美一卡二卡| 中文字幕一区二区在线观看| 午夜精品久久久久久久久| 国产高清在线精品| 欧美日韩精品三区| 综合久久一区二区三区| 久久99精品国产91久久来源| 色综合久久88色综合天天| 久久这里只有精品首页| 亚洲自拍与偷拍| 懂色av一区二区三区免费观看 | 91久久精品日日躁夜夜躁欧美|