List of usage examples for org.jfree.ui RectangleAnchor BOTTOM_RIGHT
RectangleAnchor BOTTOM_RIGHT
To view the source code for org.jfree.ui RectangleAnchor BOTTOM_RIGHT.
Click Source Link
From source file:org.jfree.chart.demo.XYTitleAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, false, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); LegendTitle legendtitle = new LegendTitle(xyplot); legendtitle.setItemFont(new Font("Dialog", 0, 9)); legendtitle.setBackgroundPaint(new Color(200, 200, 255, 100)); legendtitle.setFrame(new BlockBorder(Color.white)); legendtitle.setPosition(RectangleEdge.BOTTOM); XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.97999999999999998D, 0.02D, legendtitle, RectangleAnchor.BOTTOM_RIGHT); xytitleannotation.setMaxWidth(0.47999999999999998D); xyplot.addAnnotation(xytitleannotation); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }/*from w w w . j a va 2 s. c om*/ DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); ValueAxis valueaxis = xyplot.getRangeAxis(); valueaxis.setLowerMargin(0.34999999999999998D); return jfreechart; }
From source file:org.jfree.experimental.chart.demo.XYTitleAnnotationDemo1.java
/** * Creates a chart./*from w w w . j av a 2s . co m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data false, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); LegendTitle lt = new LegendTitle(plot); lt.setItemFont(new Font("Dialog", Font.PLAIN, 9)); lt.setBackgroundPaint(new Color(200, 200, 255, 100)); lt.setFrame(new BlockBorder(Color.white)); lt.setPosition(RectangleEdge.BOTTOM); XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, lt, RectangleAnchor.BOTTOM_RIGHT); ta.setMaxWidth(0.48); plot.addAnnotation(ta); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setLowerMargin(0.35); return chart; }
From source file:org.jfree.chart.demo.MarkerDemo1.java
/** * Creates a sample chart.// w w w.j a v a2 s .c om * * @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:com.googlecode.logVisualizer.chart.turnrundownGantt.GanttChartBuilder.java
private void addLevelMarkers(final CategoryPlot plot) { for (final LevelData ld : getLogData().getLevels()) { final ValueMarker level = new ValueMarker(ld.getLevelReachedOnTurn()); level.setLabel("Level " + ld.getLevelNumber()); level.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); level.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); level.setStroke(new BasicStroke(2)); level.setPaint(new Color(0, 150, 0)); plot.addRangeMarker(level);/* www .ja va2 s . c o m*/ } }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortHeatMapPlotPanel.java
private PortHeatMapPlotPanel(OMS_Collection history, ArrayList<IB_Vertex> includedNodes, EnumSet<IB_Depth> includedDepths) { super(new BorderLayout()); // creates the main chart panel, which creates the PortHeatMapDataSet // (so all the data has been initialized here, available for all subsequent actions) overallDimension = new java.awt.Dimension(900, 500); heatPanel = (ChartPanel) createHeatPanel(history, includedNodes, includedDepths); heatPanel.setPreferredSize(overallDimension); // add the vertical and horizontal crosshairs CrosshairOverlay overlay = new CrosshairOverlay(); TimeXhair = new Crosshair(0); TimeXhair.setPaint(TimeSliceColor); // vertical slice (single timestamp) for dataset1, SingleTimeChart plot 1, slider 2, etc PortXhair = new Crosshair(0); PortXhair.setPaint(PortSliceColor); // horizontal slice (single port) for dataset2, SinglePortChart, slider 1 overlay.addDomainCrosshair(TimeXhair); overlay.addRangeCrosshair(PortXhair); heatPanel.addOverlay(overlay);/*from ww w . jav a 2 s .c o m*/ TimeXhair.setLabelVisible(true); TimeXhair.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); TimeXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100)); PortXhair.setLabelVisible(true); PortXhair.setLabelBackgroundPaint(new Color(255, 255, 0, 100)); add(heatPanel); JPanel PortSliderPanel = new JPanel(new BorderLayout()); // all ports, single timestamp (right vertical plot) - uses TimeXhair and slider 2 from the horizontal panel (TimeSliderPanel) XYSeriesCollection dataset1 = new XYSeriesCollection(); SingleTimeChart = ChartFactory.createXYLineChart("Vertical Cross-section (all ports single timestamp)", PortAxisLabel, UtilizationAxisLabel, dataset1, PlotOrientation.HORIZONTAL, false, false, false); XYPlot plot1 = (XYPlot) SingleTimeChart.getPlot(); plot1.getDomainAxis().setLowerMargin(0.0); plot1.getDomainAxis().setUpperMargin(0.0); plot1.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot1.getRenderer().setSeriesPaint(0, TimeSliceColor); // this is the right ChartPanel SingleTimeChartPanel = new ChartPanel(SingleTimeChart); SingleTimeChartPanel.setMinimumDrawWidth(0); SingleTimeChartPanel.setMinimumDrawHeight(0); SingleTimeChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getWidth() / 3))); ((XYPlot) SingleTimeChart.getPlot()).getRangeAxis().setRange(new Range(0, 1)); ((XYPlot) SingleTimeChart.getPlot()).getDomainAxis().setRange(new Range(0, 1)); // this slider panel holds the slider and the Single Time Snapshot of all ports, on the right or EAST (for use with plot2) PortSlider = new JSlider(0, 1, 0); PortSlider.addChangeListener(this); PortSlider.setOrientation(JSlider.VERTICAL); PortSliderPanel.add(SingleTimeChartPanel); PortSliderPanel.add(PortSlider, BorderLayout.WEST); TimeSliderPanel = new JPanel(new BorderLayout()); // single port, all timestamps (lower horizontal plot) - uses PortXhair and slider 1 from the vertical panel (PortSliderPanel) XYSeriesCollection dataset2 = new XYSeriesCollection(); SinglePortChart = ChartFactory.createXYLineChart("Horizontal Cross-section (single port over time)", TimeAxisLabel, UtilizationAxisLabel, dataset2, PlotOrientation.VERTICAL, false, false, false); XYPlot plot2 = (XYPlot) SinglePortChart.getPlot(); plot2.getDomainAxis().setLowerMargin(0.0); plot2.getDomainAxis().setUpperMargin(0.0); plot2.getRenderer().setSeriesPaint(0, PortSliceColor); ChartPanel SinglePortChartPanel = new ChartPanel(SinglePortChart); SinglePortChartPanel.setMinimumDrawWidth(0); SinglePortChartPanel.setMinimumDrawHeight(0); SinglePortChartPanel.setPreferredSize(new Dimension(200, (int) (overallDimension.getHeight() / 3))); ((XYPlot) SinglePortChart.getPlot()).getRangeAxis().setRange(new Range(0, 1)); ((XYPlot) SinglePortChart.getPlot()).getDomainAxis().setRange(new Range(0, 1)); DepthPanel = new HeatMapDepthPanel(null); DepthPanel.setPreferredSize( new Dimension((int) (overallDimension.getWidth() / 4), (int) (overallDimension.getHeight() / 3))); TimeSliderPanel.add(DepthPanel, BorderLayout.EAST); // this slider panel holds the slider and the Single Port for all times, in the BOTTOM (for use with plot1) TimeSlider = new JSlider(0, 1, 0); TimeSlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 200)); TimeSlider.addChangeListener(this); TimeSliderPanel.add(SinglePortChartPanel); TimeSliderPanel.add(TimeSlider, BorderLayout.NORTH); add(PortSliderPanel, BorderLayout.EAST); add(TimeSliderPanel, BorderLayout.SOUTH); heatChart.setNotify(true); }
From source file:daylightchart.daylightchart.chart.DaylightChart.java
private void createDSTMarker(final XYPlot plot) { if (!riseSetData.usesDaylightTime()) { return;/*from www.j ava2s. c om*/ } final long intervalStart = riseSetData.getDstStartDate().atStartOfDay().atZone(ZoneId.systemDefault()) .toInstant().toEpochMilli(); final long intervalEnd = riseSetData.getDstEndDate().atStartOfDay().atZone(ZoneId.systemDefault()) .toInstant().toEpochMilli(); final IntervalMarker dstMarker = new IntervalMarker(intervalStart, intervalEnd, ChartConfiguration.nightColor, new BasicStroke(0.0f), null, null, 0.4f); dstMarker.setLabelPaint(Color.WHITE); dstMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); dstMarker.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT); // plot.addDomainMarker(dstMarker, Layer.BACKGROUND); }
From source file:nl.vu.nat.jfreechartcustom.XYBlockRenderer.java
/** * Updates the offsets to take into account the block width, height and * anchor./* ww w . j av a 2 s . c o m*/ */ private void updateOffsets() { if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) { this.xOffset = 0.0; this.yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) { this.xOffset = -this.blockWidth / 2.0; this.yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { this.xOffset = -this.blockWidth; this.yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) { this.xOffset = 0.0; this.yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) { this.xOffset = -this.blockWidth / 2.0; this.yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) { this.xOffset = -this.blockWidth; this.yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) { this.xOffset = 0.0; this.yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP)) { this.xOffset = -this.blockWidth / 2.0; this.yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) { this.xOffset = -this.blockWidth; this.yOffset = -this.blockHeight; } }
From source file:anl.verdi.plot.jfree.XYBlockRenderer.java
/** * Updates the offsets to take into account the block width, height and * anchor.//from w w w.j a va 2s . c o m */ private void updateOffsets() { if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) { xOffset = 0.0; yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) { xOffset = -this.blockWidth / 2.0; yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { xOffset = -this.blockWidth; yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) { xOffset = 0.0; yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) { xOffset = -this.blockWidth / 2.0; yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) { xOffset = -this.blockWidth; yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) { xOffset = 0.0; yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP)) { xOffset = -this.blockWidth / 2.0; yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) { xOffset = -this.blockWidth; yOffset = -this.blockHeight; } }
From source file:com.android.ddmuilib.net.NetworkPanel.java
/** * Create chart of recent network activity. *///from w w w . j a v a 2 s .c o m private void createChart() { mChart = ChartFactory.createTimeSeriesChart(null, null, null, null, false, false, false); // create backing datasets and series mRxTotalSeries = new TimeSeries("RX total"); mTxTotalSeries = new TimeSeries("TX total"); mRxTotalSeries.setMaximumItemAge(HISTORY_MILLIS); mTxTotalSeries.setMaximumItemAge(HISTORY_MILLIS); mTotalCollection = new TimeSeriesCollection(); mTotalCollection.addSeries(mRxTotalSeries); mTotalCollection.addSeries(mTxTotalSeries); mRxDetailDataset = new LiveTimeTableXYDataset(); mTxDetailDataset = new LiveTimeTableXYDataset(); mTotalRenderer = new XYAreaRenderer(XYAreaRenderer.AREA); mRenderer = new StackedXYAreaRenderer2(); final XYPlot xyPlot = mChart.getXYPlot(); xyPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); xyPlot.setDataset(0, mTotalCollection); xyPlot.setDataset(1, mRxDetailDataset); xyPlot.setDataset(2, mTxDetailDataset); xyPlot.setRenderer(0, mTotalRenderer); xyPlot.setRenderer(1, mRenderer); xyPlot.setRenderer(2, mRenderer); // we control domain axis manually when taking samples mDomainAxis = xyPlot.getDomainAxis(); mDomainAxis.setAutoRange(false); final NumberAxis axis = new NumberAxis(); axis.setNumberFormatOverride(new BytesFormat(true)); axis.setAutoRangeMinimumSize(50); xyPlot.setRangeAxis(axis); xyPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); // draw thick line to separate RX versus TX traffic xyPlot.addRangeMarker(new ValueMarker(0, java.awt.Color.BLACK, new java.awt.BasicStroke(2))); // label to indicate that positive axis is RX traffic final ValueMarker rxMarker = new ValueMarker(0); rxMarker.setStroke(new java.awt.BasicStroke(0)); rxMarker.setLabel("RX"); rxMarker.setLabelFont(rxMarker.getLabelFont().deriveFont(30f)); rxMarker.setLabelPaint(java.awt.Color.LIGHT_GRAY); rxMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); rxMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); xyPlot.addRangeMarker(rxMarker); // label to indicate that negative axis is TX traffic final ValueMarker txMarker = new ValueMarker(0); txMarker.setStroke(new java.awt.BasicStroke(0)); txMarker.setLabel("TX"); txMarker.setLabelFont(txMarker.getLabelFont().deriveFont(30f)); txMarker.setLabelPaint(java.awt.Color.LIGHT_GRAY); txMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); txMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); xyPlot.addRangeMarker(txMarker); mChartComposite = new ChartComposite(mPanel, SWT.BORDER, mChart, ChartComposite.DEFAULT_WIDTH, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH, ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 4096, 4096, true, true, true, true, false, true); final FormData data = new FormData(); data.top = new FormAttachment(mHeader); data.left = new FormAttachment(0); data.bottom = new FormAttachment(70); data.right = new FormAttachment(100); mChartComposite.setLayoutData(data); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.scattercharts.MarkerScatter.java
public JFreeChart createChart(DatasetMap datasets) { DefaultXYDataset dataset = (DefaultXYDataset) datasets.getDatasets().get("1"); JFreeChart chart = ChartFactory.createScatterPlot(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL, false, true, false);//from ww w . jav a2 s. c o m TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); chart.setBackgroundPaint(Color.white); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); //defines colors int seriesN = dataset.getSeriesCount(); if ((colorMap != null && colorMap.size() > 0) || (defaultColor != null && !defaultColor.equals(""))) { for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getSeriesKey(i); Color color = new Color(Integer.decode(defaultColor).intValue()); if (colorMap != null && colorMap.size() > 0) color = (Color) colorMap.get(serieName); if (color != null) renderer.setSeriesPaint(i, color); } } // add un interval marker for the Y axis... if (yMarkerStartInt != null && yMarkerEndInt != null && !yMarkerStartInt.equals("") && !yMarkerEndInt.equals("")) { Marker intMarkerY = new IntervalMarker(Double.parseDouble(yMarkerStartInt), Double.parseDouble(yMarkerEndInt)); intMarkerY.setLabelOffsetType(LengthAdjustmentType.EXPAND); intMarkerY.setPaint( new Color(Integer.decode((yMarkerIntColor.equals("")) ? "0" : yMarkerIntColor).intValue())); //intMarkerY.setLabel(yMarkerLabel); intMarkerY.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); intMarkerY.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(intMarkerY, Layer.BACKGROUND); } // add un interval marker for the X axis... if (xMarkerStartInt != null && xMarkerEndInt != null && !xMarkerStartInt.equals("") && !xMarkerEndInt.equals("")) { Marker intMarkerX = new IntervalMarker(Double.parseDouble(xMarkerStartInt), Double.parseDouble(xMarkerEndInt)); intMarkerX.setLabelOffsetType(LengthAdjustmentType.EXPAND); intMarkerX.setPaint( new Color(Integer.decode((xMarkerIntColor.equals("")) ? "0" : xMarkerIntColor).intValue())); //intMarkerX.setLabel(xMarkerLabel); intMarkerX.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); intMarkerX.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addRangeMarker(intMarkerX, Layer.BACKGROUND); } // add a labelled marker for the Y axis... if (yMarkerValue != null && !yMarkerValue.equals("")) { Marker markerY = new ValueMarker(Double.parseDouble(yMarkerValue)); markerY.setLabelOffsetType(LengthAdjustmentType.EXPAND); if (!yMarkerColor.equals("")) markerY.setPaint(new Color(Integer.decode(yMarkerColor).intValue())); markerY.setLabel(yMarkerLabel); markerY.setLabelFont(new Font("Arial", Font.BOLD, 11)); markerY.setLabelAnchor(RectangleAnchor.TOP_RIGHT); markerY.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(markerY, Layer.BACKGROUND); } // add a labelled marker for the X axis... if (xMarkerValue != null && !xMarkerValue.equals("")) { Marker markerX = new ValueMarker(Double.parseDouble(xMarkerValue)); markerX.setLabelOffsetType(LengthAdjustmentType.EXPAND); if (!xMarkerColor.equals("")) markerX.setPaint(new Color(Integer.decode(xMarkerColor).intValue())); markerX.setLabel(xMarkerLabel); markerX.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); markerX.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addRangeMarker(markerX, Layer.BACKGROUND); } if (xRangeLow != null && !xRangeLow.equals("") && xRangeHigh != null && !xRangeHigh.equals("")) { if (Double.valueOf(xRangeLow).doubleValue() > xMin) xRangeLow = String.valueOf(xMin); if (Double.valueOf(xRangeHigh).doubleValue() < xMax) xRangeHigh = String.valueOf(xMax); ValueAxis rangeAxis = plot.getRangeAxis(); //rangeAxis.setRange(Double.parseDouble(xRangeLow), Double.parseDouble(xRangeHigh)); rangeAxis.setRangeWithMargins(Double.parseDouble(xRangeLow), Double.parseDouble(xRangeHigh)); } else { NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); rangeAxis.setRange(xMin, xMax); } if (yRangeLow != null && !yRangeLow.equals("") && yRangeHigh != null && !yRangeHigh.equals("")) { if (Double.valueOf(yRangeLow).doubleValue() > yMin) yRangeLow = String.valueOf(yMin); if (Double.valueOf(yRangeHigh).doubleValue() < yMax) yRangeHigh = String.valueOf(yMax); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); //domainAxis.setRange(Double.parseDouble(yRangeLow), Double.parseDouble(yRangeHigh)); domainAxis.setRangeWithMargins(Double.parseDouble(yRangeLow), Double.parseDouble(yRangeHigh)); domainAxis.setAutoRangeIncludesZero(false); } else { NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setRange(yMin, yMax); domainAxis.setAutoRangeIncludesZero(false); } //add annotations if requested if (viewAnnotations != null && viewAnnotations.equalsIgnoreCase("true")) { if (annotationMap == null || annotationMap.size() == 0) logger.error("Annotations on the chart are requested but the annotationMap is null!"); else { int cont = 1; for (Iterator iterator = annotationMap.keySet().iterator(); iterator.hasNext();) { String text = (String) iterator.next(); String pos = (String) annotationMap.get(text); double x = Double.parseDouble(pos.substring(0, pos.indexOf("__"))); double y = Double.parseDouble(pos.substring(pos.indexOf("__") + 2)); //default up position XYTextAnnotation annotation = new XYTextAnnotation(text, y - 1, x + ((text.length() > 20) ? text.length() / 3 + 1 : text.length() / 2 + 1)); if (cont % 2 != 0) //dx annotation = new XYTextAnnotation(text, y, x + ((text.length() > 20) ? text.length() / 3 + 1 : text.length() / 2 + 1)); else //sx //annotation = new XYTextAnnotation(text, y, x-((text.length()%2==0)?text.length():text.length()-1)); annotation = new XYTextAnnotation(text, y, x - (text.length() - 1)); annotation.setFont(new Font("SansSerif", Font.PLAIN, 11)); //annotation.setRotationAngle(Math.PI / 4.0); annotation.setRotationAngle(0.0); // horizontal plot.addAnnotation(annotation); cont++; } renderer.setShape(new Ellipse2D.Double(-3, -5, 8, 8)); } } else if (viewAnnotations != null && viewAnnotations.equalsIgnoreCase("false")) { renderer.setShape(new Ellipse2D.Double(-3, -5, 8, 8)); } if (legend == true) { drawLegend(chart); } return chart; }