List of usage examples for java.awt BasicStroke BasicStroke
public BasicStroke(float width)
From source file:org.jfree.chart.demo.SurveyResultsDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart(null, null, null, categorydataset, PlotOrientation.HORIZONTAL, false, true, false); jfreechart.setBackgroundPaint(Color.white); TextTitle texttitle = new TextTitle( "Figure 7 | I. Resources - The site offers users relevant, informative and educational resources"); texttitle.setHorizontalAlignment(HorizontalAlignment.LEFT); texttitle.setBackgroundPaint(Color.red); texttitle.setPaint(Color.white); jfreechart.setTitle(texttitle);//from w ww. j a va 2s .c o m CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setOutlinePaint(null); categoryplot.setDomainGridlinesVisible(true); categoryplot.setDomainGridlinePosition(CategoryAnchor.END); categoryplot.setDomainGridlineStroke(new BasicStroke(0.5F)); categoryplot.setDomainGridlinePaint(Color.black); categoryplot.setRangeGridlinesVisible(false); categoryplot.clearRangeMarkers(); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setVisible(false); categoryaxis.setCategoryMargin(0.5D); categoryplot.getRangeAxis().setVisible(false); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setSeriesPaint(0, new Color(156, 164, 74)); barrenderer.setDrawBarOutline(false); barrenderer.setBaseItemLabelsVisible(true); barrenderer.setBaseItemLabelFont(new Font("SansSerif", 1, 10)); ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); barrenderer.setBasePositiveItemLabelPosition(itemlabelposition); CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation("1. White papers are available.", "Category 1", 0.0D); categorytextannotation.setFont(new Font("SansSerif", 1, 12)); categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation); CategoryTextAnnotation categorytextannotation1 = new CategoryTextAnnotation( "2. White papers enhance users understanding of the firm and its expertise.", "Category 2", 0.0D); categorytextannotation1.setFont(new Font("SansSerif", 0, 12)); categorytextannotation1.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation1.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation1); CategoryTextAnnotation categorytextannotation2 = new CategoryTextAnnotation( "3. White papers are relevant to the firm's prospects and clients.", "Category 3", 0.0D); categorytextannotation2.setFont(new Font("SansSerif", 0, 12)); categorytextannotation2.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation2.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation2); CategoryTextAnnotation categorytextannotation3 = new CategoryTextAnnotation( "4. White papers are relevant to the firm's positioning.", "Category 4", 0.0D); categorytextannotation3.setFont(new Font("SansSerif", 0, 12)); categorytextannotation3.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation3.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation3); CategoryTextAnnotation categorytextannotation4 = new CategoryTextAnnotation( "5. Case studies are available.", "Category 5", 0.0D); categorytextannotation4.setFont(new Font("SansSerif", 1, 12)); categorytextannotation4.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation4.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation4); CategoryTextAnnotation categorytextannotation5 = new CategoryTextAnnotation( "6. Case studies enhance users understanding of the firm and its expertise.", "Category 6", 0.0D); categorytextannotation5.setFont(new Font("SansSerif", 0, 12)); categorytextannotation5.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation5.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation5); CategoryTextAnnotation categorytextannotation6 = new CategoryTextAnnotation( "7. Case studies are relevant to the firm's prospects and clients.", "Category 7", 0.0D); categorytextannotation6.setFont(new Font("SansSerif", 0, 12)); categorytextannotation6.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation6.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation6); CategoryTextAnnotation categorytextannotation7 = new CategoryTextAnnotation( "8. White papers are relevant to the firm's positioning.", "Category 8", 0.0D); categorytextannotation7.setFont(new Font("SansSerif", 0, 12)); categorytextannotation7.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation7.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation7); CategoryTextAnnotation categorytextannotation8 = new CategoryTextAnnotation( "9. Case studies are available.", "Category 9", 0.0D); categorytextannotation8.setFont(new Font("SansSerif", 1, 12)); categorytextannotation8.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation8.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation8); CategoryTextAnnotation categorytextannotation9 = new CategoryTextAnnotation( "10. Case studies enhance users understanding of the firm and its expertise.", "Category 10", 0.0D); categorytextannotation9.setFont(new Font("SansSerif", 0, 12)); categorytextannotation9.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation9.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation9); CategoryTextAnnotation categorytextannotation10 = new CategoryTextAnnotation( "11. Case studies are relevant to the firm's prospects and clients.", "Category 11", 0.0D); categorytextannotation10.setFont(new Font("SansSerif", 0, 12)); categorytextannotation10.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation10.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation10); CategoryTextAnnotation categorytextannotation11 = new CategoryTextAnnotation( "12. White papers are relevant to the firm's positioning.", "Category 12", 0.0D); categorytextannotation11.setFont(new Font("SansSerif", 0, 12)); categorytextannotation11.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation11.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation11); CategoryTextAnnotation categorytextannotation12 = new CategoryTextAnnotation( "13. Users can easily access resources based on viewer interest.", "Category 13", 0.0D); categorytextannotation12.setFont(new Font("SansSerif", 1, 12)); categorytextannotation12.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation12.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation12); CategoryTextAnnotation categorytextannotation13 = new CategoryTextAnnotation( "14. Access to additional hyperlinks enhances users's ability to find relevant information.", "Category 14", 0.0D); categorytextannotation13.setFont(new Font("SansSerif", 1, 12)); categorytextannotation13.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation13.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation13); CategoryTextAnnotation categorytextannotation14 = new CategoryTextAnnotation("15. OVERALL EFFECTIVENESS.", "Overall", 0.0D); categorytextannotation14.setFont(new Font("SansSerif", 1, 12)); categorytextannotation14.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation14.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation14); return jfreechart; }
From source file:IHM.compargraph.java
/** * * @param title//from w w w .j av a 2 s .c om * @param c1 * @param c2 * @param comp * */ public compargraph(String title, ArrayList<ReleveMeteo> c1, ArrayList<ReleveMeteo> c2, String comp) { super(title); t1 = c1; t2 = c2; c = comp; // jp = new JInternalFrame("courbes"); JFreeChart chart = createChart(createDataset()); ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new Dimension(500, 300)); setContentPane(panel); // jp.add(panel, BorderLayout.EAST); // jp.setVisible(true); panel.setVisible(true); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); // sets thickness for series (using strokes) renderer.setSeriesStroke(0, new BasicStroke(4.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); plot.setRenderer(renderer); plot.setOutlinePaint(Color.BLUE); plot.setOutlineStroke(new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.DARK_GRAY); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.BLACK); }
From source file:com.googlecode.logVisualizer.chart.StatDevelopmentLineChart.java
@Override protected ChartPanel createChartPanel() { final ChartPanel panel = super.createChartPanel(); final XYPlot plot = (XYPlot) panel.getChart().getPlot(); for (final DayChange dc : getLogData().getDayChanges()) { final ValueMarker day = new ValueMarker(dc.getTurnNumber()); day.setLabel("Day " + dc.getDayNumber()); day.setLabelAnchor(RectangleAnchor.TOP_RIGHT); day.setLabelTextAnchor(TextAnchor.TOP_LEFT); day.setStroke(new BasicStroke(2)); day.setPaint(new Color(175, 175, 255)); plot.addDomainMarker(day);//w ww. j a v a2 s . com } return panel; }
From source file:org.jfree.chart.demo.BarChart3DDemo4.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart3D("Student Grades", "Students", "Grade", categorydataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); CustomBarRenderer3D custombarrenderer3d = new CustomBarRenderer3D(); custombarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); custombarrenderer3d.setBaseItemLabelsVisible(true); custombarrenderer3d.setItemLabelAnchorOffset(10D); custombarrenderer3d.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); categoryplot.setRenderer(custombarrenderer3d); ValueMarker valuemarker = new ValueMarker(0.69999999999999996D, new Color(200, 200, 255), new BasicStroke(1.0F), new Color(200, 200, 255), new BasicStroke(1.0F), 1.0F); categoryplot.addRangeMarker(valuemarker, Layer.BACKGROUND); custombarrenderer3d.setBaseItemLabelsVisible(true); custombarrenderer3d.setMaximumBarWidth(0.050000000000000003D); CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation("Minimum grade to pass", "Robert", 0.70999999999999996D); categorytextannotation.setCategoryAnchor(CategoryAnchor.START); categorytextannotation.setFont(new Font("SansSerif", 0, 12)); categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT); categoryplot.addAnnotation(categorytextannotation); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); numberaxis.setUpperMargin(0.10000000000000001D); return jfreechart; }
From source file:QandE.XMarksTheSpot.java
protected void paintComponent(Graphics g) { if (isOpaque()) { g.setColor(getBackground());//from ww w.j a v a 2 s .c om g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(getForeground()); } Graphics2D g2 = (Graphics2D) g; Insets insets = getInsets(); g2.setStroke(new BasicStroke(5.0f)); g2.draw(new Line2D.Double(insets.left, insets.top, getWidth() - insets.right, getHeight() - insets.bottom)); g2.draw(new Line2D.Double(insets.left, getHeight() - insets.bottom, getWidth() - insets.right, insets.top)); }
From source file:org.btrg.df.betterologist.swingui.ProjectJobSchedulingPanel.java
private JFreeChart createChart(Schedule schedule) { YIntervalSeriesCollection seriesCollection = new YIntervalSeriesCollection(); Map<Project, YIntervalSeries> projectSeriesMap = new LinkedHashMap<Project, YIntervalSeries>( schedule.getProjectList().size()); YIntervalRenderer renderer = new YIntervalRenderer(); int maximumEndDate = 0; int seriesIndex = 0; for (Project project : schedule.getProjectList()) { YIntervalSeries projectSeries = new YIntervalSeries(project.getLabel()); seriesCollection.addSeries(projectSeries); projectSeriesMap.put(project, projectSeries); renderer.setSeriesShape(seriesIndex, new Rectangle()); renderer.setSeriesStroke(seriesIndex, new BasicStroke(3.0f)); seriesIndex++;/*from w ww. j av a 2 s . c o m*/ } for (Allocation allocation : schedule.getAllocationList()) { int startDate = allocation.getStartDate(); int endDate = allocation.getEndDate(); YIntervalSeries projectSeries = projectSeriesMap.get(allocation.getProject()); projectSeries.add(allocation.getId(), (startDate + endDate) / 2.0, startDate, endDate); maximumEndDate = Math.max(maximumEndDate, endDate); } NumberAxis domainAxis = new NumberAxis("Job"); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-0.5, schedule.getAllocationList().size() - 0.5); domainAxis.setInverted(true); NumberAxis rangeAxis = new NumberAxis("Day (start to end date)"); rangeAxis.setRange(-0.5, maximumEndDate + 0.5); XYPlot plot = new XYPlot(seriesCollection, domainAxis, rangeAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); return new JFreeChart("Project Job Scheduling", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.openmrs.module.usagestatistics.web.view.chart.AbstractChartView.java
/** * @see org.springframework.web.servlet.view.AbstractView */// w w w . j av a2s. co m @Override @SuppressWarnings("unchecked") protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Respond as a PNG image response.setContentType("image/png"); // Disable caching response.setHeader("Pragma", "No-cache"); response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); int width = ServletRequestUtils.getIntParameter(request, "width", 500); int height = ServletRequestUtils.getIntParameter(request, "height", 300); from = (Date) model.get("from"); until = (Date) model.get("until"); untilInclusive = (Date) model.get("untilInclusive"); usageFilter = (ActionCriteria) model.get("usageFilter"); location = (Location) model.get("location"); JFreeChart chart = createChart(model, request); chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setOutlineStroke(new BasicStroke(0)); chart.getPlot().setOutlinePaint(getBackgroundColor()); chart.getPlot().setBackgroundPaint(getBackgroundColor()); ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, width, height); }
From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.Thermometer.java
/** * Creates a chart of type thermometer.//from w w w.j a v a 2s. c o m * * @return A chart thermometer. */ public JFreeChart createChart() { logger.debug("IN"); if (dataset == null) { logger.debug("The dataset to be represented is null"); return null; } ThermometerPlot plot = new ThermometerPlot((ValueDataset) dataset); logger.debug("Created the new Thermometer Plot"); JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, true); logger.debug("Created the new Chart"); chart.setBackgroundPaint(color); logger.debug("Setted the background color of the chart"); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); logger.debug("Setted the title of the chart"); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); logger.debug("Setted the subtitle of the chart"); } plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setPadding(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); plot.setThermometerStroke(new BasicStroke(2.0f)); plot.setThermometerPaint(Color.lightGray); plot.setGap(3); plot.setValueLocation(3); plot.setRange(lower, upper); plot.setUnits(ThermometerPlot.UNITS_NONE); logger.debug("Setted all the properties of the plot"); // set subranges for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval subrange = (KpiInterval) iterator.next(); int range = 0; //For the thermometer the number of intervals is forced to 3 and they have to have as labels the following ones if (subrange.getLabel().equalsIgnoreCase("NORMAL")) range = (ThermometerPlot.NORMAL); else if (subrange.getLabel().equalsIgnoreCase("WARNING")) range = (ThermometerPlot.WARNING); else if (subrange.getLabel().equalsIgnoreCase("CRITICAL")) range = (ThermometerPlot.CRITICAL); plot.setSubrange(range, subrange.getMin(), subrange.getMax()); if (subrange.getColor() != null) { plot.setSubrangePaint(range, subrange.getColor()); } logger.debug("Setted new range of the plot"); } logger.debug("OUT"); return chart; }
From source file:org.sakaiproject.evaluation.tool.reporting.EvalLikertChartBuilder.java
@SuppressWarnings("deprecation") public JFreeChart makeLikertChart() { DefaultCategoryDataset likertDataset = new DefaultCategoryDataset(); for (int i = 0; i < responses.length; i++) { likertDataset.addValue(values[i], "Responses", responses[i]); }//from w w w.j a va2s . c om JFreeChart chart = ChartFactory.createBarChart(null, // "Likert Chart", // Chart title null, // "Choices", // domain axis label null, // "# of Responses", // range axis label likertDataset, PlotOrientation.HORIZONTAL, false, // show legend false, // show tooltips false // show URLs ); // Set the background colours chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); // Configure the bar colors and display BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, new Color(244, 252, 212)); renderer.setDrawBarOutline(true); renderer.setOutlinePaint(new Color(34, 35, 237)); renderer.setOutlineStroke(new BasicStroke(0.5f)); renderer.setBaseItemLabelsVisible(true); if (showPercentages) { renderer.setBaseItemLabelGenerator(new LikertPercentageItemLabelGenerator(this.responseCount)); } else { renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); } // Turn off the Top Value Axis ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setVisible(false); rangeAxis.setUpperMargin(0.35); rangeAxis.resizeRange(1.1f); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(0.4f); domainAxis.setMaximumCategoryLabelLines(2); // Set the font for the labels Font labelFont = new Font("Serif", Font.PLAIN, 6); CategoryItemRenderer itemRenderer = plot.getRenderer(); itemRenderer.setBaseItemLabelFont(labelFont); plot.setOutlinePaint(null); domainAxis.setLabelFont(labelFont); domainAxis.setTickLabelFont(labelFont); rangeAxis.setLabelFont(labelFont); rangeAxis.setTickLabelFont(labelFont); return chart; }
From source file:PerformanceGraph.java
/** * Plots the performance graph of the best fitness value so far versus the * number of function calls (NFC).//ww w.jav a2 s . c o m * * @param bestFitness A linked hashmap mapping the NFC to the best fitness value * found so far. * @param fitnessFunction The name of the fitness function, used for the title and the * name of the file that is saved, e.g. "De Jong". */ public static void plot(LinkedHashMap<Integer, Double> bestFitness, String fitnessFunction) { /* Create an XYSeries plot */ XYSeries series = new XYSeries("Best Fitness Value Vs. Number of Function Calls"); /* Add the NFC and best fitness value data to the series */ for (Integer NFC : bestFitness.keySet()) { /* Jfreechart crashes if double values are too large! */ if (bestFitness.get(NFC) <= 10E12) { series.add(NFC.doubleValue(), bestFitness.get(NFC).doubleValue()); } } /* Add the x,y series data to the dataset */ XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); /* Plot the data as an X,Y line chart */ JFreeChart chart = ChartFactory.createXYLineChart("Best Fitness Value Vs. Number of Function Calls", "Number of Function Calls (NFC)", "Best Fitness Value", dataset, PlotOrientation.VERTICAL, false, true, false); /* Configure the chart settings such as anti-aliasing, background colour */ chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); plot.setDomainGridlinePaint(Color.black); /* Set the domain range from 0 to NFC */ NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(0.0, ControlVariables.MAX_FUNCTION_CALLS.doubleValue()); /* Logarithmic range axis */ plot.setRangeAxis(new LogAxis()); /* Set the thickness and colour of the lines */ XYItemRenderer renderer = plot.getRenderer(); BasicStroke thickLine = new BasicStroke(3.0f); renderer.setSeriesStroke(0, thickLine); renderer.setPaint(Color.BLACK); /* Display the plot in a JFrame */ ChartFrame frame = new ChartFrame(fitnessFunction + " Best Fitness Value", chart); frame.setVisible(true); frame.setSize(1000, 600); /* Save the plot as an image named after fitness function try { ChartUtilities.saveChartAsJPEG(new File("plots/" + fitnessFunction + ".jpg"), chart, 1600, 900); } catch (IOException e) { e.printStackTrace(); }*/ }