Java Code Examples for org.jfree.data.time.RegularTimePeriod#getLastMillisecond()

The following examples show how to use org.jfree.data.time.RegularTimePeriod#getLastMillisecond() . 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: OHLCSeriesCollection.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example 2
Source File: OHLCSeriesCollection.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example 3
Source File: OHLCSeriesCollection.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example 4
Source File: OHLCSeriesCollection.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond(); 
    }
    return result;
}
 
Example 5
Source File: OHLCSeriesCollection.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond(); 
    }
    return result;
}
 
Example 6
Source File: OHLCSeriesCollection.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example 7
Source File: OHLCSeriesCollection.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example 8
Source File: OHLCSeriesCollection.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example 9
Source File: OHLCSeriesCollection.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example 10
Source File: PeriodAxis.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or
 * bottom of the plot.
 *
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0;
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = createInstance(this.majorTickTimePeriodClass, 
            this.first.getStart(), getTimeZone(), this.locale);
    long t0 = t.getFirstMillisecond();
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond();
    long lastOnAxis = getLast().getLastMillisecond() + 1;
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(Double.valueOf(t0), "", TextAnchor.CENTER,
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 >= firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = createInstance(
                    this.minorTickTimePeriodClass, new Date(t0),
                    getTimeZone(), this.locale);
            long tt0 = tminor.getFirstMillisecond();
            while (tt0 < t.getLastMillisecond()
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tminor.peg(this.calendar);
                tt0 = tminor.getFirstMillisecond();
            }
        }
        t = t.next();
        t.peg(this.calendar);
        t0 = t.getFirstMillisecond();
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}
 
Example 11
Source File: PeriodAxis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or
 * bottom of the plot.
 *
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state,
                                       Rectangle2D dataArea,
                                       RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0 = dataArea.getX();
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = createInstance(this.majorTickTimePeriodClass,
            this.first.getStart(), getTimeZone(), this.locale);
    long t0 = t.getFirstMillisecond();
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond();
    long lastOnAxis = getLast().getLastMillisecond() + 1;
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(new Double(t0), "", TextAnchor.CENTER,
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 >= firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = createInstance(
                    this.minorTickTimePeriodClass, new Date(t0),
                    getTimeZone(), this.locale);
            long tt0 = tminor.getFirstMillisecond();
            while (tt0 < t.getLastMillisecond()
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tminor.peg(this.calendar);
                tt0 = tminor.getFirstMillisecond();
            }
        }
        t = t.next();
        t.peg(this.calendar);
        t0 = t.getFirstMillisecond();
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}
 
Example 12
Source File: PeriodAxis.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or
 * bottom of the plot.
 *
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0;
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = createInstance(this.majorTickTimePeriodClass, 
            this.first.getStart(), getTimeZone(), this.locale);
    long t0 = t.getFirstMillisecond();
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond();
    long lastOnAxis = getLast().getLastMillisecond() + 1;
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(Double.valueOf(t0), "", TextAnchor.CENTER,
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 >= firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = createInstance(
                    this.minorTickTimePeriodClass, new Date(t0),
                    getTimeZone(), this.locale);
            long tt0 = tminor.getFirstMillisecond();
            while (tt0 < t.getLastMillisecond()
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tminor.peg(this.calendar);
                tt0 = tminor.getFirstMillisecond();
            }
        }
        t = t.next();
        t.peg(this.calendar);
        t0 = t.getFirstMillisecond();
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}
 
Example 13
Source File: PeriodAxis.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or 
 * bottom of the plot.
 * 
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state, 
                                       Rectangle2D dataArea, 
                                       RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0 = dataArea.getX();
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = RegularTimePeriod.createInstance(
            this.majorTickTimePeriodClass, this.first.getStart(), 
            getTimeZone());
    long t0 = t.getFirstMillisecond(this.calendar);
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond(this.calendar);
    long lastOnAxis = getLast().getLastMillisecond(this.calendar);
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(new Double(t0), "", TextAnchor.CENTER, 
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);  
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 > firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = RegularTimePeriod.createInstance(
                    this.minorTickTimePeriodClass, new Date(t0), 
                    getTimeZone());
            long tt0 = tminor.getFirstMillisecond(this.calendar);
            while (tt0 < t.getLastMillisecond(this.calendar) 
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0, 
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0, 
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0, 
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0, 
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tt0 = tminor.getFirstMillisecond(this.calendar);
            }
        }            
        t = t.next();
        t0 = t.getFirstMillisecond(this.calendar);
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength, 
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength, 
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}
 
Example 14
Source File: PeriodAxis.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or
 * bottom of the plot.
 *
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0;
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = createInstance(this.majorTickTimePeriodClass, 
            this.first.getStart(), getTimeZone(), this.locale);
    long t0 = t.getFirstMillisecond();
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond();
    long lastOnAxis = getLast().getLastMillisecond() + 1;
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(Double.valueOf(t0), "", TextAnchor.CENTER,
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 >= firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = createInstance(
                    this.minorTickTimePeriodClass, new Date(t0),
                    getTimeZone(), this.locale);
            long tt0 = tminor.getFirstMillisecond();
            while (tt0 < t.getLastMillisecond()
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tminor.peg(this.calendar);
                tt0 = tminor.getFirstMillisecond();
            }
        }
        t = t.next();
        t.peg(this.calendar);
        t0 = t.getFirstMillisecond();
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}
 
