/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package eric.jobs; import eric.GUI.pipe_tools; import eric.Progress_Bar; import java.util.ArrayList; import java.util.Enumeration; import rene.gui.Global; import rene.zirkel.ZirkelCanvas; import rene.zirkel.construction.Construction; import rene.zirkel.objects.ConstructionObject; import rene.zirkel.objects.PointObject; /** * * @author erichake */ public class JobValidation { private final int MAX=1000; private ZirkelCanvas ZC; private Construction C; private ArrayList mobiles=new ArrayList(); private ArrayList mobilesCoords=new ArrayList(); private ArrayList targets, clones; public JobValidation(ZirkelCanvas zc) { ZC=zc; C=ZC.getConstruction(); initMobiles(); targets=ZC.job_getTargets(); } public void initMobiles() { mobiles.clear(); mobilesCoords.clear(); Enumeration e=C.elements(); while (e.hasMoreElements()) { final ConstructionObject c=(ConstructionObject) e.nextElement(); if (c instanceof PointObject) { PointObject pt=(PointObject) c; if (pt.moveable()&&pt.insidewindow()) { mobiles.add(pt); double[] tab={pt.getX(), pt.getY()}; mobilesCoords.add(tab); } } } } /** * Find every clones of targets object in the whole construction * @return true if everything is fine. return false in case of * error. */ public boolean initClones() { clones=new ArrayList(); for (int i=0; i"; if (!pipe_tools.Exercise_To_HTML(false, ZC.job_getMessageFailed())) { JobMessage.showMessage(message); } } public void constructionOk() { reset(); if (!pipe_tools.Exercise_To_HTML(true, ZC.job_getMessageOk())) { JobMessage.showMessage(ZC.job_getMessageOk()); } } public void constructionOkExceptAlignment() { reset(); String message=""+ZC.job_getMessageOk(); message+="
("+Global.Loc("job.gui.alignment")+")"; if (!pipe_tools.Exercise_To_HTML(true, ZC.job_getMessageOk()+" ("+Global.Loc("job.gui.alignment")+")")) { JobMessage.showMessage(message); } } public void justSee() { ZC.paint(ZC.getGraphics()); try { Thread.sleep(200); } catch (InterruptedException ex) { } } public void checkAllsteps() { if ((mobiles.size()>0)&&(!ZC.job_isStaticJob())) { // if it's a dynamic exercise : int failed=0; if (!initClones()) { dynamicConstructionFailed(); return; } int progress=0; Progress_Bar.create(Global.Loc("job.gui.progressmessage"), 0, MAX-1); for (int i=0; i0) { dynamicConstructionFailed(failed); return; } if (!checkHorizontalAligment()) { constructionOkExceptAlignment(); return; } constructionOk(); } else { // if it's a static exercise : if (!initClones()) { staticConstructionFailed(); return; } constructionOk(); } } }