Example usage for org.jfree.chart.axis ValueAxis getLowerBound

List of usage examples for org.jfree.chart.axis ValueAxis getLowerBound

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis getLowerBound.

Prototype

public double getLowerBound() 

Source Link

Document

Returns the lower bound of the axis range.

Usage

From source file:org.toobsframework.pres.chart.ChartBuilder.java

public void setValueAxisBounds(IRequest componentRequest, ValueAxis valueAxis, RangeAxisDef valueAxisDef,
        Map params) {//from www .  j a v a  2  s .  c om
    if (valueAxisDef.getUpperBound() != null) {
        Double upper = Double.parseDouble(
                ParameterUtil.resolveParam(componentRequest, valueAxisDef.getUpperBound(), params, "0.0")[0]);
        if (valueAxis == null || valueAxis.getUpperBound() < upper)
            valueAxis.setUpperBound(upper);
    }
    if (valueAxisDef.getLowerBound() != null) {
        Double lower = Double.parseDouble(
                ParameterUtil.resolveParam(componentRequest, valueAxisDef.getLowerBound(), params, "0.0")[0]);
        if (valueAxis == null || valueAxis.getLowerBound() < lower)
            valueAxis.setLowerBound(lower);
    }

    double lowerMargin = Double.parseDouble(
            ParameterUtil.resolveParam(componentRequest, valueAxisDef.getLowerMargin(), params, "0.0")[0]);
    double upperMargin = Double.parseDouble(
            ParameterUtil.resolveParam(componentRequest, valueAxisDef.getUpperMargin(), params, "0.0")[0]);
    valueAxis.setLowerMargin(lowerMargin);
    valueAxis.setUpperMargin(upperMargin);
}

From source file:com.tradedesksoftware.ets.client.charting.ChartShiftController.java

/**
 * Pan/Shifts a plot if the arrow keys are pressed.
 * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
 *///  ww w .  java  2s.c o  m
public void keyPressed(KeyEvent e) {
    if (!plotSupported)
        return;

    int keyCode = e.getKeyCode();

    // we're only interested in arrows (code 37,38,39,40)
    if ((keyCode < 37) || (keyCode > 40))
        return;

    // The axis we're gonna shift
    ValueAxis axis = null;

    // Delta is the amount we'll shift in axis units.
    double delta;

    boolean domainShift = false; // used for PAN_FIXED
    // Calculations for the domain axis
    if ((keyCode == KeyEvent.VK_LEFT) || (keyCode == KeyEvent.VK_RIGHT)) {
        axis = getPlotAxis(chartPanel.getChart(), !axesSwaped);
        domainShift = true;
    }
    // Calculations for the range axis
    else {
        axis = getPlotAxis(chartPanel.getChart(), axesSwaped);
    }

    // Let's calculate 'delta', the amount by which we'll shift the plot
    switch (shiftType) {
    case SHIFT_PERCENTUAL:
        delta = (axis.getUpperBound() - axis.getLowerBound()) / 100.0;
        break;
    case SHIFT_FIXED:
        delta = (domainShift ? fixedDomainShiftUnits : fixedRangeShiftUnits);
        break;
    case SHIFT_PIXEL: // also the default
    default:
        // Let's find out what's the range for 1 pixel.
        final Rectangle scaledDataArea = chartPanel.getScreenDataArea();
        delta = axis.getRange().getLength() / (scaledDataArea.width);
        break;
    }

    // Shift modifier multiplies delta by 10
    if (e.isShiftDown()) {
        delta *= 10;
    }

    switch (keyCode) {
    case KeyEvent.VK_LEFT:
    case KeyEvent.VK_DOWN:
        axis.setRange(axis.getLowerBound() - delta, axis.getUpperBound() - delta);
        break;
    case KeyEvent.VK_UP:
    case KeyEvent.VK_RIGHT:
        axis.setRange(axis.getLowerBound() + delta, axis.getUpperBound() + delta);
        break;
    }
}

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

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

    state = STATE_RUNNING;/*from  ww  w.  ja  v a 2  s.  co  m*/

    gridWidth = (int) dataArea.getWidth();
    gridHeight = (int) dataArea.getHeight();

    //imageX,imageY correspond to point(0,0)
    int imageX = (int) dataArea.getX() + 1;
    int imageY = (int) dataArea.getY() + 1;

    DataBufferInt dataBuffer;

    image = new BufferedImage(gridWidth, gridHeight, BufferedImage.TYPE_INT_RGB);
    WritableRaster raster = image.getRaster();
    grid = ((DataBufferInt) raster.getDataBuffer()).getData();

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

    xEpsilon = Math.abs((domainAxis.getUpperBound() - domainAxis.getLowerBound()) / (double) gridWidth);
    yEpsilon = Math.abs((rangeAxis.getUpperBound() - rangeAxis.getLowerBound()) / (double) gridHeight);

    int numPoints = gridHeight * gridWidth;
    int index = 0;
    int rate = numPoints / 100;

    if (justClearedSet) {
        if (criticalSetFound) {
            this.clearDisplay();
            g2.drawImage(image, null, imageX, imageY);
        }
        justClearedSet = false;
        return;
    }

    if (!notYetRendered) {
        plotCopiedDisplay();
        g2.drawImage(image, null, imageX, imageY);
    }
    notYetRendered = false;
    if (criticalSetFound && !findCriticalSetAgain) {
        if (this.chooseSegmentsSet)
            chooseSegments(g2, image, imageX, imageY);
        if (this.plotAttractorSet)
            plotAttractor(g2, image, imageX, imageY);
        if (this.iterateChosenSegmentsSet)
            iterateChosenSegments(g2, image, imageX, imageY);
        if (this.hideAttractorSet)
            hideAttractor(g2, image, imageX, imageY);
    } else {
        this.disableAllActionsExceptStop();
        det = new AbsorbingAreaRenderer.ImplicitDeterminant(gridWidth, gridHeight, epsilon, g2, image, imageX,
                imageY);
        gridBackup = new int[grid.length];
        copyDisplay();
        criticalSetFound = true;
        findCriticalSetAgain = false;
        g2.drawImage(image, null, imageX, imageY);
        this.enableAllActionsExceptStop();
    }
}

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java

public void mouseDragged(MouseEvent event) {
    try {/*from  w w w  . j av a 2  s.  c  o  m*/
        if (this.panStartPoint != null) {
            Rectangle2D scaledDataArea = this.chartPanel.getScaledDataArea();

            this.panStartPoint = RefineryUtilities.getPointInRectangle(this.panStartPoint.getX(),
                    this.panStartPoint.getY(), scaledDataArea);
            Point2D panEndPoint = RefineryUtilities.getPointInRectangle(event.getX(), event.getY(),
                    scaledDataArea);

            // horizontal pan

            Plot plot = this.chartPanel.getChart().getPlot();
            if (plot instanceof XYPlot) {
                XYPlot hvp = (XYPlot) plot;
                ValueAxis xAxis = hvp.getDomainAxis();

                if (xAxis != null) {
                    double translatedStartPoint = xAxis.java2DToValue((float) panStartPoint.getX(),
                            scaledDataArea, hvp.getDomainAxisEdge());
                    double translatedEndPoint = xAxis.java2DToValue((float) panEndPoint.getX(), scaledDataArea,
                            hvp.getDomainAxisEdge());
                    double dX = translatedStartPoint - translatedEndPoint;

                    double oldMin = xAxis.getLowerBound();
                    double newMin = oldMin + dX;

                    double oldMax = xAxis.getUpperBound();
                    double newMax = oldMax + dX;

                    // do not pan out of range
                    if (newMin >= hvp.getDataRange(xAxis).getLowerBound()
                            && newMax <= hvp.getDataRange(xAxis).getUpperBound()) {
                        xAxis.setLowerBound(newMin);
                        xAxis.setUpperBound(newMax);
                    }
                }
            }

            // vertical pan (1. Y-Axis)

            if (plot instanceof XYPlot) {
                XYPlot vvp = (XYPlot) plot;
                ValueAxis yAxis = vvp.getRangeAxis();

                if (yAxis != null) {
                    double translatedStartPoint = yAxis.java2DToValue((float) panStartPoint.getY(),
                            scaledDataArea, vvp.getRangeAxisEdge());
                    double translatedEndPoint = yAxis.java2DToValue((float) panEndPoint.getY(), scaledDataArea,
                            vvp.getRangeAxisEdge());
                    double dY = translatedStartPoint - translatedEndPoint;

                    double oldMin = yAxis.getLowerBound();
                    double newMin = oldMin + dY;

                    double oldMax = yAxis.getUpperBound();
                    double newMax = oldMax + dY;

                    // do not pan out of range
                    if (newMin >= yMin && newMax <= yMax) {
                        yAxis.setLowerBound(newMin);
                        yAxis.setUpperBound(newMax);
                    }
                }
            }

            // for the next time
            this.panStartPoint = panEndPoint;
        }
    } catch (Exception e) {
        MsgBox.error(e.getMessage());
    }
}

From source file:aprofplot.jfreechart.SamplingXYLineAndShapeRenderer.java

/**
 * Draws the visual representation of a series as lines.
 *
 * @param g2  the graphics device.//from www .  jav a 2  s  .  c  o m
 * @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.
 */
protected void drawVerticalSeriesLine(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea,
        PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
        int series, CrosshairState crosshairState, int pass) {

    State s = (State) state;
    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    double lowestVisibleX = domainAxis.getLowerBound();
    double highestVisibleX = domainAxis.getUpperBound();
    double width = dataArea.getWidth();
    double dX = (highestVisibleX - lowestVisibleX) / width * lineWidth;
    double lowestVisibleY = rangeAxis.getLowerBound();
    double highestVisibleY = rangeAxis.getUpperBound();

    double lastX = Double.NEGATIVE_INFINITY;
    double lastY = 0.0;
    double highY = 0.0;
    double lowY = 0.0;
    double openY = 0.0;
    double closeY = 0.0;
    boolean lastIntervalDone = false;
    boolean currentPointVisible = false;
    boolean lastPointVisible = false;
    boolean lastPointGood = false;
    boolean lastPointInInterval = false;
    boolean pathStarted = false;
    for (int itemIndex = state.getFirstItemIndex(); itemIndex <= state.getLastItemIndex(); itemIndex++) {
        double x = dataset.getXValue(series, itemIndex);
        double y = dataset.getYValue(series, itemIndex);
        if (!Double.isNaN(x) && !Double.isNaN(y)) {
            //System.out.println ("Breakpoint 736: pathStarted " + pathStarted);
            if (!pathStarted) {
                float startX = (float) domainAxis.valueToJava2D(x, dataArea, xAxisLocation);
                float startY = (float) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation);
                s.seriesPath.moveTo(startX, startY);
                pathStarted = true;
            }
            if ((Math.abs(x - lastX) > dX)) {
                //System.out.println ("Breakpoint 744: leaving interval ");
                //in any case, add the interval that we are about to leave to the intervalPath
                float intervalPathX = 0.0f;
                float intervalPathStartY = 0.0f;
                float intervalPathEndY = 0.0f;
                float seriesPathCurrentX = 0.0f;
                float seriesPathCurrentY = 0.0f;
                float seriesPathLastX = 0.0f;
                float seriesPathLastY = 0.0f;

                //first set some variables
                intervalPathX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                intervalPathStartY = (float) rangeAxis.valueToJava2D(lowY, dataArea, yAxisLocation);
                intervalPathEndY = (float) rangeAxis.valueToJava2D(highY, dataArea, yAxisLocation);
                seriesPathCurrentX = (float) domainAxis.valueToJava2D(x, dataArea, xAxisLocation);
                seriesPathLastX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                seriesPathCurrentY = (float) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation);
                seriesPathLastY = (float) rangeAxis.valueToJava2D(closeY, dataArea, yAxisLocation);
                /*if((lowY - highY) < 1){
                lastPointInInterval = false;
                }*/
                //Double[] values = new Double[]{new Double(openY), new Double(closeY), new Double(highY), new Double(lowY), new Double(lastX)};
                /*MessageFormat mf = new MessageFormat("openY {0,number, integer},"
                    + " closeY {1,number, integer}"
                    + " highY {2,number, integer}"
                    + " lowY {3,number, integer}"
                    + "lastX {4,number, integer}");*/
                //String text = mf.format(values);
                //System.out.println("Breakpoint 772"  + text);
                boolean drawInterval = false;
                if (openY >= closeY) {
                    if (highY > openY || lowY < closeY) {
                        drawInterval = true;
                    }
                }
                if (openY < closeY) {
                    if (lowY < openY || highY > closeY) {
                        drawInterval = true;
                    }
                }
                //System.out.println("Breakpoint 784, drawInterval "  + drawInterval);
                if (drawInterval) {
                    s.intervalPath.moveTo(intervalPathX, intervalPathStartY);
                    s.intervalPath.lineTo(intervalPathX, intervalPathEndY);
                }
                lastIntervalDone = true;

                //now the series path
                currentPointVisible = ((x >= lowestVisibleX) && (x <= highestVisibleX) && (y >= lowestVisibleY)
                        && (y <= highestVisibleY));
                if (!lastPointGood && !lastPointInInterval) {//last point not valid --
                    if (currentPointVisible) {//--> if the current position is visible move seriesPath cursor to the current position
                        s.seriesPath.moveTo(seriesPathCurrentX, seriesPathCurrentY);
                    }
                } else {//last point valid
                    //if the last point was visible and not part of an interval,
                    //we have already moved the seriesPath cursor to the last point, either with or without drawingh a line
                    //thus we only need to draw a line to the current position
                    if (lastPointInInterval && lastPointGood) {
                        s.seriesPath.lineTo(seriesPathLastX, seriesPathLastY);
                        s.seriesPath.lineTo(seriesPathCurrentX, seriesPathCurrentY);
                    } //if the last point was not visible or part of an interval, we have just stored the y values of the last point
                      //and not yet moved the seriesPath cursor. Thus, we need to move the cursor to the last point without drawing
                      //and draw a line to the current position.
                    else {
                        s.seriesPath.lineTo(seriesPathCurrentX, seriesPathCurrentY);
                    }
                }
                lastPointVisible = currentPointVisible;
                lastX = x;
                lastY = y;
                highY = y;
                lowY = y;
                openY = y;
                closeY = y;
                lastPointInInterval = false;
            } else {
                lastIntervalDone = false;
                lastPointInInterval = true;
                highY = Math.max(highY, y);
                lowY = Math.min(lowY, y);
                closeY = y;
            }
            lastPointGood = true;
        } else {
            lastPointGood = false;
        }
    }
    // if this is the last item, draw the path ...
    // draw path, but first check whether we need to complete an interval
    if (!lastIntervalDone) {
        if (lowY < highY) {
            float intervalX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
            float intervalStartY = (float) rangeAxis.valueToJava2D(lowY, dataArea, yAxisLocation);
            float intervalEndY = (float) rangeAxis.valueToJava2D(highY, dataArea, yAxisLocation);
            s.intervalPath.moveTo(intervalX, intervalStartY);
            s.intervalPath.lineTo(intervalX, intervalEndY);
        }
    }
    PathIterator pi = s.seriesPath.getPathIterator(null);
    g2.setStroke(getItemStroke(series, 0));
    g2.setPaint(getItemPaint(series, 0));
    g2.draw(s.seriesPath);
    g2.draw(s.intervalPath);
}

From source file:aprofplot.jfreechart.SamplingXYLineAndShapeRenderer.java

protected void drawSeriesLine(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea,
        PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset,
        int series, CrosshairState crosshairState, int pass) {

    State s = (State) state;
    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    double lowestVisibleX = domainAxis.getLowerBound();
    double highestVisibleX = domainAxis.getUpperBound();
    double width = (orientation == PlotOrientation.HORIZONTAL) ? dataArea.getHeight() : dataArea.getWidth();
    double dX = (highestVisibleX - lowestVisibleX) / width * lineWidth;
    double lowestVisibleY = rangeAxis.getLowerBound();
    double highestVisibleY = rangeAxis.getUpperBound();

    double lastX = Double.NEGATIVE_INFINITY;
    double lastY = 0.0;
    double highY = 0.0;
    double lowY = 0.0;
    double closeY = 0.0;
    boolean lastIntervalDone = false;
    boolean currentPointVisible = false;
    boolean lastPointVisible = false;
    boolean lastPointGood = false;
    boolean lastPointInInterval = false;
    int intervalCount = 0;
    int badPoints = 0;
    for (int itemIndex = state.getFirstItemIndex(); itemIndex <= state.getLastItemIndex(); itemIndex++) {
        double x = dataset.getXValue(series, itemIndex);
        double y = dataset.getYValue(series, itemIndex);
        if (!Double.isNaN(x) && !Double.isNaN(y)) {
            if ((Math.abs(x - lastX) > dX)) {
                //System.out.println("Breakpoint 1: leaving interval");
                //in any case, add the interval that we are about to leave to the intervalPath
                float intervalStartX = 0.0f;
                float intervalEndX = 0.0f;
                float intervalStartY = 0.0f;
                float intervalEndY = 0.0f;
                float currentX = 0.0f;
                float currentY = 0.0f;
                float lastFX = 0.0f;
                float lastFY = 0.0f;

                //first set some variables
                if (orientation == PlotOrientation.VERTICAL) {
                    intervalStartX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                    intervalEndX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                    intervalStartY = (float) rangeAxis.valueToJava2D(lowY, dataArea, yAxisLocation);
                    intervalEndY = (float) rangeAxis.valueToJava2D(highY, dataArea, yAxisLocation);
                    currentX = (float) domainAxis.valueToJava2D(x, dataArea, xAxisLocation);
                    lastFX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                    currentY = (float) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation);
                    lastFY = (float) rangeAxis.valueToJava2D(closeY, dataArea, yAxisLocation);
                } else {
                    intervalStartX = (float) rangeAxis.valueToJava2D(lowY, dataArea, yAxisLocation);
                    intervalEndX = (float) rangeAxis.valueToJava2D(highY, dataArea, yAxisLocation);
                    intervalStartY = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                    intervalEndY = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                    currentX = (float) rangeAxis.valueToJava2D(y, dataArea, yAxisLocation);
                    lastFX = (float) rangeAxis.valueToJava2D(closeY, dataArea, yAxisLocation);
                    currentY = (float) domainAxis.valueToJava2D(x, dataArea, xAxisLocation);
                    lastFY = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                }/*from  w  ww .  j a  v a  2s. c o  m*/
                if ((lowY - highY) < 1) {
                    //System.out.println("Breakpoint 2: setting lastPointInInterval");
                    lastPointInInterval = false;
                }
                //System.out.println("Breakpoint 3: lastPointInInterval: " +lastPointInInterval);
                if ((lowY < highY)) {
                    intervalCount++;
                    //System.out.println("Breakpoint 4: adding segment to interval path:" );
                    //System.out.println("xStart" + intervalStartX + ", yStart " + intervalStartY + ", xEnd " + intervalEndX + ", yEnd " + intervalEndY);
                    s.intervalPath.moveTo(intervalStartX, intervalStartY);
                    s.intervalPath.lineTo(intervalEndX, intervalEndY);
                    lastIntervalDone = true;
                }

                //now the series path
                currentPointVisible = ((x >= lowestVisibleX) && (x <= highestVisibleX) && (y >= lowestVisibleY)
                        && (y <= highestVisibleY));
                if (!lastPointGood) {//last point not valid --
                    badPoints++;
                    if (currentPointVisible) {//--> if the current position is visible move seriesPath cursor to the current position
                        s.seriesPath.moveTo(currentX, currentY);
                    }
                } else {//last point valid
                    //if the last point was visible and not part of an interval,
                    //we have already moved the seriesPath cursor to the last point, either with or without drawingh a line
                    //thus we only need to draw a line to the current position
                    if (lastPointVisible && !lastPointInInterval) {
                        s.seriesPath.lineTo(currentX, currentY);
                    } //if the last point was not visible or part of an interval, we have just stored the y values of the last point
                      //and not yet moved the seriesPath cursor. Thus, we need to move the cursor to the last point without drawing
                      //and draw a line to the current position.
                    else {
                        s.seriesPath.moveTo(lastFX, lastFY);
                        s.seriesPath.lineTo(currentX, currentY);
                    }
                }
                lastPointVisible = currentPointVisible;
                lastX = x;
                lastY = y;
                highY = y;
                lowY = y;
                closeY = y;
                lastPointInInterval = false;
            } else {
                lastIntervalDone = false;
                lastPointInInterval = true;
                highY = Math.max(highY, y);
                lowY = Math.min(lowY, y);
                closeY = y;
            }
            lastPointGood = true;
        } else {
            lastPointGood = false;
        }
    }
    // if this is the last item, draw the path ...
    // draw path, but first check whether we need to complete an interval
    if (!lastIntervalDone) {
        if (lowY < highY) {
            float intervalStartX = 0.0f;
            float intervalEndX = 0.0f;
            float intervalStartY = 0.0f;
            float intervalEndY = 0.0f;
            if (orientation == PlotOrientation.VERTICAL) {
                intervalStartX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                intervalEndX = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                intervalStartY = (float) rangeAxis.valueToJava2D(lowY, dataArea, yAxisLocation);
                intervalEndY = (float) rangeAxis.valueToJava2D(highY, dataArea, yAxisLocation);
            } else {
                intervalStartX = (float) rangeAxis.valueToJava2D(lowY, dataArea, yAxisLocation);
                intervalEndX = (float) rangeAxis.valueToJava2D(highY, dataArea, yAxisLocation);
                intervalStartY = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
                intervalEndY = (float) domainAxis.valueToJava2D(lastX, dataArea, xAxisLocation);
            }
            intervalCount++;
            s.intervalPath.moveTo(intervalStartX, intervalStartY);
            s.intervalPath.lineTo(intervalEndX, intervalEndY);
        }
    }
    PathIterator pi = s.seriesPath.getPathIterator(null);
    g2.setStroke(getItemStroke(series, 0));
    g2.setPaint(getItemPaint(series, 0));
    g2.draw(s.seriesPath);
    g2.draw(s.intervalPath);
    //System.out.println("Interval count " + intervalCount);
    //System.out.println("Bad points " + badPoints);
}

