Example usage for org.jfree.data Range getLowerBound

List of usage examples for org.jfree.data Range getLowerBound

Introduction

In this page you can find the example usage for org.jfree.data Range getLowerBound.

Prototype

public double getLowerBound() 

Source Link

Document

Returns the lower bound for the range.

Usage

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Adds a marker to the chart./*from ww w  . ja va 2  s  .c o  m*/
 *
 * @param markerStr  the string encoding of the marker.
 * @param chart  the chart to apply the marker to.
 */
private static void addMarker(String markerStr, JFreeChart chart) {
    String[] args = breakString(markerStr, ',');
    Plot p = chart.getPlot();
    Color c = parseColor(args[1]);
    if (args[0].startsWith("t")) {
        String text = args[0].substring(1);
        int dataset = Integer.parseInt(args[2]);
        int datapoint = Integer.parseInt(args[3]);
        float fontsize = Float.parseFloat(args[4]);
        if (p instanceof CategoryPlot) {
            CategoryPlot cp = (CategoryPlot) p;

            CategoryItemRenderer r = cp.getRenderer();
            GCategoryPlot.LabelGenerator label = (GCategoryPlot.LabelGenerator) r.getItemLabelGenerator(dataset,
                    datapoint);
            label.setLabel(dataset, datapoint, text);
        } else if (p instanceof XYPlot) {
            XYPlot xyp = (XYPlot) p;
            XYItemRenderer r = xyp.getRenderer();
            ((GXYPlot.LabelGenerator) r.getItemLabelGenerator(dataset, datapoint)).setLabel(dataset, datapoint,
                    text);
            //XYDataset d = xyp.getDataset();
            //XYPointerAnnotation a = new XYPointerAnnotation(text, d.getXValue(dataset, datapoint), d.getYValue(dataset, datapoint), Math.random()-2);
            //xyp.addAnnotation(a);
        }
    } else if ("r".equals(args[0])) {
        // add a range marker
        float f0 = Float.parseFloat(args[3]);
        float f1 = Float.parseFloat(args[4]);
        if (p instanceof CategoryPlot) {
            CategoryPlot cp = (CategoryPlot) p;
            Range yRange = cp.getRangeAxis().getRange();
            double r0 = yRange.getLowerBound();
            double rl = yRange.getLength();
            IntervalMarker m = new IntervalMarker(r0 + Math.min(f0, f1) * rl, r0 + Math.max(f0, f1) * rl);
            m.setPaint(c);
            cp.addRangeMarker(m, Layer.BACKGROUND);
        } else if (p instanceof XYPlot) {
            XYPlot cp = (XYPlot) p;
            Range yRange = cp.getRangeAxis().getRange();
            double r0 = yRange.getLowerBound();
            double rl = yRange.getLength();
            IntervalMarker m = new IntervalMarker(r0 + Math.min(f0, f1) * rl, r0 + Math.max(f0, f1) * rl);
            m.setPaint(c);
            cp.addRangeMarker(m, Layer.BACKGROUND);
        }

    } else if ("R".equals(args[0])) {
        // add a domain marker
        float f0 = Float.parseFloat(args[3]);
        float f1 = Float.parseFloat(args[4]);
        if (p instanceof XYPlot) {
            XYPlot xyp = (XYPlot) p;
            Range yRange = xyp.getRangeAxis().getRange();
            double r0 = yRange.getLowerBound();
            double rl = yRange.getLength();
            IntervalMarker m = new IntervalMarker(r0 + Math.min(f0, f1) * rl, r0 + Math.max(f0, f1) * rl);
            m.setPaint(c);
            xyp.addDomainMarker(m, Layer.BACKGROUND);
        }
    }
}

From source file:net.sf.maltcms.chromaui.charts.format.ScaledNumberFormatter.java

/**
 *
 * @param cce//from   w w  w.ja va  2  s . c  o m
 */
@Override
public void chartChanged(ChartChangeEvent cce) {
    ChartChangeEventType ccet = cce.getType();
    if (ccet == ChartChangeEventType.DATASET_UPDATED || ccet == ChartChangeEventType.NEW_DATASET) {
        if (cce.getSource() != (this)) {
            Plot p = cce.getChart().getPlot();
            if (p instanceof XYPlot) {
                XYPlot xyp = (XYPlot) p;
                Range axisRange = xyp.getRangeAxis().getRange();
                ;
                if (relativeMode) {
                    int cnt = xyp.getDatasetCount();
                    Range r = new Range(0, 1);
                    for (int i = 0; i < cnt; i++) {
                        Dataset d = xyp.getDataset(i);
                        if (d != null && d instanceof XYDataset) {
                            XYDataset xyd = (XYDataset) d;
                            Range dr = DatasetUtilities.findRangeBounds(xyd);
                            if (dr != null) {
                                r = new Range(Math.min(r.getLowerBound(), dr.getLowerBound()),
                                        Math.max(r.getUpperBound(), dr.getUpperBound()));

                            }
                        } else {
                            throw new NotImplementedException(
                                    "No support yet for dataset of type: " + d.getClass());
                        }
                    }
                    this.dataMin = Math.min(0, r.getLowerBound());
                    this.dataMax = r.getUpperBound();
                    cce.getChart().fireChartChanged();
                } else {
                    this.min = axisRange.getLowerBound();
                    this.max = axisRange.getUpperBound();
                    cce.getChart().fireChartChanged();
                }
            }
        }
    }
}

From source file:org.jfree.experimental.chart.annotations.XYTitleAnnotation.java

/**
 * Draws the annotation.  This method is called by the drawing code in the 
 * {@link XYPlot} class, you don't normally need to call this method 
 * directly./*from w  ww. j  a va 2  s  .c  om*/
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 * @param rendererIndex  the renderer index.
 * @param info  if supplied, this info object will be populated with
 *              entity information.
 */
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis,
        int rendererIndex, PlotRenderingInfo info) {

    PlotOrientation orientation = plot.getOrientation();
    AxisLocation domainAxisLocation = plot.getDomainAxisLocation();
    AxisLocation rangeAxisLocation = plot.getRangeAxisLocation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(domainAxisLocation, orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(rangeAxisLocation, orientation);
    Range xRange = domainAxis.getRange();
    Range yRange = rangeAxis.getRange();
    double anchorX = 0.0;
    double anchorY = 0.0;
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        anchorX = xRange.getLowerBound() + (this.x * xRange.getLength());
        anchorY = yRange.getLowerBound() + (this.y * yRange.getLength());
    } else {
        anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge);
        anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge);
    }

    float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea, domainEdge);
    float j2DY = (float) rangeAxis.valueToJava2D(anchorY, dataArea, rangeEdge);
    float xx = 0.0f;
    float yy = 0.0f;
    if (orientation == PlotOrientation.HORIZONTAL) {
        xx = j2DY;
        yy = j2DX;
    } else if (orientation == PlotOrientation.VERTICAL) {
        xx = j2DX;
        yy = j2DY;
    }

    double maxW = dataArea.getWidth();
    double maxH = dataArea.getHeight();
    if (this.coordinateType == XYCoordinateType.RELATIVE) {
        if (this.maxWidth > 0.0) {
            maxW = maxW * this.maxWidth;
        }
        if (this.maxHeight > 0.0) {
            maxH = maxH * this.maxHeight;
        }
    }
    if (this.coordinateType == XYCoordinateType.DATA) {
        maxW = this.maxWidth;
        maxH = this.maxHeight;
    }
    RectangleConstraint rc = new RectangleConstraint(new Range(0, maxW), new Range(0, maxH));

    Size2D size = this.title.arrange(g2, rc);
    Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width, size.height);
    Point2D anchorPoint = RectangleAnchor.coordinates(titleRect, this.anchor);
    xx = xx - (float) anchorPoint.getX();
    yy = yy - (float) anchorPoint.getY();
    titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight());
    BlockParams p = new BlockParams();
    if (info != null) {
        if (info.getOwner().getEntityCollection() != null) {
            p.setGenerateEntities(true);
        }
    }
    Object result = this.title.draw(g2, titleRect, p);
    if (result instanceof EntityBlockResult) {
        EntityBlockResult ebr = (EntityBlockResult) result;
        info.getOwner().getEntityCollection().addAll(ebr.getEntityCollection());
    }
    String toolTip = getToolTipText();
    String url = getURL();
    if (toolTip != null || url != null) {
        addEntity(info, new Rectangle2D.Float(xx, yy, (float) size.width, (float) size.height), rendererIndex,
                toolTip, url);
    }
}

