List of usage examples for org.jfree.ui TextAnchor TOP_RIGHT
TextAnchor TOP_RIGHT
To view the source code for org.jfree.ui TextAnchor TOP_RIGHT.
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 va 2s . c om return cp; }
From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java
/** * Generate a {@link ValueMarker}.//from www. j av a 2s . c om */ 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.CategoryMarkerDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 1", "Category", "Count", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setSeriesShapesVisible(0, true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); CategoryMarker categorymarker = new CategoryMarker("Category 4", Color.blue, new BasicStroke(1.0F)); categorymarker.setDrawAsLine(true);//w w w.ja v a2 s .co m categorymarker.setLabel("Marker Label"); categorymarker.setLabelFont(new Font("Dialog", 0, 11)); categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D)); categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND); return jfreechart; }
From source file:org.jfree.chart.demo.CategoryMarkerDemo2.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 2", "Category", "Count", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setSeriesShapesVisible(0, true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); CategoryMarker categorymarker = new CategoryMarker("Category 4", new Color(0, 0, 255, 25), new BasicStroke(1.0F)); categorymarker.setDrawAsLine(false); categorymarker.setAlpha(1.0F);/*w w w.jav a 2 s .co m*/ categorymarker.setLabel("Marker Label"); categorymarker.setLabelFont(new Font("Dialog", 0, 11)); categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D)); categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND); return jfreechart; }
From source file:grafix.graficos.eixos.EixoHorizontalComLabels.java
@Override public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { try {//from w w w . j a va2s. c o m long l1 = this.getMaximumDate().getTime(); long l2 = this.getMinimumDate().getTime(); int diasExibidos = (int) ((l1 - l2) / ref); if (diasExibidos == diasExibidosAnterior && ticksAnteriores != null) { return ticksAnteriores; // otimizacao } else { List result = new ArrayList(); int j = 0; for (int i = acao.getNumeroRegistros() - 1; i >= 0; i--) { int n = (int) (diasExibidos / QUANTIDADE_DATAS); if (j++ % n == 0) { result.add(new DateTick(acao.getRegistro(i).getDataCorrida().getStart(), new DateFormatter(new SimpleDateFormat("dd/MM/yy")) .valueToString(acao.getRegistro(i).getData().getStart()), TextAnchor.TOP_CENTER, TextAnchor.TOP_RIGHT, 0)); } else { result.add(new DateTick(acao.getRegistro(i).getDataCorrida().getStart(), "", TextAnchor.TOP_CENTER, TextAnchor.TOP_RIGHT, 0)); } } ticksAnteriores = result; diasExibidosAnterior = diasExibidos; return result; } } catch (Exception e) { return new ArrayList(); } }
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);/* ww w . j ava 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: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;// www .ja va2 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:eu.udig.tools.jgrass.profile.ProfileView.java
public void addStopLine(double x) { DecimalFormat formatter = new DecimalFormat("0.0"); // add a category marker ValueMarker marker = new ValueMarker(x, Color.red, new BasicStroke(1.0f)); marker.setAlpha(0.6f);/*from ww w. java 2 s . c om*/ marker.setLabel(formatter.format(x)); marker.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); marker.setLabelOffset(new RectangleInsets(2, 5, 2, 5)); plot.addDomainMarker(marker, Layer.BACKGROUND); markers.add(marker); }
From source file:com.bdb.weather.display.day.DayPressurePane.java
@Override protected void addAnnotations(XYPlot plot, SummaryRecord summaryRecord) { plot.getRenderer(0).removeAnnotations(); plot.getRenderer(1).removeAnnotations(); if (summaryRecord == null) return;/*from w w w. j a va2 s .co m*/ LocalDateTime maxTime = summaryRecord.getMaxBaroPressureTime(); Pressure maxBaroPressure = summaryRecord.getMaxBaroPressure(); LocalDateTime minTime = summaryRecord.getMinBaroPressureTime(); Pressure minBaroPressure = summaryRecord.getMinBaroPressure(); // // Barometric pressure // String highAnnotation = maxBaroPressure.toString() + Pressure.getDefaultUnit() + " " + DisplayConstants.formatTime(maxTime.toLocalTime()); String lowAnnotation = minBaroPressure.toString() + Pressure.getDefaultUnit() + " " + DisplayConstants.formatTime(minTime.toLocalTime()); XYTextAnnotation a = new XYTextAnnotation(highAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(maxTime), maxBaroPressure.get()); a.setTextAnchor(TextAnchor.BASELINE_CENTER); plot.getRenderer(0).addAnnotation(a); TextAnchor anchor = TextAnchor.TOP_CENTER; if (minTime.getHour() <= 2) anchor = TextAnchor.TOP_LEFT; else if (minTime.getHour() >= 22) anchor = TextAnchor.TOP_RIGHT; a = new XYTextAnnotation(lowAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(minTime), minBaroPressure.get()); a.setTextAnchor(anchor); plot.getRenderer(0).addAnnotation(a); SolarRadiation maxSolarRadiation = summaryRecord.getMaxSolarRadiation(); maxTime = summaryRecord.getMaxSolarRadiationTime(); if (maxSolarRadiation != null) { highAnnotation = maxSolarRadiation.toString() + SolarRadiation.Unit.WATTS_PER_METER_SQUARED + " " + DisplayConstants.formatTime(maxTime.toLocalTime()); a = new XYTextAnnotation(highAnnotation, (double) TimeUtils.localDateTimeToEpochMillis(maxTime), maxSolarRadiation.get()); a.setTextAnchor(TextAnchor.BASELINE_CENTER); plot.getRenderer(1).addAnnotation(a); } }
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 va2 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; }