x() { Boolean cb1 = new Boolean(true); simulator.setVar("flagx",cb1); } edit() { Boolean cb = new Boolean(true); simulator.setVar("flag",cb); } double fc2(double x) { return sbC.getDouble("Value")*Math.pow(x-a1,al1)*Math.pow(x-a2,al2)*Math.pow(x-a3,al3)/(Math.pow(x-b1,bt1)*Math.pow(x-b2,bt2)*Math.pow(x-b3,bt3)); } void dispatch() { String command = simulator.getNextEvent(); if (command.equals("spinboxChange")) {x(); edit();} if (command.equals("l")) {edit();simulator.setVar("type",command);} if (command.equals("e")) {edit();simulator.setVar("type",command);} if (command.equals("g")) {edit();simulator.setVar("type",command);} if (command.equals("le")) {edit();simulator.setVar("type",command);} if (command.equals("ge")) {edit();simulator.setVar("type",command);} } void p_upd() { pta1.update(); pta2.update(); pta3.update(); ptb1.update(); ptb2.update(); ptb3.update(); } Element el = simulator.getObject("Plotter Tank 0"); Element f = simulator.getObject("el00191"); Element pta1 = simulator.getObject("el00452"); Element pta2 = simulator.getObject("el00455"); Element pta3 = simulator.getObject("el00458"); Element ptb1 = simulator.getObject("el00461"); Element ptb2 = simulator.getObject("el00464"); Element ptb3 = simulator.getObject("el00467"); Element tf = simulator.getObject("el00397"); tf.setEnabled(false); Element sba1 = simulator.getObject("el00255"); Element sba2 = simulator.getObject("el00258"); Element sba3 = simulator.getObject("el00261"); Element sbal1 = simulator.getObject("el00264"); Element sbal2 = simulator.getObject("el00267"); Element sbal3 = simulator.getObject("el00270"); Element sbb1 = simulator.getObject("el00273"); Element sbb2 = simulator.getObject("el00276"); Element sbb3 = simulator.getObject("el00279"); Element sbbt1 = simulator.getObject("el00282"); Element sbbt2 = simulator.getObject("el00285"); Element sbbt3 = simulator.getObject("el00288"); Element sbC = simulator.getObject("el00291"); Element mt = simulator.getObject("el00449"); Boolean bb = new Boolean(true); Boolean bbx = new Boolean(true); simulator.setVar("flag",bb); simulator.setVar("flagx",bbx); simulator.setVar("type","ge"); String mts1="\\italic{x} \\: \\in \\:", mtsU="\\: \\cup \\:", mts="", fs1, fs2,bo,bc, emp="\\emptyset "; double a1,a2,a3,b1,b2,b3,al1,al2,al3,bt1,bt2,bt3,maxmod, eq_sign, e=0.1; Double[] ar = null; while (true) { Boolean ab = simulator.getVar("flagx"); if (ab.booleanValue()) { //INIT a1=sba1.getDouble("Value"); a2=sba2.getDouble("Value"); a3=sba3.getDouble("Value"); b1=sbb1.getDouble("Value"); b2=sbb2.getDouble("Value"); b3=sbb3.getDouble("Value"); al1=sbal1.getDouble("Value"); al2=sbal2.getDouble("Value"); al3=sbal3.getDouble("Value"); bt1=sbbt1.getDouble("Value"); bt2=sbbt2.getDouble("Value"); bt3=sbbt3.getDouble("Value"); //масштабирование по x: if((maxmod=Math.max(Math.max(Math.max(Math.abs(a1),Math.abs(a2)),Math.abs(a3)),Math.max(Math.max(Math.abs(b1),Math.abs(b2)),Math.abs(b3))))>=5) { el.set("Minimal_X_value", -maxmod-1); el.set("Maximal_X_value", maxmod+1); el.update(); } else { el.set("Minimal_X_value", -5.0); el.set("Maximal_X_value", 5.0); el.update(); } //POINTS pta1.set("Var1", a1); pta2.set("Var1", a2); pta3.set("Var1", a3); ptb1.set("Var1", b1); ptb2.set("Var1", b2); ptb3.set("Var1", b3); p_upd(); //FUNCTION String fs1 = ""; if (al1!=0.0 && al1!=2.0 && al1!=4.0 && al1!=6.0 && al1!=8.0 && al1!=10.0) fs1 += "sign(x+"+(-a1)+")"; else if (al1!=0.0) fs1 += "0.5*(sign(x+" +(-a1+0.02)+ ")sign(x+" +(-a1-0.02)+ ")+1)"; if (al2!=0.0 && al2!=2.0 && al2!=4.0 && al2!=6.0 && al2!=8.0 && al2!=10.0) fs1 += "sign(x+"+(-a2)+")"; else if (al2!=0.0) fs1 += "0.5*(sign(x+" +(-a2+0.02)+ ")sign(x+" +(-a2-0.02)+ ")+1)"; if (al3!=0.0 && al3!=2.0 && al3!=4.0 && al3!=6.0 && al3!=8.0 && al3!=10.0) fs1 += "sign(x+"+(-a3)+")"; else if (al3!=0.0) fs1 += "0.5*(sign(x+" +(-a3+0.02)+ ")sign(x+" +(-a3-0.02)+ ")+1)"; String fs2 = ""; if (bt1!=0.0 && bt1!=2.0 && bt1!=4.0 && bt1!=6.0 && bt1!=8.0 && bt1!=10.0) fs2 += "sign(x+"+(-b1)+")"; else if (bt1!=0.0) fs2 += "0.5*(sign(x+" +(-b1+0.02)+ ")sign(x+" +(-b1-0.02)+ ")+1)"; if (bt2!=0.0 && bt2!=2.0 && bt2!=4.0 && bt2!=6.0 && bt2!=8.0 && bt2!=10.0) fs2 += "sign(x+"+(-b2)+")"; else if (bt2!=0.0) fs2 += "0.5*(sign(x+" +(-b2+0.02)+ ")sign(x+" +(-b2-0.02)+ ")+1)"; if (bt3!=0.0 && bt3!=2.0 && bt3!=4.0 && bt3!=6.0 && bt3!=8.0 && bt3!=10.0) fs2 += "sign(x+"+(-b3)+")"; else if (bt3!=0.0) fs2 += "0.5*(sign(x+" +(-b3+0.02)+ ")sign(x+" +(-b3-0.02)+ ")+1)"; if(fs1.length()+fs2.length()>0) f.set("Function", "sign("+sbC.getDouble("Value")+")*("+ fs1 + fs2 +")"); else f.set("Function", "sign("+sbC.getDouble("Value")+")"); f.update(); ab = new Boolean(false); simulator.setVar("flagx",ab); } //METATEX String type = simulator.getVar("type"); Boolean ab2 = simulator.getVar("flag"); if (ab2.booleanValue()) { mts = mts1; ar = new Double[]{a1,a2,a3,b1,b2,b3}; for (n=0;n<5;n++) { if (ar[n].doubleValue() > ar[n+1].doubleValue()) { Double shv = ar[n+1]; ar[n+1]=ar[n]; ar[n]=shv; n=-1; } } // System.out.println(ar[0]+" "+ar[1]+" "+ar[2]+" "+ar[3]+" "+ar[4]+" "+ar[5]); if (type.equals("le")||type.equals("l")) eq_sign=-1.0; if (type.equals("ge")||type.equals("g")) eq_sign=1.0; if (type.equals("e")) eq_sign=0.0; if (type.equals("g")||type.equals("l")) { pta1.set("Point_options", new boolean[]{false, false, true}); pta2.set("Point_options", new boolean[]{false, false, true}); pta3.set("Point_options", new boolean[]{false, false, true}); p_upd(); } else { pta1.set("Point_options", new boolean[]{false, false, false}); pta2.set("Point_options", new boolean[]{false, false, false}); pta3.set("Point_options", new boolean[]{false, false, false}); p_upd(); } /*CYCLE*/ for (i=0;i<6;i++) { for (n=0;n<5;n++) { if (i<5 && Math.abs(ar[i].doubleValue()-ar[i+1].doubleValue())<0.05) { i++; } } bo ="("; bc =")"; if ((type.equals("ge")||type.equals("le")) && ar[i].doubleValue()!=b1 && ar[i].doubleValue()!=b2 && ar[i].doubleValue()!=b3) { bo ="["; bc ="]"; } //string formation if (mts.equals(mts1) && (eq_sign*fc2(ar[i].doubleValue()-e))>0.0) { mts+= "(-\\infty;"; } if (type.equals("e") && ar[i].doubleValue()!=b1 && ar[i].doubleValue()!=b2 && ar[i].doubleValue()!=b3) { mts+= "\\{" + ar[i].doubleValue() + "\\}" + mtsU; } else if ( (eq_sign*fc2(ar[i].doubleValue()-e))>0.0 && eq_sign*fc2(ar[i].doubleValue()+e)<0.0 && mts.length()>0 && mts.charAt(mts.length()-1).equals(';') ) { mts+= "\\:"+ar[i].doubleValue()+bc+mtsU; } else if (eq_sign*fc2(ar[i].doubleValue()-e)<0.0 && (eq_sign*fc2(ar[i].doubleValue()+e))>0.0 && !mts.charAt(mts.length()-1).equals(';')) { mts+= bo +ar[i].doubleValue()+";"; } else if (eq_sign*fc2(ar[i].doubleValue()-e)<0.0 && eq_sign*fc2(ar[i].doubleValue()-e)<0.0) { if ( fc2(ar[i].doubleValue())==0.0 && (type.equals("le")||type.equals("ge")) ) mts+= "\\{" + ar[i].doubleValue() + "\\}" + mtsU; } else if ( (eq_sign*fc2(ar[i].doubleValue()-e))>0.0 && (eq_sign*fc2(ar[i].doubleValue()+e))>0.0 ) { if (fc2(ar[i].doubleValue())!=0.0) mts+= "\\:" +ar[i].doubleValue() +")" + mtsU + "("+ ar[i].doubleValue()+";"; else if ( (type.equals("l")||type.equals("g")) ) mts+= "\\:" +ar[i].doubleValue() +")" + mtsU + "("+ ar[i].doubleValue()+";"; } if ( (eq_sign*fc2(ar[i].doubleValue()+e))>0.0 && i==5 && mts.length()>0 && mts.charAt(mts.length()-1).equals(';') ) { mts+= "\\:+\\infty)"; } } if (mts.substring(mts.length()-10,mts.length()).equals(mtsU)) mts=mts.substring(0,mts.length()-10); if (mts.length()==20) mts+=emp; mt.getElement().setEquation(mts); mt.update(); /* if (ar[0].doubleValue()<-4.0) { el.set("Minimal_X_value", ""+ar[0].doubleValue()-1.0); el.update(); } if (ar[5].doubleValue()>4.0) { el.setProperty("Maximal_X_value", ""+ar[5].doubleValue()+1.0); el.update(); */ ab2 = new Boolean(false); simulator.setVar("flag",ab2); } dispatch(); Thread.sleep(100); }