List of usage examples for org.jfree.chart.axis NumberAxis setLowerMargin
public void setLowerMargin(double margin)
From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java
private void updateMFI(int days, boolean show) { if (this.priceVolumeChart == null) { this.priceVolumeChart = this.createPriceVolumeChart(this.priceDataset, this.volumeDataset); }//from w w w .j a va2 s . c om if (this.candlestickChart == null) { this.candlestickChart = this.createCandlestickChart(this.priceOHLCDataset); } final TAEx taEx = TAEx.newInstance(TA.MFI, new Integer(days)); if (show) { if (price_volume_ta_map.containsKey(taEx) == false) { final XYDataset dataset = org.yccheok.jstock.charting.TechnicalAnalysis.createMFI(this.chartDatas, getMFIKey(days), days); NumberAxis rangeAxis1 = new NumberAxis(GUIBundle.getString("ChartJDialog_MFI")); rangeAxis1.setAutoRangeIncludesZero(false); // override default rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars DecimalFormat format = new DecimalFormat("0"); rangeAxis1.setNumberFormatOverride(format); final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date")); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#"))); plot.setRenderer(0, renderer1); price_volume_ta_map.put(taEx, plot); } if (candlestick_ta_map.containsKey(taEx) == false) { try { /* Not sure why. I cannot make priceVolumeChart and candlestickChart sharing the same * plot. If not, this will inhibit incorrect zooming behavior. */ candlestick_ta_map.put(taEx, (XYPlot) price_volume_ta_map.get(taEx).clone()); } catch (CloneNotSupportedException ex) { log.error(null, ex); } } if (this.activeTAExs.contains(taEx) == false) { // Avoid duplication. final XYPlot price_volume_ta = price_volume_ta_map.get(taEx); final XYPlot candlestick_ta = candlestick_ta_map.get(taEx); final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot(); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot(); if (price_volume_ta != null) cplot0.add(price_volume_ta, 1); // weight is 1. if (candlestick_ta != null) cplot1.add(candlestick_ta, 1); // weight is 1. org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.priceVolumeChart); org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.candlestickChart); } } else { final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot(); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot(); final XYPlot price_volume_ta = price_volume_ta_map.get(taEx); final XYPlot candlestick_ta = candlestick_ta_map.get(taEx); if (price_volume_ta != null) cplot0.remove(price_volume_ta); if (candlestick_ta != null) cplot1.remove(candlestick_ta); } if (show && this.activeTAExs.contains(taEx) == false) { this.activeTAExs.add(taEx); JStock.instance().getChartJDialogOptions().add(taEx); } else if (!show) { this.activeTAExs.remove(taEx); JStock.instance().getChartJDialogOptions().remove(taEx); } }
From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java
private void updateRSI(int days, boolean show) { if (this.priceVolumeChart == null) { this.priceVolumeChart = this.createPriceVolumeChart(this.priceDataset, this.volumeDataset); }// ww w. j ava 2 s .c om if (this.candlestickChart == null) { this.candlestickChart = this.createCandlestickChart(this.priceOHLCDataset); } final TAEx taEx = TAEx.newInstance(TA.RSI, new Integer(days)); if (show) { if (price_volume_ta_map.containsKey(taEx) == false) { final XYDataset dataset = org.yccheok.jstock.charting.TechnicalAnalysis.createRSI(this.chartDatas, getRSIKey(days), days); NumberAxis rangeAxis1 = new NumberAxis(GUIBundle.getString("ChartJDialog_RSI")); rangeAxis1.setAutoRangeIncludesZero(false); // override default rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars DecimalFormat format = new DecimalFormat("0"); rangeAxis1.setNumberFormatOverride(format); final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date")); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#"))); plot.setRenderer(0, renderer1); price_volume_ta_map.put(taEx, plot); } if (candlestick_ta_map.containsKey(taEx) == false) { try { /* Not sure why. I cannot make priceVolumeChart and candlestickChart sharing the same * plot. If not, this will inhibit incorrect zooming behavior. */ candlestick_ta_map.put(taEx, (XYPlot) price_volume_ta_map.get(taEx).clone()); } catch (CloneNotSupportedException ex) { log.error(null, ex); } } if (this.activeTAExs.contains(taEx) == false) { // Avoid duplication. final XYPlot price_volume_ta = price_volume_ta_map.get(taEx); final XYPlot candlestick_ta = candlestick_ta_map.get(taEx); final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot(); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot(); if (price_volume_ta != null) cplot0.add(price_volume_ta, 1); // weight is 1. if (candlestick_ta != null) cplot1.add(candlestick_ta, 1); // weight is 1. org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.priceVolumeChart); org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.candlestickChart); } } else { final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot(); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot(); final XYPlot price_volume_ta = price_volume_ta_map.get(taEx); final XYPlot candlestick_ta = candlestick_ta_map.get(taEx); if (price_volume_ta != null) cplot0.remove(price_volume_ta); if (candlestick_ta != null) cplot1.remove(candlestick_ta); } if (show && this.activeTAExs.contains(taEx) == false) { this.activeTAExs.add(taEx); JStock.instance().getChartJDialogOptions().add(taEx); } else if (!show) { this.activeTAExs.remove(taEx); JStock.instance().getChartJDialogOptions().remove(taEx); } }
From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java
private void updateCCI(int days, boolean show) { if (this.priceVolumeChart == null) { this.priceVolumeChart = this.createPriceVolumeChart(this.priceDataset, this.volumeDataset); }//from ww w .ja va2 s . c om if (this.candlestickChart == null) { this.candlestickChart = this.createCandlestickChart(this.priceOHLCDataset); } final TAEx taEx = TAEx.newInstance(TA.CCI, new Integer(days)); if (show) { if (price_volume_ta_map.containsKey(taEx) == false) { final XYDataset dataset = org.yccheok.jstock.charting.TechnicalAnalysis.createCCI(this.chartDatas, getCCIKey(days), days); NumberAxis rangeAxis1 = new NumberAxis(GUIBundle.getString("ChartJDialog_CCI")); rangeAxis1.setAutoRangeIncludesZero(false); // override default rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars DecimalFormat format = new DecimalFormat("0"); rangeAxis1.setNumberFormatOverride(format); final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date")); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#"))); plot.setRenderer(0, renderer1); org.yccheok.jstock.charting.Utils.setPriceSeriesPaint(renderer1); price_volume_ta_map.put(taEx, plot); } if (candlestick_ta_map.containsKey(taEx) == false) { try { /* Not sure why. I cannot make priceVolumeChart and candlestickChart sharing the same * plot. If not, this will inhibit incorrect zooming behavior. */ candlestick_ta_map.put(taEx, (XYPlot) price_volume_ta_map.get(taEx).clone()); } catch (CloneNotSupportedException ex) { log.error(null, ex); } } if (this.activeTAExs.contains(taEx) == false) { // Avoid duplication. final XYPlot price_volume_ta = price_volume_ta_map.get(taEx); final XYPlot candlestick_ta = candlestick_ta_map.get(taEx); final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot(); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot(); if (price_volume_ta != null) cplot0.add(price_volume_ta, 1); // weight is 1. if (candlestick_ta != null) cplot1.add(candlestick_ta, 1); // weight is 1. org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.priceVolumeChart); org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.candlestickChart); } } else { final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot(); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot(); final XYPlot price_volume_ta = price_volume_ta_map.get(taEx); final XYPlot candlestick_ta = candlestick_ta_map.get(taEx); if (price_volume_ta != null) cplot0.remove(price_volume_ta); if (candlestick_ta != null) cplot1.remove(candlestick_ta); } if (show && this.activeTAExs.contains(taEx) == false) { this.activeTAExs.add(taEx); JStock.instance().getChartJDialogOptions().add(taEx); } else if (!show) { this.activeTAExs.remove(taEx); JStock.instance().getChartJDialogOptions().remove(taEx); } }
From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java
private void updateMACD(MACD.Period period, boolean show) { if (this.priceVolumeChart == null) { this.priceVolumeChart = this.createPriceVolumeChart(this.priceDataset, this.volumeDataset); }/* w ww. j ava 2s . c o m*/ if (this.candlestickChart == null) { this.candlestickChart = this.createCandlestickChart(this.priceOHLCDataset); } final TAEx taEx = TAEx.newInstance(TA.MACD, period); if (show) { if (price_volume_ta_map.containsKey(taEx) == false) { final MACD.ChartResult macdChartResult = org.yccheok.jstock.charting.TechnicalAnalysis .createMACD(this.chartDatas, getMACDKey(period), period); // MACD! NumberAxis rangeAxis1 = new NumberAxis(GUIBundle.getString("ChartJDialog_MACD")); rangeAxis1.setAutoRangeIncludesZero(false); // override default rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars DecimalFormat format = new DecimalFormat("0.00#"); rangeAxis1.setNumberFormatOverride(format); final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date")); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); XYPlot plot = new XYPlot(macdChartResult.outMACD, timeAxis, rangeAxis1, null); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#"))); plot.setRenderer(0, renderer1); org.yccheok.jstock.charting.Utils.setPriceSeriesPaint(renderer1); // MACD SIGNAL! plot.setDataset(1, macdChartResult.outMACDSignal); XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false); renderer2.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#"))); plot.setRenderer(1, renderer2); // VOLUME! //plot.setRangeAxis(1, rangeAxis1); plot.setDataset(2, macdChartResult.outMACDHist); //plot.mapDatasetToRangeAxis(1, 1); XYBarRenderer renderer3 = new XYBarRenderer(0.20); renderer3.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00"))); plot.setRenderer(2, renderer3); price_volume_ta_map.put(taEx, plot); } if (candlestick_ta_map.containsKey(taEx) == false) { try { /* Not sure why. I cannot make priceVolumeChart and candlestickChart sharing the same * plot. If not, this will inhibit incorrect zooming behavior. */ candlestick_ta_map.put(taEx, (XYPlot) price_volume_ta_map.get(taEx).clone()); } catch (CloneNotSupportedException ex) { log.error(null, ex); } } if (this.activeTAExs.contains(taEx) == false) { // Avoid duplication. final XYPlot price_volume_ta = price_volume_ta_map.get(taEx); final XYPlot candlestick_ta = candlestick_ta_map.get(taEx); final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot(); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot(); if (price_volume_ta != null) cplot0.add(price_volume_ta, 1); // weight is 1. if (candlestick_ta != null) cplot1.add(candlestick_ta, 1); // weight is 1. org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.priceVolumeChart); org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.candlestickChart); } } else { final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot(); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot(); final XYPlot price_volume_ta = price_volume_ta_map.get(taEx); final XYPlot candlestick_ta = candlestick_ta_map.get(taEx); if (price_volume_ta != null) cplot0.remove(price_volume_ta); if (candlestick_ta != null) cplot1.remove(candlestick_ta); } if (show && this.activeTAExs.contains(taEx) == false) { this.activeTAExs.add(taEx); JStock.instance().getChartJDialogOptions().add(taEx); } else if (!show) { this.activeTAExs.remove(taEx); JStock.instance().getChartJDialogOptions().remove(taEx); } }
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java
private JFreeChart createXYZBubbleChart(String title, String xLabel, String yLabel, XYZDataset dataset) { JFreeChart chart = ChartFactory.createBubbleChart(title, xLabel, yLabel, dataset, orientation, true, true, false);/*from w ww . ja v a 2 s .c o m*/ XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); //renderer.setLegendItemLabelGenerator(new SOCRXYZSeriesLabelGenerator()); // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerMargin(0.15); domainAxis.setUpperMargin(0.15); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:whitebox.stats.Kriging.java
/** * Draw Semivariogram surface map and also draw the search are if * Anisotropic//w ww . ja va2 s . co m * * @param Radius * @param AnIsotropic */ public void DrawSemivariogramSurface(double Radius, boolean AnIsotropic) { double[][] data = new double[3][BinSurface.length * BinSurface[0].length]; int n = 0; double max = Double.MIN_VALUE; for (int i = 0; i < BinSurface.length; i++) { for (int j = 0; j < BinSurface[i].length; j++) { data[0][n] = BinSurface[i][j].GridHorDistance; data[1][n] = BinSurface[i][j].GridVerDistance; if ((Math.pow(data[0][n], 2) + Math.pow(data[1][n], 2)) <= Radius * Radius && !Double.isNaN(BinSurface[i][j].Value)) { data[2][n] = BinSurface[i][j].Value; if (max < data[2][n]) { max = data[2][n]; } } else { data[2][n] = -1; } n++; } } DefaultXYZDataset dataset = new DefaultXYZDataset(); dataset.addSeries("Value", data); NumberAxis xAxis = new NumberAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth(LagSize); renderer.setBlockHeight(LagSize); renderer.setBlockAnchor(RectangleAnchor.CENTER); LookupPaintScale paintScale = new LookupPaintScale(0, max, Color.white); double colorRange = max / 6; //double colorRange = 23013; paintScale.add(0.0, Color.blue); paintScale.add(1 * colorRange, Color.green); paintScale.add(2 * colorRange, Color.cyan); paintScale.add(3 * colorRange, Color.yellow); paintScale.add(4 * colorRange, Color.ORANGE); paintScale.add(5 * colorRange, Color.red); renderer.setPaintScale(paintScale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); if (AnIsotropic) { CombinedRangeXYPlot combinedrangexyplot = new CombinedRangeXYPlot(); XYSeries seriesT1 = new XYSeries("1"); XYSeriesCollection AngleCollct = new XYSeriesCollection(); double bw = BandWidth; double r = bw / Math.sin(Tolerance); if (r > Radius) { bw = Radius * Math.sin(Tolerance); r = Radius; } seriesT1.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance)); if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) { if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) { double a = (1 + Math.pow(Math.tan(Angle), 2)); double b = 2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2); double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2) - Math.pow(Radius, 2); double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y1 = Math.tan(Angle) * (x1 + bw / Math.sin(Angle)); double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y2 = Math.tan(Angle) * (x2 + bw / Math.sin(Angle)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x2, y2); } } else { double x1 = -bw * Math.sin(Angle); double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x1, y2); } } } else { double y1 = bw * Math.cos(Angle); double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); if (d1 < d2) { seriesT1.add(x1, y1); } else { seriesT1.add(x2, y1); } } AngleCollct.addSeries(seriesT1); XYSeries seriesT2 = new XYSeries("2"); seriesT2.add(r * Math.cos(Angle + Tolerance), r * Math.sin(Angle + Tolerance)); seriesT2.add(0.0, 0.0); AngleCollct.addSeries(seriesT2); XYSeries seriesT3 = new XYSeries("3"); seriesT3.add(Radius * Math.cos(Angle), Radius * Math.sin(Angle)); seriesT3.add(0, 0); AngleCollct.addSeries(seriesT3); XYSeries seriesT4 = new XYSeries("4"); seriesT4.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance)); seriesT4.add(0, 0); AngleCollct.addSeries(seriesT4); XYSeries seriesT5 = new XYSeries("5"); seriesT5.add(r * Math.cos(Angle - Tolerance), r * Math.sin(Angle - Tolerance)); if ((double) Math.round(Math.sin(Angle) * 10000) / 10000 != 0) { if ((double) Math.round(Math.cos(Angle) * 10000) / 10000 != 0) { double a = (1 + Math.pow(Math.tan(Angle), 2)); double b = -2 * bw / Math.sin(Angle) * Math.pow(Math.tan(Angle), 2); double c = Math.pow(Math.tan(Angle), 2) * Math.pow(bw / Math.sin(Angle), 2) - Math.pow(Radius, 2); double x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y1 = Math.tan(Angle) * (x1 - bw / Math.sin(Angle)); double x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); double y2 = Math.tan(Angle) * (x2 - bw / Math.sin(Angle)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x2, y2); } } else { double x1 = bw * Math.sin(Angle); double y1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double y2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(x1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y2), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x1, y2); } } } else { double y1 = -bw * Math.cos(Angle); double x1 = Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double x2 = -Math.sqrt(Math.pow(Radius, 2) - Math.pow(y1, 2)); double d1 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x1), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); double d2 = Math.sqrt((Math.pow((Radius * Math.cos(Angle) - x2), 2)) + (Math.pow((Radius * Math.sin(Angle) - y1), 2))); if (d1 < d2) { seriesT5.add(x1, y1); } else { seriesT5.add(x2, y1); } } AngleCollct.addSeries(seriesT5); plot.setDataset(1, AngleCollct); XYLineAndShapeRenderer lineshapRend = new XYLineAndShapeRenderer(true, false); for (int i = 0; i < AngleCollct.getSeriesCount(); i++) { //plot.getRenderer().setSeriesPaint(i , Color.BLUE); lineshapRend.setSeriesPaint(i, Color.BLACK); } plot.setRenderer(1, lineshapRend); combinedrangexyplot.add(plot); } plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart chart = new JFreeChart("Semivariogram Surface", plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); // create and display a frame... ChartFrame frame = new ChartFrame("", chart); frame.pack(); //frame.setSize(100, 50); frame.setVisible(true); }
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java
private JFreeChart createXYLineChart(String title, String xLabel, String yLabel, XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data orientation, // orientation true, // include legend true, // tooltips false // urls );/*ww w .ja va 2 s . c om*/ chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setNoDataMessage("No data available"); // customise the renderer... XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // customise the range axis... if (lineCondition.indexOf("qq") != -1) { renderer.setBaseShapesFilled(true); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0); return chart; } NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (timeType.length() != 0) { setDateAxis(plot); } else { NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(false); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } // System.out.println("lineCondition "+lineCondition); if (lineCondition.indexOf("noshape") != -1) renderer.setBaseShapesVisible(false); else renderer.setBaseShapesVisible(true); if (lineCondition.indexOf("noline") != -1) renderer.setBaseLinesVisible(false); if (lineCondition.indexOf("nofill") != -1) { renderer.setBaseShapesFilled(false); renderer.setBaseFillPaint(Color.white); renderer.setDrawOutlines(true); } else { renderer.setBaseShapesFilled(true); renderer.setUseFillPaint(false); } return chart; }
From source file:gda.plots.SimplePlot.java
private void initAxis(NumberAxis axis, boolean autoRange, NumberFormat formatter) { axis.setAutoRange(autoRange);/*from w w w . ja v a2s .c om*/ axis.setLowerMargin(0.); axis.setUpperMargin(0.); axis.setAutoRangeIncludesZero(false); axis.setNumberFormatOverride(formatter); }
From source file:org.jfree.chart.ChartFactory.java
/** * Creates a stacked XY area plot. The chart object returned by this * method uses an {@link XYPlot} instance as the plot, with a * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the * range axis, and a {@link StackedXYAreaRenderer2} as the renderer. * * @param title the chart title ({@code null} permitted). * @param xAxisLabel a label for the X-axis ({@code null} permitted). * @param yAxisLabel a label for the Y-axis ({@code null} permitted). * @param dataset the dataset for the chart ({@code null} permitted). * * @return A stacked XY area chart./* w w w .j a va2 s . c om*/ */ public static JFreeChart createStackedXYAreaChart(String title, String xAxisLabel, String yAxisLabel, TableXYDataset dataset) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator(); StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(toolTipGenerator, null); renderer.setOutline(true); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setRangeAxis(yAxis); // forces recalculation of the axis range JFreeChart chart = new JFreeChart(title, plot); currentTheme.apply(chart); return chart; }