Example usage for org.jfree.chart.axis TickType MAJOR

List of usage examples for org.jfree.chart.axis TickType MAJOR

Introduction

In this page you can find the example usage for org.jfree.chart.axis TickType MAJOR.

Prototype

TickType MAJOR

To view the source code for org.jfree.chart.axis TickType MAJOR.

Click Source Link

Document

Major tick.

Usage

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

/**
  * Draws the gridlines for the plot, if they are visible.
  */*from w  ww.j av  a  2  s. c  o  m*/
  * @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:com.lfx.web.WebChartXYPlot.java

/**
 * Draws the gridlines for the plot's primary range axis, if they are
 * visible./*from  w w w. ja va2  s.c o m*/
 *
 * @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:org.jstockchart.axis.TimeseriesDateAxis.java

protected AxisState drawTickMarksAndLabels(Graphics2D g2, double cursor, Rectangle2D plotArea,
        Rectangle2D dataArea, RectangleEdge edge) {

    AxisState state = new AxisState(cursor);

    if (isAxisLineVisible()) {
        drawAxisLine(g2, cursor, dataArea, edge);
    }//from  w w  w  .  j a  v a  2 s . c o m

    List ticks = refreshTicks(g2, state, dataArea, edge);
    state.setTicks(ticks);
    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);
            //System.out.println("label:"+tick.getText());
            String tickLabel = tick.getText();
            if (tickLabel == "13:00") {
                TextUtilities.drawRotatedString("/", g2, anchorPoint[0] - 2, anchorPoint[1],
                        tick.getTextAnchor(), tick.getAngle(), tick.getRotationAnchor());
            }
            if (hideTickLabel != null) {
                if (!hideTickLabel.contains(tickLabel)) {
                    TextUtilities.drawRotatedString(tickLabel, g2, anchorPoint[0], anchorPoint[1],
                            tick.getTextAnchor(), tick.getAngle(), tick.getRotationAnchor());
                }
            } else {
                TextUtilities.drawRotatedString(tick.getText(), g2, anchorPoint[0], anchorPoint[1],
                        tick.getTextAnchor(), tick.getAngle(), tick.getRotationAnchor());
            }

        }

        if ((isTickMarksVisible() && tick.getTickType().equals(TickType.MAJOR))
                || (isMinorTickMarksVisible() && tick.getTickType().equals(TickType.MINOR))) {

            double ol = (tick.getTickType().equals(TickType.MINOR)) ? getMinorTickMarkOutsideLength()
                    : getTickMarkOutsideLength();

            double il = (tick.getTickType().equals(TickType.MINOR)) ? getMinorTickMarkInsideLength()
                    : getTickMarkInsideLength();

            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);
        }
    }

    // need to work out the space used by the tick labels...
    // so we can update the cursor...
    double used = 0.0;
    if (isTickLabelsVisible()) {
        if (edge == RectangleEdge.LEFT) {
            used += findMaximumTickLabelWidth(ticks, g2, plotArea, isVerticalTickLabels());
            state.cursorLeft(used);
        } else if (edge == RectangleEdge.RIGHT) {
            used = findMaximumTickLabelWidth(ticks, g2, plotArea, isVerticalTickLabels());
            state.cursorRight(used);
        } else if (edge == RectangleEdge.TOP) {
            used = findMaximumTickLabelHeight(ticks, g2, plotArea, isVerticalTickLabels());
            state.cursorUp(used);
        } else if (edge == RectangleEdge.BOTTOM) {
            used = findMaximumTickLabelHeight(ticks, g2, plotArea, isVerticalTickLabels());
            state.cursorDown(used);
        }
    }

    return state;
}