List of usage examples for org.jfree.chart.title TextTitle DEFAULT_FONT
Font DEFAULT_FONT
To view the source code for org.jfree.chart.title TextTitle DEFAULT_FONT.
Click Source Link
From source file:net.sf.jasperreports.components.spiderchart.SpiderChartDesignEvaluator.java
/** * /*from w ww. ja v a 2 s . c om*/ */ public static JRRenderable evaluateRenderer(ReportConverter reportConverter, JRComponentElement element) { SpiderChartComponent chartComponent = (SpiderChartComponent) element.getComponent(); ChartSettings chartSettings = chartComponent.getChartSettings(); SpiderPlot plot = chartComponent.getPlot(); SpiderWebPlot spiderWebPlot = new SpiderWebPlot(getSampleDataset()); if (plot.getAxisLineColor() != null) { spiderWebPlot.setAxisLinePaint(plot.getAxisLineColor()); } if (plot.getAxisLineWidth() != null) { spiderWebPlot.setAxisLineStroke(new BasicStroke(plot.getAxisLineWidth())); } if (plot.getBackcolor() != null) { spiderWebPlot.setBackgroundPaint(plot.getBackcolor()); } if (plot.getBackgroundAlpha() != null) { spiderWebPlot.setBackgroundAlpha(plot.getBackgroundAlpha()); } if (plot.getForegroundAlpha() != null) { spiderWebPlot.setForegroundAlpha(plot.getForegroundAlpha()); } if (plot.getHeadPercent() != null) { spiderWebPlot.setHeadPercent(plot.getHeadPercent()); } if (plot.getInteriorGap() != null) { spiderWebPlot.setInteriorGap(plot.getInteriorGap()); } if (plot.getLabelColor() != null) { spiderWebPlot.setLabelPaint(plot.getLabelColor()); } if (plot.getLabelFont() != null) { spiderWebPlot.setLabelFont(JRFontUtil.getAwtFont(plot.getLabelFont(), Locale.getDefault())); } if (plot.getLabelGap() != null) { spiderWebPlot.setAxisLabelGap(plot.getLabelGap()); } spiderWebPlot.setMaxValue(MAX_VALUE); if (plot.getRotation() != null) { spiderWebPlot.setDirection(plot.getRotation().getRotation()); } if (plot.getStartAngle() != null) { spiderWebPlot.setStartAngle(plot.getStartAngle()); } if (plot.getTableOrder() != null) { spiderWebPlot.setDataExtractOrder(plot.getTableOrder().getOrder()); } if (plot.getWebFilled() != null) { spiderWebPlot.setWebFilled(plot.getWebFilled()); } spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); spiderWebPlot.setLabelGenerator(new StandardCategoryItemLabelGenerator()); String titleText = JRExpressionUtil.getExpressionText(chartSettings.getTitleExpression()); Font titleFont = chartSettings.getTitleFont() != null ? JRFontUtil.getAwtFont(chartSettings.getTitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true); if (chartSettings.getBackcolor() != null) { jfreechart.setBackgroundPaint(chartSettings.getBackcolor()); } RectangleEdge titleEdge = getEdge(chartSettings.getTitlePosition(), RectangleEdge.TOP); if (titleText != null) { TextTitle title = jfreechart.getTitle(); title.setText(titleText); if (chartSettings.getTitleColor() != null) { title.setPaint(chartSettings.getTitleColor()); } title.setFont(titleFont); title.setPosition(titleEdge); jfreechart.setTitle(title); } String subtitleText = JRExpressionUtil.getExpressionText(chartSettings.getSubtitleExpression()); if (subtitleText != null) { TextTitle subtitle = new TextTitle(subtitleText); subtitle.setText(subtitleText); if (chartSettings.getSubtitleColor() != null) { subtitle.setPaint(chartSettings.getSubtitleColor()); } if (chartSettings.getSubtitleColor() != null) { Font subtitleFont = chartSettings.getSubtitleFont() != null ? JRFontUtil.getAwtFont(chartSettings.getSubtitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; subtitle.setFont(subtitleFont); } subtitle.setPosition(titleEdge); jfreechart.addSubtitle(subtitle); } // Apply all of the legend formatting options LegendTitle legend = jfreechart.getLegend(); if (legend != null) { legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend())); if (legend.isVisible()) { if (chartSettings.getLegendColor() != null) { legend.setItemPaint(chartSettings.getLegendColor()); } if (chartSettings.getLegendBackgroundColor() != null) { legend.setBackgroundPaint(chartSettings.getLegendBackgroundColor()); } if (chartSettings.getLegendFont() != null) { legend.setItemFont(JRFontUtil.getAwtFont(chartSettings.getLegendFont(), Locale.getDefault())); } legend.setPosition(getEdge(chartSettings.getLegendPosition(), RectangleEdge.BOTTOM)); } } Rectangle2D rectangle = new Rectangle2D.Double(0, 0, element.getWidth(), element.getHeight()); String renderType = chartSettings.getRenderType(); if (renderType == null) { renderType = JRProperties.getProperty(reportConverter.getReport(), JRChart.PROPERTY_CHART_RENDER_TYPE); } return ChartUtil.getChartRendererFactory(renderType).getRenderer(jfreechart, null, rectangle); }
From source file:edu.ucla.stat.SOCR.chart.demo.SpiderWebChartDemo1.java
/** * Creates a sample chart./* w w w.java2s .co m*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // get a reference to the plot for further customisation... SOCRSpiderWebPlot plot = new SOCRSpiderWebPlot(dataset); JFreeChart chart = new JFreeChart(chartTitle, TextTitle.DEFAULT_FONT, plot, false); LegendTitle legend = new LegendTitle(plot); legend.setPosition(RectangleEdge.BOTTOM); //renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); chart.addSubtitle(legend); setCategorySummary(dataset); if (legendPanelOn) chart.removeLegend(); return chart; }
From source file:net.sf.jasperreports.components.spiderchart.SpiderChartRendererEvaluator.java
/** * //from www.j av a 2 s .c o m */ public static Renderable evaluateRenderable(JasperReportsContext jasperReportsContext, JRComponentElement element, SpiderChartSharedBean spiderchartBean, ChartCustomizer chartCustomizer, String defaultRenderType, String datasetType) { SpiderChartComponent chartComponent = (SpiderChartComponent) element.getComponent(); ChartSettings chartSettings = chartComponent.getChartSettings(); SpiderPlot plot = (SpiderPlot) chartComponent.getPlot(); DefaultCategoryDataset dataset = null; StandardCategoryItemLabelGenerator labelGenerator = null; if (FILL_DATASET.equals(datasetType)) { dataset = ((FillSpiderDataset) spiderchartBean.getDataset()).getCustomDataset(); labelGenerator = ((FillSpiderDataset) spiderchartBean.getDataset()).getLabelGenerator(); } else { dataset = getSampleDataset(); labelGenerator = new StandardCategoryItemLabelGenerator(); } SpiderWebPlot spiderWebPlot = new SpiderWebPlot(dataset); if (plot.getAxisLineColor() != null) { spiderWebPlot.setAxisLinePaint(plot.getAxisLineColor()); } if (plot.getAxisLineWidth() != null) { spiderWebPlot.setAxisLineStroke(new BasicStroke(plot.getAxisLineWidth())); } if (plot.getBackcolor() != null) { spiderWebPlot.setBackgroundPaint(plot.getBackcolor()); } if (plot.getBackgroundAlpha() != null) { spiderWebPlot.setBackgroundAlpha(plot.getBackgroundAlpha()); } if (plot.getForegroundAlpha() != null) { spiderWebPlot.setForegroundAlpha(plot.getForegroundAlpha()); } if (plot.getHeadPercent() != null) { spiderWebPlot.setHeadPercent(plot.getHeadPercent()); } if (plot.getInteriorGap() != null) { spiderWebPlot.setInteriorGap(plot.getInteriorGap()); } if (plot.getLabelColor() != null) { spiderWebPlot.setLabelPaint(plot.getLabelColor()); } if (plot.getLabelFont() != null) { spiderWebPlot.setLabelFont(FontUtil.getInstance(jasperReportsContext).getAwtFont(plot.getLabelFont(), Locale.getDefault())); } if (plot.getLabelGap() != null) { spiderWebPlot.setAxisLabelGap(plot.getLabelGap()); } if (spiderchartBean.getMaxValue() != null) { spiderWebPlot.setMaxValue(spiderchartBean.getMaxValue()); } if (plot.getRotation() != null) { spiderWebPlot.setDirection(plot.getRotation().getRotation()); } if (plot.getStartAngle() != null) { spiderWebPlot.setStartAngle(plot.getStartAngle()); } if (plot.getTableOrder() != null) { spiderWebPlot.setDataExtractOrder(plot.getTableOrder().getOrder()); } if (plot.getWebFilled() != null) { spiderWebPlot.setWebFilled(plot.getWebFilled()); } spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); spiderWebPlot.setLabelGenerator(labelGenerator); Font titleFont = chartSettings.getTitleFont() != null ? FontUtil.getInstance(jasperReportsContext) .getAwtFont(chartSettings.getTitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; String titleText = spiderchartBean.getTitleText(); JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true); Color backcolor = chartSettings.getBackcolor() != null ? chartSettings.getBackcolor() : element.getBackcolor(); if (backcolor != null) { jfreechart.setBackgroundPaint(backcolor); } RectangleEdge titleEdge = getEdge(chartSettings.getTitlePosition(), RectangleEdge.TOP); if (titleText != null) { TextTitle title = jfreechart.getTitle(); title.setText(titleText); if (chartSettings.getTitleColor() != null) { title.setPaint(chartSettings.getTitleColor()); } title.setFont(titleFont); title.setPosition(titleEdge); jfreechart.setTitle(title); } String subtitleText = spiderchartBean.getSubtitleText(); if (subtitleText != null) { TextTitle subtitle = new TextTitle(subtitleText); subtitle.setText(subtitleText); if (chartSettings.getSubtitleColor() != null) { subtitle.setPaint(chartSettings.getSubtitleColor()); } if (chartSettings.getSubtitleColor() != null) { Font subtitleFont = chartSettings.getSubtitleFont() != null ? FontUtil.getInstance(jasperReportsContext).getAwtFont(chartSettings.getSubtitleFont(), Locale.getDefault()) : TextTitle.DEFAULT_FONT; subtitle.setFont(subtitleFont); } subtitle.setPosition(titleEdge); jfreechart.addSubtitle(subtitle); } // Apply all of the legend formatting options LegendTitle legend = jfreechart.getLegend(); if (legend != null) { legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend())); if (legend.isVisible()) { if (chartSettings.getLegendColor() != null) { legend.setItemPaint(chartSettings.getLegendColor()); } if (chartSettings.getLegendBackgroundColor() != null) { legend.setBackgroundPaint(chartSettings.getLegendBackgroundColor()); } if (chartSettings.getLegendFont() != null) { legend.setItemFont(FontUtil.getInstance(jasperReportsContext) .getAwtFont(chartSettings.getLegendFont(), Locale.getDefault())); } legend.setPosition(getEdge(chartSettings.getLegendPosition(), RectangleEdge.BOTTOM)); } } String renderType = chartSettings.getRenderType() == null ? defaultRenderType : chartSettings.getRenderType(); Rectangle2D rectangle = new Rectangle2D.Double(0, 0, element.getWidth(), element.getHeight()); if (chartCustomizer != null) { chartCustomizer.customize(jfreechart, chartComponent); } return ChartUtil.getInstance(jasperReportsContext).getChartRenderableFactory(renderType) .getRenderable(jasperReportsContext, jfreechart, spiderchartBean.getHyperlinkProvider(), rectangle); }
From source file:piramide.interaction.reasoner.FuzzyReasonerWizardFacade.java
@Override public void generateMembershipFunctionGraph(boolean isInput, boolean isDevices, String variableName, RegionDistributionInfo[] linguisticTerms, OutputStream destination, int width, int height, Geolocation geo, DecayFunctions decayFunction, Calendar when) { BufferedImage img;/*from www . j ava 2s.c om*/ if (variableName == null) { img = createErrorMessagesImage("Error generating graph: variableName not provided"); } else if (linguisticTerms == null) { img = createErrorMessagesImage("Error generating graph: linguisticTerms not provided"); } else if (isInput && isDevices && !isValidDeviceVariableName(variableName)) { img = createErrorMessagesImage("Error generating graph: invalid device variable name: " + variableName); } else if (isInput && !isDevices && !isValidUserVariableName(variableName)) { img = createErrorMessagesImage("Error generating graph: invalid user variable name: " + variableName); } else { try { final WarningStore warningStore = new WarningStore(); final net.sourceforge.jFuzzyLogic.rule.Variable variable = processVariable(isInput, isDevices, variableName, linguisticTerms, geo, decayFunction, when, warningStore); final JFreeChart theChart = variable.chart(false); final String[] messages = warningStore.getMessages(); if (messages.length > 0) { final Font font = TextTitle.DEFAULT_FONT; final Font bigBold = new Font(font.getName(), Font.BOLD, font.getSize() + 2); final Font bold = new Font(font.getName(), Font.BOLD, font.getSize()); theChart.addSubtitle(new TextTitle("WARNINGS:", bigBold, Color.RED, Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING)); for (String message : messages) theChart.addSubtitle(new TextTitle(message, bold, Color.RED, Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING)); } img = theChart.createBufferedImage(width, height); } catch (FuzzyReasonerException e) { e.printStackTrace(); img = createErrorMessagesImage("Error generating graph: " + e.getMessage()); } } try { final ImageEncoder myEncoder = ImageEncoderFactory.newInstance("png"); myEncoder.encode(img, destination); destination.flush(); destination.close(); } catch (IOException e) { // Cry e.printStackTrace(); return; } }
From source file:org.sonar.server.charts.jruby.TrendsChart.java
@Override protected BufferedImage getChartImage() throws IOException { JFreeChart chart = new JFreeChart(null, TextTitle.DEFAULT_FONT, plot, true); configureChart(chart, displayLegend ? RectangleEdge.BOTTOM : null); return super.getBufferedImage(chart); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.XYChartExpression.java
protected XYChartExpression() { domainPeriodCount = 0;/*from w w w . java2s.com*/ titlePositionText = "top"; borderPaint = Color.BLACK; horizontal = false; stacked = false; domainVerticalTickLabels = false; domainIncludesZero = false; domainStickyZero = false; rangeIncludesZero = true; rangeStickyZero = true; domainTitle = null; domainTitleFont = TextTitle.DEFAULT_FONT; domainTickFont = null; domainTickFormat = null; domainMinimum = 0; domainMaximum = 1; domainAxisAutoRange = true; rangeTitle = null; rangeTitleFont = TextTitle.DEFAULT_FONT; rangeMinimum = 0; rangeMaximum = 1; rangeAxisAutoRange = true; }
From source file:com.xpn.xwiki.plugin.charts.params.DefaultChartParams2.java
void setTitle(String prefix) throws ParamException { set(prefix + TITLE_SUFFIX, ""); // ? set(prefix + TITLE_BACKGROUND_COLOR_SUFFIX, (Color) null); set(prefix + TITLE_POSITION_SUFFIX, Title.DEFAULT_POSITION); set(prefix + TITLE_HORIZONTAL_ALIGNMENT_SUFFIX, Title.DEFAULT_HORIZONTAL_ALIGNMENT); set(prefix + TITLE_VERTICAL_ALIGNMENT_SUFFIX, Title.DEFAULT_VERTICAL_ALIGNMENT); set(prefix + TITLE_COLOR_SUFFIX, TextTitle.DEFAULT_TEXT_PAINT); set(prefix + TITLE_FONT_SUFFIX, TextTitle.DEFAULT_FONT); set(prefix + TITLE_PADDING_SUFFIX, Title.DEFAULT_PADDING); }
From source file:org.squale.squaleweb.util.graph.KiviatMaker.java
/** * Create the JreeChart object/*from w w w . j av a 2 s . co m*/ * * @param showLegend indicate if it should display the legend or not * @param showBackground indicate if we want showBackground * @return The JreeChart object */ public JFreeChart getChart(boolean showLegend, boolean showBackground) { JFreeChart retChart = super.getChart(); // Creation of the graph if it not already exist if (null == retChart) { // Creation of the plot SpiderWebPlot plot = new SpiderWebPlot(mDataset); // Creation of the picture. The plot is inside the picture retChart = new JFreeChart(mTitle, TextTitle.DEFAULT_FONT, plot, false); // Display of the legend if (showLegend) { LegendTitle legendtitle = new LegendTitle(plot); legendtitle.setPosition(RectangleEdge.BOTTOM); retChart.addSubtitle(legendtitle); } // Definition of the style of the three first draw in the spiderWEbPlot. // This three first draw represent the scale for the mark 1.0, 2.0 and 3.0 in the plot // First we define the style final float miterLimit = 10.0f; final float[] dashPattern = { 5.0f, 3.0f }; BasicStroke dash = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, // End cap BasicStroke.JOIN_MITER, // Join style miterLimit, // Miter limit dashPattern, // Dash pattern 0.0f); // We associate this style to the draw plot.setSeriesPaint(0, new Color(WebMessages.getInt("kiviat.color.1"))); plot.setSeriesOutlineStroke(0, dash); plot.setSeriesPaint(1, new Color(WebMessages.getInt("kiviat.color.2"))); plot.setSeriesOutlineStroke(1, dash); plot.setSeriesPaint(2, new Color(WebMessages.getInt("kiviat.color.3"))); plot.setSeriesOutlineStroke(2, dash); // Define the gap what is draw and the border of the plot plot.setInteriorGap(DEFAULT_GAP); // Define the style of the line stroke plot.setBaseSeriesOutlineStroke(new BasicStroke(2.0f)); // The max value put in the plot (for the scale) plot.setMaxValue(SCALE_MAX_VALUE); // Indicate if we want fill the inner of the draw plot.setWebFilled(FILL_RADAR); if (!showBackground) { // Set the background of the picture to white retChart.setBackgroundPaint(Color.WHITE); // Set the border of the plot to white plot.setOutlinePaint(Color.WHITE); } super.setChart(retChart); } return retChart; }
From source file:org.emftrace.quarc.ui.views.RatioView.java
/** * create a SpiderChart /*from w w w .j av a 2s . c om*/ * @param dataset the dataset for the chart * @param weighted include weights? * @return the created SpiderChart */ private JFreeChart createSpiderChart(DefaultCategoryDataset dataset, boolean weighted) { SpiderWebPlot plot = new SpiderWebPlot(dataset); plot.setMaxValue(200.0f); plot.setStartAngle(54); plot.setInteriorGap(0.40); plot.setToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset dataset, int section, int index) { Float ratingValue = (Float) dataset.getValue(section, index); if (ratingValue == null) ratingValue = 0.0f; else ratingValue -= 100.0f; return String.valueOf("(" + dataset.getRowKey(section) + "," + dataset.getColumnKey(index) + ") = " + String.format("%.2f", ratingValue)); } }); plot.setNoDataMessage("No data to display"); String titleStr = "ratings of selected elements"; if (weighted) titleStr = "weighted " + titleStr; JFreeChart chart = new JFreeChart(titleStr, TextTitle.DEFAULT_FONT, plot, false); LegendTitle legend = new LegendTitle(plot); legend.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legend); ChartUtilities.applyCurrentTheme(chart); return chart; }
From source file:org.ash.history.TopActivityPreview.java
/** * Creates the chart.//from ww w . ja va2s. c o m * * @return the j free chart */ private JFreeChart createChart() { xAxis = new DateAxis("time"); xAxis.setLabel(null); chart = ChartFactory.createStackedXYAreaChart(this.title, // chart title "X Value", // domain axis label "Active Sessions", // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation xAxis, false, // legend true, // tooltips false // urls ); chart.getTitle() .setFont(new Font(TextTitle.DEFAULT_FONT.getFontName(), TextTitle.DEFAULT_FONT.getStyle(), 14)); plot = (XYPlot) chart.getPlot(); StackedXYAreaRenderer3 renderer = new StackedXYAreaRenderer3(); renderer.setRoundXCoordinates(true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} ({1}, {2})", new SimpleDateFormat("HH:mm"), new DecimalFormat("0.0"))); plot.setRenderer(0, renderer); plot.getRangeAxis().setLowerBound(0.0); plot.getRangeAxis().setAutoRange(true); // add a labelled marker for the cpu_count thresholdMaxCpu = new ValueMarker(this.maxCpu); thresholdMaxCpu.setLabelOffsetType(LengthAdjustmentType.EXPAND); thresholdMaxCpu.setPaint(Color.red); thresholdMaxCpu.setStroke(new BasicStroke(1.0f)); thresholdMaxCpu.setLabel("Maximum CPU"); thresholdMaxCpu.setLabelFont(new Font("SansSerif", Font.PLAIN, 11)); thresholdMaxCpu.setLabelPaint(Color.red); thresholdMaxCpu.setLabelAnchor(RectangleAnchor.TOP_LEFT); thresholdMaxCpu.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); plot.addRangeMarker(thresholdMaxCpu); renderer.setSeriesPaint(0, Options.getInstance().getColor(Options.getInstance().getResource("cpuLabel.text")), true); renderer.setSeriesPaint(1, Options.getInstance().getColor(Options.getInstance().getResource("schedulerLabel.text")), true); renderer.setSeriesPaint(2, Options.getInstance().getColor(Options.getInstance().getResource("userIOLabel.text")), true); renderer.setSeriesPaint(3, Options.getInstance().getColor(Options.getInstance().getResource("systemIOLabel.text")), true); renderer.setSeriesPaint(4, Options.getInstance().getColor(Options.getInstance().getResource("concurrencyLabel.text")), true); renderer.setSeriesPaint(5, Options.getInstance().getColor(Options.getInstance().getResource("applicationsLabel.text")), true); renderer.setSeriesPaint(6, Options.getInstance().getColor(Options.getInstance().getResource("commitLabel.text")), true); renderer.setSeriesPaint(7, Options.getInstance().getColor(Options.getInstance().getResource("configurationLabel.text")), true); renderer.setSeriesPaint(8, Options.getInstance().getColor(Options.getInstance().getResource("administrativeLabel.text")), true); renderer.setSeriesPaint(9, Options.getInstance().getColor(Options.getInstance().getResource("networkLabel.text")), true); renderer.setSeriesPaint(11, Options.getInstance().getColor(Options.getInstance().getResource("queueningLabel.text")), true);//que renderer.setSeriesPaint(10, Options.getInstance().getColor(Options.getInstance().getResource("clusterLabel.text")), true);//cluster renderer.setSeriesPaint(12, Options.getInstance().getColor(Options.getInstance().getResource("otherLabel.text")), true); return chart; }