Geometry - Java 2D Oracle official tutorial translation (Bilingual)

Translation from Official Oracle tutorial

Geometric Primitives


The Java 2D API provides a useful set of standard shapes such as points, lines, rectangles, arcs, ellipses, and curves.

The Java 2D API provides a useful set of standard graphics, such as points, lines, rectangles, arcs, ellipses, and curves.

The most important package to define common geometric primitives is the java.awt.geom package.

The most important package for defining common geometry is the java.awt.geom package.

Arbitrary shapes can be represented by combinations of straight geometric primitives.

Irregular shapes can be described by a combination of neat geometry.

The Shape interface represents a geometric shape, which has an outline and an interior.

The Shape interface represents a profile and internal geometry.

This interface provides a common set of methods for describing and inspecting two-dimensional geometric objects and supports curved line segments and multiple sub-shapes.

In order to describe and check 2D geometric objects, and support curve segments and multi seed graphics,
This interface provides a set of common methods.

The Graphics class supports only straight line segments. The Shape interface can support curves segments.

The Graphics class only supports line segments. The Shape interface can support curve segments.

For more details about how to draw and fill shapes, see the Working with Geometry lesson.

For more details on how to draw and fill figures, see geometry operations.


spot


The Point2D class defines a point representing a location in (x, y) coordinate space.

The Point2D class defines a point that represents a position in (x, y) coordinate space.

The term "point" in the Java 2D API is not the same as a pixel. A point has no area, does not contain a color, and cannot be rendered.

The term "point" differs from pixel in the Java 2D API. A point has no region or color and cannot be rendered.

Points are used to create other shapes. The Point2D class also includes a method for calculating the distance between two points.

Points are used to create other shapes. The Point2D class also contains a method to calculate the distance between two points.

straight line


The Line2D class is an abstract class that represents a line.
However, in the source code annotation of Line2D class, This Line2D represents a line segment in (x,y)coordinate space
And then I will set the endpoint of line, so line here should refer to the line segment.
In this tutorial, there are some ambiguities about the lines and line segments. In some places, the line segments are shown in the pictures, but the words used in the sentences are line.

The Line2D class is an abstract class that represents a line segment.

A line's coordinates can be retrieved as double.

The coordinates of a straight line segment can be obtained with double precision data type.

The Line2D class includes several methods for setting a line's endpoints.

The Line2D class includes methods for setting the endpoints of line segments.

You can also create a straight line segment by using the GeneralPath class described below.

You can also create a line segment using the GeneralPath class described below.

Class Rectangle


The Rectangle2D, RoundRectangle2D, Arc2D, and Ellipse2D primitives are all derived from the RectangularShape class.This class defines methods for Shape objects that can be described by a rectangular bounding box.

Rectangle2D, RoundRectangle2D, Arc2D, and Ellipse2D are all derived from the RectangularShape class. This class defines methods for objects that can be described with rectangular borders.

The geometry of a RectangularShape object can be extrapolated from a rectangle that completely encloses the outline of the Shape.

The geometry of a rectangle shape object can be pushed out by a rectangle that completely encloses its shape.


Quadratic and cubic curves


The QuadCurve2D enables you to create quadratic parametric curve segments. A quadratic curve is defined by two endpoints and one control point.

The QuadCurve2D class enables you to create quadratic parametric curve segments. A conic segment is defined by two endpoints and a control point.

The CubicCurve2D class enables you to create cubic parametric curve segments. A cubic curve is defined by two endpoints and two control points.

The CubicCurve2D class enables you to create cubic parametric curve segments. A cubic curve segment is defined by two endpoints and two control points.

The following are examples of quadratic and cubic curves. See Stroking and Filling Graphics Primitives for implementations of cubic and quadratic curves.

The following are examples of conics and cubic curves. Their specific implementation can refer to tracing and filling entities.


>This figure represents a quadratic curve.

This figure describes a quadratic curve segment.

This figure represents a cubic curve.

This figure describes a cubic curve segment.


Irregular shape


The GeneralPath class enables you to construct an arbitrary shape by specifying a series of positions along the shape's boundary.

The GeneralPath class enables you to construct irregular shapes by specifying a series of positions along the graph boundary.

These positions can be connected by line segments, quadratic curves, or cubic (B├ęzier) curves.

These positions can be linked by line segments, quadratic curve segments, or cubic (Bezier) curve segments.

The following shape can be created with three line segments and a cubic curve. See Stroking and Filling Graphics Primitives for more information about the implementation of this shape.

The following figure can be constructed with three line segments and one curve segment. For more information about the construction process, see tracing and filling elements.


region


With the Area class, you can perform boolean operations, such as union, intersection, and subtraction, on any two Shape objects.

With the Area class, you can perform Boolean operations on any two graphic objects, such as union, intersection and difference.

This technique, often referred to as constructive area geometry, enables you to quickly create complex Shape objects without having to describe each line segment or curve.

This technique (often called constructive area geometry) allows you to quickly create complex graphic objects without having to describe each line segment.

Published 2 original articles, won praise 0, visited 141
Private letter follow

Tags: Java Oracle

Posted on Tue, 14 Jan 2020 00:10:04 -0500 by Havenot