/** * init this task by creating new instance of the ant task and configuring it's by calling its own * init method. */ public void init() { callee = (Ant) getProject().createTask("ant"); callee.setOwningTarget(getOwningTarget()); callee.setTaskName(getTaskName()); callee.setLocation(getLocation()); callee.init(); }
/** * Runs the given target on the provided build file. * * @param file the build file to execute * @param directory the directory of the current iteration * @throws BuildException is the file cannot be found, read, is a directory, or the target called * failed, but only if <code>failOnError</code> is <code>true</code>. Otherwise, a warning log * message is simply output. */ private void execute(File file, File directory) throws BuildException { if (!file.exists() || file.isDirectory() || !file.canRead()) { String msg = "Invalid file: " + file; if (failOnError) { throw new BuildException(msg); } log(msg, Project.MSG_WARN); return; } ant = createAntTask(directory); String antfilename = file.getAbsolutePath(); ant.setAntfile(antfilename); try { ant.execute(); } catch (BuildException e) { if (failOnError) { throw e; } log( "Failure for target '" + target + "' of: " + antfilename + "\n" + e.getMessage(), Project.MSG_WARN); } catch (Throwable e) { if (failOnError) { throw new BuildException(e); } log( "Failure for target '" + target + "' of: " + antfilename + "\n" + e.toString(), Project.MSG_WARN); } finally { ant = null; } }
public Move(Ant ant, Position currentPosition) { this.ant = ant; this.currentPosition = currentPosition; this.toPosition = ant.getPosition(); this.isAntDead = ((currentPosition.getX() == -1) && (currentPosition.getY() == -1)); this.turnWhere = ant.getDirection(); }
public void init() { callee = (Ant) project.createTask("ant"); callee.setOwningTarget(target); callee.setTaskName(getTaskName()); callee.setLocation(location); callee.init(); initialized = true; }
// get the index number of a food pile that the given ant is on. public int getFoodPileIndex(Ant currentAnt) { for (int i = 0; i < Parameters.NUM_OF_FOOD_PILES; i++) { if (theFood[i].getX() == currentAnt.getX() && theFood[i].getY() == currentAnt.getY()) return i; } System.out.println("Reached the unreachable"); return -1; // this line will never happen but eclipse made me add another return state }
/** * hand off the work to the ant task of ours, after setting it up * * @throws BuildException on validation failure or if the target didn't execute */ public void execute() throws BuildException { if (callee == null) { init(); } if (subTarget == null) { throw new BuildException("Attribute target is required.", getLocation()); } callee.setAntfile(getProject().getProperty("ant.file")); callee.setTarget(subTarget); callee.setInheritAll(inheritAll); callee.setInheritRefs(inheritRefs); callee.execute(); }
public void execute() { if (!initialized) { init(); } if (subTarget == null) { throw new BuildException("Attribute target is required.", location); } callee.setDir(project.getBaseDir()); callee.setAntfile(project.getProperty("ant.file")); callee.setTarget(subTarget); callee.setInheritAll(inheritAll); callee.execute(); }
/** * Pass output sent to System.out to the new project. * * @param output a line of output * @since Ant 1.6.2 */ public void handleOutput(String output) { if (ant != null) { ant.handleOutput(output); } else { super.handleOutput(output); } }
// constructor // public QueenAntActionSequenceController( MapSpace passedMapSpace, Ant passedAnt, int passedHungerThreshold, double passedScoutAntBirthPercentage, double passedForagerAntBirthPercentage, double passedSoldierAntBirthPercentage, int passedHealthDecrementAmount, int passedTimeInTurnsForBirth) { this.setAntWhoIsTakingAction(passedAnt); this.setMapSpaceToUse(passedMapSpace); this.setHungerThreshold(passedHungerThreshold); this.setHealthDecrementAmount(passedHealthDecrementAmount); this.setForagerAntBirthPercentage(passedForagerAntBirthPercentage); this.setScoutAntBirthPercentage(passedScoutAntBirthPercentage); this.setSoldierAntBirthPercentage(passedSoldierAntBirthPercentage); consume = new ConsumeFood(passedMapSpace, passedAnt, passedAnt.getFoodConsumptionRate()); antBirth = new AntBirth( this.getScoutAntBirthPercentage(), this.getForagerAntBirthPercentage(), this.getSoldierAntBirthPercentage(), this.getAntWhoIsTakingAction().getAntID()); this.setNumberOfTurnsToBirth(passedTimeInTurnsForBirth); }
/** * Process input into the ant task * * @param buffer the buffer into which data is to be read. * @param offset the offset into the buffer at which data is stored. * @param length the amount of data to read * @return the number of bytes read * @exception IOException if the data cannot be read * @see Task#handleInput(byte[], int, int) * @since Ant 1.6.2 */ public int handleInput(byte[] buffer, int offset, int length) throws IOException { if (ant != null) { return ant.handleInput(buffer, offset, length); } else { return super.handleInput(buffer, offset, length); } }
/** * Pass output sent to System.err to the new project. * * @param output The error output to log. Should not be <code>null</code>. * @since Ant 1.6.2 */ public void handleErrorFlush(String output) { if (ant != null) { ant.handleErrorFlush(output); } else { super.handleErrorFlush(output); } }
protected void handleErrorOutput(String line) { if (callee != null) { callee.handleErrorOutput(line); } else { super.handleErrorOutput(line); } }
/** * Pass output sent to System.err to the new project and flush stream. * * @since Ant 1.5.2 */ public void handleErrorFlush(String output) { if (callee != null) { callee.handleErrorFlush(output); } else { super.handleErrorFlush(output); } }
/** * Pass output sent to System.out to the new project. * * @since Ant 1.5 */ public void handleOutput(String output) { if (callee != null) { callee.handleOutput(output); } else { super.handleOutput(output); } }
public void setup() { // System.out.printf( "==> GUIModel setup() called...\n" ); super.setup(); // the super class does conceptual-model setup // NOTE: you may want to set these next two to 'true' // if you are on a windows machine. that would tell repast // to by default send System.out and .err output to // a special repast output window. AbstractGUIController.CONSOLE_ERR = false; AbstractGUIController.CONSOLE_OUT = false; AbstractGUIController.UPDATE_PROBES = true; if (dsurf != null) dsurf.dispose(); if (graph != null) graph.dispose(); if (graphNbors != null) graphNbors.dispose(); if (graphFood != null) graphFood.dispose(); graph = null; dsurf = null; graphNbors = null; graphFood = null; // tell the Ant class we are in GUI mode. Ant.setupBugDrawing(this); Food.setupFoodDrawing(this); // init, setup and turn on the modelMinipulator stuff (in custom actions) modelManipulator.init(); // one custom action to just print the bug list modelManipulator.addButton( "Print Bugs", new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.printf("printBugs...\n"); printBugs(); } }); // another action: reset all bugs probRandMove field // using the parameters that define the distribution to use modelManipulator.addButton( "Reset Bug probRandMove", new ActionListener() { public void actionPerformed(ActionEvent evt) { resetBugProbRandMove(); } }); if (rDebug > 0) System.out.printf("<== GUIModel setup() done.\n"); }
/** // setBugColorBasedOnProbRandMove */ public void setBugColorBasedOnProbRandMove() { for (Ant bug : antList) bug.setBugColorFromPRM(); }
/** * Creates the <ant> task configured to run a specific target. * * @param directory : if not null the directory where the build should run * @return the ant task, configured with the explicit properties and references necessary to run * the sub-build. */ private Ant createAntTask(File directory) { Ant ant = (Ant) getProject().createTask("ant"); ant.setOwningTarget(getOwningTarget()); ant.setTaskName(getTaskName()); ant.init(); if (target != null && target.length() > 0) { ant.setTarget(target); } if (output != null) { ant.setOutput(output); } if (directory != null) { ant.setDir(directory); } ant.setInheritAll(inheritAll); for (Enumeration i = properties.elements(); i.hasMoreElements(); ) { copyProperty(ant.createProperty(), (Property) i.nextElement()); } for (Enumeration i = propertySets.elements(); i.hasMoreElements(); ) { ant.addPropertyset((PropertySet) i.nextElement()); } ant.setInheritRefs(inheritRefs); for (Enumeration i = references.elements(); i.hasMoreElements(); ) { ant.addReference((Ant.Reference) i.nextElement()); } return ant; }
/** Property to pass to the invoked target. */ public Property createParam() { if (callee == null) { init(); } return callee.createProperty(); }
public Property createParam() { return callee.createProperty(); }
/** * Reference element identifying a data type to carry over to the invoked target. * * @since Ant 1.5 */ public void addReference(Ant.Reference r) { if (callee == null) { init(); } callee.addReference(r); }
/** * Set of properties to pass to the new project. * * @since Ant 1.6 */ public void addPropertyset(org.apache.tools.ant.types.PropertySet ps) { if (callee == null) { init(); } callee.addPropertyset(ps); }