@Override public AbstractXYItemRenderer getItemRenderer(boolean nominal, int size, double minColor, double maxColor) { XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(new BlockPaintScale(minColor, maxColor)); renderer.setBlockAnchor(RectangleAnchor.CENTER); // if Block dimension is increased (e.g 1.2x1.2), the grid effect gets bigger // so it could be that blocks are overlapping a little // but if Block dimension is decreased (e.g. 0.9x0.9), each rectangle seems to have // a less-transparent border (you have to zoom-in to notice), and that could be the cause of // the grid effect. // renderer.setBlockHeight(1.0); // renderer.setBlockWidth(1.0); return renderer; }
/** * Resets the display. */ @Override void resetUI() { super.resetUI(); XYPlot xyPlot = mChart.getXYPlot(); AbstractXYItemRenderer br = new XYBarRenderer(); mDatasetsSyncHist = new TimePeriodValues[NUM_AUTHS+1]; @SuppressWarnings("unchecked") Map<SimpleTimePeriod, Integer> mTimePeriodMapTmp[] = new HashMap[NUM_AUTHS + 1]; mTimePeriodMap = mTimePeriodMapTmp; TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection(); xyPlot.setDataset(tpvc); xyPlot.setRenderer(br); for (int i = 0; i < NUM_AUTHS + 1; i++) { br.setSeriesPaint(i, AUTH_COLORS[i]); mDatasetsSyncHist[i] = new TimePeriodValues(AUTH_NAMES[i]); tpvc.addSeries(mDatasetsSyncHist[i]); mTimePeriodMap[i] = new HashMap<SimpleTimePeriod, Integer>(); } }
private TimeSeriesCollection buildDataSet(SortedMap<DataSetBarDescr, SortedMap<Date,Double>> series, AbstractXYItemRenderer renderer) { TimeSeriesCollection dataset = new TimeSeriesCollection(); int seriesIdx = 0; for (DataSetBarDescr serieDef : series.keySet()) { TimeSeries timeSerie = new TimeSeries(serieDef.getSerieName()); SortedMap<Date, Double> serie = series.get(serieDef); for (Date date : serie.keySet()) { RegularTimePeriod period = new Day(date); Number value = serie.get(date); TimeSeriesDataItem item = new TimeSeriesDataItem(period, value); timeSerie.add(item, false); } dataset.addSeries(timeSerie); renderer.setSeriesPaint(seriesIdx, serieDef.getSerieColor()); renderer.setSeriesFillPaint(seriesIdx, serieDef.getSerieColor()); renderer.setSeriesStroke(seriesIdx, new BasicStroke(serieDef.getSerieStrokeSize())); seriesIdx++; } return dataset; }
/** * Some checks for the findDomainBounds() method. */ public void testFindDomainBounds() { AbstractXYItemRenderer renderer = new StandardXYItemRenderer(); // check the bounds of a simple dataset XYDataset dataset = createDataset1(); Range r = renderer.findDomainBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(3.0, r.getUpperBound(), EPSILON); // check that a null dataset returns null bounds assertTrue(renderer.findDomainBounds(null) == null); }
/** * Draws a base line across the chart at value zero on the domain axis. * * @param g2 the graphics device. * @param area the data area. * * @see #setDomainZeroBaselineVisible(boolean) * * @since 1.0.5 */ protected void drawZeroDomainBaseline(Graphics2D g2, Rectangle2D area) { if (isDomainZeroBaselineVisible()) { XYItemRenderer r = getRenderer(); // FIXME: the renderer interface doesn't have the drawDomainLine() // method, so we have to rely on the renderer being a subclass of // AbstractXYItemRenderer (which is lame) if (r instanceof AbstractXYItemRenderer) { AbstractXYItemRenderer renderer = (AbstractXYItemRenderer) r; renderer.drawDomainLine(g2, this, getDomainAxis(), area, 0.0, this.domainZeroBaselinePaint, this.domainZeroBaselineStroke); } } }
/** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the data area. * @param ticks the ticks. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // no renderer, no gridlines... if (getRenderer() == null) { return; } // draw the domain grid lines, if any... if (isDomainGridlinesVisible() || isDomainMinorGridlinesVisible()) { Stroke gridStroke = null; Paint gridPaint = null; Iterator iterator = ticks.iterator(); boolean paintLine; while (iterator.hasNext()) { paintLine = false; ValueTick tick = (ValueTick) iterator.next(); if ((tick.getTickType() == TickType.MINOR) && isDomainMinorGridlinesVisible()) { gridStroke = getDomainMinorGridlineStroke(); gridPaint = getDomainMinorGridlinePaint(); paintLine = true; } else if ((tick.getTickType() == TickType.MAJOR) && isDomainGridlinesVisible()) { gridStroke = getDomainGridlineStroke(); gridPaint = getDomainGridlinePaint(); paintLine = true; } XYItemRenderer r = getRenderer(); if ((r instanceof AbstractXYItemRenderer) && paintLine) { ((AbstractXYItemRenderer) r).drawDomainLine(g2, this, getDomainAxis(), dataArea, tick.getValue(), gridPaint, gridStroke); } } } }
/** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the data area. * @param ticks the ticks. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // no renderer, no gridlines... if (getRenderer() == null) { return; } // draw the domain grid lines, if any... if (isDomainGridlinesVisible() || isDomainMinorGridlinesVisible()) { Stroke gridStroke = null; Paint gridPaint = null; Iterator iterator = ticks.iterator(); boolean paintLine = false; while (iterator.hasNext()) { paintLine = false; ValueTick tick = (ValueTick) iterator.next(); if ((tick.getTickType() == TickType.MINOR) && isDomainMinorGridlinesVisible()){ gridStroke = getDomainMinorGridlineStroke(); gridPaint = getDomainMinorGridlinePaint(); paintLine = true; } else if ((tick.getTickType() == TickType.MAJOR) && isDomainGridlinesVisible()){ gridStroke = getDomainGridlineStroke(); gridPaint = getDomainGridlinePaint(); paintLine = true; } XYItemRenderer r = getRenderer(); if ((r instanceof AbstractXYItemRenderer) && paintLine) { ((AbstractXYItemRenderer) r).drawDomainLine(g2, this, getDomainAxis(), dataArea, tick.getValue(), gridPaint, gridStroke); } } } }
protected void resetRenderer(final IScope scope, final String serieid) { final AbstractXYItemRenderer newr = (AbstractXYItemRenderer) this.getOrCreateRenderer(scope, serieid); // newr.setSeriesStroke(0, new BasicStroke(0)); newr.setBaseCreateEntities(true); final ChartDataSeries myserie = this.getChartdataset().getDataSeries(scope, serieid); if (newr instanceof XYLineAndShapeRenderer) { ((XYLineAndShapeRenderer) newr).setSeriesLinesVisible(0, myserie.getMysource().showLine); ((XYLineAndShapeRenderer) newr).setSeriesShapesFilled(0, myserie.getMysource().fillMarker); ((XYLineAndShapeRenderer) newr).setSeriesShapesVisible(0, myserie.getMysource().useMarker); } if (newr instanceof XYShapeRenderer) { if (!myserie.getMysource().fillMarker) { ((XYShapeRenderer) newr).setUseFillPaint(false); // ((XYShapeRenderer) newr).setDrawOutlines(true); } } if (myserie.getMycolor() != null) { newr.setSeriesPaint(0, myserie.getMycolor()); } newr.setSeriesStroke(0, new BasicStroke((float) myserie.getLineThickness())); if (newr instanceof myXYErrorRenderer) { ((myXYErrorRenderer) newr).setDrawYError(false); ((myXYErrorRenderer) newr).setDrawXError(false); if (myserie.isUseYErrValues()) ((myXYErrorRenderer) newr).setDrawYError(true); if (myserie.isUseXErrValues()) ((myXYErrorRenderer) newr).setDrawXError(true); if (myserie.getMysource().isUseSize()) ((myXYErrorRenderer) newr).setUseSize(scope, true); } if (myserie.getMysource().getUniqueMarkerName() != null) setSerieMarkerShape(scope, myserie.getName(), myserie.getMysource().getUniqueMarkerName()); }
@Override public void setUseSize(final IScope scope, final String name, final boolean b) { // TODO Auto-generated method stub final AbstractXYItemRenderer newr = (AbstractXYItemRenderer) this.getOrCreateRenderer(scope, name); if (newr instanceof myXYErrorRenderer) { ((myXYErrorRenderer) newr).setUseSize(scope, b); } }
/** * Draws the gridlines for the plot, if they are visible. * * @param g2 the graphics device. * @param dataArea the data area. * @param ticks the ticks. * * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) */ protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) { // no renderer, no gridlines... if (getRenderer() == null) { return; } // draw the domain grid lines, if any... if (isDomainGridlinesVisible() || isDomainMinorGridlinesVisible()) { Stroke gridStroke = null; Paint gridPaint = null; Iterator iterator = ticks.iterator(); boolean paintLine = false; while (iterator.hasNext()) { paintLine = false; ValueTick tick = (ValueTick) iterator.next(); if ((tick.getTickType() == TickType.MINOR) && isDomainMinorGridlinesVisible()) { gridStroke = getDomainMinorGridlineStroke(); gridPaint = getDomainMinorGridlinePaint(); paintLine = true; } else if ((tick.getTickType() == TickType.MAJOR) && isDomainGridlinesVisible()) { gridStroke = getDomainGridlineStroke(); gridPaint = getDomainGridlinePaint(); paintLine = true; } XYItemRenderer r = getRenderer(); if ((r instanceof AbstractXYItemRenderer) && paintLine) { ((AbstractXYItemRenderer) r).drawDomainLine(g2, this, getDomainAxis(), dataArea, tick.getValue(), gridPaint, gridStroke); } } } }
@Override protected void drawZeroDomainBaseline(Graphics2D g2, Rectangle2D area) { if (isDomainZeroBaselineVisible()) { XYItemRenderer r = getRenderer(); if (r instanceof AbstractXYItemRenderer) { AbstractXYItemRenderer renderer = (AbstractXYItemRenderer) r; renderer.drawDomainLine(g2, this, getDomainAxis(), area, 0.0, getDomainZeroBaselinePaint(), getDomainZeroBaselineStroke()); } } }
@Override public AbstractXYItemRenderer getItemRenderer(boolean nominal, int size, double minColor, double maxColor) { XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(new BlockPaintScale(minColor, maxColor)); renderer.setBlockAnchor(RectangleAnchor.CENTER); // if Block dimension is increased (e.g 1.2x1.2), the grid effect gets bigger // so it could be that blocks are overlapping a little // but if Block dimension is decreased (e.g. 0.9x0.9), each rectangle seems to have // a less-transparent border (you have to zoom-in to notice), and that could be the cause of the grid effect. //renderer.setBlockHeight(1.0); //renderer.setBlockWidth(1.0); return renderer; }
/** Subclasses have to implement this method. */ public abstract AbstractXYItemRenderer getItemRenderer(boolean nominal, int size, double minColor, double maxColor);