Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.FlowLayout;
- import java.awt.Graphics;
- import java.awt.GridBagLayout;
- import java.awt.Paint;
- import java.awt.Polygon;
- import java.util.ArrayList;
- import java.util.Date;
- import javax.sound.midi.Instrument;
- import javax.swing.BoxLayout;
- import javax.swing.GroupLayout;
- import javax.swing.JFrame;
- public class SegundoYMedio extends JFrame{
- private ArrayList<Integer> lados = new ArrayList<Integer>();
- private ArrayList<Integer> numCir = new ArrayList<Integer>();
- private ArrayList<Integer> circ = new ArrayList<Integer>();
- private ArrayList<String> colores = new ArrayList<String>();
- private ArrayList <Color> color = new ArrayList<Color>();
- private String compararStr="";
- private String[] instrucciones;
- private Polygon poly = new Polygon();
- public SegundoYMedio(StringBuffer texto, StringBuffer radio){
- setVisible(true);
- setSize(600,500);
- setLayout(new FlowLayout());
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- String xm=texto.toString();
- instrucciones=xm.split("");
- for (int i = 0; i < instrucciones.length; i++) {
- compararStr=instrucciones[i].toString();
- if(compararStr.equals("C")){
- circ.add(i+1);
- numCir.add(Integer.parseInt(instrucciones[i+1]));
- i++;
- }else{
- try {
- lados.add(Integer.parseInt(instrucciones[i]));
- } catch (Exception e) {
- colores.add(instrucciones[i].toString());
- }
- }
- }
- }
- public void paint(Graphics g){
- for (int i = 0; i < lados.size(); i++) {
- double alfa;
- int a,b;
- alfa=2*Math.PI/lados.get(i);
- compararStr=colores.get(i).toString();
- if (compararStr.equals("Z")) {
- color.add(Color.blue);
- }else{
- if(compararStr.equals("R")){
- color.add(Color.red);
- }else{
- if(compararStr.equals("A")){
- color.add(Color.yellow);
- }else{
- if (compararStr.equals("V")) {
- color.add(Color.green);
- }else{
- if (compararStr.equals("M")) {
- color.add(new Color(76, 40, 130));
- }else{
- if (compararStr.equals("F")) {
- color.add(new Color(150,75,0));
- }else{
- if (compararStr.equals("G")) {
- color.add(Color.magenta);
- }else{
- if (compararStr.equals("T")) {
- color.add(new Color(48,213,200));
- }else{
- if (compararStr.equals("S")) {
- color.add(new Color(19,101,134));
- }else{
- if(compararStr.equals("s")){
- color.add(Color.orange);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- for (int j = 0; j < lados.get(i); j++) {
- a=400+(int)(250*Math.cos((j)*alfa));
- b=400+(int)(250*Math.sin((j)*alfa));
- poly.addPoint(a, b);
- }
- }
- new TerceraVentana(poly, color);
- hide();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement