Example usage for org.jfree.chart.axis ValueTick getValue

List of usage examples for org.jfree.chart.axis ValueTick getValue

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueTick getValue.

Prototype

public double getValue() 

Source Link

Document

Returns the value.

Usage

From source file:com.rapidminer.gui.plotter.charts.WeightBasedSymbolAxis.java

/**
 * Draws the grid bands for the axis when it is at the top or bottom of the plot.
 * /*ww  w.  ja  v  a2  s.  c  om*/
 * @param g2
 *            the graphics device.
 * @param plotArea
 *            the area within which the chart should be drawn.
 * @param dataArea
 *            the area within which the plot should be drawn (a subset of the drawArea).
 * @param firstGridBandIsDark
 *            True: the first grid band takes the color of <CODE>gridBandPaint<CODE>.
 *                             False: the second grid band takes the
 *                             color of <CODE>gridBandPaint<CODE>.
 * @param ticks
 *            the ticks.
 */
@Override
protected void drawGridBandsHorizontal(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea,
        boolean firstGridBandIsDark, List ticks) {
    double yy = dataArea.getY();
    double xx1, xx2;

    // gets the outline stroke width of the plot
    double outlineStrokeWidth;
    if (getPlot().getOutlineStroke() != null) {
        outlineStrokeWidth = ((BasicStroke) getPlot().getOutlineStroke()).getLineWidth();
    } else {
        outlineStrokeWidth = 1d;
    }

    Iterator iterator = ticks.iterator();
    ValueTick tick;
    Rectangle2D band;
    while (iterator.hasNext()) {
        tick = (ValueTick) iterator.next();
        int weightIndex = (int) tick.getValue();
        xx1 = valueToJava2D(tick.getValue() - 0.5d, dataArea, RectangleEdge.BOTTOM);
        xx2 = valueToJava2D(tick.getValue() + 0.5d, dataArea, RectangleEdge.BOTTOM);

        g2.setColor(PlotterAdapter.getWeightColor(this.weights[weightIndex], this.maxWeight));

        band = new Rectangle2D.Double(xx1, yy + outlineStrokeWidth, xx2 - xx1,
                dataArea.getMaxY() - yy - outlineStrokeWidth);
        g2.fill(band);
    }
    g2.setPaintMode();
}

From source file:com.rapidminer.gui.plotter.charts.WeightBasedSymbolAxis.java

/**
 * Draws the grid bands for the axis when it is at the top or bottom of the plot.
 * /* ww  w.  j av  a 2 s  . c  o  m*/
 * @param g2
 *            the graphics device.
 * @param drawArea
 *            the area within which the chart should be drawn.
 * @param plotArea
 *            the area within which the plot should be drawn (a subset of the drawArea).
 * @param firstGridBandIsDark
 *            True: the first grid band takes the color of <CODE>gridBandPaint<CODE>.
 *                             False: the second grid band takes the
 *                             color of <CODE>gridBandPaint<CODE>.
 * @param ticks
 *            a list of ticks.
 */
@Override
protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D drawArea, Rectangle2D plotArea,
        boolean firstGridBandIsDark, List ticks) {
    double xx = plotArea.getX();
    double yy1, yy2;

    // gets the outline stroke width of the plot
    double outlineStrokeWidth;
    Stroke outlineStroke = getPlot().getOutlineStroke();
    if (outlineStroke != null && outlineStroke instanceof BasicStroke) {
        outlineStrokeWidth = ((BasicStroke) outlineStroke).getLineWidth();
    } else {
        outlineStrokeWidth = 1d;
    }

    Iterator iterator = ticks.iterator();
    ValueTick tick;
    Rectangle2D band;
    while (iterator.hasNext()) {
        tick = (ValueTick) iterator.next();
        int weightIndex = (int) tick.getValue();
        yy1 = valueToJava2D(tick.getValue() + 0.5d, plotArea, RectangleEdge.LEFT);
        yy2 = valueToJava2D(tick.getValue() - 0.5d, plotArea, RectangleEdge.LEFT);

        g2.setColor(PlotterAdapter.getWeightColor(this.weights[weightIndex], this.maxWeight));

        band = new Rectangle2D.Double(xx + outlineStrokeWidth, yy1,
                plotArea.getMaxX() - xx - outlineStrokeWidth, yy2 - yy1);
        g2.fill(band);
    }
    g2.setPaintMode();
}

From source file:com.lfx.web.WebChartXYPlot.java

/**
 * Draws the gridlines for the plot's primary range axis, if they are
 * visible./* w  ww.java 2  s . com*/
 *
 * @param g2  the graphics device.
 * @param area  the data area.
 * @param ticks  the ticks.
 *
 * @see #drawDomainGridlines(Graphics2D, Rectangle2D, List)
 */
protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) {
    Composite oldcomp = g2.getComposite();
    Paint bandPaint = getBackgroundPaint();
    if (bandPaint != null && bandPaint instanceof java.awt.Color) {
        g2.setComposite(AlphaComposite.SrcIn);
        java.awt.Color bandcolor = (java.awt.Color) (bandPaint);
        boolean fillBand = true;
        ValueAxis axis = getDomainAxis();
        double previous = axis.getLowerBound();
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            if (!tick.getTickType().equals(TickType.MAJOR))
                continue;
            double current = tick.getValue();
            double y1 = axis.valueToJava2D(previous, dataArea, getDomainAxisEdge());
            double y2 = axis.valueToJava2D(current, dataArea, getDomainAxisEdge());
            Rectangle2D band = new Rectangle2D.Double(y1, dataArea.getMinY(), y2 - y1, dataArea.getWidth());
            if (fillBand)
                g2.setPaint(bandcolor);
            else
                g2.setPaint(bandcolor.darker());
            g2.fill(band);
            previous = current;
            fillBand = !fillBand;
        }
        double end = axis.getUpperBound();
        double y1 = axis.valueToJava2D(previous, dataArea, getDomainAxisEdge());
        double y2 = axis.valueToJava2D(end, dataArea, getDomainAxisEdge());
        Rectangle2D band = new Rectangle2D.Double(y1, dataArea.getMinY(), y2 - y1, dataArea.getWidth());
        if (fillBand)
            g2.setPaint(bandcolor);
        else
            g2.setPaint(bandcolor.darker());
        g2.fill(band);
    } else {
        super.drawDomainGridlines(g2, dataArea, ticks);
    }
    g2.setComposite(oldcomp);
}

From source file:com.lfx.web.WebChartXYPlot.java

/**
  * Draws the gridlines for the plot, if they are visible.
  */*from  w w  w  . j  a  v  a2 s.  c  om*/
  * @param g2  the graphics device.
  * @param dataArea  the data area.
  * @param ticks  the ticks.
  *
  * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List)
  */

protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) {
    Composite oldcomp = g2.getComposite();
    Paint bandPaint = getBackgroundPaint();
    if (bandPaint != null && bandPaint instanceof java.awt.Color) {
        // g2.setComposite(AlphaComposite.SrcO);
        java.awt.Color bandcolor = (java.awt.Color) (bandPaint);
        boolean fillBand = false;
        ValueAxis axis = getRangeAxis();
        double previous = axis.getLowerBound();
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            if (!tick.getTickType().equals(TickType.MAJOR))
                continue;
            double current = tick.getValue();
            double y1 = axis.valueToJava2D(previous, dataArea, getRangeAxisEdge());
            double y2 = axis.valueToJava2D(current, dataArea, getRangeAxisEdge());
            Rectangle2D band = new Rectangle2D.Double(dataArea.getMinX(), y2, dataArea.getWidth(), y1 - y2);
            if (fillBand)
                g2.setPaint(bandcolor);
            else
                g2.setPaint(bandcolor.darker());
            g2.fill(band);
            previous = current;
            fillBand = !fillBand;
        }
        double end = axis.getUpperBound();
        double y1 = axis.valueToJava2D(previous, dataArea, getRangeAxisEdge());
        double y2 = axis.valueToJava2D(end, dataArea, getRangeAxisEdge());
        Rectangle2D band = new Rectangle2D.Double(dataArea.getMinX(), y2, dataArea.getWidth(), y1 - y2);
        if (fillBand)
            g2.setPaint(bandcolor);
        else
            g2.setPaint(bandcolor.darker());
        g2.fill(band);
    } else {
        super.drawRangeGridlines(g2, dataArea, ticks);
    }
    g2.setComposite(oldcomp);
}

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

protected void drawGridlines(Graphics2D g2, Rectangle2D dataArea, List domainTicks, List rangeTicks) {

    if ((gridStroke != null) && (gridPaint != null) && domainAxis != null) {
        Iterator iterator = domainTicks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            drawDomainGridLine(g2, dataArea, tick.getValue());
        }/*w  w w  .j av a2 s  .c om*/
    }

    if ((gridStroke != null) && (gridPaint != null) && rangeAxis != null) {
        Iterator iterator = rangeTicks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            drawRangeGridLine(g2, dataArea, tick.getValue());
        }
    }
}

From source file:figs.treeVisualization.gui.PhyloDateAxis.java

