List of usage examples for org.jfree.chart.axis NumberAxis setTickLabelFont
public void setTickLabelFont(Font font)
From source file:org.sbml.bargraph.MainWindow.java
/** * Creates an empty bar graph.// w w w . java 2 s. co m * @return */ public JFreeChart createModelBarGraph() { // Initialize the style. Have to do this before creating charts. BarRenderer.setDefaultShadowsVisible(false); ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); // Create the actual chart. chartData = new DefaultCategoryDataset(); JFreeChart chart = ChartFactory.createBarChart(null, // chart title null, // domain axis label "Total count", // range axis label chartData, // data PlotOrientation.HORIZONTAL, // orientation false, // include legend false, // tooltips? false // URLs? ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, new Color(0, 101, 178)); return chart; }
From source file:com.att.aro.main.ProperSessionTerminationPanel.java
/** * Initializes the Panel for Proper Session Termination plot. *///from w w w . j av a 2 s . com private void initialize() { JFreeChart chart = ChartFactory.createBarChart(rb.getString("overview.sessionoverview.title"), null, null, createDataset(null), PlotOrientation.HORIZONTAL, false, false, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(1.0f); domainAxis.setMaximumCategoryLabelLines(2); domainAxis.setLabelFont(AROUIManager.LABEL_FONT); domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(rb.getString("analysisresults.percentage")); rangeAxis.setRange(0.0, 100.0); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String sessionInfo = ""; switch (arg2) { case SESSION_TERMINATION: sessionInfo = rb.getString("tooltip.sessionTermination"); break; case SESSION_TIGHT_CONN: sessionInfo = rb.getString("tooltip.sessionTightConn"); break; case SESSION_BURST: sessionInfo = rb.getString("tooltip.sessionBurst"); break; case SESSION_LONG_BURST: sessionInfo = rb.getString("tooltip.sessionLongBurst"); break; } return sessionInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100, 100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER, PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); this.add(chartPanel, BorderLayout.CENTER); }
From source file:com.att.aro.main.TraceOverviewPanel.java
/** * Initializes the Main panel and its various components. */// ww w .j ava 2 s . c om private void initialize() { JFreeChart chart = ChartFactory.createBarChart(rb.getString("overview.traceoverview.title"), null, null, createDataset(null), PlotOrientation.HORIZONTAL, false, true, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis valueRangeAxis = plot.getDomainAxis(); valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f); valueRangeAxis.setMaximumCategoryLabelLines(2); valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT); valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(rb.getString("analysisresults.percentile")); rangeAxis.setRange(0.0, 100.0); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String traceInfo = ""; switch (arg2) { case TRACE_AVERAGE: traceInfo = rb.getString("tooltip.traceAnalysis.avg"); break; case TRACE_ENERGY: traceInfo = rb.getString("tooltip.traceAnalysis.engy"); break; case TRACE_OVERHEAD: traceInfo = rb.getString("tooltip.traceAnalysis.ovrhd"); break; } return traceInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); ChartPanel chartPanel = new ChartPanel(chart, WIDTH, HEIGHT, ChartPanel.DEFAULT_MINIMUM_DRAW_WIDTH + 100, 100, ChartPanel.DEFAULT_MAXIMUM_DRAW_WIDTH, ChartPanel.DEFAULT_MAXIMUM_DRAW_HEIGHT, USER_BUFFER, PROPERTIES, COPY, SAVE, PRINT, ZOOM, TOOL_TIPS); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); this.add(chartPanel, BorderLayout.CENTER); }
From source file:ecg.ecgshow.ECGShowUI.java
private void createECGData(long timeZone) { ECGData = new JPanel(new GridLayout(LEAD_COUNT, 1)); dateAxises = new DateAxis[LEAD_COUNT]; ECGSeries = new TimeSeries[LEAD_COUNT * 2]; for (int i = 0; i < LEAD_COUNT; i++) { TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); //XYDataset TimeSeriesCollection ECGSeries[i] = new TimeSeries("?" + (i + 1)); ECGSeries[i].setMaximumItemCount(500); ECGSeries[i + LEAD_COUNT] = new TimeSeries(""); ECGSeries[i + LEAD_COUNT].setMaximumItemAge(timeZone); ECGSeries[i + LEAD_COUNT].setMaximumItemCount(2); timeseriescollection.addSeries(ECGSeries[i]); timeseriescollection.addSeries(ECGSeries[i + LEAD_COUNT]); //DateAxis dateaxis = new DateAxis("Time"); dateAxises[i] = new DateAxis(""); dateAxises[i].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); dateAxises[i].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); dateAxises[i].setTickLabelsVisible(true); dateAxises[i].setVisible(false); //NumberAxis numberaxis = new NumberAxis("ecg"); NumberAxis numberaxis = new NumberAxis("ecg"); numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setVisible(false);/*from w w w . ja va2 s . com*/ numberaxis.setLowerBound(1500D); numberaxis.setUpperBound(3000D); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); // xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2)); xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5)); XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[i], numberaxis, xylineandshaperenderer); xyplot.setBackgroundPaint(Color.LIGHT_GRAY); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setBackgroundPaint(Color.BLACK); JFreeChart jfreechart = new JFreeChart(xyplot); jfreechart.setBackgroundPaint(new Color(237, 237, 237));//? jfreechart.getLegend().setVisible(false); ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 46 / 100), (int) (HEIGHT * 17 / 100), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0 , BorderFactory.createEmptyBorder() //???? )); chartpanel.setMouseZoomable(false); //? ECGData.add(chartpanel); } }
From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java
private void updateChart(SimpleFeatureCollection features, String[] fields) { // Setup Box plot int fontStyle = java.awt.Font.BOLD; FontData fontData = getShell().getDisplay().getSystemFont().getFontData()[0]; CategoryAxis xPlotAxis = new CategoryAxis(EMPTY); // Type xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 12)); NumberAxis yPlotAxis = new NumberAxis("Value"); // Value //$NON-NLS-1$ yPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); yPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10)); yPlotAxis.setAutoRangeIncludesZero(false); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setMedianVisible(true);// ww w. j a va 2 s .c om renderer.setMeanVisible(false); renderer.setFillBox(true); renderer.setSeriesFillPaint(0, java.awt.Color.CYAN); renderer.setBaseFillPaint(java.awt.Color.CYAN); renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); // Set the scatter data, renderer, and axis into plot CategoryDataset dataset = getDataset(features, fields); CategoryPlot plot = new CategoryPlot(dataset, xPlotAxis, yPlotAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setRangePannable(false); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setForegroundAlpha(0.85f); // Map the scatter to the first Domain and first Range plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); // 3. Setup Selection /***************************************************************************************** * CategoryAxis xSelectionAxis = new CategoryAxis(EMPTY); * xSelectionAxis.setTickMarksVisible(false); xSelectionAxis.setTickLabelsVisible(false); * * NumberAxis ySelectionAxis = new NumberAxis(EMPTY); * ySelectionAxis.setTickMarksVisible(false); ySelectionAxis.setTickLabelsVisible(false); * * BoxAndWhiskerRenderer selectionRenderer = new BoxAndWhiskerRenderer(); * selectionRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 6, 6)); * selectionRenderer.setSeriesPaint(0, java.awt.Color.RED); // dot * * plot.setDataset(2, new DefaultBoxAndWhiskerCategoryDataset()); plot.setRenderer(2, * selectionRenderer); plot.setDomainAxis(2, xSelectionAxis); plot.setRangeAxis(2, * ySelectionAxis); * * // Map the scatter to the second Domain and second Range plot.mapDatasetToDomainAxis(2, * 0); plot.mapDatasetToRangeAxis(2, 0); *****************************************************************************************/ // 5. Finally, Create the chart with the plot and a legend java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20); JFreeChart chart = new JFreeChart(EMPTY, titleFont, plot, false); chart.setBackgroundPaint(java.awt.Color.WHITE); chart.setBorderVisible(false); chartComposite.setChart(chart); chartComposite.forceRedraw(); }
From source file:playground.christoph.evacuation.analysis.AgentsInMunicipalityEventsHandler.java
private JFreeChart getGraphic() { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries insideSerie = new XYSeries("total inside area", false, true); final XYSeries residentsSerie = new XYSeries("residents inside area", false, true); final XYSeries commutersSerie = new XYSeries("commuters inside area", false, true); for (int i = 0; i < plotData.size(); i++) { PlotData pd = plotData.get(i);//w w w .j a v a 2 s .com double hour = pd.time / 3600.0; insideSerie.add(hour, pd.commuterAgentCount + pd.residentAgentCount); residentsSerie.add(hour, pd.residentAgentCount); commutersSerie.add(hour, pd.commuterAgentCount); } xyData.addSeries(insideSerie); xyData.addSeries(residentsSerie); xyData.addSeries(commutersSerie); final JFreeChart chart = ChartFactory.createXYStepChart("agents inside area", "time [hour]", "# agents", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); NumberAxis na = new NumberAxis("time [hour]"); na.setRange(0, maxTime / 3600.0); na.setLabelFont(plot.getRangeAxis().getLabelFont()); na.setTickLabelFont(plot.getRangeAxis().getTickLabelFont()); plot.setDomainAxis(na); return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.XYCharts.SimpleBlockChart.java
/** * Creates a chart for the specified dataset. * /* w w w . j a v a2s.c om*/ * @param dataset the dataset. * * @return A chart instance. */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); XYZDataset dataset = (XYZDataset) datasets.getDatasets().get("1"); JFreeChart chart = null; NumberAxis xAxis = new NumberAxis(xLabel); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (xLowerBound != null && xUpperBound != null) { xAxis.setLowerBound(xLowerBound); xAxis.setUpperBound(xUpperBound); } else { xAxis.setAutoRange(true); } xAxis.setAxisLinePaint(Color.white); xAxis.setTickMarkPaint(Color.white); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { xAxis.setLabelFont(addLabelsStyle.getFont()); xAxis.setLabelPaint(addLabelsStyle.getColor()); } NumberAxis yAxis = new NumberAxis(yLabel); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (yLowerBound != null && yUpperBound != null) { yAxis.setLowerBound(yLowerBound); yAxis.setUpperBound(yUpperBound); } else yAxis.setAutoRange(true); yAxis.setAxisLinePaint(Color.white); yAxis.setTickMarkPaint(Color.white); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { yAxis.setLabelFont(addLabelsStyle.getFont()); yAxis.setLabelPaint(addLabelsStyle.getColor()); } XYBlockRenderer renderer = new XYBlockRenderer(); PaintScale paintScale = null; if (grayPaintScale) { paintScale = new GrayPaintScale(minScaleValue, maxScaleValue); } else { if (scaleLowerBound != null && scaleUpperBound != null) { paintScale = new LookupPaintScale(scaleLowerBound, scaleUpperBound, Color.gray); } else { paintScale = new LookupPaintScale(minScaleValue, maxScaleValue, Color.gray); } for (int i = 0; i < zRangeArray.length; i++) { ZRange zRange = zRangeArray[i]; ((LookupPaintScale) paintScale).add(zRange.getValue().doubleValue(), zRange.getColor()); } } renderer.setPaintScale(paintScale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setForegroundAlpha(0.66f); chart = new JFreeChart(plot); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } chart.removeLegend(); NumberAxis scaleAxis = new NumberAxis(zLabel); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7)); if (scaleLowerBound != null && scaleUpperBound != null) { scaleAxis.setLowerBound(scaleLowerBound); scaleAxis.setUpperBound(scaleUpperBound); } else scaleAxis.setAutoRange(true); if (addLabelsStyle != null && addLabelsStyle.getFont() != null) { scaleAxis.setLabelFont(addLabelsStyle.getFont()); scaleAxis.setLabelPaint(addLabelsStyle.getColor()); } if (blockHeight != null && blockWidth != null) { renderer.setBlockWidth(blockWidth.doubleValue()); renderer.setBlockHeight(blockHeight.doubleValue()); } PaintScaleLegend legend = new PaintScaleLegend(paintScale, scaleAxis); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); legend.setMargin(new RectangleInsets(5, 5, 5, 5)); legend.setFrame(new BlockBorder(Color.black)); legend.setPadding(new RectangleInsets(10, 10, 10, 10)); legend.setStripWidth(10); legend.setPosition(RectangleEdge.RIGHT); legend.setBackgroundPaint(color); chart.addSubtitle(legend); // chart.setBackgroundPaint(new Color(180, 180, 250)); chart.setBackgroundPaint(color); logger.debug("OUT"); return chart; }
From source file:ecg.ecgshow.ECGShowUI.java
private void createPressureData(long timeZone) { PressureData = new JPanel(); PressuredateAxises = new DateAxis[1]; SystolicPressureSeries = new TimeSeries[2]; DiastolicPressureSeries = new TimeSeries[2]; TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); SystolicPressureSeries[0] = new TimeSeries(""); SystolicPressureSeries[0].setMaximumItemAge(timeZone); SystolicPressureSeries[0].setMaximumItemCount(500); SystolicPressureSeries[1] = new TimeSeries(""); SystolicPressureSeries[1].setMaximumItemAge(timeZone); SystolicPressureSeries[1].setMaximumItemCount(2); timeseriescollection.addSeries(SystolicPressureSeries[0]); timeseriescollection.addSeries(SystolicPressureSeries[1]); PressuredateAxises[0] = new DateAxis(""); PressuredateAxises[0].setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); PressuredateAxises[0].setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); PressuredateAxises[0].setTickLabelsVisible(true); PressuredateAxises[0].setVisible(false); DiastolicPressureSeries[0] = new TimeSeries(""); DiastolicPressureSeries[0].setMaximumItemAge(timeZone); DiastolicPressureSeries[0].setMaximumItemCount(500); DiastolicPressureSeries[1] = new TimeSeries(""); DiastolicPressureSeries[1].setMaximumItemAge(timeZone); DiastolicPressureSeries[1].setMaximumItemCount(2); timeseriescollection.addSeries(DiastolicPressureSeries[0]); timeseriescollection.addSeries(DiastolicPressureSeries[1]); NumberAxis numberaxis = new NumberAxis("Pressure"); numberaxis.setTickLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.016))); numberaxis.setLabelFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.018))); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setVisible(false);/*ww w .j ava 2 s. c o m*/ numberaxis.setLowerBound(0D); numberaxis.setUpperBound(200D); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.GREEN); // xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2)); // xylineandshaperenderer.setSeriesPaint(1, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(5)); xylineandshaperenderer.setSeriesPaint(2, Color.ORANGE); // xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2)); // xylineandshaperenderer.setSeriesPaint(3, Color.LIGHT_GRAY); // xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(5)); //XYPlot xyplot = new XYPlot(timeseriescollection, PressuredateAxises[0], numberaxis, xylineandshaperenderer); XYPlot xyplot = new XYPlot(timeseriescollection, dateAxises[0], numberaxis, xylineandshaperenderer); xyplot.setBackgroundPaint(Color.LIGHT_GRAY); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setBackgroundPaint(Color.BLACK); JFreeChart jfreechart = new JFreeChart(xyplot); jfreechart.setBackgroundPaint(new Color(237, 237, 237));//? jfreechart.getLegend().setVisible(false); ChartPanel chartpanel = new ChartPanel(jfreechart, (int) (WIDTH * 0.155), (int) (HEIGHT * 0.18), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0) //??0 , BorderFactory.createEmptyBorder() //???? )); chartpanel.setMouseZoomable(false); PressureData.add(chartpanel); }
From source file:org.pf.midea.SimulationController.java
@Override public void run() { textAreaNumeric.setText(""); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); double progress = 0; double progressStep = 100.0 / (planCells.length * (hSquareHigh - hSquareLow + hSquareStep) / hSquareStep); progressBar.setValue(0);//from w ww .j av a 2 s .co m for (int i = 0; i < planCells.length; i++) { XYSeries xySeries; if (showLineNumbers) xySeries = new XYSeries(String.valueOf(i + 1) + ") " + planCells[i].getShortDescription()); else xySeries = new XYSeries(planCells[i].getShortDescription()); textAreaNumeric.append(planCells[i].getDescription() + "\n"); textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength()); PlanStates.SourceType currentSourceType = planCells[i].getSourceCell().getSourceType(); PlanStates.CodeType currentCodeType = planCells[i].getCodeCell().getCodeType(); PlanStates.ModulationType currentModulationType = planCells[i].getModulationCell().getModulationType(); PlanStates.ChannelType currentChannelType = planCells[i].getChannelCell().getChannelType(); PlanStates.ErrorsType currentErrorsType = planCells[i].getErrorsCell().getErrorsType(); BinaryNumber[] sourcePoints = null; switch (currentSourceType) { case ST_TEST: sourcePoints = ConstellationPointsGenerator.getTestPoints(currentModulationType, iterationsCount); break; case ST_RANDOM: sourcePoints = ConstellationPointsGenerator.getRandomPoints(currentModulationType, iterationsCount); break; } Coder coder = null; Decoder decoder = null; switch (currentCodeType) { case CT_NONE: coder = new CoderNone(); decoder = new DecoderNone(); break; case CT_HAMMING74: coder = new CoderHamming74(); decoder = new DecoderHamming74(); break; case CT_CYCLIC: coder = new CoderCyclic85(); decoder = new DecoderCyclic85(); break; case CT_BCH155: coder = new CoderBCH155(); decoder = new DecoderBCH155(); break; } Modulator modulator = null; Demodulator demodulator = null; switch (currentModulationType) { case MT_ASK: modulator = new ModulatorASK(); demodulator = new DemodulatorASK(); break; case MT_FSK: modulator = new ModulatorFSK(); demodulator = new DemodulatorFSK(); break; case MT_BPSK: modulator = new ModulatorBPSK(); demodulator = new DemodulatorBPSK(); break; case MT_QPSK: modulator = new ModulatorQPSK(); demodulator = new DemodulatorQPSK(); break; case MT_8PSK: modulator = new Modulator8PSK(); demodulator = new Demodulator8PSK(); break; case MT_16PSK: modulator = new Modulator16PSK(); demodulator = new Demodulator16PSK(); break; case MT_32PSK: modulator = new Modulator32PSK(); demodulator = new Demodulator32PSK(); break; case MT_16QAM: modulator = new Modulator16QAM(); demodulator = new Demodulator16QAM(); break; case MT_32QAM: modulator = new Modulator32QAM(); demodulator = new Demodulator32QAM(); break; case MT_64QAM: modulator = new Modulator64QAM(); demodulator = new Demodulator64QAM(); break; case MT_256QAM: modulator = new Modulator256QAM(); demodulator = new Demodulator256QAM(); break; } Channel channel = null; switch (currentChannelType) { case CHT_AWGN: channel = new ChannelAWGN(); break; case CHT_RAYLEIGH: channel = new ChannelRayleigh(); break; } BinaryNumber[] encoded = coder.encode(sourcePoints); Signal[] modulated = modulator.modulate(encoded); double error = 0; for (double h = hSquareLow; h <= hSquareHigh; h += hSquareStep) { double realH; if (dBs) realH = StatisticsTools.decibelsToTimes(h); else realH = h; Signal[] noised = channel.noise(realH, modulated); BinaryNumber[] demodulated = demodulator.demodulate(noised); noised = null; System.gc(); BinaryNumber[] decoded = decoder.decode(demodulated); demodulated = null; System.gc(); switch (currentErrorsType) { case ET_SER: error = StatisticsTools.getSER(sourcePoints, decoded); break; case ET_BER: error = StatisticsTools.getBER(sourcePoints, decoded); break; } decoded = null; System.gc(); if (error > 0) { xySeries.add(h, error); textAreaNumeric.append(String.valueOf(h) + "\t" + String.valueOf(error) + "\n"); textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength()); } progress += progressStep; progressBar.setValue((int) Math.round(progress)); } xySeriesCollection.addSeries(xySeries); textAreaNumeric.append("\n"); textAreaNumeric.setCaretPosition(textAreaNumeric.getDocument().getLength()); } JFreeChart chart = ChartFactory.createXYLineChart("", dBs ? "" : "", "?", xySeriesCollection, PlotOrientation.VERTICAL, true, true, false); chart.getLegend().setPosition(RectangleEdge.RIGHT); XYPlot xyPlot = chart.getXYPlot(); for (int i = 0; i < planCells.length; i++) { xyPlot.getRenderer().setSeriesStroke(i, new BasicStroke(planCells[i].getLineWidth())); if (planCells[i].getLineColor() != null) xyPlot.getRenderer().setSeriesPaint(i, planCells[i].getLineColor()); if (showLineNumbers) { XYSeries currentSeries = xySeriesCollection.getSeries(i); double annotationY = currentSeries.getY(0).doubleValue(); double annotationX = currentSeries.getX(0).doubleValue(); for (int j = 1; j < currentSeries.getItemCount(); j++) if (currentSeries.getY(j).doubleValue() == 0) { annotationY = currentSeries.getY(j - 1).doubleValue(); annotationX = currentSeries.getX(j - 1).doubleValue(); break; } else { annotationY = currentSeries.getY(j).doubleValue(); annotationX = currentSeries.getX(j).doubleValue(); } XYTextAnnotation annotation = new XYTextAnnotation(String.valueOf(i + 1), annotationX, annotationY); annotation.setBackgroundPaint(Color.WHITE); annotation.setFont(new Font("Dialog", 0, 14)); xyPlot.addAnnotation(annotation); } } xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); NumberAxis domainAxis = new NumberAxis("h, " + (dBs ? "" : "")); LogAxis rangeAxis = new LogAxis("?"); rangeAxis.setNumberFormatOverride(new HumanNumberFormat(1)); domainAxis.setTickLabelFont(new Font("Dialog", 0, 14)); rangeAxis.setTickLabelFont(new Font("Dialog", 0, 14)); xyPlot.setDomainAxis(domainAxis); xyPlot.setRangeAxis(rangeAxis); ChartPanel nestedPanel = new ChartPanel(chart); chartPanel.removeAll(); chartPanel.add(nestedPanel, new CellConstraints()); chartPanel.updateUI(); }
From source file:com.att.aro.ui.view.overviewtab.TraceBenchmarkChartPanel.java
private JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createBarChart( ResourceBundleHelper.getMessageString("overview.traceoverview.title"), null, null, createDataset(), PlotOrientation.HORIZONTAL, false, true, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis valueRangeAxis = plot.getDomainAxis(); valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f); valueRangeAxis.setMaximumCategoryLabelLines(2); valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT); valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentile")); rangeAxis.setRange(0.0, 100.0);//ww w . ja v a2s . c o m rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String traceInfo = ""; switch (arg2) { case TRACE_AVERAGE: traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.avg"); break; case TRACE_ENERGY: traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.engy"); break; case TRACE_OVERHEAD: traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.ovrhd"); break; default: break; } return traceInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); return chart; }