Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
* Kevin Li
* Daniel Zhu
*/
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import javax.swing.JComponent;
import java.lang.Math;
public class Flag extends JComponent {
private int FLAG_WIDTH;
private int FLAG_HEIGHT;
private final int STRIPES = 13;
private final double B = 1.9;
private final double C = 7.0 / STRIPES;
private final double D = 0.76;
private final double E = 0.054;
private final double F = 0.054;
private final double G = 0.063;
private final double H = 0.063;
private final double K = 0.0616;
private final double L = 1.0 / STRIPES;
private final double SIN36 = Math.sin(Math.PI/5);
private final double COS36 = Math.cos(Math.PI/5);
private final double SIN72 = Math.sin( 2 *(Math.PI/5) );
private final double COS72 = Math.cos( 2 * (Math.PI/5) );
public Flag(int width, int height) {
FLAG_WIDTH = width;
FLAG_HEIGHT = height;
init();
}
public void init() {
setSize(FLAG_WIDTH, FLAG_HEIGHT);
}
public void paintComponent(Graphics g) {
if ((float)this.getParent().getWidth() / this.getParent().getHeight() >= 1.9) {
FLAG_HEIGHT = this.getParent().getHeight();
FLAG_WIDTH = (int) (FLAG_HEIGHT * B);
} else {
FLAG_WIDTH = this.getParent().getWidth();
FLAG_HEIGHT = (int) (FLAG_WIDTH / B);
}
setSize(FLAG_WIDTH, FLAG_HEIGHT);
drawStripes(g);
drawField(g);
int starXPos = (int) (G * FLAG_HEIGHT);
int starYPos = (int) (E * FLAG_HEIGHT);
for (int i = 0; i < 9; i++) {
for (int j = 0; j < ((i % 2 == 0) ? 6 : 5); j++) {
drawStar(starXPos, starYPos, (int) (K * FLAG_HEIGHT / 2.0), (int) (K * FLAG_HEIGHT / 4.0), g);
starXPos += (int) (2 * H * FLAG_HEIGHT);
}
starXPos = ((i % 2 == 1) ? (int) (G * FLAG_HEIGHT) : (int) (G * FLAG_HEIGHT + H * FLAG_HEIGHT));
starYPos += (int) (F * FLAG_HEIGHT);
}
}
public void drawStripes(Graphics g) {
for (int i = 0; i < STRIPES; i++) {
if (i % 2 == 0) {
g.setColor(Color.RED);
} else {
g.setColor(Color.WHITE);
}
g.fillRect(0, (int)(i * L * FLAG_HEIGHT), (int)(B * FLAG_HEIGHT), (int)(L * FLAG_HEIGHT));
}
}
public void drawField(Graphics g) {
g.setColor(Color.BLUE);
g.fillRect(0 , 0 ,(int) (D * FLAG_HEIGHT), (int) (C * FLAG_HEIGHT));
}
public void drawStar(int xCenter, int yCenter, int outerRadius, int innerRadius, Graphics g) {
Graphics2D g2d = (Graphics2D) g;
AffineTransform rotateTransform = new AffineTransform();
rotateTransform.rotate(Math.toRadians(180.0), xCenter, yCenter);
g2d.setTransform(rotateTransform);
int xPoints[] = {xCenter, xCenter + (int) (innerRadius * SIN36) , xCenter + (int) ( (outerRadius) * SIN72) , xCenter + (int) ( (innerRadius) * SIN72) , xCenter + (int) ( (outerRadius) * SIN36) , xCenter , xCenter - (int) ( (outerRadius) * SIN36) , xCenter - (int) ( (innerRadius) * SIN72) , xCenter - (int) ( (outerRadius) * SIN72) , xCenter - (int) ( (innerRadius) * SIN36)};
int yPoints[] = {yCenter + outerRadius , yCenter + (int) (innerRadius * SIN36) , yCenter + (int) (outerRadius* COS72) , yCenter - (int) ( (innerRadius) * COS72) , yCenter - (int) ( (outerRadius) * COS36) , yCenter - innerRadius , yCenter - (int) ( (outerRadius) * COS36) , yCenter - (int) ( (innerRadius) * COS72) , yCenter + (int) ( (outerRadius) * COS72) , yCenter + (int) ( (innerRadius) * COS36)};
int points = 10;
g2d.setColor(Color.WHITE);
g2d.fillPolygon(xPoints, yPoints, points);
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team