List of usage examples for java.util Formatter toString
public String toString()
From source file:com.itemanalysis.psychometrics.irt.estimation.JointMaximumLikelihoodEstimation.java
/** * This method is for displaying item parameter estimates, standard errors, and other information. * * @return//from w ww . j av a 2s .c om */ public String printBasicItemStats(String title) { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); int maxCat = 0; for (int j = 0; j < nItems; j++) { maxCat = Math.max(irm[j].getNcat(), maxCat); } f.format("%40s", title); f.format("%n"); String line1 = "========================================================"; int lineLength = 44; if (maxCat > 2) { for (int k = 0; k < maxCat - 1; k++) { line1 += "============"; lineLength += 12; } } f.format("%" + lineLength + "s", line1); f.format("%n"); f.format("%20s", "Name"); f.format("%12s", "Difficulty"); f.format("%12s", "Std. Error"); if (maxCat > 2) { for (int k = 0; k < maxCat - 1; k++) { f.format("%12s", "step" + (k + 1)); } } f.format("%12s", "Extreme"); f.format("%n"); String line = "--------------------------------------------------------"; lineLength = 44; if (maxCat > 2) { for (int k = 0; k < maxCat - 1; k++) { line += "------------"; lineLength += 12; } } f.format("%" + lineLength + "s", line); f.format("%n"); for (int j = 0; j < nItems; j++) { f.format("%20s", irm[j].getName()); if (droppedStatus[j] == 0) { f.format("%12.2f", irm[j].getDifficulty()); f.format("%12.2f", irm[j].getDifficultyStdError()); if (irm[j].getNcat() > 2) { double[] t = irm[j].getThresholdParameters(); for (int k = 0; k < t.length; k++) { f.format("%12.2f", t[k]); } } if (itemSummary[j].isExtremeMaximum()) { f.format("%12s", "MAXIMUM"); } else if (itemSummary[j].isExtremeMinimum()) { f.format("%12s", "MINIMUM"); } else { f.format("%12s", ""); } f.format("%n"); if (irm[j].getNcat() > 2) { String id = irm[j].getGroupId(); double[] tse = rsg.get(id).getThresholdStandardError(); f.format("%44s", ""); for (int k = 0; k < tse.length; k++) { f.format("%12.2f", tse[k]); } f.format("%n"); } } else { f.format("%12s", "DROPPED"); f.format("%n"); } } f.format("%" + lineLength + "s", line1); f.format("%n"); return f.toString(); }
From source file:umontreal.iro.lecuyer.charts.HistogramSeriesCollection.java
public String toLatex(double XScale, double YScale, double XShift, double YShift, double xmin, double xmax, double ymin, double ymax) { // Calcule les bornes reelles du graphique, en prenant en compte la position des axes xmin = Math.min(XShift, xmin); xmax = Math.max(XShift, xmax); ymin = Math.min(YShift, ymin); ymax = Math.max(YShift, ymax); CustomHistogramDataset tempSeriesCollection = (CustomHistogramDataset) seriesCollection; Formatter formatter = new Formatter(Locale.US); double var; double margin = ((XYBarRenderer) renderer).getMargin(); for (int i = tempSeriesCollection.getSeriesCount() - 1; i >= 0; i--) { List temp = tempSeriesCollection.getBins(i); ListIterator iter = temp.listIterator(); Color color = (Color) renderer.getSeriesPaint(i); String colorString = detectXColorClassic(color); if (colorString == null) { colorString = "color" + i; formatter.format("\\definecolor{%s}{rgb}{%.2f, %.2f, %.2f}%n", colorString, color.getRed() / 255.0, color.getGreen() / 255.0, color.getBlue() / 255.0); }/*from w w w. ja v a 2 s .c om*/ HistogramBin currentBin = null; while (iter.hasNext()) { double currentMargin; currentBin = (HistogramBin) iter.next(); currentMargin = ((margin * (currentBin.getEndBoundary() - currentBin.getStartBoundary()))) * XScale; if ((currentBin.getStartBoundary() >= xmin && currentBin.getStartBoundary() <= xmax) && (currentBin.getCount() >= ymin && currentBin.getCount() <= ymax)) { var = Math.min(currentBin.getEndBoundary(), xmax); if (filled[i]) { formatter.format( "\\filldraw [line width=%.2fpt, opacity=%.2f, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], (color.getAlpha() / 255.0), colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (currentBin.getCount() - YShift) * YScale); } else { formatter.format( "\\draw [line width=%.2fpt, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (currentBin.getCount() - YShift) * YScale); } } else if ((currentBin.getStartBoundary() >= xmin && currentBin.getStartBoundary() <= xmax) && (currentBin.getCount() >= ymin && currentBin.getCount() > ymax)) { // Cas ou notre rectangle ne peut pas etre affiche en entier (trop haut) var = Math.min(currentBin.getEndBoundary(), xmax); if (filled[i]) { formatter.format( "\\filldraw [line width=%.2fpt, opacity=%.2f, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], (color.getAlpha() / 255.0), colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); formatter.format( "\\draw [line width=%.2fpt, color=%s, style=dotted] ([xshift=%.4f] %.4f, %.4f) rectangle ([yshift=3mm, xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, (ymax - YShift) * YScale, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); } else { formatter.format( "\\draw [line width=%.2fpt, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); formatter.format( "\\draw [line width=%.2fpt, color=%s, style=dotted] ([xshift=%.4f] %.4f, %.4f) rectangle ([yshift=3mm, xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, (ymax - YShift) * YScale, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); } } } } return formatter.toString(); }
From source file:com.itemanalysis.psychometrics.cfa.CfaSummary.java
public String multipleCfa(int estimationMethod, int optimizationMethod) { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); ConfirmatoryFactorAnalysis congeneric = new ConfirmatoryFactorAnalysis(cfaMatrix, numberOfExaminees, ConfirmatoryFactorAnalysisModel.CONGENERIC, estimationMethod); congeneric.optimize(optimizationMethod); logger.info("Congeneric Model CFA completed\n" + congeneric.printOptimizationSummary()); ConfirmatoryFactorAnalysis tauEquivalent = new ConfirmatoryFactorAnalysis(cfaMatrix, numberOfExaminees, ConfirmatoryFactorAnalysisModel.TAU_EQUIVALENT, estimationMethod); tauEquivalent.optimize(optimizationMethod); logger.info("Tau-equivalent Model CFA completed\n" + tauEquivalent.printOptimizationSummary()); ConfirmatoryFactorAnalysis parallel = new ConfirmatoryFactorAnalysis(cfaMatrix, numberOfExaminees, ConfirmatoryFactorAnalysisModel.PARALLEL, estimationMethod); parallel.optimize(optimizationMethod); logger.info("Parallel Model CFA completed\n" + parallel.printOptimizationSummary()); f.format("%-60s", " CONGENERIC, TAU-EQUIVALENT, AND PARALLEL"); f.format("%n"); f.format("%-60s", " CONFIRMATORY FACTOR ANLAYSIS"); f.format("%n"); f.format("%n"); f.format("%n"); f.format("%-60s", " ****CAUTION CONFIRMATORY FACTOR ANALYSIS IS STILL IN DEVELOPMENT****"); f.format("%n"); f.format("%-60s", " ****IT HAS NOT BEEN THOROUGHLY TESTED****"); f.format("%n"); f.format("%n"); f.format("%-25s", " MODEL SUMMARY"); f.format("%n"); f.format("%-60s", "================================================================="); f.format("%n"); f.format("%11s", "Statistic"); f.format("%5s", ""); f.format("%10s", "Congeneric"); f.format("%5s", ""); f.format("%14s", "Tau-Equivalent"); f.format("%5s", ""); f.format("%10s", "Parallel"); f.format("%n"); f.format("%-60s", "-----------------------------------------------------------------"); f.format("%n"); f.format("%11s", "Fmin"); f.format("%5s", ""); f.format("% 10.4f", congeneric.getEstimator().fMin()); f.format("%5s", ""); f.format("% 10.4f", tauEquivalent.getEstimator().fMin()); f.format("%9s", ""); f.format("% 10.4f", parallel.getEstimator().fMin()); f.format("%n"); f.format("%11s", "Chi^2"); f.format("%5s", ""); f.format("% 10.4f", congeneric.getEstimator().chisquare()); f.format("%5s", ""); f.format("% 10.4f", tauEquivalent.getEstimator().chisquare()); f.format("%9s", ""); f.format("% 10.4f", parallel.getEstimator().chisquare()); f.format("%n"); f.format("%11s", "df"); f.format("%5s", ""); f.format("% 10.4f", congeneric.getEstimator().degreesOfFreedom()); f.format("%5s", ""); f.format("% 10.4f", tauEquivalent.getEstimator().degreesOfFreedom()); f.format("%9s", ""); f.format("% 10.4f", parallel.getEstimator().degreesOfFreedom()); f.format("%n"); f.format("%11s", "p-rho"); f.format("%5s", ""); f.format("% 10.4f", congeneric.getEstimator().pvalue()); f.format("%5s", ""); f.format("% 10.4f", tauEquivalent.getEstimator().pvalue()); f.format("%9s", ""); f.format("% 10.4f", parallel.getEstimator().pvalue()); f.format("%n"); f.format("%11s", "GFI"); f.format("%5s", ""); f.format("% 10.4f", congeneric.getEstimator().gfi()); f.format("%5s", ""); f.format("% 10.4f", tauEquivalent.getEstimator().gfi()); f.format("%9s", ""); f.format("% 10.4f", parallel.getEstimator().gfi()); f.format("%n"); f.format("%11s", "AGFI"); f.format("%5s", ""); f.format("% 10.4f", congeneric.getEstimator().agfi()); f.format("%5s", ""); f.format("% 10.4f", tauEquivalent.getEstimator().agfi()); f.format("%9s", ""); f.format("% 10.4f", parallel.getEstimator().agfi()); f.format("%n"); f.format("%11s", "RMR"); f.format("%5s", ""); f.format("% 10.4f", Math.sqrt(congeneric.getEstimator().meanSquaredResidual())); f.format("%5s", ""); f.format("% 10.4f", Math.sqrt(tauEquivalent.getEstimator().meanSquaredResidual())); f.format("%9s", ""); f.format("% 10.4f", Math.sqrt(parallel.getEstimator().meanSquaredResidual())); f.format("%n"); f.format("%11s", "RMSEA"); f.format("%5s", ""); f.format("% 10.4f", congeneric.getEstimator().rmsea()); f.format("%5s", ""); f.format("% 10.4f", tauEquivalent.getEstimator().rmsea()); f.format("%9s", ""); f.format("% 10.4f", parallel.getEstimator().rmsea()); f.format("%n"); f.format("%11s", "Reliability"); f.format("%5s", ""); f.format("% 10.4f", congeneric.getEstimator().mcdonaldOmega()); f.format("%5s", ""); f.format("% 10.4f", tauEquivalent.getEstimator().mcdonaldOmega()); f.format("%9s", ""); f.format("% 10.4f", parallel.getEstimator().mcdonaldOmega()); f.format("%n"); f.format("%-60s", "-----------------------------------------------------------------"); f.format("%n"); f.format("%n"); f.format("%n"); f.format("%n"); sb.append(congeneric.getEstimator().printEstimates(items)); f.format("%n"); f.format("%n"); f.format("%n"); sb.append(tauEquivalent.getEstimator().printEstimates(items)); f.format("%n"); f.format("%n"); f.format("%n"); sb.append(parallel.getEstimator().printEstimates(items)); f.format("%n"); f.format("%n"); return f.toString(); }
From source file:umontreal.iro.lecuyer.charts.XYListSeriesCollection.java
public String toLatex(double XScale, double YScale, double XShift, double YShift, double xmin, double xmax, double ymin, double ymax) { // Calcule les bornes reelles du graphique, en prenant en compte la position des axes xmin = Math.min(XShift, xmin); xmax = Math.max(XShift, xmax); ymin = Math.min(YShift, ymin); ymax = Math.max(YShift, ymax); Formatter formatter = new Formatter(Locale.US); XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection; double XEPSILON = (1.0E-4 / XScale) + XShift; double YEPSILON = (1.0E-4 / YScale) + YShift; boolean outOfBounds = false; MathFunction[] spline = null;/*from w w w . j av a2s . com*/ double[] xBounds = getRangeBounds(); double[] yBounds = getDomainBounds(); double x, y; // Smoothing splines, consulter ref: QA278.2 G74, QA278.2 T35, QA278.2 E87 // if(xBounds[0] < xmin || xBounds[1] > xmax || yBounds[0] < ymin || yBounds[1] > ymax) { // // on sait qu'il y a des points qui vont sortir du chart // // initialisation d'une spline pour chaque courbe // spline = new SmoothingCubicSpline[seriesCollection.getSeriesCount()]; // for(int i = 0; i<seriesCollection.getSeriesCount(); i++) // spline[i] = new SmoothingCubicSpline( (seriesCollection.getSeries(i).toArray())[0], // (seriesCollection.getSeries(i).toArray())[1], 0.5); // } // on sait qu'il y a des points qui vont sortir du chart // initialisation d'une spline pour chaque courbe if (true) { spline = new SmoothingCubicSpline[tempSeriesCollection.getSeriesCount()]; for (int i = 0; i < tempSeriesCollection.getSeriesCount(); i++) spline[i] = new SmoothingCubicSpline((tempSeriesCollection.getSeries(i).toArray())[0], (tempSeriesCollection.getSeries(i).toArray())[1], 1); } else { spline = new AffineFit[tempSeriesCollection.getSeriesCount()]; for (int i = 0; i < tempSeriesCollection.getSeriesCount(); i++) spline[i] = new AffineFit((tempSeriesCollection.getSeries(i).toArray())[0], (tempSeriesCollection.getSeries(i).toArray())[1]); } for (int i = tempSeriesCollection.getSeriesCount() - 1; i >= 0; i--) { XYSeries temp = tempSeriesCollection.getSeries(i); if (temp.getItemCount() < 2) throw new IllegalArgumentException( "Unable to plot series " + i + ": this series must have two points at least"); Color color = (Color) renderer.getSeriesPaint(i); String colorString = detectXColorClassic(color); if (colorString == null) { colorString = "color" + i; formatter.format("\\definecolor{%s}{rgb}{%.2f, %.2f, %.2f}%n", colorString, color.getRed() / 255.0, color.getGreen() / 255.0, color.getBlue() / 255.0); } // Cas particulier pour le premier point, on doit savoir si il est dans le chart ou pas if (temp.getX(0).doubleValue() >= xmin && temp.getX(0).doubleValue() <= xmax && temp.getY(0).doubleValue() >= ymin && temp.getY(0).doubleValue() <= ymax) { outOfBounds = false; formatter.format("\\draw [%s, color=%s, mark=%s, style=%s] plot coordinates {%%%n", plotStyle[i], colorString, marksType[i], dashPattern[i]); } else { outOfBounds = true; formatter.format("%% "); } formatter.format("(%.2f,%.4f)", (temp.getX(0).doubleValue() - XShift) * XScale, (temp.getY(0).doubleValue() - YShift) * YScale); formatter.format(" %% (%f, %f)%n", temp.getX(0).doubleValue(), temp.getY(0).doubleValue()); // Cas general for (int j = 1; j < temp.getItemCount(); j++) { double[] result; if (!outOfBounds) { //on est dans le chart result = evalLimitValues(xmin, xmax, ymin, ymax, XEPSILON, YEPSILON, spline[i], temp, j, false); // on regarde si on ne sort pas du chart, si c'est le cas on evalue le point en limite if (result != null) { // le point courant n'est pas dans le chart, on sort donc du chart outOfBounds = true; if (autoCompletion) formatter.format("(%.2f,%.4f) %%%n", (result[0] - XShift) * XScale, (result[1] - YShift) * YScale); formatter.format("}%%%n%% "); } } else { // le point precedent etait hors du chart if (temp.getX(j).doubleValue() >= xmin && temp.getX(j).doubleValue() <= xmax && temp.getY(j).doubleValue() >= ymin && temp.getY(j).doubleValue() <= ymax) { // on rentre dans le chart, il faut evaluer le point en limite j = j - 1; result = evalLimitValues(xmin, xmax, ymin, ymax, XEPSILON, YEPSILON, spline[i], temp, j, true); // ici result ne peut pas etre null formatter.format(";%%%n\\draw [%s, color=%s, mark=%s, style=%s] plot coordinates {%%%n", plotStyle[i], colorString, marksType[i], dashPattern[i]); if (autoCompletion) formatter.format("(%.2f,%.4f) %%%n ", (result[0] - XShift) * XScale, (result[1] - YShift) * YScale); formatter.format("%% "); outOfBounds = false; } else { formatter.format("%% "); // on les donnees sont toujours hors du chart } } /* on affiche les coordonnees du point quoiqu'il arrive, si celui ci est hors du chart alors la balise de commentaire a ete deja place */ formatter.format("(%.2f,%.4f)", (temp.getX(j).doubleValue() - XShift) * XScale, (temp.getY(j).doubleValue() - YShift) * YScale); if (j == temp.getItemCount() - 1) formatter.format("}"); formatter.format(" %% (%f, %f)%n", temp.getX(j).doubleValue(), temp.getY(j).doubleValue()); // formatter.format(" %%%n"); } formatter.format(" node[right] {%s};%n", (String) temp.getKey()); } return formatter.toString(); }
From source file:adapters.AxisAdapter.java
/** * Formats and returns a string containing a <SPAN CLASS="logo,LaTeX">L<SUP><SMALL>A</SMALL></SUP>T<SMALL>E</SMALL>X</SPAN>-compatible * source code which represents this axis and its parameters. * * @return LaTeX source code in a String. * @param scale current axis wished scale. * * *///from w w w . j av a 2 s . co m public String toLatex(double scale) { Formatter formatter = new Formatter(Locale.US); double maxAxis = Math.max(axis.getRange().getUpperBound(), twinAxisPosition); //valeur du label le plus grand double minAxis = Math.min(axis.getRange().getLowerBound(), twinAxisPosition); //valeur du label le plus petit String precisionAffichageLabel; //determine combien de decimales seront affichees pour les labels double pas = axis.getTickUnit().getSize(); //step d'affichage des labels pas = fixStep(minAxis, maxAxis, pas); int puissDix; //echelle des valeurs sur l'axe if (Math.log10(pas) < 0) puissDix = (int) Math.log10(pas) - 1; else puissDix = (int) Math.log10(pas); //Placement des fleches, on pourrait facilement les rendre personnalisables... String arrowLeftType = "latex"; String arrowRightType = "latex"; String arrowLeftMargin = "3mm"; String arrowRightMargin = "3mm"; if (twinAxisPosition == minAxis) { arrowLeftType = ""; arrowLeftMargin = "0mm"; } else if (twinAxisPosition == maxAxis) { arrowRightType = ""; arrowRightMargin = "0mm"; } // Label pour l'axe, avec eventuellement l'echelle String label = axis.getLabel(); if (label == null) label = " "; if (puissDix < -2 || puissDix > 2) label = label + " $(10^{" + puissDix + "})$"; else puissDix = 0; if (orientation) { //on est sur l'axe des abscisses //affichage de l'axe formatter.format("\\draw [%s-%s] ([xshift=-%s] %s,0) -- ([xshift=%s] %s,0) node[right] {%s};%n", arrowLeftType, arrowRightType, arrowLeftMargin, (minAxis - twinAxisPosition) * scale, arrowRightMargin, (maxAxis - twinAxisPosition) * scale, label); if (labelsFlag) { //labels manuels String name; double value; double labelTemp; for (int i = 0; i < labelsValue.length; i++) { value = labelsValue[i]; if (labelsName == null) { labelTemp = (value * 100.0 / Math.pow(10, puissDix)); // if(labelTemp == (int)(labelTemp)) name = Integer.toString((int) (labelTemp / 100.0)); // else // name = Double.toString(Math.round(labelTemp)/100.0); } else name = labelsName[i]; if (value == twinAxisPosition && tick0Flag) formatter.format("\\draw (%s,00) -- +(0mm,1mm) -- +(0mm,-1mm) node[below right] {%s};%n", (value - twinAxisPosition) * scale, name); else formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below] {%s};%n", (value - twinAxisPosition) * scale, name); } } else { //labels automatiques double labelTemp; double k = twinAxisPosition; labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; if (tick0Flag) formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below right] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); else formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k += pas; while (k <= maxAxis) { //cote positif labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k += pas; } k = twinAxisPosition - pas; while (k >= minAxis) { //cote negatif labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k -= pas; } } } else { //On est sur l'axe des ordonnees //affichage de l'axe formatter.format("\\draw [%s-%s] ([yshift=-%s] 0,%s) -- ([yshift=%s] 0, %s) node[above] {%s};%n", arrowLeftType, arrowRightType, arrowLeftMargin, (minAxis - twinAxisPosition) * scale, arrowRightMargin, (maxAxis - twinAxisPosition) * scale, label); if (labelsFlag) { //labels manuels String name; double value; double labelTemp; for (int i = 0; i < labelsValue.length; i++) { value = labelsValue[i]; if (labelsName == null) { labelTemp = (value * scale * 100 / Math.pow(10, puissDix)); if (labelTemp == (int) (labelTemp)) name = Integer.toString((int) (labelTemp / 100.0)); else name = Double.toString(Math.round(labelTemp) / 100.0); } else name = labelsName[i]; if (value == twinAxisPosition && tick0Flag) formatter.format("\\draw (%s,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[above left] {%s};%n", 0, (value - twinAxisPosition) * scale, name); else formatter.format("\\draw (%s,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[left] {%s};%n", 0, (value - twinAxisPosition) * scale, name); } } else { //Les labels automatiques double k = twinAxisPosition; double labelTemp; labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; if (tick0Flag) formatter.format("\\draw (0,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[above left] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); else formatter.format("\\draw (0,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[left] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k += pas; while (k <= maxAxis) { //cote positif de l'axe labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; formatter.format("\\draw (0,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[left] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k += pas; } k = twinAxisPosition - pas; while (k >= minAxis) { //cote negatif de l'axe labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; formatter.format("\\draw (0,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[left] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k -= pas; } } } return formatter.toString(); }