List of usage examples for org.jfree.util ShapeUtilities createDiagonalCross
public static Shape createDiagonalCross(final float l, final float t)
From source file:jprobix.ui.SPlotFinal.java
public static JPanel creteDemoPanel() { JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter plot demo", "X", "Y", samplexydataset2(), PlotOrientation.VERTICAL, true, true, false); Shape cross = ShapeUtilities.createDiagonalCross(3, 2); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesShape(5, cross);//from ww w . ja va 2 s. c om renderer.setSeriesPaint(0, Color.YELLOW); XYDotRenderer xydotrenderer = new XYDotRenderer(); xyPlot.setRenderer(xydotrenderer); xydotrenderer.setSeriesShape(0, cross); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); return new ChartPanel(jfreechart); }
From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.DirectionAutocorrelationLineAndShapeRenderer.java
@Override public Shape getSeriesShape(int series) { return ShapeUtilities.createDiagonalCross(2, 1); }
From source file:org.mc.okapi.Plot.java
public Plot(double[] X, double[] Y, String xLab, String yLab, String seriesName, String applicationTitle, String chartTitle) {/*from w w w . j a v a 2s . c om*/ super(applicationTitle); XYSeries series = new XYSeries(seriesName); for (int i = 0; i < X.length; i++) { series.add(X[i], Y[i]); } // create a dataset... XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); // based on the dataset we create the chart JFreeChart chart = ChartFactory.createScatterPlot(chartTitle, xLab, yLab, dataset, PlotOrientation.VERTICAL, true, rootPaneCheckingEnabled, rootPaneCheckingEnabled); Shape cross = ShapeUtilities.createDiagonalCross(3, 1); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesShape(0, cross); renderer.setSeriesPaint(0, Color.red); // we put the chart into a panel ChartPanel chartPanel = new ChartPanel(chart); setIconImage(Toolkit.getDefaultToolkit().getImage("images/ico/extra/science_32.png")); // default size chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); // add it to our application setContentPane(chartPanel); }
From source file:org.cerberus.refactor.LineChart.java
public BufferedImage bi(CategoryDataset categorydataset, String name, int count) { BufferedImage bi = null;/*from w w w .j ava 2s .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:org.gumtree.vis.core.internal.StaticValues.java
public static Shape[] createLocalMarkerShape() { Shape[] shapeSeries = new Shape[13]; shapeSeries[0] = null;/*ww w . j a va 2 s. c o m*/ shapeSeries[1] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[0]; shapeSeries[2] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[1]; shapeSeries[3] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[2]; shapeSeries[4] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[3]; shapeSeries[5] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[4]; shapeSeries[6] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[5]; shapeSeries[7] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[6]; shapeSeries[8] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[7]; shapeSeries[9] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[8]; shapeSeries[10] = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[9]; shapeSeries[11] = ShapeUtilities.createDiagonalCross(3f, 0.5f); shapeSeries[12] = ShapeUtilities.createRegularCross(3f, 0.5f); return shapeSeries; }
From source file:com.wattzap.view.graphs.GenericScatterGraph.java
public GenericScatterGraph(XYSeries series, String xAxis, String yAxis) { super();/* ww w. jav a2 s . c o m*/ XYDataset xyDataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createScatterPlot("", // chart title xAxis, // x axis label yAxis, // y axis label null, PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.darkGray); plot = chart.getXYPlot(); plot.setDataset(0, xyDataset); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // Shape cross = ShapeUtilities.createDiamond(0.5f); Shape cross = ShapeUtilities.createDiagonalCross(0.5f, 0.5f); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, new Color(252, 141, 89)); renderer.setSeriesShape(0, cross); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelPaint(Color.white); domainAxis.setLabelPaint(Color.white); ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setTickLabelPaint(Color.white); rangeAxis.setLabelPaint(Color.white); chartPanel = new ChartPanel(chart); chartPanel.setSize(100, 800); setLayout(new BorderLayout()); add(chartPanel, BorderLayout.CENTER); setBackground(Color.black); chartPanel.revalidate(); setVisible(true); }
From source file:statUtil.TurnMovementPlot.java
public TurnMovementPlot(String title) throws IOException { super(title); Data data = CSVData.getCSVData(TURN_CSV_LOG); JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", XYDatasetGenerator.generateXYDataset(data.csvData)); final XYPlot xyPlot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesStroke(0, new BasicStroke(3f)); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); Shape cross = ShapeUtilities.createDiagonalCross(2f, 0.5f); renderer.setSeriesShape(1, cross);/* www .j a va2 s .c o m*/ xyPlot.setRenderer(renderer); xyPlot.setQuadrantOrigin(new Point(0, 0)); int i = 0; for (Double[] csvRow : data.csvData) { if (i % 20 == 1) { final XYTextAnnotation annotation = new XYTextAnnotation(Double.toString(csvRow[3]), csvRow[0], csvRow[1]); annotation.setFont(new Font("SansSerif", Font.PLAIN, 10)); xyPlot.addAnnotation(annotation); } i++; } int width = (int) Math.round(data.maxX - data.minX) + 50; int height = (int) Math.round(data.maxY - data.minY) + 50; ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(width, height)); setContentPane(chartPanel); File XYChart = new File(FILE_PATH + "\\TurnMovementPlot.png"); ChartUtilities.saveChartAsPNG(XYChart, chart, width, height); }
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static Shape translateChartShape(Shape shape, Rectangle2D imageArea, JFreeChart chart) { if (shape instanceof Line2D) { Line2D line = (Line2D) shape; double length = line.getP1().distance(line.getP2()); if (length == 0) { Point2D point = line.getP1(); Point2D newPoint = ChartMaskingUtilities.translateChartPoint(point, imageArea, chart); Shape oShape = ShapeUtilities.createDiagonalCross(5f, 0.2f); // Shape oShape = ShapeUtilities.createRegularCross(3f, 0.5f); Shape newShape = ShapeUtilities.createTranslatedShape(oShape, newPoint.getX(), newPoint.getY()); return newShape; } else if (length < 1e-6) { if (line.getP1().getX() == line.getP2().getX()) { double newX = ChartMaskingUtilities.translateChartPoint(line.getP1(), imageArea, chart).getX(); Line2D newLine = new Line2D.Double(newX, imageArea.getMinY(), newX, imageArea.getMaxY()); return newLine; } else { double newY = ChartMaskingUtilities.translateChartPoint(line.getP1(), imageArea, chart).getY(); Line2D newLine = new Line2D.Double(imageArea.getMinX(), newY, imageArea.getMaxX(), newY); return newLine; }// w ww . j a va 2 s .c o m } Line2D newShape = (Line2D) line.clone(); Point2D newP1 = translateChartPoint(line.getP1(), imageArea, chart); Point2D newP2 = translateChartPoint(line.getP2(), imageArea, chart); newShape.setLine(newP1, newP2); return newShape; } else if (shape instanceof RectangularShape) { RectangularShape rect = (RectangularShape) shape; RectangularShape newShape = (RectangularShape) rect.clone(); Rectangle2D bound = rect.getBounds2D(); Point2D start = new Point2D.Double(bound.getMinX(), bound.getMinY()); Point2D end = new Point2D.Double(bound.getMaxX(), bound.getMaxY()); Point2D screenStart = translateChartPoint(start, imageArea, chart); Point2D screenEnd = translateChartPoint(end, imageArea, chart); newShape.setFrame(new Rectangle2D.Double(Math.min(screenStart.getX(), screenEnd.getX()), Math.min(screenStart.getY(), screenEnd.getY()), Math.abs(screenStart.getX() - screenEnd.getX()), Math.abs(screenStart.getY() - screenEnd.getY()))); return newShape; } else { return shape; } }
From source file:org.cerberus.refactor.LineChart.java
public BufferedImage bi(TimeSeriesCollection timeseriescollection, String xname, String name, int count) { BufferedImage bi = null;/*from w w w . j ava 2s . com*/ boolean fc = false; XYDataset xydataset = timeseriescollection; JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(name, xname, name, xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(false); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { Shape point = ShapeUtilities.createDiagonalCross(1, 1); String[] seriesColors = { "#FF0000", "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01" }; String[] seriesColors2 = { "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01" }; XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); for (int a = 0; a < count; a++) { xylineandshaperenderer.setSeriesShape(a, point); xyitemrenderer.setSeriesStroke(a, new BasicStroke(1.0F)); //TODO check this - fc is always false if (fc) { xylineandshaperenderer.setSeriesPaint(a, Color.decode(seriesColors[count - a - 1])); } else { xylineandshaperenderer.setSeriesPaint(a, Color.decode(seriesColors2[count - a - 1])); } } } DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("hh:mm")); bi = jfreechart.createBufferedImage(500, 270); return bi; }
From source file:edu.scripps.fl.curves.plot.CurvePlot.java
protected void addCurve(Curve curve, YIntervalSeries validSeries, YIntervalSeries invalidSeries, FitFunction fitFunction, double min, double max) { MyXYErrorRenderer renderer = (MyXYErrorRenderer) plot.getRenderer(); Paint paint = plot.getDrawingSupplier().getNextPaint(); addSeries(validSeries, paint, true, true); if (isDisplayInvalidPoints() && invalidSeries.getItemCount() > 0) { int idx = addSeries(invalidSeries, paint, true, false); float size = (float) DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[0].getBounds().getWidth(); DrawingSupplier ds = this.getDrawingSupplier(); if (ds instanceof CurvePlotDrawingSupplier) size = (float) ((CurvePlotDrawingSupplier) ds).getShapeSize() / 2; size = (float) Math.floor((size - 1) / 2); renderer.setSeriesShape(idx, ShapeUtilities.createDiagonalCross(size, size)); }/*w w w . j a v a 2 s . com*/ if (null != fitFunction) try { YIntervalSeries functionSeries = sampleFunction2DToSeries(curve, fitFunction, min, max, getWidth(), (Comparable<?>) (dataset.getSeriesCount() + 1)); addSeries(functionSeries, paint, false, false); } catch (NullPointerException ex) { ex.printStackTrace(); } }