Example usage for java.awt Color getRed

List of usage examples for java.awt Color getRed

Introduction

In this page you can find the example usage for java.awt Color getRed.

Prototype

public int getRed() 

Source Link

Document

Returns the red component in the range 0-255 in the default sRGB space.

Usage

From source file:com.jaspersoft.studio.property.color.chooser.AdvancedColorWidget.java

/**
 * Read the color under the mouse position and set it as the current color. This 
 * is done only if JSS or one of its components are focused. It is necessary to control
 * this dialog and its content because it modal, so every other component of JSS can not be focused
 *///from  ww  w  .ja  v  a  2  s.  com
private void checkColorPicker() {
    if (!isDisposed() && (getShell().isFocusControl() || checkControlFocused(getShell().getChildren()))) {
        Robot robot;
        try {
            robot = new Robot();
            Point pos = Display.getCurrent().getCursorLocation();
            java.awt.Color color = robot.getPixelColor(pos.x, pos.y);
            RGB rgbColor = new RGB(color.getRed(), color.getGreen(), color.getBlue());
            colorsSelector.setSelectedColor(rgbColor, false);
            updateText(rgbColor, rgbColor.getHSB(), null);
        } catch (AWTException e) {
            e.printStackTrace();
        }
    }
}

From source file:TableDialogEditDemo.java

public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Color newColor = (Color) color;
    setBackground(newColor);//from   w  w  w  .j a va 2s.  c  om
    if (isBordered) {
        if (isSelected) {
            if (selectedBorder == null) {
                selectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getSelectionBackground());
            }
            setBorder(selectedBorder);
        } else {
            if (unselectedBorder == null) {
                unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2, 5, table.getBackground());
            }
            setBorder(unselectedBorder);
        }
    }

    setToolTipText("RGB value: " + newColor.getRed() + ", " + newColor.getGreen() + ", " + newColor.getBlue());
    return this;
}

From source file:Trabalho.HistogramaHSB.java