From source file:edu.wisc.ssec.mcidasv.control.McIDASVHistogramWrapper.java

/**
 * Assumes that {@code data} has been validated and is okay to actually try
 * loading./* www  . ja  va2  s. com*/
 *
 * @param data Data to use in histogram. Cannot be {@code null} or all NaNs.
 *
 * @throws VisADException
 * @throws RemoteException
 */
private void reallyLoadData(FlatField data) throws VisADException, RemoteException {
    createChart();
    List dataChoiceWrappers = getDataChoiceWrappers();

    try {
        clearHistogram();

        Hashtable props = new Hashtable();
        ErrorEstimate[] errOut = new ErrorEstimate[1];
        for (int paramIdx = 0; paramIdx < dataChoiceWrappers.size(); paramIdx++) {
            DataChoiceWrapper wrapper = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx);

            DataChoice dataChoice = wrapper.getDataChoice();
            props = dataChoice.getProperties();
            Unit defaultUnit = ucar.visad.Util.getDefaultRangeUnits((FlatField) data)[0];
            Unit unit = ((DisplayControlImpl) imageControl).getDisplayUnit();
            double[][] samples = data.getValues(false);
            double[] actualValues = filterData(samples[0], getTimeValues(samples, data))[0];
            if ((defaultUnit != null) && !defaultUnit.equals(unit)) {
                actualValues = Unit.transformUnits(unit, errOut, defaultUnit, null, actualValues);
            }
            final NumberAxis domainAxis = new NumberAxis(wrapper.getLabel(unit));

            domainAxis.setAutoRangeIncludesZero(false);

            XYItemRenderer renderer;
            if (getStacked()) {
                renderer = new StackedXYBarRenderer();
            } else {
                renderer = new XYBarRenderer();
            }
            if ((plot == null) && (chartPanel != null)) {
                plot = chartPanel.getChart().getXYPlot();
            }
            plot.setRenderer(paramIdx, renderer);
            Color c = wrapper.getColor(paramIdx);
            domainAxis.setLabelPaint(c);
            renderer.setSeriesPaint(0, c);

            MyHistogramDataset dataset = new MyHistogramDataset();
            dataset.setType(HistogramType.FREQUENCY);
            dataset.addSeries(dataChoice.getName() + " [" + unit + ']', actualValues, getBins());
            samples = null;
            actualValues = null;
            plot.setDomainAxis(paramIdx, domainAxis, false);
            plot.mapDatasetToDomainAxis(paramIdx, paramIdx);
            plot.setDataset(paramIdx, dataset);

            domainAxis.addChangeListener(new AxisChangeListener() {
                public void axisChanged(AxisChangeEvent ae) {
                    if (!imageControl.isInitDone()) {
                        return;
                    }

                    Range range = domainAxis.getRange();
                    double newLow = Math.floor(range.getLowerBound() + 0.5);
                    double newHigh = Math.floor(range.getUpperBound() + 0.5);
                    double prevLow = getLow();
                    double prevHigh = getHigh();
                    try {
                        ucar.unidata.util.Range newRange;
                        if (prevLow > prevHigh) {
                            newRange = new ucar.unidata.util.Range(newHigh, newLow);
                        } else {
                            newRange = new ucar.unidata.util.Range(newLow, newHigh);
                        }
                        ((DisplayControlImpl) imageControl).setRange(newRange);
                    } catch (Exception e) {
                        logger.error("Cannot change range", e);
                    }
                }
            });

            Range range = domainAxis.getRange();
            low = range.getLowerBound();
            high = range.getUpperBound();
        }

    } catch (Exception exc) {
        System.out.println("Exception exc=" + exc);
        LogUtil.logException("Error creating data set", exc);
    }
}

