List of usage examples for java.lang Math rint
public static double rint(double a)
From source file:de.tor.tribes.ui.views.DSWorkbenchConquersFrame.java
@Override public void dataChangedEvent(String pGroup) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(ConquerManager.getSingleton().getLastUpdate()); SimpleDateFormat f = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); jLastUpdateLabel.setText("<html><b>Letzte Aktualisierung:</b> " + f.format(c.getTime()) + "</html>"); int[] conquerStats = ConquerManager.getSingleton().getConquersStats(); int conquers = ConquerManager.getSingleton().getConquerCount(); int percGrey = (int) Math.rint(100.0 * (double) conquerStats[0] / (double) conquers); int percFriendly = (int) Math.rint(100.0 * (double) conquerStats[1] / (double) conquers); int percSelf = (int) Math.rint(100.0 * (double) conquerStats[2] / (double) conquers); jGreyConquersLabel.setText("<html><b>Grau-Adelungen:</b> " + conquerStats[0] + " von " + conquers + " (" + percGrey + "%)" + "</html>"); jFriendlyConquersLabel.setText("<html><b>Aufadelungen:</b> " + conquerStats[1] + " von " + conquers + " (" + percFriendly + "%)" + "</html>"); jSelfConquersLabel.setText("<html><b>Selbstadelungen:</b> " + conquerStats[2] + " von " + conquers + " (" + percSelf + "%)" + "</html>"); ((ConquerTableModel) jConquersTable.getModel()).fireTableDataChanged(); }
From source file:de.tor.tribes.types.FarmInformation.java
/** * Farm this farm//from w w w. j av a 2 s . c om * * @param pConfig * The troops used for farming or 'null' if the needed amount of * troops should be calculated */ public FARM_RESULT farmFarm(DSWorkbenchFarmManager.FARM_CONFIGURATION pConfig) { StringBuilder info = new StringBuilder(); if (inactive) { lastResult = FARM_RESULT.FARM_INACTIVE; info.append("Farm ist inaktiv. Aktiviere die Farm, um sie wieder nutzen zu knnen.\n"); } else {// farm is active if (!TroopsManager.getSingleton().hasInformation(TroopsManager.TROOP_TYPE.OWN)) { // we need troop information to continue.... logger.info("No own troops imported to DS Workbench"); lastResult = FARM_RESULT.FAILED; info.append("Keine Truppeninformationen aus dem Spiel nach DS Workbench importiert.\n" + "Wechsel in die Truppenbersicht im Spiel, kopiere die Seite per STRG+A und kopiere sie\n" + "per STRG+C in die Zwischenablage, von wo DS Workbench sie dann automatisch einlesen wird.\n"); } else { ////////////// troops are imported/////////////// ///////////////// start farming////////////////// final HashMap<Village, TroopAmountFixed> carriageMap = new HashMap<>(); List<Village> villages = new LinkedList<>(); for (Village selectedVillage : DSWorkbenchFarmManager.getSelectedFarmGroup()) { TroopAmountFixed units; units = new TroopAmountFixed(); VillageTroopsHolder holder = TroopsManager.getSingleton().getTroopsForVillage(selectedVillage, TroopsManager.TROOP_TYPE.OWN); if (holder == null) { //troops not read info.append("Truppen noch nicht eingelesen"); lastSendInformation = info.toString(); return FARM_RESULT.FAILED; } // Defines the Troops to be farmed with for A/B/C/K units = TroopHelper.getTroopsForCarriage(pConfig, holder, this); // Adds rams if check box is marked and contains already units if (DSWorkbenchFarmManager.getSingleton().isUseRams(pConfig) && units.hasUnits()) { TroopHelper.addNeededRams(units, holder, this); } if (pConfig.equals(DSWorkbenchFarmManager.FARM_CONFIGURATION.K) && units.hasUnits()) { // Ignore empty attacks // Only for Farm-type K TroopHelper.addNeededCatas(units, holder, this); } if (units != null && units.hasUnits()) { // Add result to the farm map... if reasonable // units from this village can carry all resources carriageMap.put(selectedVillage, units); villages.add(selectedVillage); } } // have village with valid amounts if (villages.isEmpty()) { info.append( "Es wurden alle Drfer aufgrund der Tragekapazitt ihrer Truppen, ihrer Entfernung zum Ziel oder der erwarteten Ressourcen gelscht.\n" + "Mglicherweise knnte ein erneuter Truppenimport aus dem Spiel, eine Vergrerung des Farmradius oder eine Verkleinerung der minimalen Anzahl an Einheiten\n" + "hilfreich sein. berprfe auch die eingestellte Truppenreserve (R), falls vorhanden.\n"); lastResult = FARM_RESULT.IMPOSSIBLE; } else { info.append(villages.size()) .append(" Dorf/Drfer verfgen ber die bentigte Tragekapazitt.\n"); // there are villages which can carry all resources or we use scenario A/B // sort valid villages by speed if we are not in the case that we are // using farm type C without sufficient troops Collections.sort(villages, new Comparator<Village>() { @Override public int compare(Village o1, Village o2) { // get speed of defined troops (A and B) or by troops for carriage (C)... // ...as this ordering is not performed in case of cByMinHaul, pAllowMaxCarriage // is set to 'false' double speed1 = carriageMap.get(o1).getSpeed(); double speed2 = carriageMap.get(o2).getSpeed(); return new Double(DSCalculator.calculateMoveTimeInMinutes(o1, getVillage(), speed1)) .compareTo(DSCalculator.calculateMoveTimeInMinutes(o2, getVillage(), speed2)); } }); // now select the "best" village for farming Village selection = null; TroopAmountFixed farmers = null; Range<Integer> r = DSWorkbenchFarmManager.getSingleton().getFarmRange(pConfig); int noTroops = 0; int distCheckFailed = 0; int minHaulCheckFailed = 0; double minDist = 0; int minHaul = DSWorkbenchFarmManager.getSingleton().getMinHaul(pConfig); // search feasible village for (Village v : villages) { // take troops from carriageMap TroopAmountFixed troops = carriageMap.get(v); double speed = troops.getSpeed(); int resources = getResourcesInStorage(System.currentTimeMillis() + DSCalculator.calculateMoveTimeInMillis(v, getVillage(), speed)); double dist = DSCalculator.calculateMoveTimeInMinutes(v, getVillage(), speed); // troops are empty if they are not met the minimum troop amount if (!troops.hasUnits() || (pConfig.equals(DSWorkbenchFarmManager.FARM_CONFIGURATION.C) && troops.getFarmCapacity() == 0)) { noTroops++; } else {// enough troops if (dist > 0 && r.contains((int) dist)) { if (resources < minHaul) { minHaulCheckFailed++; } else { // village and troops found...use them selection = v; farmers = troops; break; } } else { distCheckFailed++; if (dist > 0) { if (minDist == 0) { minDist = dist; } else { minDist = Math.min(dist, minDist); } } } } } // check if feasible village was found if (selection == null || farmers == null) { lastResult = FARM_RESULT.IMPOSSIBLE; info.append( "In der abschlieenden Prfung wurden alle Drfer entfernt.\nDie Grnde waren die Folgenden:\n- ") .append(noTroops) .append(" Dorf/Drfer hatten nicht ausreichend Truppen fr die erwarteten Rohstoffe\n- ") .append(distCheckFailed) .append(" Dorf/Drfer lagen auerhalb des eingestellten Farmradius (Min. Laufzeit: ") .append((int) Math.rint(minDist)).append(" Minuten)\n- ").append(minHaulCheckFailed) .append(" Dorf/Drfer wrden nicht gengend Rohstoffe vorfinden, um die minimale Beute zu erzielen"); } else { // send troops and update if (BrowserInterface.sendTroops(selection, getVillage(), farmers)) { // if (true) { if (pConfig.equals(DSWorkbenchFarmManager.FARM_CONFIGURATION.C)) { int farmCap = farmers.getFarmCapacity(); int pwood = getWoodInStorage(System.currentTimeMillis() + DSCalculator .calculateMoveTimeInMillis(selection, getVillage(), farmers.getSpeed())); int pclay = getClayInStorage(System.currentTimeMillis() + DSCalculator .calculateMoveTimeInMillis(selection, getVillage(), farmers.getSpeed())); int piron = getIronInStorage(System.currentTimeMillis() + DSCalculator .calculateMoveTimeInMillis(selection, getVillage(), farmers.getSpeed())); setExtraResources(Math.max(pwood - farmCap * pwood / (pwood + pclay + piron), 0), Math.max(pclay - farmCap * pclay / (pwood + pclay + piron), 0), Math.max(piron - farmCap * piron / (pwood + pclay + piron), 0)); } TroopHelper.sendTroops(selection, farmers); if (pConfig.equals(DSWorkbenchFarmManager.FARM_CONFIGURATION.K)) { siegeTroop = farmers; siegeTroopArrival = System.currentTimeMillis() + DSCalculator .calculateMoveTimeInMillis(selection, getVillage(), siegeTroop.getSpeed()); if (siegeTroop.getAmountForUnit("catapult") > 0) { if (siegeTroop.getAmountForUnit("ram") > 0) { setSiegeStatus(SIEGE_STATUS.BOTH_ON_WAY); } else { setSiegeStatus(SIEGE_STATUS.CATA_ON_WAY); } } else { if (siegeTroop.getAmountForUnit("ram") > 0) { setSiegeStatus(SIEGE_STATUS.RAM_ON_WAY); } else { logger.debug("Code should not get here!"); } } lastResult = FARM_RESULT.OK; info.append("Der Farmangriff konnte erfolgreich abgeschickt werden."); } else { farmTroop = farmers; farmTroopArrive = System.currentTimeMillis() + DSCalculator .calculateMoveTimeInMillis(selection, getVillage(), farmers.getSpeed()); setStatus(FARM_STATUS.FARMING); attackCount++; lastResult = FARM_RESULT.OK; info.append("Der Farmangriff konnte erfolgreich abgeschickt werden."); } } else { farmTroop = null; farmTroopArrive = -1; lastResult = FARM_RESULT.FAILED; info.append("Der Farmangriff konnte nicht im Browser geffnet werden.\n" + "Bitte berprfe die Browsereinstellungen von DS Workbench."); } } } } } usedConfig = pConfig; lastSendInformation = info.toString(); return lastResult; }
From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java
/** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device.//from w w w. ja v a 2 s . co m * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ protected List logRefreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); Range range = getRange(); //get lower bound value: double lowerBoundVal = range.getLowerBound(); //if small log values and lower bound value too small // then set to a small value (don't allow <= 0): if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) { lowerBoundVal = SMALL_LOG_VALUE; } //get upper bound value double upperBoundVal = range.getUpperBound(); //get log10 version of lower bound and round to integer: int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal)); //get log10 version of upper bound and round to integer: int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal)); if (iBegCount == iEndCount && iBegCount > 0 && Math.pow(10, iBegCount) > lowerBoundVal) { //only 1 power of 10 value, it's > 0 and its resulting // tick value will be larger than lower bound of data --iBegCount; //decrement to generate more ticks } double currentTickValue; String tickLabel; boolean zeroTickFlag = false; for (int i = iBegCount; i <= iEndCount; i++) { //for each power of 10 value; create ten ticks for (int j = 0; j < 10; ++j) { //for each tick to be displayed if (this.smallLogFlag) { //small log values in use; create numeric value for tick currentTickValue = Math.pow(10, i) + (Math.pow(10, i) * j); if (this.expTickLabelsFlag || (i < 0 && currentTickValue > 0.0 && currentTickValue < 1.0)) { //showing "1e#"-style ticks or negative exponent // generating tick value between 0 & 1; show fewer if (j == 0 || (i > -4 && j < 2) || currentTickValue >= upperBoundVal) { //first tick of series, or not too small a value and // one of first 3 ticks, or last tick to be displayed // set exact number of fractional digits to be shown // (no effect if showing "1e#"-style ticks): this.numberFormatterObj.setMaximumFractionDigits(-i); //create tick label (force use of fmt obj): tickLabel = makeTickLabel(currentTickValue, true); } else { //no tick label to be shown tickLabel = ""; } } else { //tick value not between 0 & 1 //show tick label if it's the first or last in // the set, or if it's 1-5; beyond that show // fewer as the values get larger: tickLabel = (j < 1 || (i < 1 && j < 5) || (j < 4 - i) || currentTickValue >= upperBoundVal) ? makeTickLabel(currentTickValue) : ""; } } else { //not small log values in use; allow for values <= 0 if (zeroTickFlag) { //if did zero tick last iter then --j; //decrement to do 1.0 tick now } //calculate power-of-ten value for tick: currentTickValue = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j) : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j)); if (!zeroTickFlag) { // did not do zero tick last iteration if (Math.abs(currentTickValue - 1.0) < 0.0001 && lowerBoundVal <= 0.0 && upperBoundVal >= 0.0) { //tick value is 1.0 and 0.0 is within data range currentTickValue = 0.0; //set tick value to zero zeroTickFlag = true; //indicate zero tick } } else { //did zero tick last iteration zeroTickFlag = false; //clear flag } //create tick label string: //show tick label if "1e#"-style and it's one // of the first two, if it's the first or last // in the set, or if it's 1-5; beyond that // show fewer as the values get larger: tickLabel = ((this.expTickLabelsFlag && j < 2) || j < 1 || (i < 1 && j < 5) || (j < 4 - i) || currentTickValue >= upperBoundVal) ? makeTickLabel(currentTickValue) : ""; } if (currentTickValue > upperBoundVal) { return ticks; // if past highest data value then exit // method } if (currentTickValue >= lowerBoundVal - SMALL_LOG_VALUE) { //tick value not below lowest data value TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(tick); } } } return ticks; }
From source file:org.gumtree.vis.plot1d.KLogarithmicAxis.java
private String createTickLabel(double tickVal, int index) { String tickLabel;/*from w ww. j a v a 2s . com*/ String initial = "1"; // if (tickVal > 1) initial = String.valueOf((int) (tickVal / Math.pow(10, index))); if (this.log10TickLabelsFlag) { //create "log10"-type label tickLabel = (((index < 0) ? "-" : "") + "10^" + Math.abs(index)); } else { if (this.expTickLabelsFlag) { //create "1e#"-type label tickLabel = (((index < 0) ? "-" : "") + initial + "e" + Math.abs(index)); } else { if (tickVal > 1) { NumberFormat format = getNumberFormatOverride(); if (format != null) { tickLabel = format.format(tickVal); } else { tickLabel = Long.toString((long) Math.rint(tickVal)); } } else { this.numberFormatterObj.setMaximumFractionDigits(-index); // create tick label: tickLabel = this.numberFormatterObj.format(tickVal); } } } return tickLabel; }
From source file:de.tor.tribes.ui.views.DSWorkbenchSOSRequestAnalyzer.java
private void analyzeData(boolean pReAnalyze) { if (a == null || !a.isRunning()) { jProgressBar1.setValue(0);//from ww w.j av a 2s . c om jProgressBar1.setString("Analysiere Daten..."); jButton1.setEnabled(false); TroopAmountFixed stdOffense = DSWorkbenchSettingsDialog.getSingleton().getOffense(); TroopAmountFixed stdDefense = DSWorkbenchSettingsDialog.getSingleton().getDefense(); if (stdOffense.getTroopPopCount() == 0 || stdDefense.getTroopPopCount() == 0) { showInfo( "kann die daten nicht analysieren, weil standard Off / Untersttzung nicht gesetzt sind (in den Einstellungen)"); jProgressBar1.setString("Bereit"); jButton1.setEnabled(true); updateSupportTable(); return; } a = new DefenseAnalyzer(new DefenseAnalyzer.DefenseAnalyzerListener() { @Override public void fireProceedEvent(double pStatus) { int status = (int) Math.rint(pStatus * 100.0); jProgressBar1.setValue((int) Math.rint(pStatus * 100.0)); if (status % 10 == 0) { jAttacksTable.repaint(); } } @Override public void fireFinishedEvent() { jButton1.setEnabled(true); jProgressBar1.setString("Bereit"); updateSupportTable(); } }, stdOffense, stdDefense, GlobalOptions.getProperties().getInt("max.sim.rounds"), GlobalOptions.getProperties().getInt("max.loss.ratio"), pReAnalyze); a.start(); } }
From source file:com.machinepublishers.jbrowserdriver.ElementServer.java
/** * {@inheritDoc}/* w ww . j a va2 s . c o m*/ */ @Override public Point locate() { AppThread.exec(contextItem.statusCode, new Sync<Object>() { @Override public Point perform() { validate(false); node.eval(SCROLL_INTO_VIEW); return null; } }); return AppThread.exec(contextItem.statusCode, new Sync<Point>() { @Override public Point perform() { validate(true); JSObject obj = (JSObject) node.call("getBoundingClientRect"); double y = Double.parseDouble(obj.getMember("top").toString()); double x = Double.parseDouble(obj.getMember("left").toString()); y = y < 0d ? 0d : y; x = x < 0d ? 0d : x; final org.openqa.selenium.Point frameLocation = contextItem.selectedFrameLocation(); return new Point((int) Math.rint(x) + 1 + frameLocation.getX(), (int) Math.rint(y) + 1 + frameLocation.getY()); } }); }
From source file:forseti.JUtil.java
public static synchronized float redondear(float cant, byte dec) { float res;//from ww w. j a v a2 s .c o m switch (dec) { case 0: res = (float) Math.rint(cant); break; case 1: res = (float) Math.rint(cant * 10) / 10; break; case 2: res = (float) Math.rint(cant * 100) / 100; break; case 3: res = (float) Math.rint(cant * 1000) / 1000; break; case 4: res = (float) Math.rint(cant * 10000) / 10000; break; case 5: res = (float) Math.rint(cant * 100000) / 100000; break; case 6: res = (float) Math.rint(cant * 1000000) / 1000000; break; case 7: res = (float) Math.rint(cant * 10000000) / 10000000; break; case 8: res = (float) Math.rint(cant * 100000000) / 100000000; break; case 9: res = (float) Math.rint(cant * 1000000000) / 1000000000; break; default: res = cant; break; } return res; }
From source file:forseti.JUtil.java
public static synchronized float redondear(float cant, int dec) { float res;//w w w . jav a 2 s.c om switch (dec) { case 0: res = (float) Math.rint(cant); break; case 1: res = (float) Math.rint(cant * 10) / 10; break; case 2: res = (float) Math.rint(cant * 100) / 100; break; case 3: res = (float) Math.rint(cant * 1000) / 1000; break; case 4: res = (float) Math.rint(cant * 10000) / 10000; break; case 5: res = (float) Math.rint(cant * 100000) / 100000; break; case 6: res = (float) Math.rint(cant * 1000000) / 1000000; break; case 7: res = (float) Math.rint(cant * 10000000) / 10000000; break; case 8: res = (float) Math.rint(cant * 100000000) / 100000000; break; case 9: res = (float) Math.rint(cant * 1000000000) / 1000000000; break; default: res = cant; break; } return res; }
From source file:forseti.JUtil.java
public static synchronized double redondear(double cant, int dec) { double res;/*from w w w. ja v a 2 s. c o m*/ switch (dec) { case 0: res = Math.rint(cant); break; case 1: res = Math.rint(cant * 10) / 10; break; case 2: res = Math.rint(cant * 100) / 100; break; case 3: res = Math.rint(cant * 1000) / 1000; break; case 4: res = Math.rint(cant * 10000) / 10000; break; case 5: res = Math.rint(cant * 100000) / 100000; break; case 6: res = Math.rint(cant * 1000000) / 1000000; break; case 7: res = Math.rint(cant * 10000000) / 10000000; break; case 8: res = Math.rint(cant * 100000000) / 100000000; break; case 9: res = Math.rint(cant * 1000000000) / 1000000000; break; default: res = cant; break; } return res; }
From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java
protected List newRefreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); //get lower bound value: double lowerBoundVal = getRange().getLowerBound(); //if small log values and lower bound value too small // then set to a small value (don't allow <= 0): if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) { lowerBoundVal = SMALL_LOG_VALUE; }//ww w. j a v a2 s . co m //get upper bound value double upperBoundVal = getRange().getUpperBound(); //get log10 version of lower bound and round to integer: int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal)); //get log10 version of upper bound and round to integer: int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal)); if (iBegCount == iEndCount && iBegCount > 0 && Math.pow(10, iBegCount) > lowerBoundVal) { //only 1 power of 10 value, it's > 0 and its resulting // tick value will be larger than lower bound of data --iBegCount; //decrement to generate more ticks } // nxi@ansto: check how many ticks get produced. Put more if less than 4 int numberOfGrids = 0; int numberOfTicks = 0; NumberTick lastTick = null; double tickVal; String tickLabel; // tickVal = lowerBoundVal; // // tickLabel = Long.toString((long) Math.rint(tickVal)); // ticks.add(new NumberTick(new Double(tickVal), tickLabel, // TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0.0)); boolean zeroTickFlag = false; for (int i = iBegCount; i <= iEndCount; i++) { //for each tick with a label to be displayed int jEndCount = 10; if (i == iEndCount) { // jEndCount = 1; } for (int j = 0; j < jEndCount; j++) { //for each tick to be displayed if (this.smallLogFlag) { //small log values in use tickVal = Math.pow(10, i) + (Math.pow(10, i) * j); if (j == 0 || j == 1 || j == 4) { //first tick of group; create label text if (this.log10TickLabelsFlag) { //if flag then tickLabel = "10^" + i; //create "log10"-type label } else { //not "log10"-type label if (this.expTickLabelsFlag) { //if flag then tickLabel = "1e" + i; //create "1e#"-type label } else { //not "1e#"-type label if (i >= 0) { // if positive exponent then // make integer NumberFormat format = getNumberFormatOverride(); if (format != null) { tickLabel = format.format(tickVal); } else { tickLabel = Long.toString((long) Math.rint(tickVal)); } } else { //negative exponent; create fractional value //set exact number of fractional digits to // be shown: this.numberFormatterObj.setMaximumFractionDigits(-i); //create tick label: tickLabel = this.numberFormatterObj.format(tickVal); } } } } else { //not first tick to be displayed if (numberOfTicks == 0) tickLabel = createTickLabel(tickVal, i); else tickLabel = ""; //no label // tickLabel = ""; //no tick label } } else { //not small log values in use; allow for values <= 0 if (zeroTickFlag) { //if did zero tick last iter then --j; } //decrement to do 1.0 tick now tickVal = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j) : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j)); if (j == 0 || j == 1 || j == 4) { //first tick of group if (!zeroTickFlag) { // did not do zero tick last // iteration if (i > iBegCount && i < iEndCount && Math.abs(tickVal - 1.0) < 0.0001) { // not first or last tick on graph and value // is 1.0 tickVal = 0.0; //change value to 0.0 zeroTickFlag = true; //indicate zero tick tickLabel = "0"; //create label for tick } else { //first or last tick on graph or value is 1.0 //create label for tick: tickLabel = createTickLabel(tickVal, i); } } else { // did zero tick last iteration if (numberOfTicks == 0) tickLabel = createTickLabel(tickVal, i); else tickLabel = ""; //no label zeroTickFlag = false; //clear flag } } else { // not first tick of group if (numberOfTicks == 0) tickLabel = createTickLabel(tickVal, i); else tickLabel = ""; //no label zeroTickFlag = false; //make sure flag cleared } } if (tickVal > upperBoundVal) { if (lastTick != null) { String lastTickText = lastTick.getText(); double value = lastTick.getValue(); if (numberOfTicks < 8 || getFirstDigit(value) != 6) if (lastTickText == null || lastTickText.trim().length() == 0) { ticks.remove(lastTick); ticks.add(new NumberTick(lastTick.getValue(), createTickLabel(lastTick.getValue(), i - 1), lastTick.getTextAnchor(), lastTick.getRotationAnchor(), lastTick.getAngle())); } } if (numberOfTicks < 4) { return getAllTicksVertical(g2, dataArea, edge); } return ticks; //if past highest data value then exit method } if (tickVal >= lowerBoundVal - SMALL_LOG_VALUE) { //tick value not below lowest data value TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; angle = -Math.PI / 2.0; } else { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; angle = Math.PI / 2.0; } } else { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; } else { anchor = TextAnchor.CENTER_LEFT; rotationAnchor = TextAnchor.CENTER_LEFT; } } // nxi@ansto: create tick object and add to list: lastTick = new NumberTick(new Double(tickVal), tickLabel, anchor, rotationAnchor, angle); ticks.add(lastTick); if (tickLabel != null && tickLabel.trim().length() > 0) numberOfTicks++; numberOfGrids++; } } } if (numberOfTicks < 4) { return getAllTicksVertical(g2, dataArea, edge); } return ticks; }