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

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

?? scribble.java

?? Examples From Java Examples in a Nutshell, 2nd Edition 書中的源碼
?? 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久久香蕉国产日韩欧美9色| 日韩午夜激情视频| 亚洲一二三专区| www.日韩精品| 久久久精品影视| 日本不卡一区二区三区高清视频| 91视频国产观看| 久久精品在这里| 人人超碰91尤物精品国产| 91色porny| 国产精品久久久久久久久快鸭 | 制服视频三区第一页精品| 综合电影一区二区三区| 激情六月婷婷久久| 日韩欧美亚洲一区二区| 日精品一区二区三区| 欧美日韩中文精品| 亚洲精品一二三区| 91免费看片在线观看| 国产精品第四页| jlzzjlzz亚洲女人18| 国产精品人妖ts系列视频| 粉嫩aⅴ一区二区三区四区| 日韩三级.com| 老鸭窝一区二区久久精品| 欧美精品乱码久久久久久| 亚洲最新在线观看| 欧美视频三区在线播放| 午夜视频一区在线观看| 欧美人与性动xxxx| 日韩电影在线观看网站| 欧美一区三区四区| 麻豆久久久久久久| 久久久久九九视频| 国产99久久久久| 国产精品久久久久久妇女6080| 成人黄色在线视频| 成人免费在线观看入口| 在线观看av一区| 午夜欧美一区二区三区在线播放| 制服.丝袜.亚洲.中文.综合| 人人精品人人爱| 久久久久亚洲蜜桃| 91视频国产资源| 婷婷国产v国产偷v亚洲高清| 日韩亚洲欧美在线| 国产精品亚洲视频| 一区二区三区电影在线播| 正在播放亚洲一区| 国产精品一区二区三区四区 | 国产99久久久国产精品免费看| 久久这里只有精品6| av不卡在线播放| 亚洲成精国产精品女| 精品少妇一区二区三区在线播放 | 精品在线播放免费| 国产精品无码永久免费888| 在线精品国精品国产尤物884a| 日日噜噜夜夜狠狠视频欧美人| 久久久国产精品麻豆 | 国产自产视频一区二区三区| 欧美韩日一区二区三区| 欧美怡红院视频| 国产一区二区三区四区在线观看| 亚洲视频1区2区| 日韩欧美久久一区| 色综合天天性综合| 麻豆精品蜜桃视频网站| 有码一区二区三区| 久久奇米777| 欧美亚洲国产一区二区三区| 国产乱子轮精品视频| 一区二区三区美女视频| 国产日韩影视精品| 欧美一区二区高清| 欧洲在线/亚洲| 国产精品一区三区| 日日摸夜夜添夜夜添精品视频| 国产精品国产三级国产a| 日韩视频一区二区三区在线播放| 91美女在线视频| 国产精品一区二区你懂的| 亚洲成av人综合在线观看| 欧美国产激情一区二区三区蜜月| 51精品视频一区二区三区| 99riav一区二区三区| 国产伦精品一区二区三区免费| 日韩成人一区二区三区在线观看| 亚洲精品国产第一综合99久久| 欧美国产精品v| 久久精品水蜜桃av综合天堂| 日韩女同互慰一区二区| 欧美三级蜜桃2在线观看| 91在线观看下载| 国产91精品一区二区麻豆网站| 精品一区二区在线观看| 午夜日韩在线观看| 亚洲va国产va欧美va观看| 亚洲人成网站精品片在线观看| 国产欧美一区二区精品忘忧草| 日韩免费观看高清完整版在线观看| 欧美日韩国产精选| 欧美视频一区在线观看| 欧美亚洲一区二区三区四区| 色狠狠桃花综合| 欧洲国内综合视频| 欧美亚洲综合在线| 欧美日韩在线免费视频| 欧美日韩在线电影| 欧美丰满嫩嫩电影| 欧美一级理论性理论a| 日韩三级免费观看| 久久只精品国产| 国产视频一区二区三区在线观看| 久久蜜臀精品av| 中文字幕精品在线不卡| 国产精品久久精品日日| 亚洲欧美日韩国产中文在线| 亚洲精品国产a| 五月婷婷激情综合| 久久国产综合精品| 国产激情一区二区三区| av成人老司机| 欧美日韩亚洲综合一区| 欧美电视剧在线观看完整版| 精品国产污污免费网站入口| 久久精品人人做人人爽人人| 中文字幕不卡一区| 亚洲精品一二三| 首页欧美精品中文字幕| 国产自产v一区二区三区c| 菠萝蜜视频在线观看一区| 一本大道久久精品懂色aⅴ| 欧美日本国产视频| 久久免费国产精品| 一区二区三区四区在线| 久久电影网站中文字幕| 成人理论电影网| 欧美调教femdomvk| 久久色.com| 亚洲欧美激情视频在线观看一区二区三区 | 国产传媒欧美日韩成人| 91网站视频在线观看| 欧美日韩一区精品| wwwwww.欧美系列| 一区二区三区四区在线播放| 黑人巨大精品欧美一区| 99久久伊人精品| 日韩一区二区三区视频在线观看| 国产精品三级视频| 日韩av一区二区在线影视| av在线这里只有精品| 日韩欧美成人激情| 亚洲欧美日本韩国| 国产一区二区三区久久悠悠色av| 色狠狠综合天天综合综合| 精品国产伦一区二区三区免费| 亚洲女同女同女同女同女同69| 激情五月婷婷综合| 欧美日韩在线播放一区| 国产日本欧美一区二区| 免费成人在线观看| 91国模大尺度私拍在线视频| 久久久久久久久久久电影| 爽好久久久欧美精品| 在线免费观看一区| 国产精品视频观看| 国产曰批免费观看久久久| 欧美高清一级片在线| 一区二区三区在线观看动漫| 成人性视频网站| 日韩精品一区二区三区在线播放| 一区二区三区四区精品在线视频| 国产91清纯白嫩初高中在线观看| 欧美成人精品3d动漫h| 亚瑟在线精品视频| 色综合 综合色| 国产精品网友自拍| 国产精品99精品久久免费| 日韩欧美一级精品久久| 天天操天天综合网| 欧美男生操女生| 亚洲一区二区三区四区的| 色婷婷国产精品综合在线观看| 国产精品丝袜久久久久久app| 国产麻豆日韩欧美久久| 久久日韩精品一区二区五区| 激情五月婷婷综合网| 亚洲精品在线观看网站| 久久99国产精品免费| 日韩美女主播在线视频一区二区三区| 亚洲综合色成人| 欧美私模裸体表演在线观看| 一区二区三区鲁丝不卡| 日本丰满少妇一区二区三区| 亚洲一区在线视频观看|