From source file:org.rdv.viz.dial.DialPanel.java

/**
 * Updates the dial range./*from ww w.ja  va 2  s .  c om*/
 * 
 * @param range  the dial range
 */
private void updateRange() {
    Range range = model.getRange();

    lowerBoundTextField.setText(engineeringFormat.format(model.getRange().getLowerBound()));
    upperBoundTextField.setText(engineeringFormat.format(model.getRange().getUpperBound()));

    dialScale.setLowerBound(range.getLowerBound());
    dialScale.setUpperBound(range.getUpperBound());

    double tickIncrement = range.getLength() / 10;
    dialScale.setMajorTickIncrement(tickIncrement);

    plot.addScale(0, dialScale);

    updateThresholdRanges();
}

From source file:org.rdv.viz.dial.DialPanel.java

/**
 * Updates the threshold ranges./*from  ww  w  .  ja  v  a  2  s.  co m*/
 * 
 * @param range  the dial range
 */
private void updateThresholdRanges() {
    Range range = model.getRange();
    double warningThresh = model.getWarningThreshold() * (range.getLength());
    double criticalThresh = model.getCriticalThreshold() * (range.getLength());

    criticalMinimumThreshold = range.getLowerBound() + criticalThresh;
    warningMinimumThreshold = range.getLowerBound() + warningThresh;
    warningMaximumThreshold = range.getUpperBound() - warningThresh;
    criticalMaxThreshold = range.getUpperBound() - criticalThresh;

    // remove previous dial ranges
    for (StandardDialRange dialRange : thresholdDialRanges) {
        if (dialRange != null) {
            plot.removeLayer(dialRange);
        }
    }

    thresholdDialRanges[0] = new StandardDialRange(range.getLowerBound(), criticalMinimumThreshold, Color.red);
    thresholdDialRanges[0].setInnerRadius(0);
    thresholdDialRanges[0].setOuterRadius(0.9);
    plot.addLayer(thresholdDialRanges[0]);

    thresholdDialRanges[1] = new StandardDialRange(criticalMinimumThreshold, warningMinimumThreshold,
            Color.yellow);
    thresholdDialRanges[1].setInnerRadius(0);
    thresholdDialRanges[1].setOuterRadius(0.9);
    plot.addLayer(thresholdDialRanges[1]);

    thresholdDialRanges[2] = new StandardDialRange(warningMaximumThreshold, criticalMaxThreshold, Color.yellow);
    thresholdDialRanges[2].setInnerRadius(0);
    thresholdDialRanges[2].setOuterRadius(0.9);
    plot.addLayer(thresholdDialRanges[2]);

    thresholdDialRanges[3] = new StandardDialRange(criticalMaxThreshold, range.getUpperBound(), Color.red);
    thresholdDialRanges[3].setInnerRadius(0);
    thresholdDialRanges[3].setOuterRadius(0.9);
    plot.addLayer(thresholdDialRanges[3]);

    // make sure to do this after changing the dial ranges because it gets reset for some reason
    dialValueIndicator.setTemplateValue(-222.222e222);

    checkThresholds();
}

From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java

/**
 * This method implements the graph zoom out functionality.
 *//*from ww w.  j a  va 2s.  c o  m*/
private void zoomOut() {
    Range r = timeAxis.getRange();
    double low = r.getLowerBound();
    double high = low + (r.getUpperBound() - low) * ZOOM_FACTOR;
    setTimeRange(low, high);
}

From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java

/**
 * This method implements the graph zoom in functionality.
 *//*from   w ww. j  a va  2s .  c  o m*/
private void zoomIn() {
    Range range = timeAxis.getRange();
    double lowl = range.getLowerBound();
    double high = lowl + (range.getUpperBound() - lowl) / ZOOM_FACTOR;
    setTimeRange(lowl, high);
}

