Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //everythink
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import java.util.Random;
- import controlP5.*;
- Random randa = new Random();
- ControlP5 cp5;
- int mode = 1;//1 - gravitation , 2 - pendulum, 3 - programs on whole screen
- boolean field = false;//true - central field , false - homogeneous field
- boolean pendul = false;//true - single pendulum , false - double pendulum
- boolean wholeScreen = false;// true - Lisajous table, false - nBonaci Sequence
- boolean information = false;
- boolean startMenu = true;
- boolean stopStart = false;//true - everything is working , false - everything is stoped
- boolean isMouseOver = false;
- boolean centralAction = false, homogeneousAction = false, singleAction = false, doubleAction = false, lisajousAction = false, nBonaciAction = false, strangeCirclesAction = false;
- boolean[] changePositionByMouse = new boolean[5];
- boolean[] contextMenuOpenByMouse = new boolean[5];
- long StartedMillis = 0;
- String buttonName;
- char shortcutCentralField = 'V', shortcutHomogenField = 'F', shortcutSinglePendulum = 'P', shortcutDoublePendulum = 'D', shortcutLisajousTable = 'L', shortcutBonaciSeqense = 'N', shortcutStrangeCircles = 'C';
- int control = 10, current, control2 = control, i, control3 = control2+1, ile = 1, ile2 = ile, ile_pend =1, ile_pend2 = ile_pend, pozX =2, pozY;
- int centerX = 0, centerY = 0, button_height =30, button_width = 106, he = button_height, hi = 1, pozXSet = pozX + button_width;
- float mass = 1000, radius = 20, density, G_const = 0.6673, total_mass = 0, a1 = 4*PI, w = 0.01;
- float length1, length2, mas1, mas2, a2, poz, rad = 10, angleChange_ = 0.01;
- float pozYSet[] = new float[2], screenSizeX = 0, screenSizeY = 0;
- LisajousTable table;
- BonaciSequence seq;
- StrengeCircles stren;
- ArrayList<Circum> cir = new ArrayList<Circum>(control);
- ArrayList<pendulum> pend = new ArrayList<pendulum>(ile_pend);
- ArrayList<double_pendulum> doublePend = new ArrayList<double_pendulum>(ile);
- PVector inic = new PVector(0.0000, 0.0000);
- int amo = 1000, currentIndex = 0;
- PFont font;
- void settings() {
- size(1000, 800, P2D);
- //fullScreen(P2D, 1);
- //screenSizeX = width;
- //screenSizeY = height;
- PJOGL.setIcon("icon5.png");
- }
- void setup() {
- //surface.setResizable(true);
- //surface.setLocation(0,0);
- surface.setTitle("Fizyka");
- //surface.setSize(displayWidth, displayHeight);
- stroke(255);
- background(255);
- font = createFont("arial", 20);
- centerX = (width/2) - (button_width/2);
- centerY = (height/2) - (button_height/2);
- //creating individual objects
- table = new LisajousTable();
- seq = new BonaciSequence();
- stren = new StrengeCircles( rad, angleChange_, amo);
- //creating random circles
- for (int i = 0; i <control; i++)
- {
- mass = 10;
- total_mass += mass;
- radius = 10;
- cir.add(new Circum(0, 0, radius, mass));
- cir.get(i).velocity = new PVector(0, 0);
- cir.get(i).acceleration = new PVector(0, 0);
- cir.get(i).gre = new PVector(0, 0);
- }
- //creating a random double pendulum
- for (int i = 0; i< ile; i++)
- {
- a1 = PI / (randa.nextFloat() + 1);
- a2 = PI / (randa.nextFloat() + 3);
- length1 = 350;
- length2 = 200;
- mas1 = 40;
- mas2 = 20;
- doublePend.add(new double_pendulum( a1, a2, length1, length2, mas1, mas2));
- }
- //creating a random pendulum
- for (int i = 0; i <ile_pend; i++)
- {
- a1 = PI / (randa.nextFloat() + 0.5);
- pend.add(new pendulum(a1));
- }
- cp5 = new ControlP5(this);
- //creating buttons
- cp5.addButton("Menu").setPosition(pozX, 2).setSize(button_width, button_height);
- cp5.addButton("Start").setPosition(centerX, centerY).setSize(200, 60).setCaptionLabel("Start");
- cp5.addButton("Settings").setPosition(centerX, centerY+ 60).setSize(200, 60).setCaptionLabel("Ustawienia");
- cp5.addButton("Exit").setPosition(centerX, centerY + 120).setSize(200, 60).setCaptionLabel("Wyjscie z programu");
- cp5.addButton("Save").setPosition(pozXSet, 63).setSize(button_width, button_height).setCaptionLabel("Zapis").hide();
- cp5.addButton("Load").setPosition(pozXSet, 63).setSize(button_width, button_height).setCaptionLabel("Odczyt").hide();
- cp5.addButton("Set").setPosition(pozXSet, 63).setSize(button_width, button_height).setCaptionLabel("Ustawienia").hide();
- cp5.addButton("Reset").setPosition(pozX, he * hi).setSize(button_width, button_height);
- hi++;
- cp5.addButton("StartStop").setPosition(pozX, he * hi).setSize(button_width, button_height).setCaptionLabel("Uruchomienie programu");
- hi++;
- cp5.addButton("Single").setPosition(pozX, he * hi).setSize(button_width, button_height).setCaptionLabel("Pojedyncze wahadło").setVisible(false).setValue(2);
- hi++;
- cp5.addButton("Dual").setPosition(pozX, he * hi).setSize(button_width, button_height).setCaptionLabel("Podwójne wahadło").setVisible(false).setValue(2);
- hi++;
- cp5.addButton("Homogen").setPosition(pozX, he * hi).setSize(button_width, button_height).setCaptionLabel(" Pole jednorodne").setVisible(false).setValue(1);
- hi++;
- cp5.addButton("Central").setPosition(pozX, he * hi).setSize(button_width, button_height).setCaptionLabel(" Pole centralne").setVisible(false).setValue(1);
- hi++;
- cp5.addButton("Lisajous").setPosition(pozX, he * hi).setSize(button_width, button_height).setCaptionLabel("Tablica Lisajous ").setVisible(false).setValue(3);
- hi++;
- cp5.addButton("Bonaci").setPosition(pozX, he * hi).setSize(button_width, button_height).setCaptionLabel("Sekwencja fibonacziego").setVisible(false).setValue(3);
- hi++;
- cp5.addButton("Circle").setPosition(pozX, he * hi).setSize(button_width, button_height).setCaptionLabel("Wzory").setVisible(false).setValue(4);
- cp5.addTextfield("input").setPosition(20, 100).setSize(200, 40).setFont(font).setFocus(false).setCaptionLabel(" ").setColor(color(255, 0, 0)).setVisible(false);
- }
- void drawBorders()
- {
- strokeWeight(6);
- stroke(200, 0, 10);
- line(0, height, width, height);
- line(0, 0, width, 0);
- line(0, 0, 0, height);
- line(width, 0, width, height);
- strokeWeight(1);
- }
- //reading the time that has elapsed since the program started
- String formatMillis(long millis)
- {
- int milliseconds = floor(millis)%1000;
- int seconds = (int)((millis / 1000) % 60);
- long minutes = ((millis / 1000) / 60)% 60;
- long hour = ((millis / 1000) / 3600)% 60;
- return "" + nf(hour, 2, 0) + ":" + nf(minutes, 2, 0) + ":" + nf(seconds, 2, 0) + ":" + nf(milliseconds, 3, 0);
- }
- void contextMenu(int currentIndex)
- {
- i = currentIndex;
- if (contextMenuOpenByMouse[0])
- {
- cir.get(i).showingData();
- } else if (contextMenuOpenByMouse[1])
- {
- cir.get(i).showingData();
- } else if (contextMenuOpenByMouse[2])
- {
- pend.get(i).showingData();
- } else if (contextMenuOpenByMouse[3])
- {
- doublePend.get(i).showingData(3);
- } else if (contextMenuOpenByMouse[4])
- {
- doublePend.get(i).showingData(4);
- }
- }
- void changePositionByTheMouse(int currentIndex)
- {
- i = currentIndex;
- PVector diff;
- if (changePositionByMouse[0])
- {
- cir.get(i).point.x = mouseX;
- cir.get(i).point.y = mouseY;
- cir.get(i).velocity.mult(0);
- } else if (changePositionByMouse[1])
- {
- cir.get(i).point.x = mouseX;
- cir.get(i).point.y = mouseY;
- } else if (changePositionByMouse[2])
- {
- pend.get(i).position.x = mouseX;
- pend.get(i).position.y = mouseY;
- diff = PVector.sub(pend.get(i).origin, new PVector(mouseX, mouseY)); // Difference between 2 points
- pend.get(i).angle = atan2(-1*diff.y, diff.x) - radians(90); // Angle relative to vertical axis
- pend.get(i).lengh = diff.mag();
- pend.get(i).a1_vel = 0;
- } else if (changePositionByMouse[3])
- {
- doublePend.get(i).position[0].x = mouseX;
- doublePend.get(i).position[0].y = mouseY;
- diff = PVector.sub(doublePend.get(i).origin, new PVector(mouseX, mouseY));
- doublePend.get(i).a1 = atan2(-1*diff.y, diff.x)- radians(90);
- doublePend.get(i).length1 = diff.mag();
- PVector diff2 = PVector.sub(doublePend.get(i).position[0], doublePend.get(i).position[1]);
- doublePend.get(i).length2 = diff2.mag();
- doublePend.get(i).a1_vel = 0;
- doublePend.get(i).a2_vel = 0;
- } else if (changePositionByMouse[4])
- {
- doublePend.get(i).position[1].x = mouseX;
- doublePend.get(i).position[1].y = mouseY;
- diff = PVector.sub(doublePend.get(i).position[0], new PVector(mouseX, mouseY));
- doublePend.get(i).a2 = atan2(-1*diff.y, diff.x)- radians(90);
- doublePend.get(i).length2 = diff.mag();
- doublePend.get(i).a2_vel = 0;
- }
- }
- void mousePressed() {
- if (!stopStart)
- {
- if (mode == 1)
- {
- if (field)
- {
- for (int i = 0; i<cir.size(); i++)
- {
- float d = dist(mouseX, mouseY, cir.get(i).point.x, cir.get(i).point.y);
- if (d <= cir.get(i).radius ) {
- if (mouseButton == LEFT)
- {
- changePositionByMouse[0] = true;
- } else if (mouseButton == RIGHT)
- {
- contextMenuOpenByMouse[0] = true;
- }
- currentIndex = i;
- }
- }
- } else
- {
- for (int j = 0; j<cir.size(); j++)
- {
- float d = dist(mouseX, mouseY, cir.get(j).point.x, cir.get(j).point.y);
- if (d <= cir.get(j).radius) {
- if (mouseButton == LEFT)
- {
- changePositionByMouse[1] = true;
- } else if (mouseButton == RIGHT)
- {
- contextMenuOpenByMouse[1] = true;
- }
- currentIndex = j;
- }
- }
- }
- } else if (mode == 2)
- {
- if (pendul)
- {
- for (int k = 0; k< pend.size(); k++)
- {
- float d = dist(mouseX, mouseY, pend.get(k).position.x, pend.get(k).position.y);
- if (d <= cir.get(k).radius) {
- if (mouseButton == LEFT)
- {
- changePositionByMouse[2] = true;
- } else if (mouseButton == RIGHT)
- {
- contextMenuOpenByMouse[2] = true;
- }
- currentIndex = k;
- }
- }
- } else
- {
- for (int l = 0; l< doublePend.size(); l++)
- {
- float d1 = dist(mouseX, mouseY, doublePend.get(l).position[0].x, doublePend.get(l).position[0].y);
- float d2 = dist(mouseX, mouseY, doublePend.get(l).position[1].x, doublePend.get(l).position[1].y);
- if (d1 <= doublePend.get(l).radius1) {
- if (mouseButton == LEFT)
- {
- changePositionByMouse[3] = true;
- } else if (mouseButton == RIGHT)
- {
- contextMenuOpenByMouse[3] = true;
- }
- } else if (d2 <= doublePend.get(l).radius2) {
- if (mouseButton == LEFT)
- {
- changePositionByMouse[4] = true;
- } else if (mouseButton == RIGHT)
- {
- contextMenuOpenByMouse[4] = true;
- }
- }
- currentIndex = l;
- }
- }
- } else if (mode == 4)
- {
- }
- }
- }
- void mouseReleased() {
- if (!stopStart)
- {
- if (mode == 1)
- {
- if (field)
- {
- if (changePositionByMouse[0]) {
- changePositionByMouse[0] = false;
- }
- } else
- {
- if (changePositionByMouse[1]) {
- changePositionByMouse[1] = false;
- }
- }
- } else if (mode == 2)
- {
- if (pendul)
- {
- if (changePositionByMouse[2]) {
- changePositionByMouse[2] = false;
- }
- } else
- {
- if (changePositionByMouse[3]) {
- changePositionByMouse[3] = false;
- } else if (changePositionByMouse[4]) {
- changePositionByMouse[4] = false;
- }
- }
- }
- } else if (mode == 4)
- {
- }
- }
- void keyPressed()
- {
- //reading keyboard shortcuts
- if ((key >= 'A' && key <= 'Z') || (key >= 'a' && key <= 'z'))
- {
- if (key == 'M' ||key == 'm')
- {
- information = !information; //menu
- } else if (key == (shortcutHomogenField+32) ||key == shortcutHomogenField)
- {
- mode = 1;
- field = false; // f - homogeneous field
- setting();
- } else if (key == (shortcutCentralField+32) ||key == shortcutCentralField)
- {
- mode = 1;
- field = true; //v - central field
- setting();
- } else if (key == (shortcutSinglePendulum+32) ||key == shortcutSinglePendulum)
- {
- mode = 2;
- pendul = true; //p - single pendulum
- setting();
- } else if (key == (shortcutDoublePendulum+32) ||key == shortcutDoublePendulum)
- {
- mode = 2;
- pendul = false; //d - double pendulum
- setting();
- } else if (key == (shortcutLisajousTable+32) ||key == shortcutLisajousTable)
- {
- mode = 3;
- wholeScreen = true;
- setting();
- } else if (key == (shortcutBonaciSeqense+32) ||key == shortcutBonaciSeqense)
- {
- mode = 3;
- wholeScreen = false;
- setting();
- } else if (key == (shortcutStrangeCircles+32) ||key == shortcutStrangeCircles)
- {
- mode = 4;//c - strange circles
- setting();
- } else if (key == 'R' ||key == 'r')
- {//reset
- background(255);
- setting();
- } else if (key == 'K' ||key == 'k')
- {
- if (!information)
- {
- information = !information;
- }
- //
- if (mode == 1 & field == true)
- {
- pozYSet = cp5.getController("Central").getPosition();
- cp5.get(Button.class, "Set").setPosition(pozXSet, pozYSet[1]).setVisible(true);
- cp5.get(Textfield.class, "input").setPosition(pozXSet, pozYSet[1]+button_height).setVisible(true).setFocus(true);
- } else if (mode == 1 & field == false)
- {
- pozYSet = cp5.getController("Homogen").getPosition();
- cp5.get(Button.class, "Set").setPosition(pozXSet, pozYSet[1]).setVisible(true);
- cp5.get(Textfield.class, "input").setPosition(pozXSet, pozYSet[1]+button_height).setVisible(true).setFocus(true);
- } else if (mode == 2 & pendul == true)
- {
- pozYSet = cp5.getController("Single").getPosition();
- cp5.get(Button.class, "Set").setPosition(pozXSet, pozYSet[1]).setVisible(true);
- cp5.get(Textfield.class, "input").setPosition(pozXSet, pozYSet[1]+button_height).setVisible(true).setFocus(true);
- } else if (mode == 2 & pendul == false)
- {
- pozYSet = cp5.getController("Dual").getPosition();
- cp5.get(Button.class, "Set").setPosition(pozXSet, pozYSet[1]).setVisible(true);
- cp5.get(Textfield.class, "input").setPosition(pozXSet, pozYSet[1]+button_height).setVisible(true).setFocus(true);
- } else if (mode == 3 & wholeScreen == true)
- {
- pozYSet = cp5.getController("Lisajous").getPosition();
- cp5.get(Button.class, "Set").setPosition(pozXSet, pozYSet[1]).setVisible(true);
- cp5.get(Textfield.class, "input").setPosition(pozXSet, pozYSet[1]+button_height).setVisible(true).setFocus(true);
- } else if (mode == 3 & wholeScreen == false)
- {
- //pozYSet = cp5.getController("Bonaci").getPosition();
- //cp5.get(Button.class, "Set").setPosition(pozXSet, pozYSet[1]).setVisible(true);
- //cp5.get(Button.class, "input").setPosition(pozXSet, pozYSet[1]+button_height).setVisible(true);
- } else if (mode == 4)
- {
- pozYSet = cp5.getController("Circle").getPosition();
- cp5.get(Button.class, "Set").setPosition(pozXSet, pozYSet[1]).setVisible(true);
- cp5.get(Textfield.class, "input").setPosition(pozXSet, pozYSet[1]+button_height).setVisible(true).setFocus(true);
- }
- setting();
- }
- }
- }
- void setting()
- {
- if (mode == 1)
- {
- float pozX = 0, pozY = 0;
- for (int i = control - 1; i >= 0; i--)
- {
- cir.remove(i);
- }
- if ( field == true)
- {
- for (int i = 0; i <control2; i++)
- {
- mass = 20 * randa.nextFloat() + 4;
- total_mass +=mass;
- radius = mass * 2;
- pozX = (width * new Random().nextFloat()) - radius;
- pozY = (height * new Random().nextFloat()) - radius;
- cir.add(new Circum(pozX, pozY, radius, mass));
- cir.get(i).velocity = new PVector(0, 0);
- }
- control = control2;
- } else if ( field == false)
- {
- for (int i = 0; i<control2; i++)
- {
- mass = 8 * randa.nextFloat() + 4;
- radius = mass * 2;
- pozX = (width * new Random().nextFloat()) - radius;
- pozY = (height * new Random().nextFloat()) - radius;
- cir.add(new Circum( pozX, pozY, radius, mass));
- cir.get(i).setSpeed(inic);
- }
- control = control2;
- }
- } else if (mode == 2)
- {
- if (pendul == true)
- {
- for (int i = ile_pend2 - 1; i >= 0; i--)
- {
- pend.remove(i);
- }
- a1 = PI / (4 * randa.nextFloat() + 1);
- ile_pend2 = ile_pend;
- for (int i = 0; i< ile_pend; i++)
- {
- pend.add(new pendulum(a1));
- a1+=0.2;
- }
- } else if (pendul == false)
- {
- for (int i = ile - 1; i >= 0; i--)
- {
- doublePend.remove(i);
- }
- for (int i = 0; i< ile2; i++)
- {
- doublePend.add(new double_pendulum(PI / (randa.nextFloat() + 1), PI / (randa.nextFloat() + 3), 400, 250, 40, 20));
- doublePend.get(i).set0();
- }
- ile = ile2;
- }
- } else if (mode == 3)
- {
- if (wholeScreen)
- {
- table.reset(w);
- } else
- {
- seq.reset();
- }
- } else if (mode == 4)
- {
- stren.reset();
- }
- StartedMillis = millis();
- }
- void checkingIfMouseIsOver()
- {
- if (cp5.isMouseOver(cp5.getController("Menu"))) {
- cp5.getController("Set").hide();
- cp5.getController("input").setVisible(false);
- textFont(font, 20);
- textLeading(18);
- textAlign(LEFT);
- String advice = " Nie ma znaczenia jaka jest wielkość liter.\n "+ shortcutHomogenField + "- pole jednorodne\n "+ shortcutCentralField +" - pole centralne\n "+ shortcutSinglePendulum +" - pojedyncze wahadło\n "+ shortcutDoublePendulum +" - podwójne wahadło\n "+ shortcutLisajousTable +" - tablica Lisajous\n "+ shortcutBonaciSeqense +" - sekwencja fibonacziego\n "+ shortcutStrangeCircles +" - dziwne koła \n K - zmiana ilości obiektów \n R - reset";
- text(advice, 110, 20, 660, 160);
- } else if (cp5.isMouseOver(cp5.getController("Reset")))
- {
- cp5.getController("Set").hide();
- cp5.getController("input").setVisible(false);
- } else if (cp5.isMouseOver(cp5.getController("Central"))) {
- cp5.get(Textfield.class, "input").setCaptionLabel("Ustaw ilość obiektów w centralnym polu grawitacyjnym");
- Disclosures_set("Central");
- } else if (cp5.isMouseOver(cp5.getController("Single"))) {
- Disclosures_set("Single");
- cp5.get(Textfield.class, "input").setCaptionLabel("Ustaw ilość pojedyńczych wahadeł");
- } else if (cp5.isMouseOver(cp5.getController("Dual"))) {
- cp5.get(Textfield.class, "input").setCaptionLabel("Ustaw ilość podwójnych wahadeł");
- Disclosures_set("Dual");
- } else if (cp5.isMouseOver(cp5.getController("Homogen"))) {
- cp5.get(Textfield.class, "input").setLabel("Ustaw ilość obiektów w jednorodnym polu grawitacyjnym");
- Disclosures_set("Homogen");
- } else if (cp5.isMouseOver(cp5.getController("Lisajous"))) {
- Disclosures_set("Lisajous");
- cp5.get(Textfield.class, "input").setLabel("Ustaw wielkość okręgów");
- cp5.getController("Set").setVisible(false);
- } else if (cp5.isMouseOver(cp5.getController("Bonaci"))) {
- // Disclosures_set("Bonaci");
- cp5.getController("input").setVisible(false);
- cp5.getController("Set").setVisible(false);
- } else if (cp5.isMouseOver(cp5.getController("Circle"))) {
- Disclosures_set("Circle");
- cp5.get(Textfield.class, "input").setLabel("Ustaw wielkość zmiany kąta");
- cp5.getController("Set").setVisible(true);
- }
- }
- void draw() {
- background(120);
- drawBorders();
- if (mode == 1)
- {
- if (field)
- {
- centralField();
- } else
- {
- homogeneousField();
- }
- } else if (mode == 2)
- {
- if (pendul)
- {
- singlePendulum();
- } else
- {
- dublePendulum();
- }
- } else if (mode == 3)
- {
- background(0);
- if (wholeScreen)
- {
- noFill();
- table.show();
- } else
- {
- seq.drawing();
- }
- } else if (mode == 4)
- {
- pushMatrix();
- translate(width / 2, height/2);
- background(0);
- strokeWeight(5);
- point(0, 0);
- strokeWeight(2);
- noFill();
- circle(0, 0, 100);
- stren.strangeCircle();
- popMatrix();
- }
- textSize(20);
- fill(10, 10, 10);
- if (mode == 3 || mode == 4)
- {
- fill(200, 200, 200);
- }
- if (!stopStart)
- {
- changePositionByTheMouse(currentIndex);
- contextMenu(currentIndex);
- }
- checkingIfMouseIsOver();
- menuManagement();
- ButtonManagement();
- }
- //AButton
- //reading input from buttons
- void Homogen(int n) {
- CentralButton(n, true, false);
- }
- void Circle(int n) {
- CentralButton(n, true, false);
- }
- void Lisajous(int n) {
- wholeScreen = true;
- CentralButton(n, true, false);
- }
- void Bonaci(int n) {
- wholeScreen = false;
- CentralButton(n, true, false);
- }
- void Central(int n) {
- CentralButton(n, true, true);
- }
- void Single(int n) {
- CentralButton(n, false, true);
- }
- void Dual(int n) {
- CentralButton(n, false, false);
- }
- void Menu()
- {
- information = !information;
- }
- void Reset()
- {
- background(255);
- setting();
- }
- void StartStop() {
- println("3",stopStart,startMenu);
- stopStart = !stopStart;
- println("4",stopStart,startMenu);
- if (stopStart)
- {
- cp5.getController("StartStop").setCaptionLabel("Zatrzymanie programu");
- centralAction = true;
- homogeneousAction = true;
- singleAction = true;
- doubleAction = true;
- lisajousAction = true;
- nBonaciAction = true;
- strangeCirclesAction = true;
- } else
- {
- cp5.getController("StartStop").setCaptionLabel("Uruchomienie programu");
- centralAction = false;
- homogeneousAction = false;
- singleAction = false;
- doubleAction = false;
- lisajousAction = false;
- nBonaciAction = false;
- strangeCirclesAction = false;
- }
- }
- void Start() {
- println("1",stopStart,startMenu);
- stopStart = true;
- startMenu = false;
- println("2",stopStart,startMenu);
- cp5.get(Button.class, "Start").hide();
- cp5.get(Button.class, "Settings").hide();
- cp5.get(Button.class, "Exit").hide();
- }
- void Settings() {
- }
- void Exit() {
- exit();
- }
- void menuManagement()
- {
- if(startMenu)
- {
- cp5.get(Button.class, "Start").setVisible(true);
- cp5.get(Button.class, "Settings").setVisible(true);
- cp5.get(Button.class, "Exit").setVisible(true);//.show();
- } else if (startMenu == false)
- {
- cp5.get(Button.class, "Start").setVisible(false);//.hide();
- cp5.get(Button.class, "Settings").setVisible(false);//.hide();
- cp5.get(Button.class, "Exit").setVisible(false);//.hide();
- }
- }
- void Set()
- {
- setting();
- }
- void CentralButton(int n, boolean poleOrPendul, boolean i)
- {
- mode = n;
- if (poleOrPendul)
- {
- field = i;
- } else
- {
- pendul = i;
- }
- setting();
- }
- void ButtonManagement()
- {
- if (information)
- {
- long DurationMillis = millis() - StartedMillis;
- text(formatMillis(DurationMillis), width - 136, 20);
- text( frameRate, width - 80, 40);
- cp5.get(Button.class, "Homogen").setVisible(true);
- cp5.get(Button.class, "Central").setVisible(true);
- cp5.get(Button.class, "Single").setVisible(true);
- cp5.get(Button.class, "Dual").setVisible(true);
- cp5.get(Button.class, "Lisajous").setVisible(true);
- cp5.get(Button.class, "Bonaci").setVisible(true);
- cp5.get(Button.class, "Circle").setVisible(true);
- } else if (information == false)
- {
- cp5.get(Button.class, "Homogen").setVisible(false);
- cp5.get(Button.class, "Central").setVisible(false);
- cp5.get(Button.class, "Single").setVisible(false);
- cp5.get(Button.class, "Dual").setVisible(false);
- cp5.get(Button.class, "Lisajous").setVisible(false);
- cp5.get(Button.class, "Bonaci").setVisible(false);
- cp5.get(Button.class, "Circle").setVisible(false);
- cp5.get(Textfield.class, "input").setVisible(false);
- }
- }
- void Disclosures_set(String name)
- {
- pozYSet = cp5.getController(name).getPosition();
- cp5.getController("Set").setPosition(pozXSet, pozYSet[1]);
- cp5.getController("input").setPosition(pozXSet, pozYSet[1]+button_height);
- buttonName = name;
- cp5.getController("Set").show();
- cp5.getController("input").show();
- }
- int inputChange(String theText)
- {
- Pattern numbers = Pattern.compile("[0-9]+");
- theText.replaceAll("^\\D+", "").split("\\D+");
- Matcher matcher = numbers.matcher(theText);
- int sum = 0;
- while (matcher.find()) {
- sum += Integer.parseInt(matcher.group());
- }
- return sum;
- }
- // automatically receives results from controller input
- void input(String theText) {
- int amount = inputChange(theText);
- if (buttonName == "Homogen")
- {
- control2 = amount;
- } else if (buttonName.equals("Central"))
- {
- control2 = amount;
- } else if (buttonName.equals("Dual"))
- {
- ile2 = amount;
- } else if (buttonName.equals("Single"))
- {
- ile_pend = amount;
- } else if (buttonName.equals("Lisajous"))
- {
- w = amount;
- }
- setting();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement