Example usage for java.awt.geom Rectangle2D getMinX

List of usage examples for java.awt.geom Rectangle2D getMinX

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D getMinX.

Prototype

public double getMinX() 

Source Link

Document

Returns the smallest X coordinate of the framing rectangle of the Shape in double precision.

Usage

From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java

@Override
public void mouseDragged(MouseEvent e) {
    super.mouseDragged(e);

    Rectangle2D origArea = this.getScreenDataArea();
    Plot plot = chart.getPlot();/*from  ww w . java  2s.com*/

    if (!(plot instanceof XYPlot)) {
        return;
    }

    XYPlot xyPlot = chart.getXYPlot();
    String origDomainAxisLabel = xyPlot.getDomainAxis().getLabel();

    if (SwingUtilities.isRightMouseButton(e)) {
        return;
    }
    for (DBSeerSelectableChartPanel panel : DBSeerPlotPresetFrame.chartPanels) {
        if (panel != this) {
            Plot otherPlot = panel.getChart().getPlot();
            if (!(otherPlot instanceof XYPlot)) {
                continue;
            }
            Rectangle2D otherArea = panel.getScreenDataArea();
            XYPlot otherXYPlot = panel.getChart().getXYPlot();
            String otherDomainAxisLabel = otherXYPlot.getDomainAxis().getLabel();

            if (origDomainAxisLabel.equalsIgnoreCase(otherDomainAxisLabel)) {
                double origRangeX = origArea.getMaxX() - origArea.getMinX();
                double origRangeY = origArea.getMaxY() - origArea.getMinY();
                double otherRangeX = otherArea.getMaxX() - otherArea.getMinX();
                double otherRangeY = otherArea.getMaxY() - otherArea.getMinY();

                double syncX = otherArea.getMinX() + (e.getX() - origArea.getMinX()) / origRangeX * otherRangeX;
                double syncY = otherArea.getMinY() + (e.getY() - origArea.getMinY()) / origRangeY * otherRangeY;
                MouseEvent syncEvent = new MouseEvent(this, 0, 0, 0, (int) syncX, (int) syncY, 1, false);
                panel.syncMouseDragged(syncEvent);
            }
        }
    }
}

From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java

@Override
public void mouseReleased(MouseEvent e) {
    super.mouseReleased(e);

    Rectangle2D origArea = this.getScreenDataArea();
    Plot plot = chart.getPlot();//  w  ww. ja v a 2 s  .c o m

    if (!(plot instanceof XYPlot)) {
        return;
    }

    XYPlot xyPlot = chart.getXYPlot();
    String origDomainAxisLabel = xyPlot.getDomainAxis().getLabel();

    if (SwingUtilities.isRightMouseButton(e)) {
        return;
    }
    for (DBSeerSelectableChartPanel panel : DBSeerPlotPresetFrame.chartPanels) {
        if (panel != this) {
            Plot otherPlot = panel.getChart().getPlot();
            if (!(otherPlot instanceof XYPlot)) {
                continue;
            }
            Rectangle2D otherArea = panel.getScreenDataArea();
            XYPlot otherXYPlot = panel.getChart().getXYPlot();
            String otherDomainAxisLabel = otherXYPlot.getDomainAxis().getLabel();

            if (origDomainAxisLabel.equalsIgnoreCase(otherDomainAxisLabel)) {
                double origRangeX = origArea.getMaxX() - origArea.getMinX();
                double origRangeY = origArea.getMaxY() - origArea.getMinY();
                double otherRangeX = otherArea.getMaxX() - otherArea.getMinX();
                double otherRangeY = otherArea.getMaxY() - otherArea.getMinY();

                double syncX = otherArea.getMinX() + (e.getX() - origArea.getMinX()) / origRangeX * otherRangeX;
                double syncY = otherArea.getMinY() + (e.getY() - origArea.getMinY()) / origRangeY * otherRangeY;
                MouseEvent syncEvent = new MouseEvent(this, 0, 0, 0, (int) syncX, (int) syncY, 1, false);
                panel.syncMouseReleased(syncEvent);
            }
        }
    }
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.panel.Chromatogram1DHeatmapViewerPanel.java

public void setViewport(Rectangle2D rect) {
    //ignore viewport changes if we have the focus
    if (hasFocus()) {
        Logger.getLogger(getClass().getName()).info("Ignoring viewport update since we have the focus!");
    } else {//from   www .j  av a2s .c  om
        //otherwise, clear our own viewport and set to new value
        if (this.viewport != null) {
            this.content.remove(this.viewport);
        }
        this.viewport = new ChromatogramViewViewport(rect);
        Logger.getLogger(getClass().getName()).info("Setting viewport!");
        removeAxisListener();
        this.chartPanel.getChart().getXYPlot().getDomainAxis().setLowerBound(rect.getMinX());
        this.chartPanel.getChart().getXYPlot().getDomainAxis().setUpperBound(rect.getMaxX());
        this.chartPanel.getChart().getXYPlot().getRangeAxis().setLowerBound(rect.getMinY());
        this.chartPanel.getChart().getXYPlot().getRangeAxis().setUpperBound(rect.getMaxY());
        addAxisListener();
    }
}

From source file:org.proteosuite.FastScatterPlot.java

/**
 * Draws the fast scatter plot on a Java 2D graphics device (such as the 
 * screen or a printer)./*from  w  ww.j a  v a 2 s .  c  o m*/
 *
 * @param g2  the graphics device.
 * @param area   the area within which the plot (including axis labels)
 *                   should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects chart drawing information (<code>null</code> 
 *              permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState,
        PlotRenderingInfo info) {

    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    AxisSpace space = new AxisSpace();
    space = this.domainAxis.reserveSpace(g2, this, area, RectangleEdge.BOTTOM, space);
    space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, space);
    Rectangle2D dataArea = space.shrink(area, null);

    if (info != null) {
        info.setDataArea(dataArea);
    }

    // draw the plot background and axes...
    drawBackground(g2, dataArea);

    AxisState domainAxisState = null;
    AxisState rangeAxisState = null;
    if (this.domainAxis != null) {
        domainAxisState = this.domainAxis.draw(g2, dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM,
                info);
    }
    if (this.rangeAxis != null) {
        rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(), area, dataArea, RectangleEdge.LEFT, info);
    }
    drawDomainGridlines(g2, dataArea, domainAxisState.getTicks());
    drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks());

    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();

    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha()));

    render(g2, dataArea, info, null);

    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);

}

From source file:org.gumtree.vis.awt.CompositePanel.java

@Override
public void draw(Graphics2D g2, Rectangle2D area, double shiftX, double shiftY) {
    Rectangle2D compositeBounds = getBounds();
    double xRatio = area.getWidth() / compositeBounds.getWidth();
    double yRatio = area.getHeight() / compositeBounds.getHeight();
    for (IPlot plot : plotList) {
        if (plot instanceof JPanel) {
            Rectangle2D plotBounds = ((JPanel) plot).getBounds();
            Rectangle2D newArea = new Rectangle2D.Double(area.getMinX() + plotBounds.getMinX() * xRatio,
                    area.getMinY() + plotBounds.getMinY() * yRatio, plotBounds.getWidth() * xRatio,
                    plotBounds.getHeight() * yRatio);
            plot.draw(g2, newArea, shiftX, shiftY);
        }//from   w w  w . j ava 2 s. c  om
    }
}

From source file:gda.plots.TurboXYItemRenderer.java

