Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Java Graphics2D Paint     - Linux6.1 / 6.5 dual-NIC Binding (Linux)

- Enterprise Hadoop cluster architecture - NFS installation (Server)

- Transfer MySQL database to MariaDB (Database)

- floating IP in OpenStack neutron (Server)

- Linux Network Programming - raw socket can do (Programming)

- Nginx version of helloworld (Server)

- Git Rebase Tutorial: Using Git Rebase turn back the clock (Linux)

- Linux operating system set up to effectively prevent ARP attacks (Linux)

- Spring WebSocket Comments (Programming)

- Oracle Database Restore (Database)

- Oracle metadata Reconstruction experiments (Database)

- Linux System Getting Started Tutorial: permission to permanently modify the USB device in Linux (Linux)

- CentOS7 install MySQL 5.5 (Database)

- FileZilla install on Ubuntu 14.10 (Linux)

- libnet list of functions (Programming)

- C ++ copy constructor (Programming)

- MySQL Online DDL tools of pt-online-schema-change (Database)

- Migrate Oracle database files to ASM (Database)

- For the FreeBSD install Adobe Flash plug-in (Linux)

- Use value type build better applications Swift (Programming)

  Java Graphics2D Paint
  Add Date : 2018-11-21      
  In Java, when you need to draw some particular shape, such as oval, rectangular, etc., may be used to Graphics2D drawing.

Some API:

g.drawLine (3,3,50,50); // draw a line
g.drawRect (80,100,40,25); // draw wireframe
g.drawOval (10,10,60,120); // Draw Ellipse

// Draw polygon
int px1 [] = {50,90,10,50}; // the first and last point relative weight in order to draw a polygon
int py1 [] = {10,50,50,10};
g.setColor (Color.blue);
g.fillPolygon (px1, py1,4);

More details about the drawing, you can refer to some online presentation, or the official API.

Graphics2D object is to have a function translate (x, y), the function of the function is as follows:

To move the origin of the ellipse (x, y).

The function and rotate functions in combination, can achieve a graphical rotate about a point.

g2.rotate (Math.PI * rotate / 180.0); // Note that the function is elliptical rotation around the origin

For example, a horizontal oval around the center point of the ellipse rotation angle, we need to first oval origin moved to a location, and then rotate around the new origin

Coordinates of the new origin can be calculated based on the coordinates and the rotation angle of the horizontal state origin. Note: to move the origin, then rotate the order can not be chaotic.

Sample code:

Graphics2D g2 = (Graphics2D) g.create ();
g2.setColor (Color.red);
g2.translate (translateX, translateY);
g2.rotate (Math.PI * rotate / 180.0);
g2.drawOval (0, 0, ovalWidth - 1, ovalHeight - 1);
g2.translate (-translateX, -translateY);
g2.dispose ();
- To repair Shell script by default open in Ubuntu (Linux)
- Spring Boot + Nginx + Tomcat + SSL configuration notes (Server)
- Source compiler install Nginx (Server)
- Update GAMIT10.6 command (Linux)
- To use iostat display I / O status under Linux (Linux)
- Bubble Sort Algorithms (Programming)
- Automatic Clear date directory shell script (Linux)
- Android Sets the system screen brightness (Programming)
- Eclipse improve the efficiency of good habits (Programming)
- How to manage your to-do list with the Go For It on Ubuntu (Linux)
- To install and configure the Jetty server and JDK under Ubuntu 14.04.2 (Server)
- Use OpenSSL to generate a certificate (Linux)
- Linux, MySQL / MariaDB Galera Cluster Setup Process (Database)
- Graphics of Java Tools (Programming)
- CentOS yum install LAMP (Server)
- Installation Yarock 1.1.4 Music Player in Ubuntu (Linux)
- Oracle 11g modify MEMORY_TARGET (Database)
- Firewall Configuration Red Hat Enterprise Linux 4 (Linux)
- Protobuf compiled and used on the Ubuntu 14.04 (Programming)
- Visual Studio Code experience (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.