From source file:ucar.unidata.idv.control.McVHistogramWrapper.java

/**
 * Assumes that {@code data} has been validated and is okay to actually try
 * loading.//from   w ww. j  a v  a2s . com
 *
 * @param data Data to use in histogram. Cannot be {@code null} or all NaNs.
 *
 * @throws VisADException
 * @throws RemoteException
 */
private void reallyLoadData(FlatField data) throws VisADException, RemoteException {
    createChart();
    List dataChoiceWrappers = getDataChoiceWrappers();

    try {
        clearHistogram();

        ErrorEstimate[] errOut = new ErrorEstimate[1];
        for (int paramIdx = 0; paramIdx < dataChoiceWrappers.size(); paramIdx++) {
            DataChoiceWrapper wrapper = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx);

            DataChoice dataChoice = wrapper.getDataChoice();
            Unit defaultUnit = ucar.visad.Util.getDefaultRangeUnits((FlatField) data)[0];
            Unit unit = ((DisplayControlImpl) imageControl).getDisplayUnit();
            double[][] samples = data.getValues(false);
            double[] actualValues = filterData(samples[0], getTimeValues(samples, data))[0];
            if ((defaultUnit != null) && !defaultUnit.equals(unit)) {
                actualValues = Unit.transformUnits(unit, errOut, defaultUnit, null, actualValues);
            }
            final NumberAxis domainAxis = new NumberAxis(wrapper.getLabel(unit));

            domainAxis.setAutoRangeIncludesZero(false);

            XYItemRenderer renderer;
            if (getStacked()) {
                renderer = new StackedXYBarRenderer();
            } else {
                renderer = new XYBarRenderer();
            }
            if ((plot == null) && (chartPanel != null)) {
                plot = chartPanel.getChart().getXYPlot();
            }
            plot.setRenderer(paramIdx, renderer);
            Color c = wrapper.getColor(paramIdx);
            domainAxis.setLabelPaint(c);
            renderer.setSeriesPaint(0, c);

            MyHistogramDataset dataset = new MyHistogramDataset();
            dataset.setType(HistogramType.FREQUENCY);
            dataset.addSeries(dataChoice.getName() + " [" + unit + ']', actualValues, getBins());
            samples = null;
            actualValues = null;
            plot.setDomainAxis(paramIdx, domainAxis, false);
            plot.mapDatasetToDomainAxis(paramIdx, paramIdx);
            plot.setDataset(paramIdx, dataset);

            domainAxis.addChangeListener(new AxisChangeListener() {
                public void axisChanged(AxisChangeEvent ae) {
                    if (!imageControl.isInitDone()) {
                        return;
                    }

                    Range range = domainAxis.getRange();
                    double newLow = Math.floor(range.getLowerBound() + 0.5);
                    double newHigh = Math.floor(range.getUpperBound() + 0.5);
                    double prevLow = getLow();
                    double prevHigh = getHigh();
                    try {
                        ucar.unidata.util.Range newRange;
                        if (prevLow > prevHigh) {
                            newRange = new ucar.unidata.util.Range(newHigh, newLow);
                        } else {
                            newRange = new ucar.unidata.util.Range(newLow, newHigh);
                        }
                        ((DisplayControlImpl) imageControl).setRange(newRange);
                    } catch (Exception e) {
                        logger.error("Cannot change range", e);
                    }
                }
            });

            Range range = domainAxis.getRange();
            low = range.getLowerBound();
            high = range.getUpperBound();
        }

    } catch (Exception exc) {
        System.out.println("Exception exc=" + exc);
        LogUtil.logException("Error creating data set", exc);
    }
}

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

public void initializeVsParameter(VariableDoubles parameters, VariableDoubles initialValues, String parLabel,
        Range parameterRange, int iterations) {

    this.parameters.putAll(parameters);
    this.initialPoint.putAll(initialValues);
    this.firstParLabel = parLabel;
    this.lower = parameterRange.getLowerBound();
    this.upper = parameterRange.getUpperBound();
    this.iterations = iterations;

    this.type = VSPAR;
}