Java Code Examples for org.jfree.data.Range#contains()

The following examples show how to use org.jfree.data.Range#contains() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JGenProg2017_0078_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws a line perpendicular to the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D
 *                  effect).
 * @param value  the value at which the grid line should be drawn.
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #drawRangeGridline
 *
 * @since 1.0.13
 */
public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    Line2D line = null;
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v,
                dataArea.getMaxX(), v);
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.draw(line);

}
 
Example 2
Source File: jMutRepair_0020_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws a line perpendicular to the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D
 *                  effect).
 * @param value  the value at which the grid line should be drawn.
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #drawRangeGridline
 *
 * @since 1.0.13
 */
public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    Line2D line = null;
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v,
                dataArea.getMaxX(), v);
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.draw(line);

}
 
Example 3
Source File: patch1-Chart-1-jMutRepair_patch1-Chart-1-jMutRepair_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws a line perpendicular to the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D
 *                  effect).
 * @param value  the value at which the grid line should be drawn.
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #drawRangeGridline
 *
 * @since 1.0.13
 */
public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    Line2D line = null;
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v,
                dataArea.getMaxX(), v);
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.draw(line);

}
 
Example 4
Source File: Cardumen_00139_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Draws a line perpendicular to the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D
 *                  effect).
 * @param value  the value at which the grid line should be drawn.
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #drawRangeGridline
 *
 * @since 1.0.13
 */
public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    Line2D line = null;
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v,
                dataArea.getMaxX(), v);
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.draw(line);

}
 
Example 5
Source File: ShortTextTitle.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 */
@Override
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 6
Source File: AbstractXYItemRenderer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws a line perpendicular to the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D
 *                  effect).
 * @param value  the value at which the grid line should be drawn.
 * @param paint  the paint.
 * @param stroke  the stroke.
 */
public void drawRangeLine(Graphics2D g2,
                          XYPlot plot,
                          ValueAxis axis,
                          Rectangle2D dataArea,
                          double value,
                          Paint paint,
                          Stroke stroke) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    Line2D line = null;
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v,
                dataArea.getMaxX(), v);
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.draw(line);

}
 
Example 7
Source File: AbstractXYItemRenderer.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Draws a grid line against the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 
 *                  3D effect).
 * @param value  the value at which the grid line should be drawn.
 */
public void drawDomainGridLine(Graphics2D g2,
                               XYPlot plot,
                               ValueAxis axis,
                               Rectangle2D dataArea,
                               double value) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    double v = axis.valueToJava2D(value, dataArea, 
            plot.getDomainAxisEdge());
    Line2D line = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), v, 
                dataArea.getMaxX(), v);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v, 
                dataArea.getMaxY());
    }

    Paint paint = plot.getDomainGridlinePaint();
    Stroke stroke = plot.getDomainGridlineStroke();
    g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
    g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
    g2.draw(line);

}
 
Example 8
Source File: AbstractXYItemRenderer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws a line perpendicular to the domain axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D
 *                  effect).
 * @param value  the value at which the grid line should be drawn.
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 * 
 * @since 1.0.5
 */
public void drawDomainLine(Graphics2D g2, XYPlot plot, ValueAxis axis,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    Line2D line = null;
    double v = axis.valueToJava2D(value, dataArea, 
            plot.getDomainAxisEdge());
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), 
                v);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v, 
                dataArea.getMaxY());
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    g2.draw(line);

}
 
Example 9
Source File: DatasetUtilities.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the range of z-values in the specified dataset for the
 * data items belonging to the visible series and with x-values in the
 * given range.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param visibleSeriesKeys  the visible series keys (<code>null</code> not
 *     permitted).
 * @param xRange  the x-range (<code>null</code> not permitted).
 * @param includeInterval  a flag that determines whether or not the
 *     z-interval for the dataset is included (this only applies if the
 *     dataset has an interval, which is currently not supported).
 *
 * @return The y-range (possibly <code>null</code>).
 */
public static Range iterateToFindZBounds(XYZDataset dataset,
        List visibleSeriesKeys, Range xRange, boolean includeInterval) {
    ParamChecks.nullNotPermitted(dataset, "dataset");
    ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys");
    ParamChecks.nullNotPermitted(xRange, "xRange");

    double minimum = Double.POSITIVE_INFINITY;
    double maximum = Double.NEGATIVE_INFINITY;

    Iterator iterator = visibleSeriesKeys.iterator();
    while (iterator.hasNext()) {
        Comparable seriesKey = (Comparable) iterator.next();
        int series = dataset.indexOf(seriesKey);
        int itemCount = dataset.getItemCount(series);
        for (int item = 0; item < itemCount; item++) {
            double x = dataset.getXValue(series, item);
            double z = dataset.getZValue(series, item);
            if (xRange.contains(x)) {
                if (!Double.isNaN(z)) {
                    minimum = Math.min(minimum, z);
                    maximum = Math.max(maximum, z);
                }
            }
        }
    }

    if (minimum == Double.POSITIVE_INFINITY) {
        return null;
    }
    else {
        return new Range(minimum, maximum);
    }
}
 
Example 10
Source File: ContourPlot.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Draws a horizontal line across the chart to represent a 'range marker'.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param rangeAxis  the range axis.
 * @param marker  the marker line.
 * @param dataArea  the axis data area.
 */
public void drawRangeMarker(Graphics2D g2,
                            ContourPlot plot,
                            ValueAxis rangeAxis,
                            Marker marker,
                            Rectangle2D dataArea) {

    if (marker instanceof ValueMarker) {
        ValueMarker vm = (ValueMarker) marker;
        double value = vm.getValue();
        Range range = rangeAxis.getRange();
        if (!range.contains(value)) {
            return;
        }

        double y = rangeAxis.valueToJava2D(value, dataArea, 
                RectangleEdge.LEFT);
        Line2D line = new Line2D.Double(dataArea.getMinX(), y, 
                dataArea.getMaxX(), y);
        Paint paint = marker.getOutlinePaint();
        Stroke stroke = marker.getOutlineStroke();
        g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
        g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
        g2.draw(line);
    }

}
 
Example 11
Source File: ContourPlot.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a vertical line on the chart to represent a 'range marker'.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param domainAxis  the domain axis.
 * @param marker  the marker line.
 * @param dataArea  the axis data area.
 */
public void drawDomainMarker(Graphics2D g2,
                             ContourPlot plot,
                             ValueAxis domainAxis,
                             Marker marker,
                             Rectangle2D dataArea) {

    if (marker instanceof ValueMarker) {
        ValueMarker vm = (ValueMarker) marker;
        double value = vm.getValue();
        Range range = domainAxis.getRange();
        if (!range.contains(value)) {
            return;
        }

        double x = domainAxis.valueToJava2D(value, dataArea,
                RectangleEdge.BOTTOM);
        Line2D line = new Line2D.Double(x, dataArea.getMinY(), x,
                dataArea.getMaxY());
        Paint paint = marker.getOutlinePaint();
        Stroke stroke = marker.getOutlineStroke();
        g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
        g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
        g2.draw(line);
    }

}
 
Example 12
Source File: AbstractXYItemRenderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a grid line against the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any
 *                  3D effect).
 * @param value  the value at which the grid line should be drawn.
 */
@Override
public void drawDomainGridLine(Graphics2D g2, XYPlot plot, ValueAxis axis,
        Rectangle2D dataArea, double value) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    double v = axis.valueToJava2D(value, dataArea,
            plot.getDomainAxisEdge());
    Line2D line = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), v,
                dataArea.getMaxX(), v);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
    }

    Paint paint = plot.getDomainGridlinePaint();
    Stroke stroke = plot.getDomainGridlineStroke();
    g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
    g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
    Object saved = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, 
            RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.draw(line);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, saved);
}
 
Example 13
Source File: AbstractXYItemRenderer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a line perpendicular to the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D
 *                  effect).
 * @param value  the value at which the grid line should be drawn.
 * @param paint  the paint.
 * @param stroke  the stroke.
 */
@Override
public void drawRangeLine(Graphics2D g2, XYPlot plot, ValueAxis axis,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    Line2D line = null;
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());      
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
    } else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v,
                dataArea.getMaxX(), v);
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    Object saved = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, 
            RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.draw(line);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, saved);
}
 
Example 14
Source File: ModifiedPlot.java    From chipster with MIT License 5 votes vote down vote up
/**
 * Draws a horizontal line across the chart to represent a 'range marker'.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param rangeAxis  the range axis.
 * @param marker  the marker line.
 * @param dataArea  the axis data area.
 */
public void drawRangeMarker(Graphics2D g2,
                            ModifiedPlot plot,
                            ValueAxis rangeAxis,
                            Marker marker,
                            Rectangle2D dataArea) {

    if (marker instanceof ValueMarker) {
        ValueMarker vm = (ValueMarker) marker;
        double value = vm.getValue();
        Range range = rangeAxis.getRange();
        if (!range.contains(value)) {
            return;
        }

        double y = rangeAxis.valueToJava2D(
            value, dataArea, RectangleEdge.LEFT
        );
        Line2D line = new Line2D.Double(
            dataArea.getMinX(), y, dataArea.getMaxX(), y
        );
        Paint paint = marker.getOutlinePaint();
        Stroke stroke = marker.getOutlineStroke();
        g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
        g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
        g2.draw(line);
    }

}
 
Example 15
Source File: ContourPlot.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Draws a horizontal line across the chart to represent a 'range marker'.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param rangeAxis  the range axis.
 * @param marker  the marker line.
 * @param dataArea  the axis data area.
 */
public void drawRangeMarker(Graphics2D g2,
                            ContourPlot plot,
                            ValueAxis rangeAxis,
                            Marker marker,
                            Rectangle2D dataArea) {

    if (marker instanceof ValueMarker) {
        ValueMarker vm = (ValueMarker) marker;
        double value = vm.getValue();
        Range range = rangeAxis.getRange();
        if (!range.contains(value)) {
            return;
        }

        double y = rangeAxis.valueToJava2D(value, dataArea,
                RectangleEdge.LEFT);
        Line2D line = new Line2D.Double(dataArea.getMinX(), y,
                dataArea.getMaxX(), y);
        Paint paint = marker.getOutlinePaint();
        Stroke stroke = marker.getOutlineStroke();
        g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
        g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
        g2.draw(line);
    }

}
 
