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

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

?? spiral.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.graphics;import java.awt.*;import java.awt.geom.*;/** This Shape implementation represents a spiral curve */public class Spiral implements Shape {    double centerX, centerY;            // The center of the spiral    double startRadius, startAngle;     // The spiral starting point    double endRadius, endAngle;         // The spiral ending point    double outerRadius;                 // the bigger of the two radii    int angleDirection;                 // 1 if angle increases, -1 otherwise    /**     * The constructor.  It takes arguments for the center of the shape, the     * start point, and the end point.  The start and end points are specified     * in terms of angle and radius.  The spiral curve is formed by varying     * the angle and radius smoothly between the two end points.     **/    public Spiral(double centerX, double centerY,		  double startRadius, double startAngle,		  double endRadius, double endAngle)    {	// Save the parameters that describe the spiral	this.centerX = centerX; 	this.centerY = centerY;	this.startRadius = startRadius;	this.startAngle = startAngle;	this.endRadius = endRadius;	this.endAngle = endAngle;	// figure out the maximum radius, and the spiral direction	this.outerRadius = Math.max(startRadius, endRadius);	if (startAngle < endAngle) angleDirection = 1;	else angleDirection = -1;		if ((startRadius < 0) || (endRadius < 0))	    throw new IllegalArgumentException("Spiral radii must be >= 0");    }    /**      * The bounding box of a Spiral is the same as the bounding box of a     * circle with the same center and the maximum radius     **/    public Rectangle getBounds() {	return new Rectangle((int)(centerX-outerRadius),			     (int)(centerY-outerRadius),			     (int)(outerRadius*2), (int)(outerRadius*2));    }    /** Same as getBounds(), but with floating-point coordinates */    public Rectangle2D getBounds2D() {	return new Rectangle2D.Double(centerX-outerRadius, centerY-outerRadius,				      outerRadius*2, outerRadius*2);    }    /**      * A spiral is an open curve, not a not a closed area; it does not have an     * inside and an outsize, so the contains() methods always return false.     **/    public boolean contains(double x, double y) { return false; }    public boolean contains(Point2D p) { return false; }    public boolean contains(Rectangle2D r) { return false; }    public boolean contains(double x, double y, double w, double h) {	return false;    }    /**     * This method is allowed to approximate if it would be too computationally     * intensive to determine an exact answer.  Therefore, we check whether     * the rectangle intersects a circle of the outer radius.  This is a good     * guess for a tight spiral, but less good for a "loose" spiral.      **/    public boolean intersects(double x, double y, double w, double h) {	Shape approx = new Ellipse2D.Double(centerX-outerRadius,					    centerY-outerRadius,					    outerRadius*2, outerRadius*2);	return approx.intersects(x, y, w, h);    }    /** This version of intersects() just calls the one above */    public boolean intersects(Rectangle2D r) {	return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());    }    /**     * This method is the heart of all Shape implementations.  It returns a     * PathIterator that describes the shape in terms of the line and curve     * segments that comprise it.  Our iterator implementation approximates     * the shape of the spiral using line segments only.  We pass in a     * "flatness" argument that tells it how good the approximation must be.     * (smaller numbers mean a better approximation).     */    public PathIterator getPathIterator(AffineTransform at) {	return new SpiralIterator(at, outerRadius/500.0);    }    /**     * Return a PathIterator that describes the shape in terms of line     * segments only, with an approximation quality specified by flatness.     **/    public PathIterator getPathIterator(AffineTransform at, double flatness) {	return new SpiralIterator(at, flatness);    }    /**     * This inner class is the PathIterator for our Spiral shape.  For     * simplicity, it does not describe the spiral path in terms of Bezier     * curve segments, but simply approximates it with line segments.  The     * flatness property specifies how far the approximation is allowed to     * deviate from the true curve.     **/    class SpiralIterator implements PathIterator {	AffineTransform transform;    // How to transform generated coordinates	double flatness;              // How close an approximation	double angle = startAngle;    // Current angle	double radius = startRadius;  // Current radius	boolean done = false;         // Are we done yet?	/** A simple constructor.  Just store the parameters into fields */	public SpiralIterator(AffineTransform transform, double flatness) {	    this.transform = transform;	    this.flatness = flatness;	}	/** 	 * All PathIterators have a "winding rule" that helps to specify what	 * is the inside of a area and what is the outside.  If you fill a	 * spiral (which you're not supposed to do) the winding rule returned	 * here yields better results than the alternative, WIND_EVEN_ODD	 **/	public int getWindingRule() { return WIND_NON_ZERO; }	/** Returns true if the entire path has been iterated */	public boolean isDone() { return done; }	/**	 * Store the coordinates of the current segment of the path into the	 * specified array, and return the type of the segment.  Use	 * trigonometry to compute the coordinates based on the current angle	 * and radius.  If this was the first point, return a MOVETO segment,	 * otherwise return a LINETO segment. Also, check to see if we're done.	 **/	public int currentSegment(float[] coords) {	    // given the radius and the angle, compute the point coords	    coords[0] = (float)(centerX + radius*Math.cos(angle));	    coords[1] = (float)(centerY - radius*Math.sin(angle));	    // If a transform was specified, use it on the coordinates	    if (transform != null) transform.transform(coords, 0, coords, 0,1);	    // If we've reached the end of the spiral remember that fact	    if (angle == endAngle) done = true;	    // If this is the first point in the spiral then move to it	    if (angle == startAngle) return SEG_MOVETO;	    // Otherwise draw a line from the previous point to this one	    return SEG_LINETO;	}	/** This method is the same as above, except using double values */	public int currentSegment(double[] coords) {	    coords[0] = centerX + radius*Math.cos(angle);	    coords[1] = centerY - radius*Math.sin(angle);	    if (transform != null) transform.transform(coords, 0, coords, 0,1);	    if (angle == endAngle) done = true;	    if (angle == startAngle) return SEG_MOVETO;	    else return SEG_LINETO;	}	/** 	 * Move on to the next segment of the path.  Compute the angle and	 * radius values for the next point in the spiral.	 **/	public void next() {	    if (done) return;	    // First, figure out how much to increment the angle.  This	    // depends on the required flatness, and also upon the current	    // radius.  When drawing a circle (which we'll use as our	    // approximation) of radius r, we can maintain a flatness f by	    // using angular increments given by this formula:	    //      a = acos(2*(f/r)*(f/r) - 4*(f/r) + 1)	    // Use this formula to figure out how much we can increment the	    // angle for the next segment.  Note that the formula does not	    // work well for very small radii, so we special case those.	    double x = flatness/radius;	    if (Double.isNaN(x) || (x > .1))		angle += Math.PI/4*angleDirection; 	    else {		double y = 2*x*x - 4*x + 1;		angle += Math.acos(y)*angleDirection;	    }			    // Check whether we've gone past the end of the spiral	    if ((angle-endAngle)*angleDirection > 0) angle = endAngle;	    // Now that we know the new angle, we can use interpolation to	    // figure out what the corresponding radius is.	    double fractionComplete = (angle-startAngle)/(endAngle-startAngle);	    radius = startRadius + (endRadius-startRadius)*fractionComplete;	}    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美精品区一区二区三区| 奇米在线7777在线精品| 亚洲国产美女搞黄色| 免费看欧美美女黄的网站| 韩日av一区二区| 色诱视频网站一区| 亚洲精品在线免费观看视频| 亚洲女同ⅹxx女同tv| 国产一区二区三区四区在线观看| 色狠狠av一区二区三区| 久久久噜噜噜久噜久久综合| 亚洲国产精品尤物yw在线观看| 国产福利视频一区二区三区| 在线不卡欧美精品一区二区三区| 综合婷婷亚洲小说| 国产99久久久精品| 欧美一级日韩一级| 天堂久久一区二区三区| 91国产免费观看| 中文字幕一区二区三区四区| 国产在线精品一区二区夜色| 777精品伊人久久久久大香线蕉| 中文字幕一区二区三区视频| 国产福利一区二区三区在线视频| 日韩一区二区在线看片| 一区二区免费看| 99久久精品免费| 国产精品无圣光一区二区| 韩国视频一区二区| 精品噜噜噜噜久久久久久久久试看 | 欧美系列日韩一区| 亚洲人被黑人高潮完整版| 国产91色综合久久免费分享| ww亚洲ww在线观看国产| 国产在线精品一区二区三区不卡| 日韩欧美国产wwwww| 看电视剧不卡顿的网站| 欧美一区二区播放| 美女诱惑一区二区| 精品国产91乱码一区二区三区| 精一区二区三区| 久久九九国产精品| 不卡一卡二卡三乱码免费网站| 中文字幕一区二区在线观看| 成人av综合在线| 亚洲欧美日韩成人高清在线一区| 99久久精品国产一区| 亚洲专区一二三| 91超碰这里只有精品国产| 免费看日韩精品| 久久久综合九色合综国产精品| 国产美女娇喘av呻吟久久| 中文字幕av一区二区三区高| av激情亚洲男人天堂| 一区二区三区四区视频精品免费| 欧美性高清videossexo| 日本不卡不码高清免费观看| 欧美成人性战久久| 99v久久综合狠狠综合久久| 亚洲人成网站精品片在线观看 | 日本一区二区三区四区| av不卡免费在线观看| 亚洲地区一二三色| 久久伊人蜜桃av一区二区| 成人99免费视频| 午夜影院在线观看欧美| 精品国产精品一区二区夜夜嗨| 成人va在线观看| 日韩和的一区二区| 国产精品污污网站在线观看 | 一区二区三区中文在线观看| 欧美精品第一页| 成人免费三级在线| 亚洲一区二区三区在线播放| 欧美一级欧美一级在线播放| 成人精品一区二区三区中文字幕| 亚洲444eee在线观看| 久久精品日产第一区二区三区高清版| 色综合天天性综合| 韩国女主播一区二区三区| 亚洲欧美日韩电影| 久久久国产精华| 日韩一区二区在线免费观看| 成人精品视频一区二区三区 | 一区二区三区**美女毛片| 亚洲精品在线观| 5858s免费视频成人| 国产91精品精华液一区二区三区| 性做久久久久久久免费看| 国产精品久久久久久久久免费丝袜| 欧美日韩精品久久久| 91麻豆高清视频| 粉嫩aⅴ一区二区三区四区五区| 天天操天天色综合| 亚洲免费在线视频一区 二区| 欧美xxx久久| 91精品国产综合久久香蕉麻豆 | 欧美精品一区二区三区在线播放 | 国内精品第一页| 日韩精品欧美精品| 亚洲精品亚洲人成人网| 国产日产欧美一区| 精品福利在线导航| 日韩一区二区三区三四区视频在线观看 | 亚洲三级在线观看| 中文字幕精品在线不卡| 日韩一区二区在线免费观看| 在线视频国内自拍亚洲视频| www.成人在线| 不卡一区中文字幕| 成人av免费在线观看| 成人精品亚洲人成在线| 国产一区二区三区免费| 狠狠色综合色综合网络| 久国产精品韩国三级视频| 久久精品国产77777蜜臀| 日本sm残虐另类| 麻豆精品视频在线观看免费 | 欧美午夜精品一区二区蜜桃| 成人黄色大片在线观看| 欧美午夜在线观看| 一本一道久久a久久精品| av午夜精品一区二区三区| 不卡欧美aaaaa| 93久久精品日日躁夜夜躁欧美| 91在线精品秘密一区二区| 91免费观看国产| 欧美在线一二三| 欧美猛男男办公室激情| 欧美人xxxx| 911国产精品| 欧美精品一区二区三区蜜桃| 国产色爱av资源综合区| 日本一区二区久久| 一区二区三区成人在线视频| 亚洲一区在线免费观看| 日韩影院精彩在线| 国产精品一卡二| 91丝袜美腿高跟国产极品老师 | 欧美性受xxxx黑人xyx| 欧美一级日韩一级| 国产无遮挡一区二区三区毛片日本| 久久久久久久久蜜桃| 成人免费在线播放视频| 亚洲福利视频一区二区| 美女视频一区二区三区| 成人app在线观看| 制服视频三区第一页精品| 精品久久久久久久人人人人传媒| 国产欧美精品一区二区三区四区| 亚洲精品美国一| 久久精品国产色蜜蜜麻豆| 成人午夜视频免费看| 欧美性猛交xxxxxxxx| 精品国产伦一区二区三区免费| 国产精品每日更新在线播放网址| 亚洲一区二区影院| 国产乱码精品一区二区三 | 国产美女av一区二区三区| 一本到三区不卡视频| 日韩丝袜情趣美女图片| 国产精品久久久久国产精品日日| 视频一区二区中文字幕| 99久久精品免费看国产| 精品国产自在久精品国产| 一区二区视频免费在线观看| 精品无人码麻豆乱码1区2区| 欧美在线视频全部完| 国产欧美视频在线观看| 丝袜亚洲另类丝袜在线| www.欧美亚洲| 久久久久久久久99精品| 亚洲一区二区三区国产| 成人性视频网站| 欧美大度的电影原声| 亚洲一区二区三区在线| 成人av网站免费观看| 精品久久国产老人久久综合| 一区二区三区四区在线免费观看| 国产黄色精品网站| 精品日韩在线一区| 青椒成人免费视频| 欧美麻豆精品久久久久久| 亚洲人一二三区| 不卡视频免费播放| 国产欧美精品区一区二区三区| 麻豆免费精品视频| 日韩午夜精品电影| 午夜私人影院久久久久| 91小视频在线| 麻豆精品久久精品色综合| 在线观看国产一区二区| 中文字幕国产一区二区| 国产一区二区三区美女| 精品国产凹凸成av人导航| 美女视频网站久久| 精品日韩在线观看| 毛片基地黄久久久久久天堂| 欧美一区二区三区啪啪| 日韩vs国产vs欧美|