List of usage examples for org.jfree.chart JFreeChart getCategoryPlot
public CategoryPlot getCategoryPlot()
From source file:playground.dgrether.signalsystems.cottbus.scripts.DgCottbusSignalPlanChartGenerator.java
/** * @param args//from w w w . ja v a 2s . c om */ public static void main(String[] args) { //parameters //cottbus String runId = "1224"; String baseDir = DgPaths.REPOS + "runs-svn/"; int iteration = 500; Id<SignalSystem> signalSystemId = Id.create(18, SignalSystem.class); double startSecond = 23135.0; double endSecond = startSecond + 3600.0; startSecond = 8.0 * 3600.0; endSecond = startSecond + 3600.0; baseDir = baseDir + "run" + runId; //cottbus football runId = "1222_100_football_fans"; baseDir = DgPaths.REPOS + "runs-svn/run1222/100_football_fans"; iteration = 500; startSecond = 17.0 * 3600.0; endSecond = startSecond + 3600.0; signalSystemId = Id.create(1, SignalSystem.class); // koehler strehler 2010 // runId = null; // baseDir = "/media/data/work/matsimOutput/koehlerStrehler2010Scenario5SelectBest/"; // iteration = 20; // signalSystemId = Id.create(5); // startSecond = 0.0; // endSecond = 900.0; // //skript OutputDirectoryHierarchy io = null; if (runId != null) io = new OutputDirectoryHierarchy(baseDir, runId.toString(), false ? OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists); else io = new OutputDirectoryHierarchy(baseDir, false ? OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles : OutputDirectoryHierarchy.OverwriteFileSetting.failIfDirectoryExists); String eventsFilename = io.getIterationFilename(iteration, "events.xml.gz"); DgSignalEventsCollector eventsCollector = new DgSignalEventsCollector(); EventsManager events = EventsUtils.createEventsManager(); events.addHandler(eventsCollector); MatsimEventsReader eventsReader = new MatsimEventsReader(events); eventsReader.readFile(eventsFilename); SortedSet<SignalGroupStateChangedEvent> systemEvents = eventsCollector.getSignalGroupEventsBySystemIdMap() .get(signalSystemId); log.info("Number of events for system " + signalSystemId + " is: " + systemEvents.size()); for (SignalGroupStateChangedEvent e : systemEvents) { if (e.getTime() >= startSecond && e.getTime() <= endSecond) log.debug(e); } // DgSignalPlanChart chart = new DgSignalPlanChart(startSecond, endSecond); chart.addData(systemEvents); JFreeChart jfChart = chart.createSignalPlanChart("System plan", "group", "time"); String chartFileName = io.getIterationFilename(iteration, "signal_plan_system_" + signalSystemId + "_from_" + startSecond + "_to_" + endSecond); int rowCount = jfChart.getCategoryPlot().getDataset().getRowCount(); int width = (int) (endSecond - startSecond) * 3; writeToPng(chartFileName, jfChart, width, rowCount * 3 + 50); }
From source file:com.jaxzin.iraf.demo.CdfInv.java
private static void customizeChart(JFreeChart chart) { // Set the transparency of the histogram bars chart.getCategoryPlot().setForegroundAlpha(0.5f); // Lock the y-axis to 0.0->0.5 ValueAxis axis = new NumberAxis("Value"); axis.setAutoRange(true);/*from ww w .ja v a 2 s . co m*/ chart.getCategoryPlot().setRangeAxis(axis); // Lock the x-axis to -6.0->6.0 CategoryAxis domainAxis = new CategoryAxis("Probability"); domainAxis.setTickLabelsVisible(false); chart.getCategoryPlot().setDomainAxis(domainAxis); }
From source file:br.unesp.rc.desafio.utils.Utils.java
public static void createBar(DefaultCategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Grafico", " ", " ", dataset); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartFrame frame = new ChartFrame("Grafico de BArras", chart); frame.setVisible(true);/* w w w . j a va 2s . c o m*/ //frame.setSize(400,350); ManagerGUI.centralizar(frame); }
From source file:br.unesp.rc.desafio.utils.Utils.java
public static void createLine(DefaultCategoryDataset dataset) { JFreeChart chart = ChartFactory.createLineChart("Grafico", " ", " ", dataset); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.black); ChartFrame frame = new ChartFrame("Grafico de BArras", chart); frame.setVisible(true);//from w w w . j av a2s . com frame.setSize(400, 350); ManagerGUI.centralizar(frame); }
From source file:spectrex.Charts.java
/** * @param data initial data for chart creation * @param title text which would be displayed at the top of the frame and in * the frame's title//from w w w . ja va2s. c o m * @param columnLabel text which would be displayed on the left of the * Y-axis * @param rowLabel text which would be displayed under X-axis * @param frameSize size of chart frame * @return Bar chart JFrame link * @author ReaLgressA */ public static JFrame createBarChart(ChartData data, String title, String columnLabel, String rowLabel, Dimension frameSize) { JFreeChart chart = ChartFactory.createStackedBarChart(title, columnLabel, rowLabel, data.getDataset(), PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame(title, chart, true); frame.setVisible(true); frame.setSize(frameSize); frame.setResizable(true); return (JFrame) frame; }
From source file:net.sf.jsfcomp.chartcreator.utils.ChartAxisUtils.java
public static void createCategorySeriesAxis(JFreeChart chart, ChartAxisData chartAxisData, int axisIndex) { CategoryPlot plot = chart.getCategoryPlot(); if (chartAxisData.isDomain()) { CategoryAxis axis = new CategoryAxis(chartAxisData.getLabel()); axis.setTickLabelsVisible(chartAxisData.isTickLabels()); axis.setTickMarksVisible(chartAxisData.isTickMarks()); if (chartAxisData.getTickLabelFontSize() > 0) { Font tickFont = CategoryAxis.DEFAULT_TICK_LABEL_FONT .deriveFont(chartAxisData.getTickLabelFontSize()); axis.setTickLabelFont(tickFont); }//from w ww .j ava 2s .c om if (chartAxisData.isVerticalTickLabels()) { axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); } plot.setDomainAxis(plot.getDomainAxisCount() - 1, axis); } else { ValueAxis axis = createNumberAxis(chart, chartAxisData); axis.setTickLabelsVisible(chartAxisData.isTickLabels()); axis.setTickMarksVisible(chartAxisData.isTickMarks()); if (chartAxisData.getTickLabelFontSize() > 0) { Font tickFont = CategoryAxis.DEFAULT_TICK_LABEL_FONT .deriveFont(chartAxisData.getTickLabelFontSize()); axis.setTickLabelFont(tickFont); } plot.setRangeAxis(axis); } }
From source file:com.sun.japex.report.ChartGenerator.java
static protected void configureLineChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); final DrawingSupplier supplier = new DefaultDrawingSupplier(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, // Draw a small diamond new Shape[] { new Polygon(new int[] { 3, 0, -3, 0 }, new int[] { 0, 3, 0, -3 }, 4) }); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDrawingSupplier(supplier);//w w w . ja v a 2s. com LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setStroke(new BasicStroke(2.0f)); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); }
From source file:br.unicamp.cst.util.ChartViewerUtil.java
public static synchronized ChartPanel createChart(DefaultCategoryDataset dataset, String title, String categoryAxisLabel, String valueAxisLabel, PlotOrientation chartType) { final JFreeChart chart = ChartFactory.createBarChart(title, categoryAxisLabel, valueAxisLabel, dataset, chartType, true, true, false); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); chart.setBackgroundPaint(Color.lightGray); ChartPanel localChartPanel = new ChartPanel(chart); localChartPanel.setVisible(true);//from w ww .j av a 2 s. com localChartPanel.setDomainZoomable(true); return localChartPanel; }
From source file:com.thalesgroup.hudson.plugins.sourcemonitor.SourceMonitorChartBuilder.java
public static JFreeChart buildChart(SourceMonitorBuildAction action) { JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, "Number of errors", buildDataset(action), PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null);//from ww w . j ava 2 s. co m plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); CategoryItemRenderer firstRender = new DefaultCategoryItemRenderer(); SourceMonitorRenderer renderer = new SourceMonitorRenderer(action.getUrlName()); plot.setRenderer(firstRender); return chart; }
From source file:org.jenkinsci.plugins.todos.TodosChartBuilder.java
/** * Build a trend chart from the provided data. * /*w w w . j a v a2 s .co m*/ * @param action * the build action * @return the trend chart */ public static JFreeChart buildChart(TodosBuildAction action) { String strComments = Messages.Todos_ReportSummary_Comments(); JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, strComments, buildDataset(action), PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); TodosAreaRenderer renderer = new TodosAreaRenderer(action.getUrlName()); plot.setRenderer(renderer); return chart; }