/**
 * Draws the visual representation of a single data item. This mostly reproduces the code of StandardXYItemRenderer
 * but using the line by line information stored in the SimpleXYSeries instead of the series indexed information
 * stored in the Renderer itself./*from   w  ww .j  av  a  2 s  .  c o  m*/
 * 
 * @param g2
 *            the graphics device.
 * @param state
 *            the renderer state.
 * @param dataArea
 *            the area within which the data is being drawn.
 * @param info
 *            collects information about the drawing.
 * @param plot
 *            the plot (can be used to obtain standard color information etc).
 * @param domainAxis
 *            the domain axis.
 * @param rangeAxis
 *            the range axis.
 * @param dataset
 *            the dataset.
 * @param series
 *            the series index (zero-based).
 * @param crosshairState
 *            crosshair information for the plot ( <code>null</code> permitted).
 * @param pass
 *            the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int _item,
        CrosshairState crosshairState, int pass) {

    if (_item > 0)
        return;
    SimpleXYSeries sxys = (SimpleXYSeries) ((SimpleXYSeriesCollection) dataset).getSeries(series);
    if (!sxys.isVisible()) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    g2.setPaint(sxys.getPaint());
    g2.setStroke(sxys.getStroke());

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();

    try {
        int x0 = -1; // the x position in pixels of the previous point
        int y0 = -1; // the y position in pixels of the previous point
        int x1 = -1; // the x position in pixels of the current point
        int y1 = -1; // the y position in pixels of the current point
        int xmin = (int) dataArea.getMinX();
        int xmax = (int) dataArea.getMaxX();
        int ymin = (int) dataArea.getMinY();
        int ymax = (int) dataArea.getMaxY();
        GeneralPath path = null;

        /*
         * To remove the time spent repeatedly calling domainAxis.valueToJava2D for linear axes use simple linear
         * maths
         */
        double xl = 0., mx = Double.NaN, cx = 0.;
        if (domainAxis instanceof SimpleNumberAxis) {
            xl = domainAxis.getRange().getLowerBound();
            mx = dataArea.getWidth() / (domainAxis.getRange().getUpperBound() - xl);
            cx = xmin;
        }
        double yl = 0., my = Double.NaN, cy = 0.;
        if (rangeAxis instanceof SimpleNumberAxis) {
            yl = rangeAxis.getRange().getLowerBound();
            my = -dataArea.getHeight() / (rangeAxis.getRange().getUpperBound() - yl);
            cy = ymax;
        }
        List<XYDataItem> list = sxys.getData();

        boolean MX_MY_NaN = Double.isNaN(mx) || Double.isNaN(my);
        Paint paint = sxys.getPaint();
        Stroke stroke = sxys.getStroke();
        Paint paint_symbol = sxys.getSymbolPaint();
        Stroke stroke_symbol = new BasicStroke();
        drawLines = sxys.isDrawLines();
        boolean filled = sxys.getFilled();
        Shape shape = sxys.getSymbol();
        boolean drawMarkers = sxys.isDrawMarkers() & shape != null;
        int tooltipThresholdCounts = -1; /* number of points to be shown below which markers are also to be drawn */
        if (drawLines && drawMarkers && shape != null && tooltipThreshold != 0) {
            Rectangle shapeBoundingBox = shape.getBounds();
            tooltipThresholdCounts = (int) dataArea.getWidth()
                    / (Math.max(1, shapeBoundingBox.width) * tooltipThreshold);
        }

        java.util.Vector<ddouble> markerPositions = null;
        Shape entityArea = null;
        EntityCollection entities = null;
        if (info != null) {
            entities = info.getOwner().getEntityCollection();
        }
        boolean prevLineAdded = false;
        // In case the iterator does not work then use the TODO comment iterator use and why not always
        // comment variables
        synchronized (list) {
            Iterator<XYDataItem> iter = list.iterator();
            /*
             * loop over all points calculating X1 and Y1. Store previous points positions into X0 and Y0 The
             * variable addThis determines if the current point is to be added to the path If previous line was
             * added that the current must be even if off the screen - but in this case the flag prevLineAdded is
             * set false so that the next does not have to be added.
             */
            for (int item = 0; iter.hasNext(); item++, x0 = x1, y0 = y1, x1 = -1, y1 = -1) {
                XYDataItem dataitem = iter.next();
                double x = dataitem.getX().doubleValue();
                double y = dataitem.getY().doubleValue();
                x = xValueTransformer.transformValue(x);

                x1 = MX_MY_NaN ? (int) domainAxis.valueToJava2D(x, dataArea, xAxisLocation)
                        : (int) ((x - xl) * mx + cx);
                y1 = MX_MY_NaN ? (int) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation)
                        : (int) ((y - yl) * my + cy);

                boolean addThis = true;
                if (item == 0) {
                    x0 = x1;
                    y0 = y1;
                    if ((x1 < xmin) || (x1 > xmax) || (y1 < ymin) || (y1 > ymax)) {
                        addThis = false;
                    }
                } else {
                    if (x1 == x0 && y1 == y0) {
                        addThis = false;
                    }
                    if ((x1 < xmin && x0 < xmin) || (x1 > xmax && x0 > xmax) || (y1 < ymin && y0 < ymin)
                            || (y1 > ymax && y0 > ymax)) {
                        if (prevLineAdded) {
                            path = addPointToLine(path, orientation, x1, y1);
                        }
                        addThis = false;
                    }
                }
                if (addThis) {
                    /*
                     * If the current point is to be added then ensure previous one is as well to prevent lines
                     * not crossing the edge of the screen
                     */
                    if (!prevLineAdded) {
                        path = addPointToLine(path, orientation, x0, y0);
                    }
                    path = addPointToLine(path, orientation, x1, y1);
                    prevLineAdded = true;
                }
                prevLineAdded = addThis;
                if (addThis && drawMarkers) {
                    if (markerPositions == null) {
                        markerPositions = new java.util.Vector<ddouble>();
                    }
                    markerPositions.add(new ddouble(item, x1, y1));
                    if (tooltipThresholdCounts != -1 && markerPositions.size() > tooltipThresholdCounts) {
                        drawMarkers = false;
                        markerPositions = null;
                    }
                }
            }
            if (path != null) {
                g2.setStroke(stroke);
                g2.setPaint(paint);
                g2.draw(path);
            }
            if (markerPositions != null) {
                if (drawMarkers) {
                    g2.setPaint(paint_symbol);
                    g2.setStroke(stroke_symbol);
                    for (ddouble dd : markerPositions) {
                        Shape shape_item = ShapeUtilities.createTranslatedShape(shape, dd.x, dd.y);
                        if (filled) {
                            g2.fill(shape_item);
                        } else {
                            g2.draw(shape_item);
                        }
                        entityArea = shape_item;
                        // add an entity for the item...
                        if (entities != null) {
                            addEntity(entities, entityArea, dataset, series, dd.item, dd.x, dd.y);
                        }
                    }
                    g2.setPaint(paint);
                    g2.setStroke(stroke);
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:org.proteosuite.FastScatterPlot.java

/**
 * Draws the gridlines for the plot, if they are visible.
 *
 * @param g2  the graphics device./*ww  w.  j a v  a 2s .  c  om*/
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 */
protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List<ValueTick> ticks) {

    // draw the range grid lines, if any...
    if (isRangeGridlinesVisible()) {
        Stroke gridStroke = getRangeGridlineStroke();
        Paint gridPaint = getRangeGridlinePaint();
        if ((gridStroke != null) && (gridPaint != null)) {
            Iterator<ValueTick> iterator = ticks.iterator();
            while (iterator.hasNext()) {
                ValueTick tick = (ValueTick) iterator.next();
                double v = this.rangeAxis.valueToJava2D(tick.getValue(), dataArea, RectangleEdge.LEFT);
                Line2D line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
                g2.setPaint(gridPaint);
                g2.setStroke(gridStroke);
                g2.draw(line);
            }
        }
    }

}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java

@Override
public void mouseReleased(MouseEvent e) {

    // if we've been panning, we need to reset now that the mouse is
    // released...
    Rectangle2D zoomRectangle = (Rectangle2D) getChartFieldValueByName("zoomRectangle");
    Point2D zoomPoint = (Point2D) getChartFieldValueByName("zoomPoint");
    if (getChartFieldValueByName("panLast") != null) {
        setChartFieldValue((getChartFieldByName("panLast")), null);
        setCursor(Cursor.getDefaultCursor());
    } else if (zoomRectangle != null) {
        boolean hZoom = false;
        boolean vZoom = false;
        if ((PlotOrientation) getChartFieldValueByName("orientation") == PlotOrientation.HORIZONTAL) {
            hZoom = (Boolean) getChartFieldValueByName("rangeZoomable");
            vZoom = (Boolean) getChartFieldValueByName("domainZoomable");
        } else {//from   w w  w  . java2 s  . c  o m
            hZoom = (Boolean) getChartFieldValueByName("domainZoomable");
            vZoom = (Boolean) getChartFieldValueByName("rangeZoomable");
        }

        boolean zoomTrigger1 = hZoom && Math
                .abs(e.getX() - zoomPoint.getX()) >= (Integer) getChartFieldValueByName("zoomTriggerDistance");
        boolean zoomTrigger2 = vZoom && Math
                .abs(e.getY() - zoomPoint.getY()) >= (Integer) getChartFieldValueByName("zoomTriggerDistance");
        if (zoomTrigger1 || zoomTrigger2) {
            if ((hZoom && (e.getX() < zoomPoint.getX())) || (vZoom && (e.getY() < zoomPoint.getY()))) {
                restoreAutoBounds();
            } else {
                double x, y, w, h;
                Rectangle2D screenDataArea = getScreenDataArea((int) zoomPoint.getX(), (int) zoomPoint.getY());
                double maxX = screenDataArea.getMaxX();
                double maxY = screenDataArea.getMaxY();
                // for mouseReleased event, (horizontalZoom || verticalZoom)
                // will be true, so we can just test for either being false;
                // otherwise both are true
                if (!vZoom) {
                    x = zoomPoint.getX();
                    y = screenDataArea.getMinY();
                    w = Math.min(zoomRectangle.getWidth(), maxX - zoomPoint.getX());
                    h = screenDataArea.getHeight();
                } else if (!hZoom) {
                    x = screenDataArea.getMinX();
                    y = zoomPoint.getY();
                    w = screenDataArea.getWidth();
                    h = Math.min(zoomRectangle.getHeight(), maxY - zoomPoint.getY());
                } else {
                    x = zoomPoint.getX();
                    y = zoomPoint.getY();
                    w = Math.min(zoomRectangle.getWidth(), maxX - zoomPoint.getX());
                    h = Math.min(zoomRectangle.getHeight(), maxY - zoomPoint.getY());
                }
                Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);
                zoom(zoomArea);
            }
            setChartFieldValue(getChartFieldByName("zoomPoint"), null);
            setChartFieldValue(getChartFieldByName("zoomRectangle"), null);
        } else {
            // erase the zoom rectangle
            Graphics2D g2 = (Graphics2D) getGraphics();
            if ((Boolean) getChartFieldValueByName("useBuffer")) {
                repaint();
            } else {
                drawZoomRectangle(g2, true);
            }
            g2.dispose();
            setChartFieldValue(getChartFieldByName("zoomPoint"), null);
            setChartFieldValue(getChartFieldByName("zoomRectangle"), null);
        }

    }

    else if (e.isPopupTrigger()) {
        if (getChartFieldValueByName("popup") != null) {
            displayPopupMenu(e.getX(), e.getY());
        }
    }

}

From source file:org.gumtree.vis.hist2d.Hist2DPanel.java

@Override
protected void drawToolTipFollower(Graphics2D g2, int x, int y) {
    Rectangle2D dataArea = getScreenDataArea();
    if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX()) && ((int) dataArea.getMinY() < y)
            && (y < (int) dataArea.getMaxY())) {
        String text = String.format("(%." + mouseFollowerXPrecision + "f, %." + mouseFollowerYPrecision
                + "f, %." + mouseFollowerZPrecision + "f)", getChartX(), getChartY(), getChartZ());
        int xLoc = x + 10;
        int yLoc = y + 20;
        double width = text.length() * 5.5;
        double height = 15;
        if (xLoc + width > dataArea.getMaxX()) {
            xLoc = (int) (x - width);
        }//from   w w  w  .  j a  va  2 s. c  o m
        if (yLoc + height > dataArea.getMaxY()) {
            yLoc = (int) (y - height);
        }

        Rectangle2D toolTipArea = new Rectangle2D.Double(xLoc, yLoc, width, height);
        g2.setColor(Color.white);
        g2.fill(toolTipArea);
        g2.setColor(Color.black);
        g2.drawString(text, xLoc + 3, yLoc + 11);
    }
}

