Search in sources :

Example 1 with NumberTick

use of org.jfree.chart.axis.NumberTick in project SIMVA-SoS by SESoS.

the class PolarPlot method refreshAngleTicks.

/**
 * Generates a list of tick values for the angular tick marks.
 *
 * @return A list of {@link NumberTick} instances.
 *
 * @since 1.0.10
 */
protected List refreshAngleTicks() {
    List ticks = new ArrayList();
    for (double currentTickVal = 0.0; currentTickVal < 360.0; currentTickVal += this.angleTickUnit.getSize()) {
        TextAnchor ta = calculateTextAnchor(currentTickVal);
        NumberTick tick = new NumberTick(new Double(currentTickVal), this.angleTickUnit.valueToString(currentTickVal), ta, TextAnchor.CENTER, 0.0);
        ticks.add(tick);
    }
    return ticks;
}
Also used : TextAnchor(org.jfree.ui.TextAnchor) NumberTick(org.jfree.chart.axis.NumberTick) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ObjectList(org.jfree.util.ObjectList)

Example 2 with NumberTick

use of org.jfree.chart.axis.NumberTick in project SIMVA-SoS by SESoS.

the class DefaultPolarItemRenderer method drawAngularGridLines.

/**
 * Draw the angular gridlines - the spokes.
 *
 * @param g2  the drawing surface.
 * @param plot  the plot (<code>null</code> not permitted).
 * @param ticks  the ticks (<code>null</code> not permitted).
 * @param dataArea  the data area.
 */
@Override
public void drawAngularGridLines(Graphics2D g2, PolarPlot plot, List ticks, Rectangle2D dataArea) {
    g2.setFont(plot.getAngleLabelFont());
    g2.setStroke(plot.getAngleGridlineStroke());
    g2.setPaint(plot.getAngleGridlinePaint());
    ValueAxis axis = plot.getAxis();
    double centerValue, outerValue;
    if (axis.isInverted()) {
        outerValue = axis.getLowerBound();
        centerValue = axis.getUpperBound();
    } else {
        outerValue = axis.getUpperBound();
        centerValue = axis.getLowerBound();
    }
    Point center = plot.translateToJava2D(0, centerValue, axis, dataArea);
    Iterator iterator = ticks.iterator();
    while (iterator.hasNext()) {
        NumberTick tick = (NumberTick) iterator.next();
        double tickVal = tick.getNumber().doubleValue();
        Point p = plot.translateToJava2D(tickVal, outerValue, axis, dataArea);
        g2.setPaint(plot.getAngleGridlinePaint());
        g2.drawLine(center.x, center.y, p.x, p.y);
        if (plot.isAngleLabelsVisible()) {
            int x = p.x;
            int y = p.y;
            g2.setPaint(plot.getAngleLabelPaint());
            TextUtilities.drawAlignedString(tick.getText(), g2, x, y, tick.getTextAnchor());
        }
    }
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis) NumberTick(org.jfree.chart.axis.NumberTick) PathIterator(java.awt.geom.PathIterator) Iterator(java.util.Iterator) Point(java.awt.Point) Point(java.awt.Point) Paint(java.awt.Paint)

Example 3 with NumberTick

use of org.jfree.chart.axis.NumberTick in project SIMVA-SoS by SESoS.

the class DefaultPolarItemRenderer method drawRadialGridLines.

/**
 * Draw the radial gridlines - the rings.
 *
 * @param g2  the drawing surface (<code>null</code> not permitted).
 * @param plot  the plot (<code>null</code> not permitted).
 * @param radialAxis  the radial axis (<code>null</code> not permitted).
 * @param ticks  the ticks (<code>null</code> not permitted).
 * @param dataArea  the data area.
 */
@Override
public void drawRadialGridLines(Graphics2D g2, PolarPlot plot, ValueAxis radialAxis, List ticks, Rectangle2D dataArea) {
    ParamChecks.nullNotPermitted(radialAxis, "radialAxis");
    g2.setFont(radialAxis.getTickLabelFont());
    g2.setPaint(plot.getRadiusGridlinePaint());
    g2.setStroke(plot.getRadiusGridlineStroke());
    double centerValue;
    if (radialAxis.isInverted()) {
        centerValue = radialAxis.getUpperBound();
    } else {
        centerValue = radialAxis.getLowerBound();
    }
    Point center = plot.translateToJava2D(0, centerValue, radialAxis, dataArea);
    Iterator iterator = ticks.iterator();
    while (iterator.hasNext()) {
        NumberTick tick = (NumberTick) iterator.next();
        double angleDegrees = plot.isCounterClockwise() ? plot.getAngleOffset() : -plot.getAngleOffset();
        Point p = plot.translateToJava2D(angleDegrees, tick.getNumber().doubleValue(), radialAxis, dataArea);
        int r = p.x - center.x;
        int upperLeftX = center.x - r;
        int upperLeftY = center.y - r;
        int d = 2 * r;
        Ellipse2D ring = new Ellipse2D.Double(upperLeftX, upperLeftY, d, d);
        g2.setPaint(plot.getRadiusGridlinePaint());
        g2.draw(ring);
    }
}
Also used : NumberTick(org.jfree.chart.axis.NumberTick) PathIterator(java.awt.geom.PathIterator) Iterator(java.util.Iterator) Point(java.awt.Point) Point(java.awt.Point) Paint(java.awt.Paint) Ellipse2D(java.awt.geom.Ellipse2D)

Aggregations

NumberTick (org.jfree.chart.axis.NumberTick)3 Paint (java.awt.Paint)2 Point (java.awt.Point)2 PathIterator (java.awt.geom.PathIterator)2 Iterator (java.util.Iterator)2 Ellipse2D (java.awt.geom.Ellipse2D)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ValueAxis (org.jfree.chart.axis.ValueAxis)1 TextAnchor (org.jfree.ui.TextAnchor)1 ObjectList (org.jfree.util.ObjectList)1