public void paint(Graphics2D g, float vx0, float vy0, float vx1, float vy1) {
            if (!isActive()) {
                g.drawImage(backgroundImage, 0, (int) vy1 - backgroundImage.getHeight(), null);
                return;
            }

            viewportMinX = vx0 + viewBorderX;
            viewportMaxX = vx1 - viewBorderX;
            viewportMinY = vy1 - viewBorderY;
            viewportMaxY = vy0 + viewBorderY;

            drawLegend(g, viewportMinX, viewportMinY, viewportMaxX, viewportMaxY);

            g.setColor(COLOR_LEGEND_GRID);
            g.drawLine((int) vx0, (int) vy0, (int) (vx1), (int) vy0);

            int[] xPoints = new int[curve.size()];
            int[] yPoints = new int[curve.size()];

            for (int i = 0; i < curve.size(); i++) {
                CurvePoint p = worldToView((CurvePoint) curve.get(i));
                xPoints[i] = (int) (p.x);
                yPoints[i] = (int) (p.y);
            }

            g.setColor(COLOR_LINE);
            g.drawPolyline(xPoints, yPoints, curve.size());

            int width = 6;
            int height = 6;
            for (int i = 0; i < curve.size(); i++) {
                Color color;
                Color colorOutline;
                int off;

                if (((CurvePoint) curve.get(i)).selected) {
                    color = COLOR_SELECTED_POINT;
                    colorOutline = COLOR_SELECTED_POINT_OUTLINE;
                    off = 1;
                } else {
                    color = COLOR_POINT;
                    colorOutline = COLOR_POINT_OUTLINE;
                    off = 0;
                }

                g.setColor(colorOutline);
                g.fillRect(xPoints[i] - width / 2 - off, yPoints[i] - height / 2 - off, width + off * 2,
                        height + off * 2);

                g.setColor(color);
                g.fillRect(xPoints[i] - width / 2 - off + 1, yPoints[i] - height / 2 - off + 1, width + off * 2 - 2,
                        height + off * 2 - 2);

                if (value != null && mouseX >= viewportMinX && mouseX <= viewportMaxX && mouseY >= vy0 && mouseY <=
                        vy1) {
                    value.setCurve(convertToPoint2DCurve(curve));
                    value.setMin((int) worldMinY);
                    value.setMax((int) worldMaxY);

                    // draw little cross where we are
                    CurvePoint a = viewToWorld(new CurvePoint(mouseX, 0));
                    float b = value.getValue(a.getX());

                    CurvePoint crossPoint = new CurvePoint(a.getX(), b);
                    CurvePoint p = worldToView(crossPoint);

                    // draw cross-line where we are
                    g.setColor(COLOR_LEGEND_GRID_CROSS);
                    g.drawLine((int) p.getX(), (int) vy0, (int) p.getX(), (int) vy1);

                    // update mouse position labels
                    valueXLabel.setText(TEXT_CURRENT_X + convertFloat(crossPoint.getX()));
                    valueYLabel.setText(TEXT_CURRENT_Y + convertFloat(crossPoint.getY()));

                }
            }
        }