From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java

private double userY(MouseEvent event) {
    Rectangle2D rectangle = getScaledDataArea();
    double minY = rectangle.getMinY();
    double maxY = rectangle.getMaxY();
    Plot plot = chart.getPlot();/*from w ww .  jav  a  2 s  . c  o m*/
    int yc = event.getY();

    ValueAxis ya = this.getVerticalValueAxis(plot);
    double ymin = ya.getLowerBound();
    double ymax = ya.getUpperBound();
    double v = (yc - minY) / (maxY - minY);
    v = 1 - v;
    return (v * (ymax - ymin) + ymin);
}

From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java

private double userX(MouseEvent event) {
    Rectangle2D rectangle = getScaledDataArea();
    double minX = rectangle.getMinX();
    double maxX = rectangle.getMaxX();

    Plot plot = chart.getPlot();/*from w w  w  .ja va  2 s. co  m*/

    int xc = event.getX();

    ValueAxis xa = this.getHorizontalValueAxis(plot);

    double xmin = xa.getLowerBound();
    double xmax = xa.getUpperBound();

    double u = (xc - minX) / (maxX - minX);
    return (u * (xmax - xmin) + xmin);
}

From source file:org.gumtree.vis.plot1d.Plot1DPanel.java

private double getBinWidth() {
    double binWidth = 0;
    try {//w  ww .  j  a  va2s  .  co m
        ValueAxis axis = getChart().getXYPlot().getDomainAxis();
        double max = axis.getUpperBound();
        double min = axis.getLowerBound();
        binWidth = (max - min) / StaticValues.DOMAIN_MASK_SHIFT_RESOLUTION;
        if (axis.isInverted()) {
            binWidth = -binWidth;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return binWidth;
}

From source file:gov.nih.nci.caintegrator.application.geneexpression.BoxAndWhiskerCoinPlotRenderer.java

/**
 * {@inheritDoc}/*  w w  w .  j a  va 2  s .co  m*/
 */
@Override
public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea,
        CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row,
        int column) {
    BoxAndWhiskerCategoryDataset bawDataset = (BoxAndWhiskerCategoryDataset) dataset;
    double categoryEnd = domainAxis.getCategoryEnd(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryStart = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
            plot.getDomainAxisEdge());
    double categoryWidth = categoryEnd - categoryStart;
    double xx = categoryStart;
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();
    xx = retrieveXx(state, dataArea, row, categoryWidth, xx, seriesCount, categoryCount);
    Paint p = null;
    if (this.getPlotColor() != null) {
        p = PaintUtilities.stringToColor(getPlotColor()); // coin plot should all be one color
    } else {
        p = getItemPaint(row, column);
    }
    if (p != null) {
        g2.setPaint(p);
    }
    Stroke s = getItemStroke(row, column);
    g2.setStroke(s);
    double aRadius = 0; // average radius
    RectangleEdge location = drawRectangles(g2, state, dataArea, plot, rangeAxis, row, column, bawDataset, xx);
    g2.setPaint(getArtifactPaint());
    if (this.isDisplayMean()) {
        aRadius = drawMean(g2, state, dataArea, rangeAxis, row, column, bawDataset, xx, aRadius, location);
    }
    if (this.isDisplayMedian()) {
        // draw median...
        Number yMedian = bawDataset.getMedianValue(row, column);
        if (yMedian != null) {
            double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), dataArea, location);
            g2.draw(new Line2D.Double(xx, yyMedian, xx + state.getBarWidth(), yyMedian));
        }
    }
    double maxAxisValue = rangeAxis.valueToJava2D(rangeAxis.getUpperBound(), dataArea, location) + aRadius;
    double minAxisValue = rangeAxis.valueToJava2D(rangeAxis.getLowerBound(), dataArea, location) - aRadius;
    g2.setPaint(p);
    drawOutliers(g2, state, dataArea, rangeAxis, row, column, bawDataset, xx, aRadius, location, maxAxisValue,
            minAxisValue);
}