/** * Configures the axis to work with the current plot. Override this method * to perform any special processing (such as auto-rescaling). */ @Override public void configure() { if (this.isAutoRange()) { autoAdjustRange(); } }
/** * Rescales the axis to ensure that all data is visible. */ @Override protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { r = getDefaultAutoRange(); } long upper = Math.round(r.getUpperBound()); long lower = Math.round(r.getLowerBound()); this.first = createInstance(this.autoRangeTimePeriodClass, new Date(lower), this.timeZone, this.locale); this.last = createInstance(this.autoRangeTimePeriodClass, new Date(upper), this.timeZone, this.locale); setRange(r, false, false); } }
if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); if (isTickMarksVisible()) { drawTickMarks(g2, axisState, dataArea, edge); if (isTickLabelsVisible()) { for (int band = 0; band < this.labelInfo.length; band++) { axisState = drawTickLabels(band, g2, axisState, dataArea, edge); if (getAttributedLabel() != null) { axisState = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, axisState); } else { axisState = drawLabel(getLabel(), g2, plotArea, dataArea, edge, axisState);
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(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); g2.setPaint(getTickMarkPaint()); g2.setStroke(getTickMarkStroke()); g2.draw(inside); g2.draw(outside); RegularTimePeriod tminor = createInstance( this.minorTickTimePeriodClass, new Date(t0), getTimeZone(), this.locale); long tt0 = tminor.getFirstMillisecond(); while (tt0 < t.getLastMillisecond() && tt0 < lastOnAxis) {
PeriodAxis periodaxis = new PeriodAxis(null); Class timePeriodClass = null; if(dataset instanceof TimeSeriesCollection) { timePeriodClass = org.jfree.data.time.Day.class; periodaxis.setAutoRangeTimePeriodClass(timePeriodClass); aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class, new SimpleDateFormat("yyyy", locale)); periodaxis.setLabelInfo(aperiodaxislabelinfo); periodaxis.setAutoRange(false); if(firstDate != null) { if(StatsManager.CHARTTIMESERIES_MONTH.equals(timePeriod) || StatsManager.CHARTTIMESERIES_YEAR.equals(timePeriod)) { periodaxis.setFirst(new org.jfree.data.time.Month(firstDate)); }else{ periodaxis.setFirst(new org.jfree.data.time.Day(firstDate)); periodaxis.setLast(new org.jfree.data.time.Month(lastDate)); }else{ periodaxis.setLast(new org.jfree.data.time.Day(lastDate)); periodaxis.setTickMarkOutsideLength(0.0F); plot.setDomainAxis(periodaxis);
logger.debug("Level: "+level); PeriodAxis axis = new PeriodAxis(null); axis.setAutoRangeTimePeriodClass(Month.class); axis.setMajorTickTimePeriodClass(Month.class); axis.setAutoRangeTimePeriodClass(TimePeriodFactory.getPeriodClass(ofxDateAxis.getAutoRangeTimePeriod())); axis.setMajorTickTimePeriodClass(TimePeriodFactory.getPeriodClass(ofxDateAxis.getMajorTickTimePeriod())); axis.setLabelInfo(info);
/** * Applies the attributes for this theme to a {@link PeriodAxis}. * * @param axis the axis ({@code null} not permitted). */ protected void applyToPeriodAxis(PeriodAxis axis) { PeriodAxisLabelInfo[] info = axis.getLabelInfo(); for (int i = 0; i < info.length; i++) { PeriodAxisLabelInfo e = info[i]; PeriodAxisLabelInfo n = new PeriodAxisLabelInfo(e.getPeriodClass(), e.getDateFormat(), e.getPadding(), this.regularFont, this.tickLabelPaint, e.getDrawDividers(), e.getDividerStroke(), e.getDividerPaint()); info[i] = n; } axis.setLabelInfo(info); }
/** * Draws the tick marks for the axis. * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the data area. * @param edge the edge. */ protected void drawTickMarks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { if (RectangleEdge.isTopOrBottom(edge)) { drawTickMarksHorizontal(g2, state, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { drawTickMarksVertical(g2, state, dataArea, edge); } }
this.minorTickTimePeriodClass = RegularTimePeriod.downsize( this.majorTickTimePeriodClass); setAutoRange(true); this.labelInfo = new PeriodAxisLabelInfo[2]; this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class,
/** * Sets the range for the axis, if requested, sends an * {@link AxisChangeEvent} to all registered listeners. As a side-effect, * the auto-range flag is set to <code>false</code> (optional). * * @param range the range (<code>null</code> not permitted). * @param turnOffAutoRange a flag that controls whether or not the auto * range is turned off. * @param notify a flag that controls whether or not listeners are * notified. */ public void setRange(Range range, boolean turnOffAutoRange, boolean notify) { long upper = Math.round(range.getUpperBound()); long lower = Math.round(range.getLowerBound()); this.first = createInstance(this.autoRangeTimePeriodClass, new Date(lower), this.timeZone, this.locale); this.last = createInstance(this.autoRangeTimePeriodClass, new Date(upper), this.timeZone, this.locale); super.setRange(new Range(this.first.getFirstMillisecond(), this.last.getLastMillisecond() + 1.0), turnOffAutoRange, notify); }
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); g2.setPaint(getTickMarkPaint()); g2.setStroke(getTickMarkStroke()); g2.draw(inside); g2.draw(outside); RegularTimePeriod tminor = createInstance( this.minorTickTimePeriodClass, new Date(t0), getTimeZone(), this.locale); long tt0 = tminor.getFirstMillisecond(); while (tt0 < t.getLastMillisecond() && tt0 < lastOnAxis) {
/** * Applies the attributes for this theme to a {@link PeriodAxis}. * * @param axis the axis (<code>null</code> not permitted). */ protected void applyToPeriodAxis(PeriodAxis axis) { PeriodAxisLabelInfo[] info = axis.getLabelInfo(); for (int i = 0; i < info.length; i++) { PeriodAxisLabelInfo e = info[i]; PeriodAxisLabelInfo n = new PeriodAxisLabelInfo(e.getPeriodClass(), e.getDateFormat(), e.getPadding(), this.regularFont, this.tickLabelPaint, e.getDrawDividers(), e.getDividerStroke(), e.getDividerPaint()); info[i] = n; } axis.setLabelInfo(info); }
/** * Draws the tick marks for the axis. * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the data area. * @param edge the edge. */ protected void drawTickMarks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { if (RectangleEdge.isTopOrBottom(edge)) { drawTickMarksHorizontal(g2, state, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { drawTickMarksVertical(g2, state, dataArea, edge); } }
this.minorTickTimePeriodClass = RegularTimePeriod.downsize( this.majorTickTimePeriodClass); setAutoRange(true); this.labelInfo = new PeriodAxisLabelInfo[2]; SimpleDateFormat df0 = new SimpleDateFormat("MMM", locale);
/** * Sets the range for the axis, if requested, sends an * {@link AxisChangeEvent} to all registered listeners. As a side-effect, * the auto-range flag is set to {@code false} (optional). * * @param range the range ({@code null} not permitted). * @param turnOffAutoRange a flag that controls whether or not the auto * range is turned off. * @param notify a flag that controls whether or not listeners are * notified. */ @Override public void setRange(Range range, boolean turnOffAutoRange, boolean notify) { long upper = Math.round(range.getUpperBound()); long lower = Math.round(range.getLowerBound()); this.first = createInstance(this.autoRangeTimePeriodClass, new Date(lower), this.timeZone, this.locale); this.last = createInstance(this.autoRangeTimePeriodClass, new Date(upper), this.timeZone, this.locale); super.setRange(new Range(this.first.getFirstMillisecond(), this.last.getLastMillisecond() + 1.0), turnOffAutoRange, notify); }
if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); if (isTickMarksVisible()) { drawTickMarks(g2, axisState, dataArea, edge); if (isTickLabelsVisible()) { for (int band = 0; band < this.labelInfo.length; band++) { axisState = drawTickLabels(band, g2, axisState, dataArea, edge); axisState = drawLabel(getLabel(), g2, plotArea, dataArea, edge, axisState); return axisState;
/** * Rescales the axis to ensure that all data is visible. */ protected void autoAdjustRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; Range r = vap.getDataRange(this); if (r == null) { r = getDefaultAutoRange(); } long upper = Math.round(r.getUpperBound()); long lower = Math.round(r.getLowerBound()); this.first = createInstance(this.autoRangeTimePeriodClass, new Date(lower), this.timeZone, this.locale); this.last = createInstance(this.autoRangeTimePeriodClass, new Date(upper), this.timeZone, this.locale); setRange(r, false, false); } }
/** * Configures the axis to work with the current plot. Override this method * to perform any special processing (such as auto-rescaling). */ public void configure() { if (this.isAutoRange()) { autoAdjustRange(); } }