List of usage examples for java.awt BasicStroke BasicStroke
public BasicStroke(float width)
From source file:com.ouc.cpss.view.SupTradeChartBuilder.java
private static JFreeChart createJFreeChart(PieDataset dataset) { /**/*ww w . j a va 2 s .c o m*/ * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //?? //createPieChart 2D; createPieChart3D 3D JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, false); //,? chart.setTitle(new TextTitle("", new Font("", Font.ITALIC, 22))); //? LegendTitle legend = chart.getLegend(0); //,ture,? legend.setItemFont(new Font("", Font.BOLD, 20)); //?(??) PiePlot plot = (PiePlot) chart.getPlot(); //?==? plot.setLabelFont(new Font("", Font.BOLD, 22)); // plot.setBaseSectionOutlinePaint(Color.BLUE); // plot.setBaseSectionOutlineStroke(new BasicStroke(0.5f)); //?,??,?? plot.setDirection(Rotation.CLOCKWISE);//,Rotation.CLOCKWISE //() plot.setStartAngle(70); //??? //plot.setExplodePercent(1, 0.5D); //plot.setExplodePercent("One", 0.5D); //,3D? plot.setExplodePercent(dataset.getKey(0), 0.1d); // plot.setLabelLinkPaint(Color.BLUE); // plot.setLabelOutlinePaint(Color.black); // plot.setLabelShadowPaint(Color.RED); // plot.setSectionPaint(1, Color.BLACK); // :,{0},{1},{2}?,??? plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}\r\n{2}", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); // plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={2}")); //:(true),(false) plot.setCircular(true); //? plot.setNoDataMessage("??..."); //??? plot.setToolTipGenerator(new StandardPieToolTipGenerator()); // //plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp")); return chart; }
From source file:tp2.FCFS.java
@Override public void printGraph(String filename) { int i;/*w w w.j a va2 s .c om*/ int y_axis = requestString.length * 10; XYSeries series = new XYSeries("FCFS"); /* Adiciona o pontos XY do grfico de linhas. */ series.add(y_axis, initCilindro); for (i = 0; i < requestString.length; i++) { series.add(y_axis - ((i + 1) * 10), requestString[i]); } /* Adiciona a serie criada a um SeriesCollection. */ XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); /* Gera o grfico de linhas */ JFreeChart chart = ChartFactory.createXYLineChart( /* Title */ "FCFS Scheduler Algorithm", /* Title x*/ "", /* Title y */ "Cilindro", dataset, /* Plot Orientation */ PlotOrientation.HORIZONTAL, /* Show Legend */ false, /* Use tooltips */ false, /* Configure chart to generate URLs? */ false); /* Configura a espessura da linha do grfico */ XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); plot.setRenderer(renderer); /* Escreve o grfico para um arquivo indicado. */ try { ChartUtilities.saveChartAsJPEG(new File(filename), chart, 500, 300); } catch (IOException ex) { Logger.getLogger(FCFS.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.SimpleDial.java
/** * Creates the chart .//from ww w . j a v a2 s .c o m * * @return A Simple Dial chart . */ public JFreeChart createChart() { logger.debug("IN"); if (dataset == null) { logger.debug("The dataset to be represented is null"); return null; } DialPlot plot = new DialPlot(); plot.setDataset((ValueDataset) dataset); logger.debug("Created the new Dial Plot"); ArcDialFrame dialFrame = null; plot.setView(0.21, 0.0, 0.58, 0.30); dialFrame = new ArcDialFrame(60.0, 60.0); dialFrame.setInnerRadius(0.65); dialFrame.setOuterRadius(0.90); dialFrame.setForegroundPaint(Color.darkGray); dialFrame.setStroke(new BasicStroke(3.0f)); plot.setDialFrame(dialFrame); GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(240, 240, 240)); DialBackground sdb = new DialBackground(gp); GradientPaintTransformType gradientPaintTransformType = GradientPaintTransformType.HORIZONTAL; sdb.setGradientPaintTransformer(new StandardGradientPaintTransformer(gradientPaintTransformType)); plot.addLayer(sdb); increment = (upper - lower) / 4; StandardDialScale scale = null; scale = new StandardDialScale(lower, upper, 115.0, -50.0, increment, minorTickCount); // sets intervals for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(), interval.getColor()); range.setInnerRadius(0.70); range.setOuterRadius(0.75); plot.addLayer(range); } scale.setTickRadius(0.88); scale.setTickLabelOffset(0.07); Font f = new Font("Arial", Font.PLAIN, 11); scale.setTickLabelFont(f); //scale.setMajorTickIncrement(25.0); plot.addScale(0, scale); DialPointer needle = new DialPointer.Pin(); needle.setRadius(0.82); plot.addLayer(needle); JFreeChart chart1 = new JFreeChart(plot); logger.debug("Created the chart"); chart1.setBackgroundPaint(color); logger.debug("Setted background color of the chart"); TextTitle title = setStyleTitle(name, styleTitle); chart1.setTitle(title); logger.debug("Setted the title of the chart"); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart1.addSubtitle(subTitle); logger.debug("Setted the subtitle of the chart"); } logger.debug("OUT"); return chart1; }
From source file:view.FuzzySetView.java
/** * * @param value//from w w w. j a v a 2s . c om */ public void showSingleton(double value) { plot.clearDomainMarkers(); BasicStroke stroke = new BasicStroke(2f); ValueMarker marker = new ValueMarker(value, Color.BLACK, stroke); plot.addDomainMarker(marker); fillView(); }
From source file:org.jreserve.gui.plot.charts.AbstractLineChart.java
@Override protected void formatPlot(Plot plot) { CategoryPlot cPlot = (CategoryPlot) plot; cPlot.setBackgroundPaint(format.getBackgroundColor()); cPlot.setRangeGridlinesVisible(true); cPlot.setRangeGridlinePaint(format.getGridColor()); cPlot.setRangeGridlineStroke(new BasicStroke(3)); cPlot.setDomainGridlinesVisible(true); cPlot.setDomainGridlinePaint(format.getGridColor()); cPlot.setDomainGridlineStroke(new BasicStroke(3)); formatSeries((LineAndShapeRenderer) cPlot.getRenderer()); formatRangeAxis(getMinValue(), getMaxValue()); }
From source file:org.openmrs.module.usagestatistics668.web.view.chart.AbstractChartView.java
/** * @see org.springframework.web.servlet.view.AbstractView *//*from ww w . j av a 2 s . c o 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"); System.out.println(from); maxResults = (Integer) model.get("maxResults"); until = (Date) model.get("until"); untilInclusive = (Date) model.get("untilInclusive"); usageFilter = (ActionCriteria) model.get("usageFilter"); 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:edu.msu.cme.rdp.classifier.train.validation.distance.BoxPlotUtils.java
public static void createBoxplot(DefaultBoxAndWhiskerCategoryDataset scatterDataset, PrintStream outStream, String title, String xAxisLabel, String yAxisLabel, Font lableFont) throws IOException { CategoryAxis xAxis = new CategoryAxis(xAxisLabel); xAxis.setLabelFont(lableFont);/*w w w .java 2 s .c o m*/ NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setTickLabelFont(lableFont); yAxis.setAutoRangeIncludesZero(false); yAxis.setRange(0, 100); yAxis.setLabelFont(lableFont); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); renderer.setBaseLegendTextFont(lableFont); renderer.setStroke(new BasicStroke(5.0f)); CategoryPlot plot = new CategoryPlot(scatterDataset, xAxis, yAxis, renderer); JFreeChart boxchart = new JFreeChart(title, new Font("Helvetica", Font.BOLD, 40), plot, true); // higher scale factor gives higher resolution ChartUtilities.writeScaledChartAsPNG(outStream, boxchart, 800, 1000, 3, 3); }
From source file:WeatherFrame.java
public WeatherFrame() { initComponents();/*from w w w .j a va2s. c o m*/ fc = new JFileChooser(); fc.setMultiSelectionEnabled(true); //only can select a single button a time ButtonGroup group = new ButtonGroup(); group.add(AllRadioButton); group.add(YearlyRadioButton); group.add(MonthlyRadioButton); group.add(WeeklyRadioButton); group.add(DailyRadioButton); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Temperature", "Humidity", "Barometric Pressure", "Windspeed", "UVindex", "Raindfall" })); TempSet = new TimeSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart("Temperature", "", "Degree Fahrenheit", TempSet, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); ChartPanel.setLayout(new java.awt.BorderLayout()); ChartPanel CP = new ChartPanel(chart); CP.setPreferredSize(new Dimension(ChartPanel.getWidth(), ChartPanel.getHeight())); ChartPanel.add(CP, BorderLayout.CENTER); DefaultValueDataset dataset = new DefaultValueDataset(20f); ThermometerPlot thermometerplot = new ThermometerPlot(dataset); JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, thermometerplot, true); jfreechart.setBackgroundPaint(new Color(240, 240, 240)); thermometerplot.setThermometerPaint(Color.lightGray); thermometerplot.setThermometerStroke(new BasicStroke(2.0F)); ChartPanel DP = new ChartPanel(jfreechart); DP.setPreferredSize(new Dimension(TempThermoPanel.getWidth(), TempThermoPanel.getHeight())); TempThermoPanel.setLayout(new java.awt.BorderLayout()); TempThermoPanel.add(DP); TempThermoPanel.validate(); }
From source file:org.cerberus.refactor.LineChart.java
public BufferedImage bi(CategoryDataset categorydataset, String name, int count) { BufferedImage bi = null;/*from w ww . ja va2s . c o m*/ JFreeChart jfreechart = ChartFactory.createLineChart(name, "Category", "Count", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); Shape point = ShapeUtilities.createDiagonalCross(1, 1); //TODO check this - seriesColors never used // String[] seriesColors = {"#FF0000", "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01"}; // String[] seriesColors2 = {"#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01"}; LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setBaseShapesVisible(true); lineandshaperenderer.setBaseShapesFilled(true); for (int a = 0; a < count; a++) { lineandshaperenderer.setSeriesShapesVisible(a, true); lineandshaperenderer.setSeriesLinesVisible(a, true); lineandshaperenderer.setSeriesStroke(a, new BasicStroke(1.0F)); lineandshaperenderer.setSeriesShape(a, point); } lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); //DateAxis dateaxis = (DateAxis)xyplot.getDomainAxis(); //dateaxis.setDateFormatOverride(new SimpleDateFormat("hh:mm")); bi = jfreechart.createBufferedImage(500, 270); return bi; }
From source file:daylightchart.daylightchart.chart.DaylightChartLegendItemSource.java
private LegendItem createLegendItem(final String label, final Paint paint, final boolean isLine) { final LegendItem legendItem = new LegendItem(label, /* description */ null, /* toolTipText */null, /* urlText */ null, /* shapeVisible */!isLine, /* shape */new Rectangle(10, 10), /* shapeFilled */true, paint, /* shapeOutlineVisible */true, /* outlinePaint */Color.black, /* outlineStroke */new BasicStroke(0.2f), /* lineVisible */isLine, /* line */new Rectangle(10, 3), /* lineStroke */new BasicStroke(0.6f), /* linePaint */Color.black); return legendItem; }