Example 15
Source File: PeriodAxis.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or 
 * bottom of the plot.
 * 
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state, 
                                       Rectangle2D dataArea, 
                                       RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0 = dataArea.getX();
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = RegularTimePeriod.createInstance(
            this.majorTickTimePeriodClass, this.first.getStart(), 
            getTimeZone());
    long t0 = t.getFirstMillisecond(this.calendar);
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond(this.calendar);
    long lastOnAxis = getLast().getLastMillisecond(this.calendar);
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(new Double(t0), "", TextAnchor.CENTER, 
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);  
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 > firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = RegularTimePeriod.createInstance(
                    this.minorTickTimePeriodClass, new Date(t0), 
                    getTimeZone());
            long tt0 = tminor.getFirstMillisecond(this.calendar);
            while (tt0 < t.getLastMillisecond(this.calendar) 
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0, 
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0, 
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0, 
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0, 
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tt0 = tminor.getFirstMillisecond(this.calendar);
            }
        }            
        t = t.next();
        t0 = t.getFirstMillisecond(this.calendar);
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength, 
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength, 
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}
 
Example 16
Source File: PeriodAxis.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or
 * bottom of the plot.
 *
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0;
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = createInstance(this.majorTickTimePeriodClass, 
            this.first.getStart(), getTimeZone(), this.locale);
    long t0 = t.getFirstMillisecond();
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond();
    long lastOnAxis = getLast().getLastMillisecond() + 1;
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(Double.valueOf(t0), "", TextAnchor.CENTER,
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 >= firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = createInstance(
                    this.minorTickTimePeriodClass, new Date(t0),
                    getTimeZone(), this.locale);
            long tt0 = tminor.getFirstMillisecond();
            while (tt0 < t.getLastMillisecond()
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tminor.peg(this.calendar);
                tt0 = tminor.getFirstMillisecond();
            }
        }
        t = t.next();
        t.peg(this.calendar);
        t0 = t.getFirstMillisecond();
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}
 
Example 17
Source File: PeriodAxis.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or
 * bottom of the plot.
 *
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0;
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = createInstance(this.majorTickTimePeriodClass, 
            this.first.getStart(), getTimeZone(), this.locale);
    long t0 = t.getFirstMillisecond();
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond();
    long lastOnAxis = getLast().getLastMillisecond() + 1;
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(Double.valueOf(t0), "", TextAnchor.CENTER,
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 >= firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = createInstance(
                    this.minorTickTimePeriodClass, new Date(t0),
                    getTimeZone(), this.locale);
            long tt0 = tminor.getFirstMillisecond();
            while (tt0 < t.getLastMillisecond()
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tminor.peg(this.calendar);
                tt0 = tminor.getFirstMillisecond();
            }
        }
        t = t.next();
        t.peg(this.calendar);
        t0 = t.getFirstMillisecond();
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}
 
Example 18
Source File: PeriodAxis.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the major and minor tick marks for an axis that lies at the top or
 * bottom of the plot.
 *
 * @param g2  the graphics device.
 * @param state  the axis state.
 * @param dataArea  the data area.
 * @param edge  the edge.
 */
protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state,
        Rectangle2D dataArea, RectangleEdge edge) {
    List ticks = new ArrayList();
    double x0;
    double y0 = state.getCursor();
    double insideLength = getTickMarkInsideLength();
    double outsideLength = getTickMarkOutsideLength();
    RegularTimePeriod t = createInstance(this.majorTickTimePeriodClass, 
            this.first.getStart(), getTimeZone(), this.locale);
    long t0 = t.getFirstMillisecond();
    Line2D inside = null;
    Line2D outside = null;
    long firstOnAxis = getFirst().getFirstMillisecond();
    long lastOnAxis = getLast().getLastMillisecond() + 1;
    while (t0 <= lastOnAxis) {
        ticks.add(new NumberTick(Double.valueOf(t0), "", TextAnchor.CENTER,
                TextAnchor.CENTER, 0.0));
        x0 = valueToJava2D(t0, dataArea, edge);
        if (edge == RectangleEdge.TOP) {
            inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
        }
        else if (edge == RectangleEdge.BOTTOM) {
            inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
            outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
        }
        if (t0 >= firstOnAxis) {
            g2.setPaint(getTickMarkPaint());
            g2.setStroke(getTickMarkStroke());
            g2.draw(inside);
            g2.draw(outside);
        }
        // draw minor tick marks
        if (this.minorTickMarksVisible) {
            RegularTimePeriod tminor = createInstance(
                    this.minorTickTimePeriodClass, new Date(t0),
                    getTimeZone(), this.locale);
            long tt0 = tminor.getFirstMillisecond();
            while (tt0 < t.getLastMillisecond()
                    && tt0 < lastOnAxis) {
                double xx0 = valueToJava2D(tt0, dataArea, edge);
                if (edge == RectangleEdge.TOP) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkOutsideLength);
                }
                else if (edge == RectangleEdge.BOTTOM) {
                    inside = new Line2D.Double(xx0, y0, xx0,
                            y0 - this.minorTickMarkInsideLength);
                    outside = new Line2D.Double(xx0, y0, xx0,
                            y0 + this.minorTickMarkOutsideLength);
                }
                if (tt0 >= firstOnAxis) {
                    g2.setPaint(this.minorTickMarkPaint);
                    g2.setStroke(this.minorTickMarkStroke);
                    g2.draw(inside);
                    g2.draw(outside);
                }
                tminor = tminor.next();
                tminor.peg(this.calendar);
                tt0 = tminor.getFirstMillisecond();
            }
        }
        t = t.next();
        t.peg(this.calendar);
        t0 = t.getFirstMillisecond();
    }
    if (edge == RectangleEdge.TOP) {
        state.cursorUp(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    else if (edge == RectangleEdge.BOTTOM) {
        state.cursorDown(Math.max(outsideLength,
                this.minorTickMarkOutsideLength));
    }
    state.setTicks(ticks);
}