public ChartPanel criaHistograma() throws IOException {

    //pega a imagem
    BufferedImage img = pegaImagem();
    //w pega a largura da imagem - h pega a altura da imagem
    int w = img.getWidth();
    int h = img.getHeight();
    //d calcula o tamanho da imagem
    int d = (w * h);
    //red, green e blue iro receber os tons de cor antigo da imagem - u vai receber o RGB da cor 
    int red, green, blue, u;
    //retorna rgb no mtodo
    float[] hsb;/*w w  w . ja va2 s  .c  om*/
    int[] vetH = new int[256];
    int[] vetS = new int[256];
    int[] vetB = new int[256];
    float hue, sat, bri;
    //cAux e oldColor pegam os tons originais da imagem - newColor pega os tons aps o clculo
    Color oldColor;
    Color newColor;

    //for responsvel por substituir os tons antigos pelos novos; percorrem a imagem por largura e altura
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            u = img.getRGB(i, j); //u vai receber o RGB da posio i, j
            oldColor = new Color(u); //oldColor  instanciado e recebe o valor de u
            //cada cor recebe o valor do tom original
            red = oldColor.getRed();
            green = oldColor.getGreen();
            blue = oldColor.getBlue();
            hsb = Color.RGBtoHSB(red, green, blue, null);
            hue = hsb[0];
            sat = hsb[1];
            bri = hsb[2];
            //                System.out.println("RGB [" + red + "," + green + "," + blue + "] converted to HSB [" + hue + "," + sat + "," + bri + "]");

            //                hue = hue * 360;
            //                int convH = Integer.valueOf(new Float(hue).intValue());
            //                vetH[convH]++;
            //
            //                sat = sat * 100;
            //                int convS = Integer.valueOf(new Float(sat).intValue());
            //                vetS[convS]++;
            //
            //                bri = bri * 100;
            //                int convB = Integer.valueOf(new Float(bri).intValue());
            //                vetB[convB]++;

            newColor = new Color(hue, sat, bri);
            //seta o RGB da imagem nas posies i, j pegando os valores da newColor
            img.setRGB(i, j, newColor.getRGB());
        }
    }

    File ouptut = new File("D:\\ProjetosNetBeans\\PDI\\src\\imagens\\5.jpeg");
    ImageIO.write(img, "png", ouptut);

    dataset = new HistogramDataset();
    //pega o RGB

    r = raster.getSamples(0, 0, w, h, 0, r);
    dataset.addSeries("Red", r, 360);
    r = raster.getSamples(0, 0, w, h, 1, r);
    dataset.addSeries("Green", r, 101);
    r = raster.getSamples(0, 0, w, h, 2, r);
    dataset.addSeries("Blue", r, 101);

    JFreeChart chart = ChartFactory.createHistogram("Histograma", "Pixels", "Y", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    //Plota as cores
    XYPlot plot = (XYPlot) chart.getPlot();
    renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setBarPainter(new StandardXYBarPainter());
    //vermelho, verde, azul
    Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true),
            new Color(0x800000ff, true) };
    //desenhando o grfico
    plot.setDrawingSupplier(
            new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:diet.gridr.g5k.gui.GanttChart.java

/**
 * Method creating the chart//from  w  w  w  .j a v a 2s.  c  om
 *
 * @param dataset dataset containing the data for the chart
 * @return a chart
 */
private JFreeChart createChart(XYZDataset dataset) {
    DateAxis xAxis = new DateAxis("Date");
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    xAxis.setDateFormatOverride(new SimpleDateFormat(durationsFormatterArray[this.visualizationDuration]));
    xAxis.setRange(Calendar.getInstance().getTime(),
            new Date(System.currentTimeMillis() + HistoryUtil.durationsTimesArray[visualizationDuration]
                    - HistoryUtil.blockWidthsArray[visualizationDuration]));
    NumberAxis yAxis = new NumberAxis("Nodes");
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setInverted(true);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setRange(1, numberOfNodes);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBlockRenderer renderer = new XYBlockRenderer();
    LookupPaintScale paintScale = new LookupPaintScale();
    for (int i = 0; i < jobsList.get(visualizationDuration).size(); i++) {
        // String jobId = jobsList.get(visualizationDuration).get(i).getId().substring(0,jobsList.get(visualizationDuration).get(i).getId().indexOf("."));
        String jobId = jobsList.get(visualizationDuration).get(i).getParameterValue(GridJob.KEY_GRID_JOB_ID);
        int seed = Integer.parseInt(jobId);
        Random rng = new Random(seed);
        Color tempColor = Color.red;
        int red = tempColor.getRed();
        int green = tempColor.getGreen();
        int blue = tempColor.getBlue();
        int redRNG = rng.nextInt(255);
        int greenRNG = rng.nextInt(255);
        int blueRNG = rng.nextInt(255);
        if (red == redRNG && green == greenRNG && blue == blueRNG) {
            tempColor = new Color(rng.nextInt(255), rng.nextInt(255), rng.nextInt(255));
        } else {
            tempColor = new Color(redRNG, greenRNG, blueRNG);
        }
        if (seed == 0)
            tempColor = Color.red;
        paintScale.add(new Double(i), tempColor);
    }
    renderer.setBlockWidth(HistoryUtil.blockWidthsArray[visualizationDuration]);
    renderer.setBlockAnchor(RectangleAnchor.TOP_LEFT);
    renderer.setPaintScale(paintScale);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    JFreeChart chart = new JFreeChart("Gantt Chart activity for cluster " + siteName, plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    LoggingManager.log(Level.CONFIG, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "createChart",
            "Chart created");
    return chart;
}

From source file:org.eclipse.birt.report.engine.emitter.ppt.PPTWriter.java

private String getColorString(Color color) {
    StringBuffer buffer = new StringBuffer();
    appendComponent(buffer, color.getRed());
    appendComponent(buffer, color.getGreen());
    appendComponent(buffer, color.getBlue());
    return buffer.toString();
}

From source file:org.helioviewer.jhv.plugins.hekplugin.HEKPlugin.java

public void drawPolygon(GL2 gl, HEKEvent evt, Date now) {
    if (evt == null || !evt.isVisible(now))
        return;//from  ww w. j  a v  a 2 s .  c  o  m

    List<HEKEvent.GenericTriangle<Vector3d>> triangles = evt.getTriangulation3D(now);
    List<SphericalCoord> outerBound = evt.getStonyBound(now);
    if (outerBound == null && triangles == null)
        return;

    String type = evt.getString("event_type");
    Color eventColor = HEKConstants.getSingletonInstance().acronymToColor(type, 128);

    HeliographicCoordinate heliographicCoordinate = evt.getHeliographicCoordinate(now);
    if (heliographicCoordinate == null)
        return;

    gl.glPushMatrix();
    gl.glRotated(DifferentialRotation.calculateRotationInDegrees(heliographicCoordinate.latitude,
            (now.getTime() - evt.getStart().getTime()) / 1000d), 0, 1, 0);

    if (triangles != null) {
        gl.glColor4ub((byte) eventColor.getRed(), (byte) eventColor.getGreen(), (byte) eventColor.getBlue(),
                (byte) eventColor.getAlpha());

        gl.glEnable(GL2.GL_CULL_FACE);
        gl.glDisable(GL2.GL_DEPTH_TEST);
        gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);

        gl.glBegin(GL2.GL_TRIANGLES);
        for (GenericTriangle<Vector3d> triangle : triangles) {
            gl.glVertex3d(triangle.A.x, triangle.A.y, triangle.A.z);
            gl.glVertex3d(triangle.B.x, triangle.B.y, triangle.B.z);
            gl.glVertex3d(triangle.C.x, triangle.C.y, triangle.C.z);
        }
        gl.glEnd();
    }

    // draw bounds
    gl.glColor4f(1, 1, 1, 1);
    if (outerBound != null) {
        gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
        gl.glEnable(GL2.GL_DEPTH_TEST);

        gl.glBegin(GL.GL_LINE_LOOP);
        for (SphericalCoord boundaryPoint : outerBound) {
            Vector3d boundaryPoint3d = HEKEvent.convertToSceneCoordinates(boundaryPoint, now).scaled(1.005);
            gl.glVertex3d(boundaryPoint3d.x, boundaryPoint3d.y, boundaryPoint3d.z);
        }
        gl.glEnd();
    }

    gl.glPopMatrix();
}

From source file:org.openstreetmap.josm.tools.Utils.java

/**
 * Multiply the alpha value of the given color with the factor. The alpha value is clamped to 0..255
 * @param color The color//  w  ww  . j av a  2 s . co m
 * @param alphaFactor The factor to multiply alpha with.
 * @return The new color.
 * @since 11692
 */
public static Color alphaMultiply(Color color, float alphaFactor) {
    int alpha = Utils.colorFloat2int(Utils.colorInt2float(color.getAlpha()) * alphaFactor);
    alpha = clamp(alpha, 0, 255);
    return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
}

From source file:net.chaosserver.timelord.swingui.CommonTaskPanel.java

/**
 * Builds the common task list in the main panel. This cycles through all
 * components currently in the task list and disposes of them. Then removes
 * them from the container. Afterwards it gets all TimelordTaskDays
 * associated with the displayDate and creates TaskDayPanels for them. This
 * is a slow operation and should be avoided.
 *//*from  w ww.  j av  a  2s . c  om*/
protected synchronized void buildTaskList() {
    // Dispose of the child components.
    disposeChildComponents();

    // For good measure null out the listeners
    if (popupMenu != null) {
        popupMenu.setTaskDayPanel(null);
    }

    // Remove the components.
    commonTaskPanel.removeAll();

    // After all components have been disposed of, cycle through all
    // the timelord days for ones with the display date and generate
    // new TaskDayPanels for each of them.
    Collection<TimelordTask> taskCollection = getTimelordDayView().getTaskCollection();

    Iterator<TimelordTask> taskCollectionIterator = taskCollection.iterator();

    int i = 0;

    while (taskCollectionIterator.hasNext()) {
        TimelordTask timelordTask = (TimelordTask) taskCollectionIterator.next();

        TimelordTaskDay todayTaskDay;

        if (isToday()) {
            todayTaskDay = timelordTask.getToday();
        } else {
            todayTaskDay = timelordTask.getTaskDay(this.getDateDisplayed());
        }

        // If the task filter is on, show what matches fitler.
        // If not on, show all non-hidden and hidden with time tracked.
        boolean showLine = false;
        if (tasknameFilter == null || tasknameFilter.trim().length() == 0) {
            showLine = !timelordTask.isHidden() || todayTaskDay.getHours() > 0;

        } else {
            showLine = isFilterPassed(timelordTask, tasknameFilter);
        }

        if (showLine) {
            TaskDayPanel taskDayPanel;

            if (todayTaskDay != null) {
                taskDayPanel = new TaskDayPanel(timelordTask, todayTaskDay);
            } else {
                taskDayPanel = new TaskDayPanel(timelordTask, getDateDisplayed());
            }

            // If this does not pass, then leave the original
            // color.
            if ((i % 2) != 0) {
                Color color = taskDayPanel.getBackground();
                Color color2 = new Color(color.getRed() + LayoutConstants.LIGHTEN_AMOUNT,
                        color.getGreen() + LayoutConstants.LIGHTEN_AMOUNT,
                        color.getBlue() + LayoutConstants.LIGHTEN_AMOUNT);

                taskDayPanel.setBackground(color2);
            }

            commonTaskPanel.add(taskDayPanel);
            i++;
        }
    }

    // Now that we have rebuilt with todays data (or possibly build for
    // the first time) it may have triggered the creation of a bunch of
    // task days for today. So we reset the today listeners. This should
    // be the TimelordDayView's responsility, but putting it here allows
    // for a performance increase.
    // TODO jdr - This really shouldn't be the views responsibility.
    getTimelordData().resetTaskListeners();

    // Force the container to re-layout the components in the layout
    // manager.
    this.doLayout();
    this.validate();
}

From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java

@Override
public void mouseClicked(MouseEvent event, final StateRenderer2D source) {

    if (event.getButton() == MouseEvent.BUTTON3) {
        final LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType();
        JPopupMenu popup = new JPopupMenu();
        for (String type : positions.keySet()) {
            JMenu menu = new JMenu(type + "s");
            for (final AssetPosition p : positions.get(type)) {

                if (p.getTimestamp() < oldestTimestampSelection || p.getTimestamp() > newestTimestampSelection)
                    continue;

                Color c = cmap.getColor(1 - (p.getAge() / (7200000.0)));
                String htmlColor = String.format("#%02X%02X%02X", c.getRed(), c.getGreen(), c.getBlue());
                menu.add("<html><b>" + p.getAssetName() + "</b> <font color=" + htmlColor + ">" + getAge(p)
                        + "</font>").addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                source.focusLocation(p.getLoc());
                            }/*  w  w w.ja  va 2 s.  co  m*/
                        });
            }
            popup.add(menu);
        }

        popup.addSeparator();
        popup.add("Settings").addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                PluginUtils.editPluginProperties(SituationAwareness.this, true);
            }
        });

        popup.add("Fetch asset properties").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //                    for (AssetTrack track : assets.values()) {
                //                        track.setColor(new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255)));
                //                    }
                fetchAssetProperties();
            }
        });

        popup.add("Select location sources").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                JPanel p = new JPanel();
                p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

                for (ILocationProvider l : localizers) {
                    JCheckBox check = new JCheckBox(l.getName());
                    check.setSelected(true);
                    p.add(check);
                    check.setSelected(updateMethodNames.contains(l.getName()));
                }

                int op = JOptionPane.showConfirmDialog(getConsole(), p, "Location update sources",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (op == JOptionPane.CANCEL_OPTION)
                    return;

                Vector<String> methods = new Vector<String>();
                for (int i = 0; i < p.getComponentCount(); i++) {

                    if (p.getComponent(i) instanceof JCheckBox) {
                        JCheckBox sel = (JCheckBox) p.getComponent(i);
                        if (sel.isSelected())
                            methods.add(sel.getText());
                    }
                }
                updateMethods = StringUtils.join(methods, ", ");
                propertiesChanged();
            }
        });

        popup.add("Select hidden positions types").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                JPanel p = new JPanel();
                p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

                for (String type : positions.keySet()) {
                    JCheckBox check = new JCheckBox(type);
                    check.setSelected(true);
                    p.add(check);
                    check.setSelected(hiddenPosTypes.contains(type));
                }

                int op = JOptionPane.showConfirmDialog(getConsole(), p, "Position types to be hidden",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (op == JOptionPane.CANCEL_OPTION)
                    return;

                Vector<String> types = new Vector<String>();
                for (int i = 0; i < p.getComponentCount(); i++) {

                    if (p.getComponent(i) instanceof JCheckBox) {
                        JCheckBox sel = (JCheckBox) p.getComponent(i);
                        if (sel.isSelected())
                            types.add(sel.getText());
                    }
                }
                hiddenTypes = StringUtils.join(types, ", ");
                propertiesChanged();
            }
        });

        popup.addSeparator();
        popup.add("Decision Support").addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (dialogDecisionSupport == null) {
                    dialogDecisionSupport = new JDialog(getConsole());
                    dialogDecisionSupport.setModal(false);
                    dialogDecisionSupport.setAlwaysOnTop(true);
                    dialogDecisionSupport.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
                }
                ArrayList<AssetPosition> tags = new ArrayList<AssetPosition>();
                LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType();
                Vector<AssetPosition> spots = positions.get("SPOT Tag");
                Vector<AssetPosition> argos = positions.get("Argos Tag");
                if (spots != null)
                    tags.addAll(spots);
                if (argos != null)
                    tags.addAll(argos);
                if (!assets.containsKey(getConsole().getMainSystem())) {
                    GuiUtils.errorMessage(getConsole(), "Decision Support", "UUV asset position is unknown");
                    return;
                }
                supportTable.setAssets(assets.get(getConsole().getMainSystem()).getLatest(), tags);
                JXTable table = new JXTable(supportTable);
                dialogDecisionSupport.setContentPane(new JScrollPane(table));
                dialogDecisionSupport.invalidate();
                dialogDecisionSupport.validate();
                dialogDecisionSupport.setSize(600, 300);
                dialogDecisionSupport.setTitle("Decision Support Table");
                dialogDecisionSupport.setVisible(true);
                dialogDecisionSupport.toFront();
                GuiUtils.centerOnScreen(dialogDecisionSupport);
            }
        });
        popup.show(source, event.getX(), event.getY());
    }
    super.mouseClicked(event, source);
}

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);
        }//  w  ww .j a  v a  2 s.  c o  m

        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();
}