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

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

?? scribble.java

?? JAVA數據傳送的程序。教會你一些不會但很重要的東西!
?? JAVA
字號:
/* * Copyright (c) 2000 David Flanagan.  All rights reserved. * This code is from the book Java Examples in a Nutshell, 2nd Edition. * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied. * You may study, use, and modify it for any non-commercial purpose. * You may distribute it non-commercially as long as you retain this notice. * For a commercial use license, or to purchase the book (recommended), * visit http://www.davidflanagan.com/javaexamples2. */package com.davidflanagan.examples.datatransfer;import java.awt.*;import java.awt.geom.*;import java.awt.datatransfer.*;import java.io.Serializable;import java.util.StringTokenizer;/** * This class represents a scribble composed of any number of "polylines". * Each "polyline" is set of connected line segments.  A scribble is created * through a series of calls to the moveto() and lineto() methods.  moveto() * specifies the starting point of a new polyline, and lineto() adds a new * point to the end of the current polyline().   * * This class implements the Shape interface which means that it can be drawn * using the Java2D graphics API * * It also implements the Transferable interface, which means that it can  * easily be used with cut-and-paste and drag-and-drop.  It defines a custom * DataFlavor, scribbleDataFlavor, which transfers Scribble objects as Java * objects.  However, it also supports cut-and-paste and drag-and-drop based * on a portable string representation of the scribble.  The toString() * and parse() methods write and read this string format **/public class Scribble implements Shape, Transferable, Serializable, Cloneable {    protected double[] points = new double[64]; // The scribble data    protected int numPoints = 0;                // The current number of points    double maxX = Double.NEGATIVE_INFINITY;     // The bounding box     double maxY = Double.NEGATIVE_INFINITY;    double minX = Double.POSITIVE_INFINITY;    double minY = Double.POSITIVE_INFINITY;    /**      * Begin a new polyline at (x,y).  Note the use of Double.NaN in the     * points array to mark the beginning of a new polyline     **/    public void moveto(double x, double y) {	if (numPoints + 3 > points.length) reallocate();	// Mark this as the beginning of a new line	points[numPoints++] = Double.NaN;	// The rest of this method is just like lineto();	lineto(x, y);    }    /**     * Add the point (x,y) to the end of the current polyline      **/    public void lineto(double x, double y) {	if (numPoints + 2 > points.length) reallocate();	points[numPoints++] = x;	points[numPoints++] = y;	// See if the point enlarges our bounding box	if (x > maxX) maxX = x;	if (x < minX) minX = x;	if (y > maxY) maxY = y;	if (y < minY) minY = y;    }    /**     * Append the Scribble s to this Scribble     **/    public void append(Scribble s) {	int n = numPoints + s.numPoints;	double[] newpoints = new double[n];	System.arraycopy(points, 0, newpoints, 0, numPoints);	System.arraycopy(s.points, 0, newpoints, numPoints, s.numPoints);	points = newpoints;	numPoints = n;	minX = Math.min(minX, s.minX);	maxX = Math.max(maxX, s.maxX);	minY = Math.min(minY, s.minY);	maxY = Math.max(maxY, s.maxY);    }    /**     * Translate the coordinates of all points in the Scribble by x,y     **/    public void translate(double x, double y) {	for(int i = 0; i < numPoints; i++) {	    if (Double.isNaN(points[i])) continue;	    points[i++] += x;	    points[i] += y;	}	minX += x; maxX += x;	minY += y; maxY += y;    }    /** An internal method to make more room in the data array */    protected void reallocate() {	double[] newpoints = new double[points.length * 2];	System.arraycopy(points, 0, newpoints, 0, numPoints);	points = newpoints;    }    /** Clone a Scribble object and its internal array of data */    public Object clone() {	try {	    Scribble s = (Scribble) super.clone(); // make a copy of all fields	    s.points = (double[]) points.clone();  // copy the entire array	    return s;	}	catch (CloneNotSupportedException e) {  // This should never happen	    return this;	}    }     /** Convert the scribble data to a textual format */    public String toString() {	StringBuffer b = new StringBuffer();	for(int i = 0; i < numPoints; i++) {	    if (Double.isNaN(points[i])) {		b.append("m ");	    }	    else {		b.append(points[i]);		b.append(' ');	    }	}	return b.toString();    }    /**      * Create a new Scribble object and initialize it by parsing a string of     * coordinate data in the format produced by toString()     **/    public static Scribble parse(String s) throws NumberFormatException {	StringTokenizer st = new StringTokenizer(s);	Scribble scribble = new Scribble();	while(st.hasMoreTokens()) {	    String t = st.nextToken();	    if (t.charAt(0) == 'm') {		scribble.moveto(Double.parseDouble(st.nextToken()),				Double.parseDouble(st.nextToken()));	    }	    else {		scribble.lineto(Double.parseDouble(t),				Double.parseDouble(st.nextToken()));	    }	}	return scribble;    }    // ========= The following methods implement the Shape interface ========         /** Return the bounding box of the Shape */    public Rectangle getBounds() {	return new Rectangle((int)(minX-0.5f), (int)(minY-0.5f),			     (int)(maxX-minX+0.5f), (int)(maxY-minY+0.5f));    }                                                                   /** Return the bounding box of the Shape */    public Rectangle2D getBounds2D() {	return new Rectangle2D.Double(minX, minY, maxX-minX, maxY-minY);    }                                                                   /** Our shape is an open curve, so it never contains anything */    public boolean contains(Point2D p) { return false; }    public boolean contains(Rectangle2D r) { return false; }    public boolean contains(double x, double y) { return false; }     public boolean contains(double x, double y, double w, double h) {	return false;    }    /**     * Determine if the scribble intersects the specified rectangle by testing     * each line segment individually      **/    public boolean intersects(Rectangle2D r) {	if (numPoints < 4) return false;	int i = 0;	double x1, y1, x2 = 0.0, y2 = 0.0;	while(i < numPoints) {	    if (Double.isNaN(points[i])) { // If we're beginning a new line		i++;               // Skip the NaN		x2 = points[i++];		y2 = points[i++];	    }	    else {		x1 = x2;		y1 = y2;		x2 = points[i++];		y2 = points[i++];		if (r.intersectsLine(x1, y1, x2, y2)) return true;	    }	}	return false;    }    /** Test for intersection by invoking the method above */    public boolean intersects(double x, double y, double w, double h){	return intersects(new Rectangle2D.Double(x,y,w,h));    }    /**     * Return a PathIterator object that tells Java2D how to draw this scribble     **/    public PathIterator getPathIterator(AffineTransform at) {	return new ScribbleIterator(at);    }                                                                   /**     * Return a PathIterator that doesn't include curves.  Ours never does.     **/    public PathIterator getPathIterator(AffineTransform at, double flatness) {	return getPathIterator(at);    }    /**     * This inner class implements the PathIterator interface to describe     * the shape of a scribble.  Since a Scribble is composed of arbitrary     * movetos and linetos, we simply return their coordinates     **/    public class ScribbleIterator implements PathIterator {	protected int i = 0;                 // Position in array	protected AffineTransform transform;	public ScribbleIterator(AffineTransform transform) {	    this.transform = transform;	}	/** How to determine insideness and outsideness for this shape */	public int getWindingRule() { return PathIterator.WIND_NON_ZERO; }	/** Have we reached the end of the scribble path yet? */	public boolean isDone() { return i >= numPoints; }	/** Move on to the next segment of the path */	public void next() {	    if (Double.isNaN(points[i])) i += 3;	    else i += 2;	}	/** 	 * Get the coordinates of the current moveto or lineto as floats	 **/	public int currentSegment(float[] coords) {	    int retval;	    if (Double.isNaN(points[i])) {       // If its a moveto		coords[0] = (float)points[i+1];		coords[1] = (float)points[i+2];		retval = SEG_MOVETO;	    }	    else {		coords[0] = (float)points[i];		coords[1] = (float)points[i+1];		retval = SEG_LINETO;	    }	    // If a transform was specified, use it on the coordinates	    if (transform != null) transform.transform(coords, 0, coords, 0,1);	    return retval;	}	/** 	 * Get the coordinates of the current moveto or lineto as doubles	 **/	public int currentSegment(double[] coords) {	    int retval;	    if (Double.isNaN(points[i])) {		coords[0] = points[i+1];		coords[1] = points[i+2];		retval = SEG_MOVETO;	    }	    else {		coords[0] = points[i];		coords[1] = points[i+1];		retval = SEG_LINETO;	    }	    if (transform != null) transform.transform(coords, 0, coords, 0,1);	    return retval;	}    }        //====== The following methods implement the Transferable interface =====    // This is the custom DataFlavor for Scribble objects     public static DataFlavor scribbleDataFlavor =	new DataFlavor(Scribble.class, "Scribble");    // This is a list of the flavors we know how to work with    public static DataFlavor[] supportedFlavors = {	scribbleDataFlavor,	DataFlavor.stringFlavor    };    /** Return the data formats or "flavors" we know how to transfer */    public DataFlavor[] getTransferDataFlavors() {	return (DataFlavor[]) supportedFlavors.clone();    }    /** Check whether we support a given flavor */    public boolean isDataFlavorSupported(DataFlavor flavor) {	return (flavor.equals(scribbleDataFlavor) ||		flavor.equals(DataFlavor.stringFlavor));    }    /**     * Return the scribble data in the requested format, or throw an exception     * if we don't support the requested format     **/    public Object getTransferData(DataFlavor flavor)	throws UnsupportedFlavorException    {	if (flavor.equals(scribbleDataFlavor)) { return this; }	else if (flavor.equals(DataFlavor.stringFlavor)) { return toString(); }	else throw new UnsupportedFlavorException(flavor);    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩在线一区二区| 国产日韩欧美一区二区三区综合 | 久久久久国产精品厨房| 91搞黄在线观看| 精品影视av免费| 亚洲国产另类av| 专区另类欧美日韩| 久久综合网色—综合色88| 日本久久一区二区| 成人黄色网址在线观看| 美女看a上一区| 亚洲第一电影网| 亚洲理论在线观看| 欧美国产精品一区二区三区| 欧美大白屁股肥臀xxxxxx| 欧美亚洲高清一区| 99re这里只有精品首页| 国产在线播放一区二区三区| 日韩精品电影在线| 亚洲国产精品综合小说图片区| 亚洲欧美一区二区久久| 国产欧美精品区一区二区三区| 欧美一级电影网站| 欧美精品123区| 欧美日韩在线观看一区二区| 一本一本久久a久久精品综合麻豆| 国产福利一区在线| 国产综合久久久久久鬼色| 蜜桃一区二区三区四区| 午夜欧美大尺度福利影院在线看 | 视频精品一区二区| 一区二区三区日本| 亚洲已满18点击进入久久| 亚洲欧美韩国综合色| 国产精品成人午夜| 国产精品的网站| √…a在线天堂一区| **性色生活片久久毛片| 中文字幕一区二区三区av| 国产精品国产三级国产普通话99| 国产精品水嫩水嫩| 亚洲色欲色欲www在线观看| 中文字幕一区二区三区在线播放| 中文字幕一区二区三区四区不卡 | 国产精品久久三| 国产精品麻豆欧美日韩ww| 中文欧美字幕免费| 亚洲欧美日韩国产一区二区三区| 亚洲视频一区二区在线| 亚洲国产中文字幕| 日本亚洲视频在线| 国产一区在线视频| 成人一级片在线观看| 99久久婷婷国产综合精品| 色婷婷香蕉在线一区二区| 欧美无人高清视频在线观看| 欧美片网站yy| 久久久综合激的五月天| 中文字幕不卡的av| 一区二区理论电影在线观看| 亚洲福利一二三区| 久久狠狠亚洲综合| 成人激情校园春色| 欧美日韩一区国产| 日韩精品一区二区三区swag| 欧美国产欧美亚州国产日韩mv天天看完整| 国产精品国产三级国产专播品爱网| 一区二区三区在线免费| 欧美aaa在线| 99精品偷自拍| 欧美日韩一区二区三区免费看| 91精品国产综合久久婷婷香蕉| 精品福利视频一区二区三区| 国产精品伦一区二区三级视频| 亚洲国产一区二区a毛片| 国内成人自拍视频| 色欧美88888久久久久久影院| 91精品国产综合久久蜜臀 | 一区二区高清在线| 美女爽到高潮91| eeuss影院一区二区三区 | 国产色综合久久| 一区二区三区日韩精品视频| 乱中年女人伦av一区二区| www.日韩精品| 日韩欧美国产精品| 亚洲欧美aⅴ...| 国产美女在线精品| 精品视频在线视频| 中国色在线观看另类| 婷婷夜色潮精品综合在线| 成人高清伦理免费影院在线观看| 欧美三级在线看| 国产精品久久久久四虎| 六月婷婷色综合| 在线精品视频一区二区三四| 欧美国产日韩a欧美在线观看| 日韩国产欧美视频| 91丝袜美女网| 国产三级精品三级在线专区| 日本伊人色综合网| 欧美视频第二页| 国产精品久久久久久户外露出| 蜜臀久久99精品久久久久久9| 91女厕偷拍女厕偷拍高清| 精品福利一二区| 青青草伊人久久| 欧美日韩精品一区二区天天拍小说| 国产精品久久国产精麻豆99网站| 国产在线不卡一区| 日韩美女视频在线| 日韩黄色免费网站| 欧美日韩精品一区二区三区四区| 日韩久久一区二区| 成人免费精品视频| 日本一区二区成人在线| 国产精品自拍一区| 精品日韩成人av| 激情五月播播久久久精品| 日韩欧美一级在线播放| 日本视频在线一区| 3d动漫精品啪啪一区二区竹菊| 亚洲一级二级在线| 欧美午夜理伦三级在线观看| 亚洲女人小视频在线观看| 91视频com| 日韩理论片一区二区| 91热门视频在线观看| 国产精品对白交换视频| 99re这里都是精品| 亚洲手机成人高清视频| 91片在线免费观看| 亚洲精品视频在线看| 91黄色小视频| 亚洲第四色夜色| 欧美精选在线播放| 奇米精品一区二区三区在线观看 | 一区二区国产盗摄色噜噜| 91福利视频网站| 亚洲自拍偷拍九九九| 欧美日韩国产一二三| 免费成人性网站| xvideos.蜜桃一区二区| 国产成人久久精品77777最新版本| 久久网站最新地址| 成人国产在线观看| 尤物在线观看一区| 91麻豆精品国产自产在线| 久久精品国产精品亚洲红杏| 精品国产乱码久久久久久图片 | 亚洲色图欧美在线| 色av成人天堂桃色av| 午夜久久久影院| 日韩一级完整毛片| 国产一区激情在线| 亚洲视频在线观看三级| 欧美三级中文字幕在线观看| 蜜芽一区二区三区| 中文字幕欧美激情一区| 99热国产精品| 午夜精品福利视频网站| 欧美不卡123| 99视频精品免费视频| 无码av免费一区二区三区试看| 日韩亚洲欧美一区二区三区| 国产成人在线色| 亚洲已满18点击进入久久| 日韩欧美国产成人一区二区| 波多野结衣精品在线| 亚洲成人激情自拍| 久久久久久日产精品| 欧日韩精品视频| 国内不卡的二区三区中文字幕| 国产精品女上位| 欧美日韩一区二区在线观看 | 久久久久久亚洲综合影院红桃 | 奇米影视7777精品一区二区| 久久久99精品久久| 欧美日韩1234| 粉嫩13p一区二区三区| 亚洲国产成人av网| 国产日产欧美一区二区三区| 欧美乱妇20p| 波多野结衣精品在线| 日本欧美一区二区三区| 国产精品美女久久久久高潮| 欧美久久久久久蜜桃| av中文字幕亚洲| 欧美a级一区二区| 一区二区三区精品在线观看| 久久看人人爽人人| 91麻豆精品国产91久久久久久久久| 高清视频一区二区| 蜜臀a∨国产成人精品| 亚洲激情图片一区| 欧美国产日韩亚洲一区| 欧美电影免费观看高清完整版在 | 国产精品亚洲成人| 日本欧美大码aⅴ在线播放| 亚洲精品国产高清久久伦理二区 |