List of usage examples for org.jfree.chart JFreeChart setTitle
public void setTitle(String text)
From source file:it.eng.spagobi.engines.chart.bo.charttypes.blockcharts.TimeBlockChart.java
@Override public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); super.createChart(datasets); DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1"); DateAxis xAxis = new DateAxis(yLabel); xAxis.setLowerMargin(0.0);//from w ww. j a v a 2 s . c o m xAxis.setUpperMargin(0.0); xAxis.setInverted(false); xAxis.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy")); if (dateAutoRange) { xAxis.setAutoRange(true); } else { DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 1, formatter); xAxis.setTickUnit(unit); } if (dateMin != null && dateMax != null) { xAxis.setRange(dateMin, addDay(dateMax)); } else { xAxis.setRange(minDateFound, addDay(maxDateFound)); } // Calendar c=new GregorianCalendar(); // c.set(9 + 2000, Calendar.JANUARY, 1); // java.util.Date minima=c.getTime(); // Calendar c1=new GregorianCalendar(); // c1.set(9 + 2000, Calendar.FEBRUARY, 1); // java.util.Date massima=c1.getTime(); NumberAxis yAxis = new NumberAxis(xLabel); yAxis.setUpperMargin(0.0); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setRange(hourMin, hourMax); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth(BLOCK_HEIGHT); // one block for each minute! renderer.setBlockHeight(0.017); //renderer.setBlockWidth(1); renderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT); // MyXYItemLabelGenerator my=new MyXYItemLabelGenerator(); // renderer.setItemLabelsVisible(null); // renderer.setSeriesItemLabelGenerator(0, my); // renderer.setSeriesItemLabelsVisible(0, true); // XYTextAnnotation annotation1 = new XYTextAnnotation( // "P_",1.2309372E12, 14.3); // XYTextAnnotation annotation2 = new XYTextAnnotation( // "P_",1.2308508E12, 16.3); for (Iterator iterator = annotations.keySet().iterator(); iterator.hasNext();) { String annotationCode = (String) iterator.next(); AnnotationBlock annotationBlock = annotations.get(annotationCode); XYTextAnnotation xyAnnotation = new XYTextAnnotation(annotationBlock.getAnnotation(), annotationBlock.getXPosition() + ANNOTATION_HEIGHT, annotationBlock.getYPosition()); if (styleAnnotation != null) { xyAnnotation.setFont(new Font(styleAnnotation.getFontName(), Font.BOLD, styleAnnotation.getSize())); xyAnnotation.setPaint(styleAnnotation.getColor()); } else { xyAnnotation.setFont(new Font("Nome", Font.BOLD, 8)); xyAnnotation.setPaint(Color.BLACK); } xyAnnotation.setTextAnchor(TextAnchor.BOTTOM_LEFT); renderer.addAnnotation(xyAnnotation); } logger.debug("Annotation set"); LookupPaintScale paintScale = new LookupPaintScale(0.5, ranges.size() + 0.5, color); String[] labels = new String[ranges.size() + 1]; labels[0] = ""; // ******************** SCALE **************************** for (Iterator iterator = ranges.iterator(); iterator.hasNext();) { RangeBlocks range = (RangeBlocks) iterator.next(); Integer index = patternRangeIndex.get(range.getPattern()); Color color = range.getColor(); if (color != null) { //Paint colorTransparent=new Color(color.getRed(), color.getGreen(), color.getBlue(), 50); Paint colorTransparent = null; if (addTransparency == true) { colorTransparent = new Color(color.getRed(), color.getGreen(), color.getBlue(), 50); } else { colorTransparent = new Color(color.getRed(), color.getGreen(), color.getBlue()); } paintScale.add(index + 0.5, colorTransparent); } //String insertLabel=" "+range.getLabel(); String insertLabel = range.getLabel(); labels[index + 1] = insertLabel; } renderer.setPaintScale(paintScale); SymbolAxis scaleAxis = new SymbolAxis(null, labels); scaleAxis.setRange(0.5, ranges.size() + 0.5); scaleAxis.setPlot(new PiePlot()); scaleAxis.setGridBandsVisible(false); org.jfree.chart.title.PaintScaleLegend psl = new PaintScaleLegend(paintScale, scaleAxis); psl.setMargin(new RectangleInsets(3, 10, 3, 10)); psl.setPosition(RectangleEdge.BOTTOM); psl.setAxisOffset(5.0); // ******************** END SCALE **************************** logger.debug("Scale Painted"); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); logger.debug("Plot set"); JFreeChart chart = new JFreeChart(name, plot); if (styleTitle != null) { TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); } chart.removeLegend(); chart.setBackgroundPaint(Color.white); chart.addSubtitle(psl); logger.debug("OUT"); return chart; }
From source file:eremeykin.pete.plotter.CartesianPlotterTopComponent.java
JFreeChart createChart(XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(" ?", // chart title "???", // x axis label "", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/* w w w . j ava 2 s.co m*/ chart.setTitle(new org.jfree.chart.title.TextTitle(" ?", new java.awt.Font("Arial", java.awt.Font.PLAIN, 16))); chart.setBackgroundPaint(Color.white); plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesShapesVisible(2, false); renderer.setSeriesShapesVisible(3, false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesPaint(2, Color.BLUE); renderer.setSeriesPaint(3, Color.BLACK); // renderer.setSeriesStroke(1, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {6.0f, 6.0f}, 0.0f )); plot.setRenderer(renderer); return chart; }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.fft.impl.AveragingFFTCanvas.java
/*********************************************************************************************** * Initialise this UIComponent.//from w w w . ja va 2 s .c o m */ public void initialiseUI() { final Border compoundBorder; super.initialiseUI(); removeAll(); setBackground(getBackgroundColour().getColor()); setOpaque(true); // Make sure that the Canvas uses all available space... setPreferredSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); // Add a Border to the Canvas panel compoundBorder = BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); setBorder(compoundBorder); // There is only ever one Chart, a special version with no Toolbar setChartViewer(new LogLinChartUIComponent(getHostFrameUI().getHostTask(), getHostInstrument(), "FFT", null, REGISTRY.getFrameworkResourceKey(), DataUpdateType.PRESERVE, REGISTRY.getIntegerProperty( getHostInstrument().getHostAtom().getResourceKey() + KEY_DISPLAY_DATA_MAX), -1000.0, 1000.0, -1000.0, 1000.0) { final static long serialVersionUID = -2433194350569140263L; /********************************************************************************** * Customise the XYPlot of a new chart, e.g. for fixed range axes. * * @param datasettype * @param primarydataset * @param secondarydatasets * @param updatetype * @param displaylimit * @param channelselector * @param debug * * @return JFreeChart */ public JFreeChart createCustomisedChart(final DatasetType datasettype, final XYDataset primarydataset, final List<XYDataset> secondarydatasets, final DataUpdateType updatetype, final int displaylimit, final ChannelSelectorUIComponentInterface channelselector, final boolean debug) { final JFreeChart jFreeChart; jFreeChart = super.createCustomisedChart(datasettype, primarydataset, secondarydatasets, updatetype, displaylimit, channelselector, debug); // Remove all labels jFreeChart.setTitle(EMPTY_STRING); if ((jFreeChart.getXYPlot() != null) && (jFreeChart.getXYPlot().getDomainAxis() != null)) { jFreeChart.getXYPlot().getDomainAxis().setLabel(EMPTY_STRING); } if ((jFreeChart.getXYPlot() != null) && (jFreeChart.getXYPlot().getRangeAxis() != null)) { jFreeChart.getXYPlot().getRangeAxis().setLabel(EMPTY_STRING); } return (jFreeChart); } /********************************************************************************** * Initialise the Chart. */ public synchronized void initialiseUI() { final String SOURCE = "ChartUIComponent.initialiseUI() "; setChannelSelector(false); setDatasetDomainControl(false); super.initialiseUI(); // Indicate if the Chart can Autorange, and is currently Autoranging setCanAutorange(true); setLinearMode(true); // Configure the Chart for this specific use if (getChannelSelectorOccupant() != null) { getChannelSelectorOccupant().setAutoranging(true); getChannelSelectorOccupant().setLinearMode(true); getChannelSelectorOccupant().setDecimating(false); getChannelSelectorOccupant().setLegend(false); getChannelSelectorOccupant().setShowChannels(false); getChannelSelectorOccupant().debugSelector(LOADER_PROPERTIES.isChartDebug(), SOURCE); } } }); getChartViewer().initialiseUI(); add((Component) getChartViewer(), BorderLayout.CENTER); }
From source file:org.jax.bham.test.HaplotypeAssociationTestGraphPanel.java
private void repaintGraphNow() { int[] chromosomes = this.getSelectedChromosomes(); if (chromosomes.length == 1) { int chromosome = chromosomes[0]; final RealValuedBasePairInterval[] intervals = this.chromosomeToNegLogValueMap.get(chromosome); if (intervals != null) { HighlightedSnpInterval highlightedSnpInterval = new HighlightedSnpInterval(0, intervals.length, new int[0]); long startPosition = intervals[0].getStartInBasePairs(); long endPosition = startPosition; for (RealValuedBasePairInterval interval : intervals) { long currEndPosition = interval.getEndInBasePairs(); if (currEndPosition > endPosition) { endPosition = currEndPosition; }//w ww. j av a2 s.co m } JFreeChart jFreeChart = this.graphFactory.createSnpIntervalHistogram(Arrays.asList(intervals), startPosition, 1 + endPosition - startPosition, highlightedSnpInterval, "Base Pair Position", "-log10(p-value)"); jFreeChart.setTitle(this.testToPlot.getName() + " - Chromosome " + chromosome); this.chartPanel.setChart(jFreeChart); } } else { List<ChromosomeHistogramValues> chromoHistos = new ArrayList<ChromosomeHistogramValues>(); for (int chromosome : chromosomes) { final RealValuedBasePairInterval[] intervals = this.chromosomeToNegLogValueMap.get(chromosome); if (intervals != null) { HighlightedSnpInterval highlightedSnpInterval = new HighlightedSnpInterval(0, intervals.length, new int[0]); long startPosition = intervals[0].getStartInBasePairs(); long endPosition = startPosition; for (RealValuedBasePairInterval interval : intervals) { long currEndPosition = interval.getEndInBasePairs(); if (currEndPosition > endPosition) { endPosition = currEndPosition; } } ChromosomeHistogramValues chromosomeHistogramValues = new ChromosomeHistogramValues(chromosome, Arrays.asList(intervals), startPosition, 1 + endPosition - startPosition, highlightedSnpInterval); chromoHistos.add(chromosomeHistogramValues); } } JFreeChart jFreeChart = this.graphFactory.createMultiChromosomeHistogram(chromoHistos, "Chromosome Base Pair Position", "-log10(p-value)"); jFreeChart.setTitle(this.testToPlot.getName() + " - All Chromosomes"); this.chartPanel.setChart(jFreeChart); } }
From source file:org.sipfoundry.sipxconfig.site.cdr.CdrReports.java
private Image createCallDirectionCallsPieImage(List<CdrGraphBean> beans) { // Create a dataset DefaultKeyedValuesDataset data = new DefaultKeyedValuesDataset(); // Fill dataset with beans data for (CdrGraphBean directionCall : beans) { data.setValue(directionCall.getKey(), directionCall.getCount()); }/* ww w . j av a 2s. com*/ // Create a chart with the dataset JFreeChart chart = ChartFactory.createPieChart(EMPTY_TITLE, data, true, true, false); chart.setBackgroundPaint(Color.lightGray); chart.setTitle("Summary - " + getMessages().getMessage(TITLE_CALLDIRECTION_REPORT_KEY)); chart.getTitle().setPaint(Color.BLACK); PiePlot chartplot = (PiePlot) chart.getPlot(); chartplot.setCircular(true); chartplot.setLabelGenerator(new StandardPieSectionLabelGenerator(PIECHART_SECTIONLABEL_FORMAT)); // Create and return the image return chart.createBufferedImage(500, 220, BufferedImage.TYPE_INT_RGB, null); }
From source file:org.jax.bham.test.MultiHaplotypeBlockTestGraphPanel.java
private void repaintGraphNow() { int[] chromosomes = this.getSelectedChromosomes(); if (chromosomes.length == 1) { int chromosome = chromosomes[0]; final RealValuedBasePairInterval[] intervals = this.chromosomeToNegLogValueMap.get(chromosome); if (intervals != null) { HighlightedSnpInterval highlightedSnpInterval = new HighlightedSnpInterval(0, intervals.length, new int[0]); long startPosition = intervals[0].getStartInBasePairs(); long endPosition = startPosition; for (RealValuedBasePairInterval interval : intervals) { long currEndPosition = interval.getEndInBasePairs(); if (currEndPosition > endPosition) { endPosition = currEndPosition; }/* w ww .ja v a 2 s .c om*/ } JFreeChart jFreeChart = this.graphFactory.createSnpIntervalHistogram(Arrays.asList(intervals), startPosition, 1 + endPosition - startPosition, highlightedSnpInterval, "Base Pair Position", "-log10(p-value)"); jFreeChart.setTitle( this.testToPlot.getName() + " - Chromosome " + this.chromosomeComboBox.getSelectedItem()); this.chartPanel.setChart(jFreeChart); } } else { List<ChromosomeHistogramValues> chromoHistos = new ArrayList<ChromosomeHistogramValues>(); for (int chromosome : chromosomes) { final RealValuedBasePairInterval[] intervals = this.chromosomeToNegLogValueMap.get(chromosome); if (intervals != null) { HighlightedSnpInterval highlightedSnpInterval = new HighlightedSnpInterval(0, intervals.length, new int[0]); long startPosition = intervals[0].getStartInBasePairs(); long endPosition = startPosition; for (RealValuedBasePairInterval interval : intervals) { long currEndPosition = interval.getEndInBasePairs(); if (currEndPosition > endPosition) { endPosition = currEndPosition; } } ChromosomeHistogramValues chromosomeHistogramValues = new ChromosomeHistogramValues(chromosome, Arrays.asList(intervals), startPosition, 1 + endPosition - startPosition, highlightedSnpInterval); chromoHistos.add(chromosomeHistogramValues); } } JFreeChart jFreeChart = this.graphFactory.createMultiChromosomeHistogram(chromoHistos, "Chromosome Base Pair Position", "-log10(p-value)"); jFreeChart.setTitle(this.testToPlot.getName() + " - All Chromosomes"); this.chartPanel.setChart(jFreeChart); } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.LinkableBar.java
/** * Inherited by IChart.//from w ww.java 2s . c o m * * @param chartTitle the chart title * @param dataset the dataset * * @return the j free chart */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); CategoryDataset dataset = (CategoryDataset) datasets.getDatasets().get("1"); CategoryAxis categoryAxis = new CategoryAxis(categoryLabel); ValueAxis valueAxis = new NumberAxis(valueLabel); if (rangeIntegerValues == true) { valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } org.jfree.chart.renderer.category.BarRenderer renderer = new org.jfree.chart.renderer.category.BarRenderer(); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); // renderer.setBaseItemLabelFont(new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); // renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); if (showValueLabels) { renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); } if (maxBarWidth != null) { renderer.setMaximumBarWidth(maxBarWidth.doubleValue()); } boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true; MyCategoryUrlGenerator mycatUrl = new MyCategoryUrlGenerator(rootUrl); mycatUrl.setDocument_composition(document_composition); mycatUrl.setCategoryUrlLabel(categoryUrlName); mycatUrl.setSerieUrlLabel(serieUrlname); mycatUrl.setDrillDocTitle(drillDocTitle); mycatUrl.setTarget(target); renderer.setItemURLGenerator(mycatUrl); /* } else{ renderer.setItemURLGenerator(new StandardCategoryURLGenerator(rootUrl)); }*/ CategoryPlot plot = new CategoryPlot((CategoryDataset) dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); if (horizontalView) { plot.setOrientation(PlotOrientation.HORIZONTAL); } JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(color); // get a reference to the plot for further customisation... //CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); NumberFormat nf = NumberFormat.getNumberInstance(locale); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); rangeAxis.setNumberFormatOverride(nf); if (rangeAxisLocation != null) { if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); } else if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); } } // disable bar outlines... //BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); /* if(currentSeries!=null && colorMap!=null){ //for each serie selected int j=0; for (Iterator iterator = currentSeries.iterator(); iterator.hasNext();) { String s = (String) iterator.next(); Integer position=(Integer)seriesNumber.get(s); // check if for that position a value is defined if(colorMap.get("color"+position.toString())!=null){ Color col= (Color)colorMap.get("color"+position); renderer.setSeriesPaint(j, col); } j++; } // close for on series } // close case series selcted and color defined else{ if(colorMap!=null){ // if series not selected check color each one for (Iterator iterator = colorMap.keySet().iterator(); iterator.hasNext();) { String key = (String) iterator.next(); Color col= (Color)colorMap.get(key); String keyNum=key.substring(5, key.length()); int num=Integer.valueOf(keyNum).intValue(); num=num-1; renderer.setSeriesPaint(num, col); } } }*/ int seriesN = dataset.getRowCount(); if (orderColorVector != null && orderColorVector.size() > 0) { logger.debug("color serie by SERIES_ORDER_COLORS template specification"); for (int i = 0; i < seriesN; i++) { if (orderColorVector.get(i) != null) { Color color = orderColorVector.get(i); renderer.setSeriesPaint(i, color); } } } else if (colorMap != null) { for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getRowKey(i); Color color = (Color) colorMap.get(serieName); if (color != null) { renderer.setSeriesPaint(i, color); } } } CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); if (legend == true) drawLegend(chart); logger.debug("OUT"); return chart; }
From source file:org.jax.bham.test.PhylogenyAssociationTestGraphPanel.java
private void repaintGraphNow() { int[] chromosomes = this.getSelectedChromosomes(); if (chromosomes.length == 1) { final List<PhylogenyTestResult> intervals = this.chromosomeResultsCache.get(chromosomes[0]); if (intervals != null) { RealValuedBasePairInterval[] negLog10Intervals = this.toNegLogResults(intervals); HighlightedSnpInterval highlightedSnpInterval = new HighlightedSnpInterval(0, negLog10Intervals.length, new int[0]); long startPosition = negLog10Intervals[0].getStartInBasePairs(); long endPosition = startPosition; for (RealValuedBasePairInterval interval : negLog10Intervals) { long currEndPosition = interval.getEndInBasePairs(); if (currEndPosition > endPosition) { endPosition = currEndPosition; }/*from w ww .j ava 2 s . c o m*/ } JFreeChart jFreeChart = this.graphFactory.createSnpIntervalHistogram( Arrays.asList(negLog10Intervals), startPosition, 1 + endPosition - startPosition, highlightedSnpInterval, "Base Pair Position", "-log10(p-value)"); jFreeChart.setTitle( this.testToPlot.getName() + " - Chromosome " + this.chromosomeComboBox.getSelectedItem()); this.chartPanel.setChart(jFreeChart); } } else { List<ChromosomeHistogramValues> chromoHistos = new ArrayList<ChromosomeHistogramValues>(); for (int chromosome : chromosomes) { final RealValuedBasePairInterval[] intervals = this .toNegLogResults(this.chromosomeResultsCache.get(chromosome)); if (intervals != null) { HighlightedSnpInterval highlightedSnpInterval = new HighlightedSnpInterval(0, intervals.length, new int[0]); long startPosition = intervals[0].getStartInBasePairs(); long endPosition = startPosition; for (RealValuedBasePairInterval interval : intervals) { long currEndPosition = interval.getEndInBasePairs(); if (currEndPosition > endPosition) { endPosition = currEndPosition; } } ChromosomeHistogramValues chromosomeHistogramValues = new ChromosomeHistogramValues(chromosome, Arrays.asList(intervals), startPosition, 1 + endPosition - startPosition, highlightedSnpInterval); chromoHistos.add(chromosomeHistogramValues); } } JFreeChart jFreeChart = this.graphFactory.createMultiChromosomeHistogram(chromoHistos, "Chromosome Base Pair Position", "-log10(p-value)"); jFreeChart.setTitle(this.testToPlot.getName() + " - All Chromosomes"); this.chartPanel.setChart(jFreeChart); } }
From source file:ch.agent.crnickl.demo.stox.Chart.java
private JFreeChart makeChart() throws KeyedException { if (chartSeries.size() == 0) throw new IllegalStateException("addChartSeries() not called"); if (range == null) { for (ChartSeries s : chartSeries) { if (range == null) range = s.getTimeSeries().getRange(); else/*w w w .ja va 2s .c om*/ range = range.union(s.getTimeSeries().getRange()); } } // use number axis for dates, with special formatter DateAxis dateAxis = new DateAxis(); dateAxis.setDateFormatOverride(new CustomDateFormat("M/d/y")); if (range.getTimeDomain().getLabel().equals("workweek")) dateAxis.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); // combined plot with shared date axis CombinedDomainXYPlot plot = new CombinedDomainXYPlot(dateAxis); for (ChartSeries s : chartSeries) { makeSubPlot(plot, s); } // make the chart, remove the legend, set the title JFreeChart chart = new JFreeChart(plot); if (!withLegend) chart.removeLegend(); chart.setBackgroundPaint(Color.white); chart.setTitle(new TextTitle(title)); return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.OverlaidStackedBarLine.java
public JFreeChart createChart(DatasetMap datasets) { // create the first renderer... CategoryPlot plot = new CategoryPlot(); NumberFormat nf = NumberFormat.getNumberInstance(locale); NumberAxis rangeAxis = new NumberAxis(getValueLabel()); rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis/* w ww. java 2s .co m*/ .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); rangeAxis.setNumberFormatOverride(nf); plot.setRangeAxis(rangeAxis); if (rangeIntegerValues == true) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } CategoryAxis domainAxis = new CategoryAxis(getCategoryLabel()); domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); plot.setDomainAxis(domainAxis); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); DefaultCategoryDataset datasetBar = (DefaultCategoryDataset) datasets.getDatasets().get("stackedbar"); //I create one bar renderer and one line MyStandardCategoryItemLabelGenerator generator = null; if (additionalLabels) { generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance()); } if (useBars) { CategoryItemRenderer barRenderer = new StackedBarRenderer(); if (maxBarWidth != null) { ((BarRenderer) barRenderer).setMaximumBarWidth(maxBarWidth.doubleValue()); } if (additionalLabels) { barRenderer.setBaseItemLabelGenerator(generator); double orient = (-Math.PI / 2.0); if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) { orient = 0.0; } barRenderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); barRenderer.setBaseItemLabelPaint(styleValueLabels.getColor()); barRenderer.setBaseItemLabelsVisible(true); barRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); barRenderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); } if (colorMap != null) { for (Iterator iterator = datasetBar.getRowKeys().iterator(); iterator.hasNext();) { String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetBar.getRowIndex(labelName); } else index = datasetBar.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { barRenderer.setSeriesPaint(index, color); } } } // add tooltip if enabled if (enableToolTips) { MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips, seriesTooltip, categoriesTooltip, seriesCaptions); barRenderer.setToolTipGenerator(generatorToolTip); } //defines url for drill boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true; logger.debug("Calling Url Generation"); MyCategoryUrlGenerator mycatUrl = null; if (super.rootUrl != null) { logger.debug("Set MycatUrl"); mycatUrl = new MyCategoryUrlGenerator(super.rootUrl); mycatUrl.setDocument_composition(document_composition); mycatUrl.setCategoryUrlLabel(super.categoryUrlName); mycatUrl.setSerieUrlLabel(super.serieUrlname); mycatUrl.setDrillDocTitle(drillDocTitle); mycatUrl.setTarget(target); } if (mycatUrl != null) { barRenderer.setItemURLGenerator(mycatUrl); } plot.setDataset(1, datasetBar); plot.setRenderer(1, barRenderer); } if (useLines) { LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer(); //lineRenderer.setShapesFilled(false); lineRenderer.setShapesFilled(true); if (additionalLabels) { lineRenderer.setBaseItemLabelGenerator(generator); lineRenderer.setBaseItemLabelFont( new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); lineRenderer.setBaseItemLabelPaint(defaultLabelsStyle.getColor()); lineRenderer.setBaseItemLabelsVisible(true); } DefaultCategoryDataset datasetLine = (DefaultCategoryDataset) datasets.getDatasets().get("line"); if (enableToolTips) { MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips, seriesTooltip, categoriesTooltip, seriesCaptions); lineRenderer.setToolTipGenerator(generatorToolTip); } if (colorMap != null) { for (Iterator iterator = datasetLine.getRowKeys().iterator(); iterator.hasNext();) { String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetLine.getRowIndex(labelName); } else index = datasetLine.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { lineRenderer.setSeriesPaint(index, color); } } } plot.setDataset(0, datasetLine); plot.setRenderer(0, lineRenderer); } if (secondAxis) { NumberAxis na = new NumberAxis(secondAxisLabel); na.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); na.setLabelPaint(styleXaxesLabels.getColor()); na.setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); na.setTickLabelPaint(styleXaxesLabels.getColor()); na.setUpperMargin(0.10); if (rangeIntegerValues == true) { na.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } na.setNumberFormatOverride(nf); plot.setRangeAxis(1, na); plot.mapDatasetToRangeAxis(0, 1); } //plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); JFreeChart 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.setBackgroundPaint(Color.white); if (legend == true) drawLegend(chart); return chart; }