List of usage examples for org.jfree.ui RectangleAnchor TOP_LEFT
RectangleAnchor TOP_LEFT
To view the source code for org.jfree.ui RectangleAnchor TOP_LEFT.
Click Source Link
From source file:lu.lippmann.cdb.ext.hydviga.ui.GapsUIUtil.java
public static ChartPanel buildGapChartPanel(final Instances dataSet, final int dateIdx, final Attribute attr, final int gapsize, final int position) throws Exception { Instances filteredDs = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(dataSet, new int[] { attr.index(), dateIdx }); filteredDs = WekaDataProcessingUtil.buildFilteredDataSet(filteredDs, 0, filteredDs.numAttributes() - 1, Math.max(0, position - GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize), Math.min(position + gapsize + GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize, filteredDs.numInstances() - 1)); final ChartPanel cp = TimeSeriesChartUtil.buildChartPanelForAllAttributes(filteredDs, false, WekaDataStatsUtil.getFirstDateAttributeIdx(filteredDs), null); final XYPlot xyp = (XYPlot) cp.getChart().getPlot(); xyp.getDomainAxis().setLabel(""); xyp.getRangeAxis().setLabel(""); final Marker gapBeginMarker = new ValueMarker(dataSet.instance(Math.max(0, position - 1)).value(dateIdx)); gapBeginMarker.setPaint(Color.RED); gapBeginMarker.setLabel("Gap begin"); gapBeginMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); gapBeginMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); cp.getChart().getXYPlot().addDomainMarker(gapBeginMarker); final Marker gapEndMarker = new ValueMarker( dataSet.instance(Math.min(dataSet.numInstances() - 1, position + gapsize)).value(dateIdx)); gapEndMarker.setPaint(Color.RED); gapEndMarker.setLabel("Gap end"); gapEndMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); gapEndMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); cp.getChart().getXYPlot().addDomainMarker(gapEndMarker); addExportPopupMenu(filteredDs, cp);/*from w w w . j a v a 2s . com*/ return cp; }
From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java
/** * Generate a {@link ValueMarker}.// ww w.j ava 2s .c o m */ private static ValueMarker addValueMarker(String text, double x, boolean domain) { ValueMarker marker = new ValueMarker(x); marker.setPaint(Color.GRAY); marker.setLabel(text); if (domain) { marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } else { marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } return marker; }
From source file:org.jfree.chart.demo.MarkerDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Marker Demo 2", "X", "Temperature", xydataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainGridlineStroke(new BasicStroke(1.0F)); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeGridlineStroke(new BasicStroke(1.0F)); xyplot.setRangeTickBandPaint(new Color(240, 240, 240)); PeriodAxis periodaxis = new PeriodAxis(null, new Hour(0, 30, 6, 2005), new Hour(23, 30, 6, 2005)); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Hour.class, new SimpleDateFormat("HH")); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("dd-MMM")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis);/*from w w w . j a v a 2 s. c o m*/ ValueAxis valueaxis = xyplot.getRangeAxis(); valueaxis.setRange(0.0D, 100D); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.green); xyitemrenderer.setSeriesStroke(0, new BasicStroke(2.0F)); ValueMarker valuemarker = new ValueMarker(80D); valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); valuemarker.setPaint(Color.red); valuemarker.setStroke(new BasicStroke(2.0F)); valuemarker.setLabel("Temperature Threshold"); valuemarker.setLabelFont(new Font("SansSerif", 0, 11)); valuemarker.setLabelPaint(Color.red); valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); xyplot.addRangeMarker(valuemarker); Hour hour = new Hour(18, 30, 6, 2005); Hour hour1 = new Hour(20, 30, 6, 2005); double d = hour.getFirstMillisecond(); double d1 = hour1.getFirstMillisecond(); IntervalMarker intervalmarker = new IntervalMarker(d, d1); intervalmarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); intervalmarker.setPaint(new Color(150, 150, 255)); intervalmarker.setLabel("Automatic Cooling"); intervalmarker.setLabelFont(new Font("SansSerif", 0, 11)); intervalmarker.setLabelPaint(Color.blue); intervalmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); intervalmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); xyplot.addDomainMarker(intervalmarker, Layer.BACKGROUND); ValueMarker valuemarker1 = new ValueMarker(d, Color.blue, new BasicStroke(2.0F)); ValueMarker valuemarker2 = new ValueMarker(d1, Color.blue, new BasicStroke(2.0F)); xyplot.addDomainMarker(valuemarker1, Layer.BACKGROUND); xyplot.addDomainMarker(valuemarker2, Layer.BACKGROUND); return jfreechart; }
From source file:spec.reporter.Utils.java
public static void createBmResultGraph(BenchmarkRecord record) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String iterName = ""; double max = 0; double min = Long.MAX_VALUE; for (int i = 0; i < record.iterRecords.size(); i++) { BenchmarkRecord.IterationRecord iterRecord = (BenchmarkRecord.IterationRecord) record.iterRecords .get(i);//from w w w.j av a2 s . c om String shortName = iterRecord.iterName.replaceFirst("ation", ""); if (iterRecord.score > max) { max = iterRecord.score; iterName = shortName; } if (iterRecord.score < min) { min = iterRecord.score; } dataset.addValue(iterRecord.score, " ", shortName); } JFreeChart chart = ChartFactory.createLineChart(" ", "iterations", Constants.WORKLOAD_METRIC, dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(201, 222, 254)); plot.setRangeGridlinePaint(Color.WHITE); if (record.isValidRun() && min != Long.MAX_VALUE) { plot.getRangeAxis().setRange(min - 10, max + 10); } else { plot.getRangeAxis().setRange(0, max + 10); } ValueMarker vm = new ValueMarker(record.maxScore); vm.setLabel(Utils.df.format(record.maxScore)); vm.setLabelAnchor(RectangleAnchor.TOP_LEFT); vm.setLabelTextAnchor(TextAnchor.HALF_ASCENT_LEFT); plot.addRangeMarker(vm); CategoryMarker marker = new CategoryMarker(iterName); marker.setDrawAsLine(true); marker.setPaint(vm.getPaint()); plot.addDomainMarker(marker); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setFillPaint(Color.WHITE); renderer.setSeriesPaint(0, Color.BLUE.darker()); try { ChartUtilities.saveChartAsJPEG(new File(Utils.getFullImageName(record.name + "_results")), chart, 300, 200); } catch (Exception e) { System.out.println("Problems..."); } }
From source file:org.geopublishing.atlasStyler.classification.RasterClassification.java
@Override public BufferedImage createHistogramImage(boolean showMean, boolean showSd, int histogramBins, String label_xachsis) throws InterruptedException, IOException { HistogramDataset hds = new HistogramDataset(); DoubleArrayList valuesAL;/* w w w . j a v a2 s .c o m*/ valuesAL = getStatistics().elements(); double[] elements = Arrays.copyOf(valuesAL.elements(), getStatistics().size()); hds.addSeries(1, elements, histogramBins); /** Statically label the Y Axis **/ String label_yachsis = ASUtil.R("QuantitiesClassificationGUI.Histogram.YAxisLabel"); JFreeChart chart = org.jfree.chart.ChartFactory.createHistogram(null, label_xachsis, label_yachsis, hds, PlotOrientation.VERTICAL, false, true, true); /*********************************************************************** * Paint the classes into the JFreeChart */ int countLimits = 0; for (Double cLimit : getClassLimits()) { ValueMarker marker = new ValueMarker(cLimit); XYPlot plot = chart.getXYPlot(); marker.setPaint(Color.orange); marker.setLabel(String.valueOf(countLimits)); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(marker); countLimits++; } /*********************************************************************** * Optionally painting SD and MEAN into the histogram */ try { if (showSd) { ValueMarker marker; marker = new ValueMarker(getSD(), Color.green.brighter(), new BasicStroke(1.5f)); XYPlot plot = chart.getXYPlot(); marker.setLabel(ASUtil.R("QuantitiesClassificationGUI.Histogram.SD.ShortLabel")); marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); plot.addDomainMarker(marker); } if (showMean) { ValueMarker marker; marker = new ValueMarker(getMean(), Color.green.darker(), new BasicStroke(1.5f)); XYPlot plot = chart.getXYPlot(); marker.setLabel(ASUtil.R("QuantitiesClassificationGUI.Histogram.Mean.ShortLabel")); marker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); plot.addDomainMarker(marker); } } catch (Exception e) { LOGGER.error("Painting SD and MEAN into the histogram", e); } /*********************************************************************** * Render the Chart */ BufferedImage image = chart.createBufferedImage(400, 200); return image; }
From source file:scheduler.benchmarker.manager.CreateStackedBarChart3D.java
public ChartPanel createChartPanel() { JFreeChart jfreechart = ChartFactory.createStackedBarChart3D(title, "Category", "Value", createDataset(), PlotOrientation.HORIZONTAL, true, true, false); jfreechart.setBackgroundPaint(new Color(214, 217, 223)); CustomBarRenderer cRenderer = new CustomBarRenderer(pluginColors); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); ValueMarker marker = new ValueMarker(dataSource.getSumTotalTime()); marker.setLabel("CLASSIFICATION FINISH"); marker.setPaint(Color.RED);//from w w w . j a v a 2 s.c om marker.setLabelPaint(Color.RED); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); marker.setLabelOffsetType(LengthAdjustmentType.EXPAND); marker.setLabelFont(new Font(Font.SERIF, Font.BOLD, 12)); categoryplot.addRangeMarker(marker, Layer.FOREGROUND); categoryplot.setFixedLegendItems(createCustomLegend()); categoryplot.setRenderer(cRenderer); cPanel = new ChartPanel(jfreechart, true); return cPanel; }
From source file:lu.lippmann.cdb.weka.SilhouetteUtil.java
/** * //from w w w. j a va 2 s. co m * @param sils * @return */ public static JPanel buildSilhouettePanel(final Instances ds, final WekaClusteringResult result) { final Map<Integer, List<Double>> sils = computeSilhouette(ds, result); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createBarChart("Silhouette", "Category", "Value", dataset, PlotOrientation.HORIZONTAL, true, true, false); int nbClass = sils.keySet().size(); int id = 0; double minValue = 0; int counter[][] = new int[nbClass][4]; for (int i = 0; i < nbClass; i++) { final double[] tree = ArrayUtils.toPrimitive(sils.get(i).toArray(new Double[0])); for (double val : tree) { if (val > 0.75) { dataset.addValue(val, "Cluster " + i + " ++", "" + id); counter[i][0]++; } else if (val > 0.50) { dataset.addValue(val, "Cluster " + i + " +", "" + id); counter[i][1]++; } else if (val > 0.25) { dataset.addValue(val, "Cluster " + i + " =", "" + id); counter[i][2]++; } else { dataset.addValue(val, "Cluster " + i + " -", "" + id); counter[i][3]++; } if (val < minValue) { minValue = val; } id++; } } final CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); categoryplot.setBackgroundPaint(Color.WHITE); categoryplot.getDomainAxis().setVisible(false); categoryplot.setDomainGridlinesVisible(false); categoryplot.setRangeGridlinesVisible(false); categoryplot.getRangeAxis().setRange(minValue, 1.0); //Add line markers ValueMarker target = new ValueMarker(0.75); target.setPaint(Color.BLACK); target.setLabel(" ++"); target.setLabelAnchor(RectangleAnchor.TOP_LEFT); target.setLabelTextAnchor(TextAnchor.TOP_LEFT); categoryplot.addRangeMarker(target); target = new ValueMarker(0.5); target.setPaint(Color.BLACK); target.setLabel(" +"); target.setLabelAnchor(RectangleAnchor.TOP_LEFT); target.setLabelTextAnchor(TextAnchor.TOP_LEFT); categoryplot.addRangeMarker(target); target = new ValueMarker(0.25); target.setPaint(Color.BLACK); target.setLabel(" ="); target.setLabelAnchor(RectangleAnchor.TOP_LEFT); target.setLabelTextAnchor(TextAnchor.TOP_LEFT); categoryplot.addRangeMarker(target); target = new ValueMarker(0); target.setPaint(Color.BLACK); target.setLabel(" -"); target.setLabelAnchor(RectangleAnchor.TOP_LEFT); target.setLabelTextAnchor(TextAnchor.TOP_LEFT); categoryplot.addRangeMarker(target); //Remove visual effects on bar final BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setBarPainter(new StandardBarPainter()); //set bar colors int p = 0; final int max = ColorHelper.COLORBREWER_SEQUENTIAL_PALETTES.size(); for (int i = 0; i < nbClass; i++) { final Color[] color = new ArrayList<Color[]>(ColorHelper.COLORBREWER_SEQUENTIAL_PALETTES.values()) .get((max - i) % max); final int nbColors = color.length; for (int k = 0; k < counter[i].length; k++) { if (counter[i][k] > 0) barrenderer.setSeriesPaint(p++, color[(nbColors - k - 3) % nbColors]); } } //remove blank line between bars barrenderer.setItemMargin(-dataset.getRowCount()); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(new Dimension(1200, 900)); chartPanel.setBorder(new TitledBorder("Silhouette plot")); chartPanel.setBackground(Color.WHITE); chart.setTitle(""); return chartPanel; }
From source file:grafix.graficos.eixos.Eixo.java
private void incluirLegenda(final XYPlot plot) { if (isLegenda()) { LegendTitle lt = new LegendTitle(plot); lt.setItemFont(new Font("Dialog", Font.PLAIN, 11)); lt.setBackgroundPaint(new Color(255, 255, 255, 100)); lt.setBorder(new BlockBorder(new Color(180, 180, 180))); lt.setPosition(RectangleEdge.TOP); XYTitleAnnotation ta = new XYTitleAnnotation(0.01, 0.98, lt, RectangleAnchor.TOP_LEFT); ta.setMaxWidth(0.48);//from w w w. j a v a2 s. c o m plot.addAnnotation(ta); } }
From source file:org.jfree.chart.demo.MarkerDemo1.java
/** * Creates a sample chart./*from w w w . ja va2s .c o m*/ * * @param data the sample data. * * @return A configured chart. */ private JFreeChart createChart(final XYDataset data) { final JFreeChart chart = ChartFactory.createScatterPlot("Marker Demo 1", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); // chart.getLegend().setAnchor(Legend.EAST); // customise... final XYPlot plot = chart.getXYPlot(); plot.getRenderer().setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); // set axis margins to allow space for marker labels... final DateAxis domainAxis = new DateAxis("Time"); domainAxis.setUpperMargin(0.50); plot.setDomainAxis(domainAxis); final ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setUpperMargin(0.30); rangeAxis.setLowerMargin(0.50); // add a labelled marker for the bid start price... final Marker start = new ValueMarker(200.0); start.setPaint(Color.green); start.setLabel("Bid Start Price"); start.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); start.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addRangeMarker(start); // add a labelled marker for the target price... final Marker target = new ValueMarker(175.0); target.setPaint(Color.red); target.setLabel("Target Price"); target.setLabelAnchor(RectangleAnchor.TOP_RIGHT); target.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); plot.addRangeMarker(target); // add a labelled marker for the original closing time... final Hour hour = new Hour(2, new Day(22, 5, 2003)); double millis = hour.getFirstMillisecond(); final Marker originalEnd = new ValueMarker(millis); originalEnd.setPaint(Color.orange); originalEnd.setLabel("Original Close (02:00)"); originalEnd.setLabelAnchor(RectangleAnchor.TOP_LEFT); originalEnd.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(originalEnd); // add a labelled marker for the current closing time... final Minute min = new Minute(15, hour); millis = min.getFirstMillisecond(); final Marker currentEnd = new ValueMarker(millis); currentEnd.setPaint(Color.red); currentEnd.setLabel("Close Date (02:15)"); currentEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT); currentEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT); plot.addDomainMarker(currentEnd); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // label the best bid with an arrow and label... final Hour h = new Hour(2, new Day(22, 5, 2003)); final Minute m = new Minute(10, h); millis = m.getFirstMillisecond(); final CircleDrawer cd = new CircleDrawer(Color.red, new BasicStroke(1.0f), null); final XYAnnotation bestBid = new XYDrawableAnnotation(millis, 163.0, 11, 11, cd); plot.addAnnotation(bestBid); final XYPointerAnnotation pointer = new XYPointerAnnotation("Best Bid", millis, 163.0, 3.0 * Math.PI / 4.0); pointer.setBaseRadius(35.0); pointer.setTipRadius(10.0); pointer.setFont(new Font("SansSerif", Font.PLAIN, 9)); pointer.setPaint(Color.blue); pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT); plot.addAnnotation(pointer); return chart; }
From source file:lu.lippmann.cdb.ext.hydviga.ui.GapsUIUtil.java
public static ChartPanel buildGapChartPanelWithCorrection(final Instances pdataSet, final int dateIdx, final Attribute attr, final int gapsize, final int position, final GapFiller gapFiller, final java.util.Collection<String> attrs) throws Exception { final Instances dataSetWithTheGap = new Instances(pdataSet); for (int i = position; i < position + gapsize; i++) dataSetWithTheGap.instance(i).setMissing(attr); int[] arr = new int[] { attr.index(), dateIdx }; for (final String sss : attrs) { arr = ArraysUtil.concat(arr, new int[] { dataSetWithTheGap.attribute(sss).index() }); }//from w w w . j av a 2s . co m Instances filteredDsWithTheGap = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(dataSetWithTheGap, arr); filteredDsWithTheGap = WekaDataProcessingUtil.buildFilteredDataSet(filteredDsWithTheGap, 0, filteredDsWithTheGap.numAttributes() - 1, Math.max(0, position - GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize), Math.min(position + gapsize + GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize, filteredDsWithTheGap.numInstances() - 1)); final Instances completedds = gapFiller.fillGaps(filteredDsWithTheGap); final Instances diff = WekaTimeSeriesUtil.buildDiff(filteredDsWithTheGap, completedds); Instances filteredDsWithoutTheGap = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(pdataSet, arr); filteredDsWithoutTheGap = WekaDataProcessingUtil.buildFilteredDataSet(filteredDsWithoutTheGap, 0, filteredDsWithoutTheGap.numAttributes() - 1, Math.max(0, position - GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize), Math.min(position + gapsize + GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize, filteredDsWithoutTheGap.numInstances() - 1)); diff.insertAttributeAt(new Attribute(attr.name() + "_orig"), diff.numAttributes()); for (int i = 0; i < filteredDsWithoutTheGap.numInstances(); i++) { diff.instance(i).setValue(diff.numAttributes() - 1, filteredDsWithoutTheGap.instance(i).value(filteredDsWithoutTheGap.attribute(attr.name()))); } //System.out.println(attr.name()+"\n"+diff.toSummaryString()); final java.util.List<String> toRemove = new java.util.ArrayList<String>(); for (int j = 0; j < diff.numAttributes(); j++) { final String consideredAttrName = diff.attribute(j).name(); if (!consideredAttrName.contains("timestamp") && !consideredAttrName.contains(attr.name())) toRemove.add(consideredAttrName); } diff.setClassIndex(-1); for (final String ssss : toRemove) diff.deleteAttributeAt(diff.attribute(ssss).index()); //System.out.println(attr.name()+"\n"+diff.toSummaryString()); final ChartPanel cp = TimeSeriesChartUtil.buildChartPanelForAllAttributes(diff, false, WekaDataStatsUtil.getFirstDateAttributeIdx(diff), null); final XYPlot xyp = (XYPlot) cp.getChart().getPlot(); xyp.getDomainAxis().setLabel(""); xyp.getRangeAxis().setLabel(""); final Marker gapBeginMarker = new ValueMarker( dataSetWithTheGap.instance(Math.max(0, position - 1)).value(dateIdx)); gapBeginMarker.setPaint(Color.RED); gapBeginMarker.setLabel("Gap begin"); gapBeginMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); gapBeginMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); cp.getChart().getXYPlot().addDomainMarker(gapBeginMarker); final Marker gapEndMarker = new ValueMarker(dataSetWithTheGap .instance(Math.min(dataSetWithTheGap.numInstances() - 1, position + gapsize)).value(dateIdx)); gapEndMarker.setPaint(Color.RED); gapEndMarker.setLabel("Gap end"); gapEndMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); gapEndMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); cp.getChart().getXYPlot().addDomainMarker(gapEndMarker); addExportPopupMenu(diff, cp); return cp; }