Categories:

Audio (13)

Biotech (29)

Bytecode (35)

Database (77)

Framework (7)

Game (7)

General (512)

Graphics (53)

I/O (32)

IDE (2)

JAR Tools (86)

JavaBeans (16)

JDBC (89)

JDK (337)

JSP (20)

Logging (103)

Mail (54)

Messaging (8)

Network (71)

PDF (94)

Report (7)

Scripting (83)

Security (32)

Server (119)

Servlet (17)

SOAP (24)

Testing (50)

Web (19)

XML (301)

Other Resources:

JDK 1.1 Source Code Directory

JDK 1.1 source code directory contains Java source code for JDK 1.1 core classes: "C:\fyicenter\jdk-1.1.8\src".

Here is the list of Java classes of the JDK 1.1 source code:

✍: FYIcenter

**⏎ java/awt/Polygon.java**

/* * @(#)Polygon.java 1.19 01/12/10 * * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package java.awt; /** * The <code>Polygon</code> class encapsulates a description of a * closed, two-dimensional region within a coordinate space. This * region is bounded by an arbitrary number of line segments, each of * which is one side of the polygon. Internally, a polygon * comprises of a list of (<i>x</i>, <i>y</i>) coordinate pairs, * where each pair defines a <i>vertex</i> of the polygon, and two * successive pairs are the endpoints of a line that is a side of the * polygon. The first and final pairs of (<i>x</i>, <i>y</i>) * points are joined by a line segment that closes the polygon. * * @version 1.19, 12/10/01 * @author Sami Shaio * @author Herb Jellinek * @since JDK1.0 */ public class Polygon implements Shape, java.io.Serializable { /** * The total number of points. * @since JDK1.0 */ public int npoints = 0; /** * The array of <i>x</i> coordinates. * @since JDK1.0 */ public int xpoints[] = new int[4]; /** * The array of <i>y</i> coordinates. * @since JDK1.0 */ public int ypoints[] = new int[4]; /* * Bounds of the polygon. */ protected Rectangle bounds = null; /* * JDK 1.1 serialVersionUID */ private static final long serialVersionUID = -6460061437900069969L; /** * Creates an empty polygon. * @since JDK1.0 */ public Polygon() { } /** * Constructs and initializes a polygon from the specified * parameters. * @param xpoints an array of <i>x</i> coordinates. * @param ypoints an array of <i>y</i> coordinates. * @param npoints the total number of points in the polygon. * @exception NegativeArraySizeException if the value of * <code>npoints</code> is negative. * @since JDK1.0 */ public Polygon(int xpoints[], int ypoints[], int npoints) { this.npoints = npoints; this.xpoints = new int[npoints]; this.ypoints = new int[npoints]; System.arraycopy(xpoints, 0, this.xpoints, 0, npoints); System.arraycopy(ypoints, 0, this.ypoints, 0, npoints); } /** * Translates the vertices by <code>deltaX</code> along the * <i>x</i> axis and by <code>deltaY</code> along the * <i>y</i> axis. * @param deltaX the amount to translate along the <i>x</i> axis * @param deltaY the amount to translate along the <i>y</i> axis * @since JDK1.1 */ public void translate(int deltaX, int deltaY) { for (int i = 0; i < npoints; i++) { xpoints[i] += deltaX; ypoints[i] += deltaY; } if (bounds != null) { bounds.translate(deltaX, deltaY); } } /* * Calculate the bounding box of the points passed to the constructor. * Sets 'bounds' to the result. */ void calculateBounds(int xpoints[], int ypoints[], int npoints) { int boundsMinX = Integer.MAX_VALUE; int boundsMinY = Integer.MAX_VALUE; int boundsMaxX = Integer.MIN_VALUE; int boundsMaxY = Integer.MIN_VALUE; for (int i = 0; i < npoints; i++) { int x = xpoints[i]; boundsMinX = Math.min(boundsMinX, x); boundsMaxX = Math.max(boundsMaxX, x); int y = ypoints[i]; boundsMinY = Math.min(boundsMinY, y); boundsMaxY = Math.max(boundsMaxY, y); } bounds = new Rectangle(boundsMinX, boundsMinY, boundsMaxX - boundsMinX, boundsMaxY - boundsMinY); } /* * Update the bounding box to fit the point x, y. */ void updateBounds(int x, int y) { if (x < bounds.x) { bounds.width = bounds.width + (bounds.x - x); bounds.x = x; } else { bounds.width = Math.max(bounds.width, x - bounds.x); // bounds.x = bounds.x; } if (y < bounds.y) { bounds.height = bounds.height + (bounds.y - y); bounds.y = y; } else { bounds.height = Math.max(bounds.height, y - bounds.y); // bounds.y = bounds.y; } } /** * Appends a point to this polygon. * <p> * If an operation that calculates the bounding box of this polygon * has already been performed, such as <code>getBounds</code> * or <code>contains</code>, then this method updates the bounding box. * @param x the <i>x</i> coordinate of the point. * @param y the <i>y</i> coordinate of the point. * @see java.awt.Polygon#getBounds * @see java.awt.Polygon#contains * @since JDK1.0 */ public void addPoint(int x, int y) { if (npoints == xpoints.length) { int tmp[]; tmp = new int[npoints * 2]; System.arraycopy(xpoints, 0, tmp, 0, npoints); xpoints = tmp; tmp = new int[npoints * 2]; System.arraycopy(ypoints, 0, tmp, 0, npoints); ypoints = tmp; } xpoints[npoints] = x; ypoints[npoints] = y; npoints++; if (bounds != null) { updateBounds(x, y); } } /** * Gets the bounding box of this polygon. The bounding box is the * smallest rectangle whose sides are parallel to the <i>x</i> and * <i>y</i> axes of the coordinate space, and that can completely * contain the polygon. * @return a rectangle that defines the bounds of this polygon. * @since JDK1.1 */ public Rectangle getBounds() { return getBoundingBox(); } /** * @deprecated As of JDK version 1.1, * replaced by <code>getBounds()</code>. */ public Rectangle getBoundingBox() { if (bounds == null) { calculateBounds(xpoints, ypoints, npoints); } return bounds; } /** * Determines whether the specified point is inside the Polygon. * Uses an even-odd insideness rule (also known as an alternating * rule). * @param p the point to be tested */ public boolean contains(Point p) { return contains(p.x, p.y); } /** * Determines whether the specified point is contained by this polygon. * <p> * (The <code>contains</code> method is based on code by * Hanpeter van Vliet [hvvliet@inter.nl.net].) * @param x the <i>x</i> coordinate of the point to be tested. * @param y the <i>y</i> coordinate of the point to be tested. * @return <code>true</code> if the point (<i>x</i>, <i>y</i>) * is contained by this polygon; * <code>false</code> otherwise. * @since JDK1.1 */ public boolean contains(int x, int y) { return inside(x, y); } /** * @deprecated As of JDK version 1.1, * replaced by <code>contains(int, int)</code>. */ public boolean inside(int x, int y) { if (getBoundingBox().inside(x, y)) { int hits = 0; int ySave = 0; // Find a vertex that's not on the halfline int i = 0; while (i < npoints && ypoints[i] == y) { i++; } // Walk the edges of the polygon for (int n = 0; n < npoints; n++) { int j = (i + 1) % npoints; int dx = xpoints[j] - xpoints[i]; int dy = ypoints[j] - ypoints[i]; // Ignore horizontal edges completely if (dy != 0) { // Check to see if the edge intersects // the horizontal halfline through (x, y) int rx = x - xpoints[i]; int ry = y - ypoints[i]; // Deal with edges starting or ending on the halfline if (ypoints[j] == y && xpoints[j] >= x) { ySave = ypoints[i]; } if (ypoints[i] == y && xpoints[i] >= x) { if ((ySave > y) != (ypoints[j] > y)) { hits--; } } // Tally intersections with halfline float s = (float)ry / (float)dy; if (s >= 0.0 && s <= 1.0 && (s * dx) >= rx) { hits++; } } i = j; } // Inside if number of intersections odd return (hits % 2) != 0; } return false; } }

**⏎ java/awt/Polygon.java**

Â

**â‡’** Backup JDK 1.1 Installation Directory

**â‡** JDK 1.1 classes.zip - Java Core Classes

2018-11-17, 92017👍, 0💬

Popular Posts:

ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify ex...

The Jakarta-ORO Java classes are a set of text-processing Java classes that provide Perl5 compatible...

kernel.jar is a component in iText Java library to provide low-level functionalities. iText Java lib...

Commons Pool provides an Object-pooling API, with three major aspects: 1. A generic object pool inte...

XStream is a simple library to serialize objects to XML and back again. JAR File Size and Download L...