Example 16
Source File: AbstractCategoryItemRenderer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws a line perpendicular to the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D
 *                  effect).
 * @param value  the value at which the grid line should be drawn.
 * @param paint  the paint (<code>null</code> not permitted).
 * @param stroke  the stroke (<code>null</code> not permitted).
 *
 * @see #drawRangeGridline
 *
 * @since 1.0.13
 */
public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis,
        Rectangle2D dataArea, double value, Paint paint, Stroke stroke) {

    // TODO: In JFreeChart 1.2.0, put this method in the
    // CategoryItemRenderer interface
    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    Line2D line = null;
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v,
                dataArea.getMaxY());
    } else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v,
                dataArea.getMaxX(), v);
    }

    g2.setPaint(paint);
    g2.setStroke(stroke);
    Object saved = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, 
            RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.draw(line);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, saved);
}
 
Example 17
Source File: LogAxis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a list of ticks for an axis at the top or bottom of the chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param edge  the edge.
 *
 * @return A list of ticks.
 */
protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea,
        RectangleEdge edge) {

    Range range = getRange();
    List ticks = new ArrayList();
    Font tickLabelFont = getTickLabelFont();
    g2.setFont(tickLabelFont);
    TextAnchor textAnchor;
    if (edge == RectangleEdge.TOP) {
        textAnchor = TextAnchor.BOTTOM_CENTER;
    }
    else {
        textAnchor = TextAnchor.TOP_CENTER;
    }

    if (isAutoTickUnitSelection()) {
        selectAutoTickUnit(g2, dataArea, edge);
    }
    int minorTickCount = this.tickUnit.getMinorTickCount();
    double start = Math.floor(calculateLog(getLowerBound()));
    double end = Math.ceil(calculateLog(getUpperBound()));
    double current = start;
    while (current <= end) {
        double v = calculateValue(current);
        if (range.contains(v)) {
            ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v),
                    textAnchor, TextAnchor.CENTER, 0.0));
        }
        // add minor ticks (for gridlines)
        double next = Math.pow(this.base, current
                + this.tickUnit.getSize());
        for (int i = 1; i < minorTickCount; i++) {
            double minorV = v + i * ((next - v) / minorTickCount);
            if (range.contains(minorV)) {
                ticks.add(new NumberTick(TickType.MINOR, minorV, "",
                        textAnchor, TextAnchor.CENTER, 0.0));
            }
        }
        current = current + this.tickUnit.getSize();
    }
    return ticks;
}
 
Example 18
Source File: LogAxis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a list of ticks for an axis at the left or right of the chart.
 * 
 * @param g2  the graphics device.
 * @param dataArea  the data area.
 * @param edge  the edge.
 * 
 * @return A list of ticks.
 */
protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, 
        RectangleEdge edge) {
    
    Range range = getRange();
    List ticks = new ArrayList();
    Font tickLabelFont = getTickLabelFont();
    g2.setFont(tickLabelFont);
	TextAnchor textAnchor;
    if (edge == RectangleEdge.RIGHT) {
    	textAnchor = TextAnchor.CENTER_LEFT;
    }
    else {
    	textAnchor = TextAnchor.CENTER_RIGHT;
    }
    
    if (isAutoTickUnitSelection()) {
        selectAutoTickUnit(g2, dataArea, edge);
    }
    double start = Math.floor(calculateLog(getLowerBound()));
    double end = Math.ceil(calculateLog(getUpperBound()));
    double current = start;
    while (current <= end) {
        double v = calculateValue(current);
        if (range.contains(v)) {
            ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), 
                    textAnchor, TextAnchor.CENTER, 0.0));
        }
        // add minor ticks (for gridlines)
        double next = Math.pow(this.base, current 
                + this.tickUnit.getSize());
        for (int i = 1; i < this.minorTickCount; i++) {
            double minorV = v + i * ((next - v) / this.minorTickCount);
            if (range.contains(minorV)) {
                ticks.add(new NumberTick(TickType.MINOR, minorV, "", 
                        textAnchor, TextAnchor.CENTER, 0.0));
            }
        }
        current = current + this.tickUnit.getSize();
    }
    return ticks;
}
 
Example 19
Source File: TextTitle.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.  This
 * will reflect the fact that a text title positioned on the left or right
 * of a chart will be rotated by 90 degrees.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 *
 * @since 1.0.9
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}
 
Example 20
Source File: ShortTextTitle.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Arranges the content for this title assuming a range constraint for the
 * width and no bounds on the height, and returns the required size.
 *
 * @param g2  the graphics target.
 * @param widthRange  the range for the width.
 *
 * @return The content size.
 */
protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
    Size2D s = arrangeNN(g2);
    if (widthRange.contains(s.getWidth())) {
        return s;
    }
    double ww = widthRange.constrain(s.getWidth());
    return arrangeFN(g2, ww);
}