Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); double xx = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); tickLabel = valueToString(currentTickValue); double tickLabelLength = isVerticalTickLabels() ? bounds.getHeight() : bounds.getWidth(); boolean tickLabelsOverlapping = false; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT;
Plot plot = getPlot(); if (plot == null) { return; // no plot, no data double minRange = getAutoRangeMinimumSize(); if (range < minRange) { upper = (upper + lower + minRange) / 2; double lowerMargin = 0.5; if (getAutoRangeIncludesZero()) { if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = 0.0; if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = Math.min(0.0, upper + upperMargin); setRange(new Range(lower, upper), false, false);
private void setTaskNames() { XYPlot plot = (XYPlot) chart.getPlot(); String[] taskNames = new String[ofxChart.getDataSet().size()]; int i=0; for(DataSet c : ofxChart.getDataSet()) { taskNames[i] = c.getLabel(); i++; } SymbolAxis yAxis = new SymbolAxis(ChartLabelResolver.getAxisLabelY(ofxChart),taskNames); yAxis.setGridBandsVisible(true); plot.setDomainAxis(yAxis); plot.setDomainAxis(yAxis); }
/** * Draws the grid bands (alternate bands are colored using * {@link #getGridBandPaint()} and {@link #getGridBandAlternatePaint()}. * * @param g2 the graphics target ({@code null} not permitted). * @param plotArea the area within which the plot is drawn * ({@code null} not permitted). * @param dataArea the data area to which the axes are aligned * ({@code null} not permitted). * @param edge the edge to which the axis is aligned ({@code null} not * permitted). * @param ticks the ticks ({@code null} not permitted). */ protected void drawGridBands(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, List ticks) { Shape savedClip = g2.getClip(); g2.clip(dataArea); if (RectangleEdge.isTopOrBottom(edge)) { drawGridBandsHorizontal(g2, plotArea, dataArea, true, ticks); } else if (RectangleEdge.isLeftOrRight(edge)) { drawGridBandsVertical(g2, plotArea, dataArea, true, ticks); } g2.setClip(savedClip); }
/** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device ({@code null} not permitted). * @param cursor the cursor location. * @param plotArea the area within which the plot and axes should be drawn * ({@code null} not permitted). * @param dataArea the area within which the data should be drawn * ({@code null} not permitted). * @param edge the axis location ({@code null} not permitted). * @param plotState collects information about the plot * ({@code null} permitted). * * @return The axis state (never {@code null}). */ @Override public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState info = new AxisState(cursor); if (isVisible()) { info = super.draw(g2, cursor, plotArea, dataArea, edge, plotState); } if (this.gridBandsVisible) { drawGridBands(g2, plotArea, dataArea, edge, info.getTicks()); } return info; }
public static JFreeChart chartSchedule(Collection<? extends Vehicle> vehicles, DescriptionCreator descriptionCreator, PaintSelector paintSelector) { // data TaskSeriesCollection dataset = createScheduleDataset(vehicles, descriptionCreator); XYTaskDataset xyTaskDataset = new XYTaskDataset(dataset); // chart JFreeChart chart = ChartFactory.createXYBarChart("Schedules", "Time", false, "Vehicles", xyTaskDataset, PlotOrientation.HORIZONTAL, false, true, false); XYPlot plot = (XYPlot)chart.getPlot(); // Y axis String[] series = new String[vehicles.size()]; int i = 0; for (Vehicle v : vehicles) { series[i++] = v.getId().toString(); } SymbolAxis symbolAxis = new SymbolAxis("Vehicles", series); symbolAxis.setGridBandsVisible(false); plot.setDomainAxis(symbolAxis); // X axis plot.setRangeAxis(new DateAxis("Time", TimeZone.getTimeZone("GMT"), Locale.getDefault())); // Renderer XYBarRenderer xyBarRenderer = new ChartTaskRenderer(dataset, paintSelector); xyBarRenderer.setUseYInterval(true); plot.setRenderer(xyBarRenderer); return chart; }
/** * Draws the grid bands. Alternate bands are colored using * <CODE>gridBandPaint<CODE> (<CODE>DEFAULT_GRID_BAND_PAINT</CODE> by * default). * * @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 edge the axis location. * @param ticks the ticks. */ protected void drawGridBands(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, List ticks) { Shape savedClip = g2.getClip(); g2.clip(dataArea); if (RectangleEdge.isTopOrBottom(edge)) { drawGridBandsHorizontal(g2, plotArea, dataArea, true, ticks); } else if (RectangleEdge.isLeftOrRight(edge)) { drawGridBandsVertical(g2, plotArea, dataArea, true, ticks); } g2.setClip(savedClip); }
if (isVisible()) { info = super.draw(g2, cursor, plotArea, dataArea, edge, plotState); drawGridBands(g2, plotArea, dataArea, edge, info.getTicks());
Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); double yy = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); tickLabel = valueToString(currentTickValue); double tickLabelLength = isVerticalTickLabels() ? bounds.getWidth() : bounds.getHeight(); boolean tickLabelsOverlapping = false; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER;
Plot plot = getPlot(); if (plot == null) { return; // no plot, no data double minRange = getAutoRangeMinimumSize(); if (range < minRange) { upper = (upper + lower + minRange) / 2; double lowerMargin = 0.5; if (getAutoRangeIncludesZero()) { if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = 0.0; if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = Math.min(0.0, upper + upperMargin); setRange(new Range(lower, upper), false, false);
Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); double xx = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); tickLabel = valueToString(currentTickValue); double tickLabelLength = isVerticalTickLabels() ? bounds.getHeight() : bounds.getWidth(); boolean tickLabelsOverlapping = false; TextAnchor rotationAnchor; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT;
Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); double yy = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); tickLabel = valueToString(currentTickValue); double tickLabelLength = isVerticalTickLabels() ? bounds.getWidth() : bounds.getHeight(); boolean tickLabelsOverlapping = false; TextAnchor rotationAnchor; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER;