List of usage examples for org.jfree.chart.plot IntervalMarker setPaint
public void setPaint(Paint paint)
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);/* w w w . j a v a 2s . 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:com.sciaps.utils.Util.java
public static IntervalMarker createMarker(double min, double max, String element) { IntervalMarker marker = new IntervalMarker(min, max); marker.setPaint(Color.green); DecimalFormat df = new DecimalFormat("#0.000"); String label = df.format(min); if (element != null) { label = element + ":" + label; }/* w ww .ja v a 2 s .c om*/ marker.setLabel(label); marker.setLabelPaint(Color.blue); marker.setLabelFont(new java.awt.Font("Tahoma", 1, 8)); marker.setLabelOffset(new RectangleInsets(50, 10, 10, 20)); return marker; }
From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java
/** * Creates a chart displaying the distribution of certain selected statistical * values. Uses red for normal rooms and blue for cellar rooms. * /*from ww w . java 2 s. co m*/ * @param title * The headline of the chart. Will be hidden if set to null. * @param statistics * The selected statistics of a campaign containing all needed * values. * @param roomType * The room type to determine the colour of the chart. * @param preview * Will hide annotations, labels and headlines if true. * @return A chart displaying the distribution of certain selected statistical * values. */ public static JFreeChart createDistributionChart(String title, DescriptiveStatistics statistics, OMRoomType roomType, boolean preview) { Color lineColor = new Color(0, 0, 0, 128); Color rangeColor = new Color(222, 222, 222, 128); if (roomType == OMRoomType.Room) { lineColor = new Color(255, 0, 0, 128); rangeColor = new Color(255, 222, 222, 128); } else { if (roomType == OMRoomType.Cellar) { lineColor = new Color(0, 0, 255, 128); rangeColor = new Color(222, 222, 255, 128); } else { lineColor = new Color(0, 128, 0, 255); rangeColor = new Color(222, 255, 222, 128); } } double[] distValues = statistics.getSortedValues(); XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries distSeries = new XYSeries("Distribution"); for (int i = 0; i < distValues.length; i++) { distSeries.add(distValues[i], (0.5 + (double) i) / (double) distValues.length); } dataSet.addSeries(distSeries); JFreeChart chart = ChartFactory.createXYLineChart(title, "Rn [Bq/m\u00B3]", "F(emp)", dataSet, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); float[] dash = { 5, 3 }; int pos = 0; double y = (Double) distSeries.getY(pos); XYPointerAnnotation minPointer = new XYPointerAnnotation("MIN=" + (int) distValues[pos], distValues[pos], y, Math.PI * 1.5); plot.addAnnotation(minPointer); pos = (int) (((double) distValues.length / 100. * 5.0) - 1.0); while (pos < 0) { pos++; } if (pos > 0) { y = (Double) distSeries.getY(pos); } else { y = (Double) distSeries.getY(pos + 1); } final double posQ5 = distValues[pos]; XYPointerAnnotation q05Pointer = new XYPointerAnnotation("Q5=" + (int) distValues[pos], distValues[pos], y, Math.PI * 1.5); plot.addAnnotation(q05Pointer); pos = (int) (((double) distValues.length / 2.0) - 1.0); y = (Double) distSeries.getY(pos); XYPointerAnnotation q50Pointer = new XYPointerAnnotation("Q50=" + (int) distValues[pos], distValues[pos], y, Math.PI * 1.5); plot.addAnnotation(q50Pointer); ValueMarker medMarker = new ValueMarker(distValues[pos], lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addDomainMarker(medMarker); pos = (int) (((double) distValues.length / 100.0 * 95.0) - 1.0); if (pos < distValues.length - 1) { y = (Double) distSeries.getY(pos); } else { y = (Double) distSeries.getY(pos - 1); } final double posQ95 = distValues[pos]; XYPointerAnnotation q95Pointer = new XYPointerAnnotation("Q95=" + (int) distValues[pos], distValues[pos], y, Math.PI * 0.5); plot.addAnnotation(q95Pointer); pos = distValues.length - 1; y = (Double) distSeries.getY(pos); XYPointerAnnotation maxPointer = new XYPointerAnnotation("MAX=" + (int) distValues[pos], distValues[pos], y, Math.PI * 0.5); plot.addAnnotation(maxPointer); IntervalMarker percentiles = new IntervalMarker(posQ5, posQ95); percentiles.setPaint(rangeColor); percentiles.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addDomainMarker(percentiles, Layer.BACKGROUND); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, lineColor); return chart; }
From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java
/** * Creates a chart displaying the radon concentration of a single room. Uses * red for normal rooms, blue for cellar rooms and green for misc rooms. * //from w ww . j a v a2 s .com * @param title * The headline of the chart. Will be hidden if set to null. * @param room * The room object containing the radon data. * @param preview * Will hide annotations, labels and headlines if true. * @return A chart displaying the radon concentration of a single room. */ public static JFreeChart createRoomChart(String title, OMRoom room, boolean preview) { Color lineColor = new Color(0, 0, 0, 128); Color rangeColor = new Color(222, 222, 222, 128); if (room.getType() == OMRoomType.Room) { lineColor = new Color(255, 0, 0, 128); rangeColor = new Color(255, 222, 222, 128); } else { if (room.getType() == OMRoomType.Cellar) { lineColor = new Color(0, 0, 255, 128); rangeColor = new Color(222, 222, 255, 128); } else { lineColor = new Color(0, 128, 0, 255); rangeColor = new Color(222, 255, 222, 128); } } double[] values = room.getValues(); XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries series = new XYSeries("Radon"); int count = room.getCount(); double maxPointerKey = 0; for (int i = 0; i < count; i++) { series.add(i, values[i]); if (values[i] == room.getMaximum()) { maxPointerKey = i; } } dataSet.addSeries(series); title = title + ": " + room.getType().toString() + " " + room.getId(); JFreeChart chart = ChartFactory.createXYLineChart(title, "T [h]", "Rn [Bq/m\u00B3]", dataSet, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); double positiveDeviation = room.getAverage() + room.getDeviation(); double negativeDeviation = room.getAverage() - room.getDeviation(); IntervalMarker deviation = new IntervalMarker(negativeDeviation, positiveDeviation); float[] dash = { 5, 3 }; deviation.setPaint(rangeColor); deviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(deviation, Layer.BACKGROUND); ValueMarker arithMarker = new ValueMarker(room.getAverage(), lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(arithMarker); ValueMarker maxiMarker = new ValueMarker(room.getMaximum(), lineColor, new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(maxiMarker); XYTextAnnotation amLabel = new XYTextAnnotation("AM=" + (int) room.getAverage(), count, room.getAverage() * 1.01); plot.addAnnotation(amLabel); XYTextAnnotation sdLabel = new XYTextAnnotation("SD=" + (int) room.getDeviation(), count, (room.getAverage() + room.getDeviation()) * 1.01); plot.addAnnotation(sdLabel); XYTextAnnotation maxLabel = new XYTextAnnotation("MAX=" + (int) room.getMaximum(), count, room.getMaximum() * 1.01); plot.addAnnotation(maxLabel); XYPointerAnnotation maxPointer = new XYPointerAnnotation("", maxPointerKey, room.getMaximum(), Math.PI * 1.1); plot.addAnnotation(maxPointer); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, lineColor); if (preview) { chart.setTitle(""); plot.clearAnnotations(); } return chart; }
From source file:de.bfs.radon.omsimulation.gui.data.OMCharts.java
/** * Creates a chart displaying the radon concentration of a virtual campaign. * Uses red for normal rooms and blue for cellar rooms. * /*from w w w.j a v a 2s .com*/ * @param campaign * The campaign object containing all rooms and radon data. * @param preview * Will hide annotations, labels and headlines if true. * @return A chart displaying the radon concentration of a virtual campaign. */ public static JFreeChart createCampaignChart(OMCampaign campaign, boolean preview) { OMRoom[] rooms = new OMRoom[7]; OMRoom[] tmpRooms = campaign.getRooms(); OMRoom tmpCellar = campaign.getCellar(); String variation = campaign.getVariation(); char[] variationChar = variation.toCharArray(); int cellarPosition = 0; for (int i = 0; i < variationChar.length; i++) { if (variationChar[i] == 'C' || variationChar[i] == 'c') { cellarPosition = i / 2; } } int c = 0; for (int i = 0; i < rooms.length; i++) { if (i == cellarPosition) { rooms[i] = tmpCellar; c++; } else { rooms[i] = tmpRooms[i - c]; } } int start = campaign.getStart(); final int finalStart = start; String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId() + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId() + ", Start: " + finalStart; int count = 168; double[] values = campaign.getValueChain(); XYSeriesCollection dataSet = new XYSeriesCollection(); XYSeries roomSeries1 = new XYSeries(" Radon Rooms"); XYSeries cellarSeries = new XYSeries("Radon Cellar"); XYSeries roomSeries2 = new XYSeries("Radon Rooms"); int cellarSeriesStart = cellarPosition * 24; int cellarSeriesEnd = cellarSeriesStart + 24; double cellarMaximum = campaign.getCellarMaximum(); double cellarMaximumKey = 0; double roomMaximum = campaign.getRoomMaximum(); double roomMaximumKey = 0; if (cellarSeriesStart > 0) { for (int i = 0; i < cellarSeriesStart; i++) { roomSeries1.add(finalStart + i, values[i]); if (values[i] == roomMaximum) { roomMaximumKey = i; } } } for (int i = cellarSeriesStart - 1; i < cellarSeriesEnd; i++) { if (i >= 0) { cellarSeries.add(finalStart + i, values[i]); if (values[i] == cellarMaximum) { cellarMaximumKey = i; } } } if (cellarSeriesEnd < count) { for (int i = cellarSeriesEnd - 1; i < count; i++) { roomSeries2.add(finalStart + i, values[i]); if (values[i] == roomMaximum) { roomMaximumKey = i; } } } dataSet.addSeries(roomSeries1); dataSet.addSeries(cellarSeries); dataSet.addSeries(roomSeries2); JFreeChart chart = ChartFactory.createXYLineChart(title, "T [h]", "Rn [Bq/m\u00B3]", dataSet, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); ValueMarker sepMarker; Color sepColor = Color.BLACK; float[] sepDash = { 1, 2 }; Stroke sepStroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, sepDash, 0); RectangleInsets sepLabelInsets = new RectangleInsets(20, -20, 0, 0); Font sepLabelFont = new Font(Font.SANS_SERIF, Font.BOLD, 16); sepMarker = new ValueMarker(finalStart + 0, sepColor, sepStroke); sepMarker.setLabel(rooms[0].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); if (rooms[0].getId() != rooms[1].getId()) { sepMarker = new ValueMarker(finalStart + 23, sepColor, sepStroke); sepMarker.setLabel(rooms[1].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[1].getId() != rooms[2].getId()) { sepMarker = new ValueMarker(finalStart + 47, sepColor, sepStroke); sepMarker.setLabel(rooms[2].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[2].getId() != rooms[3].getId()) { sepMarker = new ValueMarker(finalStart + 71, sepColor, sepStroke); sepMarker.setLabel(rooms[3].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[3].getId() != rooms[4].getId()) { sepMarker = new ValueMarker(finalStart + 95, sepColor, sepStroke); sepMarker.setLabel(rooms[4].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[4].getId() != rooms[5].getId()) { sepMarker = new ValueMarker(finalStart + 119, sepColor, sepStroke); sepMarker.setLabel(rooms[5].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } if (rooms[5].getId() != rooms[6].getId()) { sepMarker = new ValueMarker(finalStart + 143, sepColor, sepStroke); sepMarker.setLabel(rooms[6].getId()); sepMarker.setLabelOffset(sepLabelInsets); sepMarker.setLabelFont(sepLabelFont); plot.addDomainMarker(sepMarker); } double positiveCellarDeviation = campaign.getCellarAverage() + campaign.getCellarDeviation(); double negativeCellarDeviation = campaign.getCellarAverage() - campaign.getCellarDeviation(); IntervalMarker cellarDeviation = new IntervalMarker(negativeCellarDeviation, positiveCellarDeviation); float[] dash = { 5, 3 }; cellarDeviation.setPaint(new Color(222, 222, 255, 128)); cellarDeviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(cellarDeviation, Layer.BACKGROUND); ValueMarker arithCellarMarker = new ValueMarker(campaign.getCellarAverage(), new Color(0, 0, 255, 128), new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(arithCellarMarker); XYTextAnnotation amCellarLabel = new XYTextAnnotation("C_AM=" + (int) campaign.getCellarAverage(), finalStart + count, campaign.getCellarAverage() * 1.01); plot.addAnnotation(amCellarLabel); XYTextAnnotation sdCellarLabel = new XYTextAnnotation("C_SD=" + (int) campaign.getCellarDeviation(), finalStart + count, (campaign.getCellarAverage() + campaign.getCellarDeviation()) * 1.01); plot.addAnnotation(sdCellarLabel); ValueMarker maxiCellarMarker = new ValueMarker(cellarMaximum, new Color(0, 0, 255, 128), new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(maxiCellarMarker); XYTextAnnotation maxCellarLabel = new XYTextAnnotation("C_MAX=" + (int) cellarMaximum, finalStart + count, cellarMaximum * 1.01); plot.addAnnotation(maxCellarLabel); XYPointerAnnotation maxCellarPointer = new XYPointerAnnotation("", finalStart + cellarMaximumKey, cellarMaximum, Math.PI * 1.1); plot.addAnnotation(maxCellarPointer); double positiveRoomDeviation = campaign.getRoomAverage() + campaign.getRoomDeviation(); double negativeRoomDeviation = campaign.getRoomAverage() - campaign.getRoomDeviation(); IntervalMarker roomDeviation = new IntervalMarker(negativeRoomDeviation, positiveRoomDeviation); roomDeviation.setPaint(new Color(255, 222, 222, 128)); roomDeviation.setStroke(new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(roomDeviation, Layer.BACKGROUND); ValueMarker arithRoomMarker = new ValueMarker(campaign.getRoomAverage(), new Color(255, 0, 0, 128), new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(arithRoomMarker); XYTextAnnotation amRoomLabel = new XYTextAnnotation("R_AM=" + (int) campaign.getRoomAverage(), finalStart + count, campaign.getRoomAverage() * 1.01); plot.addAnnotation(amRoomLabel); XYTextAnnotation sdRoomLabel = new XYTextAnnotation("R_SD=" + (int) campaign.getRoomDeviation(), finalStart + count, (campaign.getRoomAverage() + campaign.getRoomDeviation()) * 1.01); plot.addAnnotation(sdRoomLabel); ValueMarker maxiRoomMarker = new ValueMarker(roomMaximum, new Color(255, 0, 0, 128), new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, 0)); plot.addRangeMarker(maxiRoomMarker); XYTextAnnotation maxRoomLabel = new XYTextAnnotation("R_MAX=" + (int) roomMaximum, finalStart + count, roomMaximum * 1.01); plot.addAnnotation(maxRoomLabel); XYPointerAnnotation maxRoomPointer = new XYPointerAnnotation("", finalStart + roomMaximumKey, roomMaximum, Math.PI * 1.1); plot.addAnnotation(maxRoomPointer); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, new Color(255, 0, 0, 128)); renderer.setSeriesPaint(1, new Color(0, 0, 255, 128)); renderer.setSeriesPaint(2, new Color(255, 0, 0, 128)); if (preview) { chart.setTitle(""); plot.clearAnnotations(); } return chart; }
From source file:org.kalypso.ogc.sensor.diagview.jfreechart.ObservationPlot.java
/** * Helper that creates a marker//from w ww .ja va2s . c o m */ private static Marker createMarker(final double start, final double end, final String label, final Color color) { final IntervalMarker marker = new IntervalMarker(start, end); marker.setPaint(color); marker.setLabel(label); marker.setLabelAnchor(RectangleAnchor.CENTER); marker.setLabelTextAnchor(TextAnchor.CENTER); return marker; }
From source file:cz.dfi.multiplegraphscomponent.SelectionHighlighter.java
@Override public void resultChanged(LookupEvent ev) { Lookup l = FileLookup.getDefault();/*ww w. jav a2 s . com*/ TimeValueSelection value = l.lookup(TimeValueSelection.class); plot.clearDomainMarkers(); if (value != null) { //To millis conversion ValueMarker valueMarker = new ValueMarker(value.getSelectedValue().getRecorderValue() / 1_000_000); plot.addDomainMarker(valueMarker); valueMarker.setPaint(ORANGE); return; } TimeIntervalSelection interval = l.lookup(TimeIntervalSelection.class); if (interval != null) { long l1 = interval.getSelectedInterval().t1.getRecorderValue(); long l2 = interval.getSelectedInterval().t2.getRecorderValue(); IntervalMarker marker = new IntervalMarker(l1 / 1_000_000, l2 / 1_000_000); marker.setPaint(ORANGE); marker.setAlpha(.3f); plot.addDomainMarker(marker); } }
From source file:imageviewer.tools.HistogramTool.java
public void plot(MouseEvent e) { if (e.getSource() instanceof ImagePanel) { Image image = ((ImagePanel) e.getSource()).getSource(); Histogram h = image.getHistogram(); SimpleHistogramDataset shd = new SimpleHistogramDataset("Voxel distribution"); for (int i = 0, numBands = h.getNumBands(); i < numBands; i++) { int[] binData = h.getBins(i); for (int j = 0; j < binData.length; j++) { SimpleHistogramBin shb = new SimpleHistogramBin(j - 0.5, j + 0.5, true, false); shb.setItemCount(binData[j]); shd.addBin(shb);/* w w w .j a v a 2 s.co m*/ } } double[] domainBounds = null, rangeBounds = null; if (chart != null) { ValueAxis va = chart.getXYPlot().getDomainAxis(); domainBounds = new double[] { va.getLowerBound(), va.getUpperBound() }; va = chart.getXYPlot().getRangeAxis(); rangeBounds = new double[] { va.getLowerBound(), va.getUpperBound() }; } chart = ChartFactory.createHistogram(null, "Voxel value", "Count", shd, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(new Color(20, 30, 45)); chart.setAntiAlias(true); ValueAxis domainAxis = chart.getXYPlot().getDomainAxis(); domainAxis.setLabelFont(axisFont); domainAxis.setTickLabelFont(tickFont); domainAxis.setAxisLinePaint(Color.white); domainAxis.setTickLabelPaint(Color.white); domainAxis.setLabelPaint(Color.white); if (domainBounds != null) { domainAxis.setAutoRange(false); domainAxis.setLowerBound(domainBounds[0]); domainAxis.setUpperBound(domainBounds[1]); } else { domainAxis.setLowerBound(0); } ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis(); rangeAxis.setLabelFont(axisFont); rangeAxis.setTickLabelFont(tickFont); rangeAxis.setAxisLinePaint(Color.white); rangeAxis.setTickLabelPaint(Color.white); rangeAxis.setLabelPaint(Color.white); if (rangeBounds != null) { rangeAxis.setAutoRange(false); rangeAxis.setLowerBound(rangeBounds[0]); rangeAxis.setUpperBound(rangeBounds[1]); } chart.getXYPlot().getRenderer().setSeriesPaint(0, new Color(0, 51, 113)); ((XYBarRenderer) chart.getXYPlot().getRenderer()).setDrawBarOutline(false); chart.getXYPlot().setBackgroundAlpha(0.05f); double[] mean = h.getMean(); double[] sd = h.getStandardDeviation(); IntervalMarker im = new IntervalMarker(mean[0] - sd[0] / 2, mean[0] + sd[0] / 2); im.setPaint(new Color(200, 200, 200, 128)); chart.getXYPlot().addDomainMarker(0, im, Layer.BACKGROUND); cp.setChart(chart); } }
From source file:com.googlecode.logVisualizer.chart.turnrundownGantt.GanttChartBuilder.java
private void addFamiliarMarkers(final CategoryPlot plot) { final LookAheadIterator<FamiliarChange> index = new LookAheadIterator<FamiliarChange>( getLogData().getFamiliarChanges().iterator()); while (index.hasNext()) { final FamiliarChange currentItem = index.next(); final int intervalEnd = index.hasNext() ? index.peek().getTurnNumber() : lastTurnNumber; final IntervalMarker familiarUsage = new IntervalMarker(currentItem.getTurnNumber(), intervalEnd); familiarUsage.setPaint(getColor(currentItem.getFamiliarName())); if (!familiarUsage.getPaint().equals(Color.white)) plot.addRangeMarker(familiarUsage, Layer.BACKGROUND); }/*ww w . j a v a2 s .c o m*/ }
From source file:org.jfree.chart.demo.XYSeriesDemo3.java
/** * Creates a sample chart.//from ww w . j a va2 s . c o m * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(IntervalXYDataset dataset) { final JFreeChart chart = ChartFactory.createXYBarChart("XY Series Demo", "X", false, "Y", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); final IntervalMarker target = new IntervalMarker(400.0, 700.0); target.setLabel("Target Range"); target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11)); target.setLabelAnchor(RectangleAnchor.LEFT); target.setLabelTextAnchor(TextAnchor.CENTER_LEFT); target.setPaint(new Color(222, 222, 255, 128)); plot.addRangeMarker(target, Layer.BACKGROUND); return chart; }