From source file:org.tsho.dmc2.core.chart.Bifurcation2DRenderer.java

public void render(final Graphics2D g2, final Rectangle2D dataArea, final PlotRenderingInfo info) {

    int numVar = model.getNVar();

    if (model instanceof ODE) {

        boolean pointBeyondPoincareSection;
        ValueAxis domainAxis = plot.getDomainAxis();
        ValueAxis rangeAxis = plot.getRangeAxis();

        int dim = initialValue.length;

        final int colorArrayLen = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length;
        final Paint[] colorArray = new Color[colorArrayLen];
        for (int i = 0; i < colorArrayLen; i++) {
            colorArray[i] = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i];
        }//  w w  w.j  a  v  a 2s. c o  m

        double[] fPars = new double[fixedParameters.length];
        System.arraycopy(fixedParameters, 0, fPars, 0, fixedParameters.length);
        double[] initVars = new double[initialValue.length];
        System.arraycopy(initialValue, 0, initVars, 0, initialValue.length);

        double[] result = new double[dim];
        double[][] periodArray = new double[period][dim];

        for (double i = dataArea.getMinX(); i <= dataArea.getMaxX(); i += 1) {

            fPars[firstParameterIdx] = domainAxis.java2DToValue(i, dataArea, RectangleEdge.BOTTOM);

            for (double j = dataArea.getMinY(); j < dataArea.getMaxY(); j += 1) {

                fPars[secondParameterIdx] = rangeAxis.java2DToValue(j, dataArea, RectangleEdge.LEFT);

                stepper.setParameters(fPars);
                stepper.setInitialValue(initVars);
                stepper.initialize();
                stepper.step();
                stepper.getCurrentValue(result);

                int h = 0;
                int transX, transY;

                double[] currentPoint = new double[numVar];
                double[] previousPoint = new double[numVar];
                stepper.getCurrentValue(currentPoint);
                stepper.getCurrentValue(previousPoint);
                pointBeyondPoincareSection = positionWrtPoincareSection(currentPoint);

                Paint color = Color.white;
                double[] cycleStartPoint = new double[numVar];
                int actualPeriod = period + 1;

                for (int jj = 0; jj < time / step; jj++) {
                    stepper.step();
                    stepper.getCurrentValue(currentPoint);

                    if (positionWrtPoincareSection(currentPoint) == pointBeyondPoincareSection) {
                        stepper.getCurrentValue(previousPoint);
                        continue;
                    }

                    pointBeyondPoincareSection = !pointBeyondPoincareSection;
                    double[] pointOnSection = pointOnPoincareSection(previousPoint, currentPoint);
                    stepper.setInitialValue(pointOnSection);
                    stepper.initialize();
                    stepper.getCurrentValue(currentPoint);
                    stepper.getCurrentValue(previousPoint);

                    h++;

                    if (h == transients) {
                        for (int kk = 0; kk < numVar; kk++)
                            cycleStartPoint[kk] = currentPoint[kk];
                    }
                    if (h > transients) {
                        if (distance(currentPoint, cycleStartPoint) < epsilon) {
                            actualPeriod = h - transients;
                            break;
                        }
                        if (h >= transients + period)
                            break;
                    }
                }

                stepper.getCurrentValue(result);

                for (h = 0; h < dim; h++) {
                    if (Math.abs(result[h]) > infinity || Double.isNaN(result[h])) {
                        color = Color.black; // black == infinity
                    }
                }

                if (stopped) {
                    state = STATE_STOPPED;
                    return;
                }

                if (actualPeriod <= period) { // found period
                    color = colorArray[actualPeriod - 1];
                }

                g2.setPaint(color);
                g2.drawRect((int) i, (int) j, 1, 1);

                if (stopped) {
                    state = STATE_STOPPED;
                    return;
                }
            }

        }
        state = STATE_FINISHED;

    } else {
        ValueAxis domainAxis = plot.getDomainAxis();
        ValueAxis rangeAxis = plot.getRangeAxis();

        int dim = initialValue.length;

        final int colorArrayLen = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length;
        final Paint[] colorArray = new Color[colorArrayLen];
        for (int i = 0; i < colorArrayLen; i++) {
            colorArray[i] = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i];
        }

        double[] fPars = new double[fixedParameters.length];
        System.arraycopy(fixedParameters, 0, fPars, 0, fixedParameters.length);
        double[] initVars = new double[initialValue.length];
        System.arraycopy(initialValue, 0, initVars, 0, initialValue.length);

        double[] result = new double[dim];
        double[][] periodArray = new double[period + 1][dim];

        for (double i = dataArea.getMinX(); i <= dataArea.getMaxX(); i += 1) {

            fPars[firstParameterIdx] = domainAxis.java2DToValue(i, dataArea, RectangleEdge.BOTTOM);

            for (double j = dataArea.getMinY(); j < dataArea.getMaxY(); j += 1) {

                fPars[secondParameterIdx] = rangeAxis.java2DToValue(j, dataArea, RectangleEdge.LEFT);

                stepper.setParameters(fPars);
                stepper.setInitialValue(initVars);
                stepper.initialize();
                stepper.step();
                stepper.getCurrentValue(result);

                for (int h = 1; h < transients; h++) {
                    if (stopped) {
                        state = STATE_STOPPED;
                        return;
                    }
                    stepper.step();
                }

                stepper.getCurrentValue(result);

                Paint color = Color.white; // white == longer period
                for (int h = 0; h < dim; h++) {
                    if (Math.abs(result[h]) > infinity || Double.isNaN(result[h])) {
                        color = Color.black; // black == infinity
                        break;
                    }
                }

                if (color != Color.black) {
                    // get maxPeriod next values
                    for (int h = 0; h <= period; h++) {
                        if (stopped) {
                            state = STATE_STOPPED;
                            return;
                        }

                        stepper.step();
                        stepper.getCurrentValue(result);

                        for (int k = 0; k < dim; k++) {
                            periodArray[h][k] = result[k];
                        }
                    }

                    int h, k = -1;
                    for (h = 1; h <= period; h++) {
                        for (k = 0; k < dim; k++) {
                            if (Math.abs(periodArray[0][k] - periodArray[h][k]) >= epsilon) {
                                break;
                            }
                        }
                        if (k == dim) {
                            break;
                        }
                    }

                    if (h <= period) { // found period
                        color = colorArray[h - 1];
                    }
                }
                g2.setPaint(color);
                g2.drawRect((int) i, (int) j, 1, 1);

                if (stopped) {
                    state = STATE_STOPPED;
                    return;
                }
            }
        }
        state = STATE_FINISHED;
    }

}