/**
 * Draws the axis line, tick marks and tick mark labels.
 * //from  w  w w  . ja v  a  2  s .  c  o  m
 * @param g2  the graphics device.
 * @param cursor  the cursor.
 * @param plotArea  the plot area.
 * @param dataArea  the data area.
 * @param edge  the edge that the axis is aligned with.
 *
 * 
 * Original method is in <code>org.jfree.chart.axis.ValueAxis</code>
 */
protected void drawTickMarksAndLabels(Graphics2D g2, double cursor, Rectangle2D dataArea) {
    //AxisState state = new AxisState(cursor);
    RectangleEdge edge = RectangleEdge.RIGHT;

    drawAxisLine(g2, cursor, dataArea);

    double ol = getTickMarkOutsideLength();
    double il = getTickMarkInsideLength();

    // Their's miss the first and last label
    //List ticks = refreshTicks(g2, state, dataArea, edge);
    List ticks = refreshTicksVertical(g2, dataArea);
    g2.setFont(getTickLabelFont());
    Iterator iterator = ticks.iterator();

    while (iterator.hasNext()) {
        ValueTick tick = (ValueTick) iterator.next();
        if (isTickLabelsVisible()) {
            g2.setPaint(getTickLabelPaint());
            float[] anchorPoint = calculateAnchorPoint(tick, cursor, dataArea, edge);
            TextUtilities.drawRotatedString(tick.getText(), g2, anchorPoint[0], anchorPoint[1],
                    tick.getTextAnchor(), tick.getAngle(), tick.getRotationAnchor());
        }

        if (isTickMarksVisible()) {
            float xx = (float) valueToJava2D(tick.getValue(), dataArea, edge);
            Line2D mark = null;
            g2.setStroke(getTickMarkStroke());
            g2.setPaint(getTickMarkPaint());
            if (edge == RectangleEdge.LEFT) {
                mark = new Line2D.Double(cursor - ol, xx, cursor + il, xx);
            } else if (edge == RectangleEdge.RIGHT) {
                mark = new Line2D.Double(cursor + ol, xx, cursor - il, xx);
            } else if (edge == RectangleEdge.TOP) {
                mark = new Line2D.Double(xx, cursor - ol, xx, cursor + il);
            } else if (edge == RectangleEdge.BOTTOM) {
                mark = new Line2D.Double(xx, cursor + ol, xx, cursor - il);
            }
            g2.draw(mark);
        }
    } // end tick list iterator
}

From source file:org.proteosuite.FastScatterPlot.java

/**
 * Draws the gridlines for the plot, if they are visible.
 *
 * @param g2  the graphics device.//from  w  w  w  . j a v a2s .c  o m
 * @param dataArea  the data area.
 * @param ticks  the ticks.
 */
protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List<ValueTick> ticks) {

    // draw the domain grid lines, if any...
    if (isDomainGridlinesVisible()) {
        Stroke gridStroke = getDomainGridlineStroke();
        Paint gridPaint = getDomainGridlinePaint();
        if ((gridStroke != null) && (gridPaint != null)) {
            Iterator<ValueTick> iterator = ticks.iterator();
            while (iterator.hasNext()) {
                ValueTick tick = (ValueTick) iterator.next();
                double v = this.domainAxis.valueToJava2D(tick.getValue(), dataArea, RectangleEdge.BOTTOM);
                Line2D line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
                g2.setPaint(gridPaint);
                g2.setStroke(gridStroke);
                g2.draw(line);
            }
        }
    }
}

From source file:org.proteosuite.FastScatterPlot.java

/**
 * Draws the gridlines for the plot, if they are visible.
 *
 * @param g2  the graphics device./*from www  . j  a v  a 2s.co  m*/
 * @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:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java

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

    // draw the domain grid lines, if the flag says they're visible...
    if (isDomainGridlinesVisible()) {
        Iterator iterator = ticks.iterator();
        while (iterator.hasNext()) {
            ValueTick tick = (ValueTick) iterator.next();
            double v = this.domainAxis.valueToJava2D(tick.getValue(), dataArea, RectangleEdge.BOTTOM);
            Line2D line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
            g2.setPaint(getDomainGridlinePaint());
            g2.setStroke(getDomainGridlineStroke());
            g2.draw(line);
        }
    }
}

From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java

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

    // draw the range grid lines, if the flag says they're visible...
    if (isRangeGridlinesVisible()) {
        Iterator 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(getRangeGridlinePaint());
            g2.setStroke(getRangeGridlineStroke());
            g2.draw(line);
        }
    }

}