Large diffs are not rendered by default.

BIN +257 Bytes (120%) out/production/SixLab/Flags.class
Binary file not shown.
@@ -0,0 +1,47 @@
import javax.swing.*;
import java.awt.*;

public class FlagRunner {
public static void main(String[] args) {

JFrame frame = new JFrame("FlagRunner");
frame.setBounds(0, 0, 700, 700);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPanel contentPane = new JPanel() {
Graphics2D g2;
String x = JOptionPane.showInputDialog("Введите позицию Х");
String y = JOptionPane.showInputDialog("Введите позицию Y");
String len = JOptionPane.showInputDialog("Введите длинну флага");
String wid = JOptionPane.showInputDialog("Введите высоту флага");
String[] possibilities = {"Russia", "France", "Holland", "Belgium", "Italy"};
String s = (String) JOptionPane.showInputDialog(frame, "Choose your country than press OK", "Choose ur country", JOptionPane.PLAIN_MESSAGE, null, possibilities, "Russia");

protected void paintComponent(Graphics g) {
super.paintComponent(g);
g2 = (Graphics2D) g;
switch (s){
case "Russia":
new Flags(Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(len), Integer.parseInt(wid), Color.white, Color.blue, Color.red, g2, s);
break;
case "France":
new Flags(Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(len), Integer.parseInt(wid), Color.blue, Color.white, Color.red, g2, s);
break;
case "Holland":
new Flags(Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(len), Integer.parseInt(wid), Color.red, Color.white, Color.blue, g2, s);
break;
case "Belgium":
new Flags(Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(len), Integer.parseInt(wid), Color.white, Color.blue, Color.red, g2, s);
break;
case "Italy":
new Flags(Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(len), Integer.parseInt(wid), Color.green, Color.white, Color.red, g2, s);
break;
}
}
};
frame.setContentPane(contentPane);
frame.setVisible(true);
}

}
@@ -1,45 +1,42 @@
import javax.swing.*;
import java.awt.*;

/**
* Created by aaand on 07.12.2016.
*/
public class Flags extends JComponent {
public Flags(int x, int y, int len, int wid, int stripe, Color color1, Color color2, Color color3, Graphics2D g2, String countryName) {
if (stripe == 1) {
Rectangle rect = new Rectangle(x, y, wid, (int) (len / 3));
g2.setColor(color1);
g2.fill(rect);
Rectangle rect2 = new Rectangle(x, y + (int) (len / 3), wid, (int) (len / 3));
g2.setColor(color2);
g2.fill(rect2);
Rectangle rect3 = new Rectangle(x, y + 2 * (int) (len / 3), wid, (int) (len / 3));
g2.setColor(color3);
g2.fill(rect3);


switch (countryName) {
case "Russia":
Rectangle firstpole = new Rectangle(0, 0, 500, 100);

break;
case "France":

break;
case "Holland":

break;
case "Belgium":

break;
case "Italy":

break;
}


//frame.setVisible(true);
class Flags extends JComponent {
private Rectangle firstPole, secondPole, thirdPole;

public Flags(int x, int y, int len, int wid, Color color1, Color color2, Color color3, Graphics2D g2, String countryName) {
switch (countryName) {
case "Russia":
firstPole = new Rectangle(x, y, wid, (int) (len / 3));//white
secondPole = new Rectangle(x, y + (int) (len / 3), wid, (int) (len / 3));//blue
thirdPole = new Rectangle(x, y + 2 * (int) (len / 3), wid, (int) (len / 3));//red
break;
case "France":
firstPole = new Rectangle(x, y, (int) (wid / 3), len);//blue
secondPole = new Rectangle(x + (int) (wid / 3), y, (int) (wid / 3), len);//white
thirdPole = new Rectangle(x + 2 * (int) (wid / 3), y, (int) (wid / 3), len);//red
break;
case "Holland":
firstPole = new Rectangle(x, y, wid, (int) (len / 3));//white
secondPole = new Rectangle(x, y + (int) (len / 3), wid, (int) (len / 3));//blue
thirdPole = new Rectangle(x, y + 2 * (int) (len / 3), wid, (int) (len / 3));
break;
case "Belgium":
firstPole = new Rectangle(x, y, wid, (int) (len / 3));//white
secondPole = new Rectangle(x, y + (int) (len / 3), wid, (int) (len / 3));//blue
thirdPole = new Rectangle(x, y + 2 * (int) (len / 3), wid, (int) (len / 3));
break;
case "Italy":
firstPole = new Rectangle(x, y, (int) (wid / 3), len);//blue
secondPole = new Rectangle(x + (int) (wid / 3), y, (int) (wid / 3), len);//white
thirdPole = new Rectangle(x + 2 * (int) (wid / 3), y, (int) (wid / 3), len);
break;
}

g2.setColor(color1);
g2.fill(firstPole);
g2.setColor(color2);
g2.fill(secondPole);
g2.setColor(color3);
g2.fill(thirdPole);
}
}
@@ -0,0 +1,38 @@
import javax.sound.sampled.Line;
import java.awt.*;
import java.awt.geom.Line2D;

/**
* Created by aaand on 09.12.2016.
*/
public class Spiral {
private int startX, startY, numberOfSpins, firstLenght, x1, x2, y1, y2, length;

public Spiral(int startX, int startY, int len, int numberOfsp, Graphics2D g2) {
this.x1 = startX;
this.y1 = startY;
this.x2 = startX+len;
this.y2 = startY;
this.firstLenght = len;
this.numberOfSpins = numberOfsp;
Line2D.Double line = new Line2D.Double(x1, y1, x2, y2);
while (numberOfSpins > 0) {
x1 += length;
y2 -= length;
Line2D.Double line1 = new Line2D.Double(x1, y1, x2, y2);
y1 -= length;
length += firstLenght;
x2 -= length;
Line2D.Double line2 = new Line2D.Double(x1, y1, x2, y2);
x1 -= length;
y2 += length;
Line2D.Double line3 = new Line2D.Double(x1, y1, x2, y2);
y1 += length;
length += firstLenght;
x2 += length;
Line2D.Double line4 = new Line2D.Double(x1, y1, x2, y2);
draw(line, line1, line2, line3, line4);
numberOfSpins--;
}
}
}

This file was deleted.