org.jfree.chart.ui.RectangleEdge Java Examples
The following examples show how to use
org.jfree.chart.ui.RectangleEdge.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PseudoSpectraRenderer.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public PseudoSpectraRenderer(Color color, boolean isTransparent) { this.isTransparent = isTransparent; // Set painting color setDefaultPaint(color); // Shadow makes fake peaks setShadowVisible(false); // Set the tooltip generator SpectraToolTipGenerator tooltipGenerator = new SpectraToolTipGenerator(); setDefaultToolTipGenerator(tooltipGenerator); // We want to paint the peaks using simple color without any gradient // effects setBarPainter(new StandardXYBarPainter() { @Override public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) { super.paintBar(g2, renderer, row, column, new Rectangle2D.Double( bar.getX() + (bar.getWidth() - 1.5) / 2, bar.getY(), 1.5, bar.getHeight()), base); } }); }
Example #2
Source File: JamelAxis.java From jamel with GNU General Public License v3.0 | 6 votes |
@Override protected void selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { final double e = this.getRange().getLength(); final double ea = Math.pow(10, Math.floor(Math.log10(e / 3))); double ep = ea; if (ea * 10 < e) { ep = ea * 5; } else if (ea * 5 < e) { ep = ea * 2; } if (this.integerUnit && ep < 1) { ep = 1; } final NumberTickUnit unit2 = new NumberTickUnit(ep); setTickUnit(unit2, false, false); }
Example #3
Source File: TwoDPlot.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public String getToolTipText(MouseEvent event) { String tooltip = super.getToolTipText(event); if (tooltip == null) { int mouseX = event.getX(); int mouseY = event.getY(); Rectangle2D plotArea = getScreenDataArea(); RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); RectangleEdge yAxisEdge = plot.getRangeAxisEdge(); double rt = (double) xAxis.java2DToValue(mouseX, plotArea, xAxisEdge); double mz = (double) yAxis.java2DToValue(mouseY, plotArea, yAxisEdge); tooltip = "Retention time: " + rtFormat.format(rt) + "\nm/z: " + mzFormat.format(mz); } return tooltip; }
Example #4
Source File: PseudoSpectraRenderer.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public PseudoSpectraRenderer(Color color, boolean isTransparent) { this.isTransparent = isTransparent; // Set painting color setDefaultPaint(color); // Shadow makes fake peaks setShadowVisible(false); // Set the tooltip generator SpectraToolTipGenerator tooltipGenerator = new SpectraToolTipGenerator(); setDefaultToolTipGenerator(tooltipGenerator); // We want to paint the peaks using simple color without any gradient // effects setBarPainter(new StandardXYBarPainter() { @Override public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) { super.paintBar(g2, renderer, row, column, new Rectangle2D.Double( bar.getX() + (bar.getWidth() - 1.5) / 2, bar.getY(), 1.5, bar.getHeight()), base); } }); }
Example #5
Source File: CrosshairOverlayFXDemo1.java From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void chartMouseMoved(ChartMouseEventFX event) { Rectangle2D dataArea = this.chartViewer.getCanvas().getRenderingInfo().getPlotInfo().getDataArea(); JFreeChart chart = event.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM); // make the crosshairs disappear if the mouse is out of range if (!xAxis.getRange().contains(x)) { x = Double.NaN; } double y = DatasetUtils.findYValue(plot.getDataset(), 0, x); this.xCrosshair.setValue(x); this.yCrosshair.setValue(y); }
Example #6
Source File: TaChart.java From TAcharting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Constructor. * @param box a ChartIndicatorBox */ public TaChart(IndicatorBox box){ mapTradingRecordMarker = new HashMap<>(); this.chartIndicatorBox = box; this.chartIndicatorBox.getIndicartors().addListener(this); XYDataset candlesBarData = createOHLCDataset(chartIndicatorBox.getBarSeries()); this.mainPlot = createMainPlot(candlesBarData); this.combinedXYPlot = createCombinedDomainXYPlot(mainPlot); this.setCache(true); this.setCacheHint(CacheHint.SPEED); final JFreeChart chart = new JFreeChart(combinedXYPlot); TaChartViewer viewer = new TaChartViewer(chart); Color chartBackground = Color.WHITE; chart.setBackgroundPaint(chartBackground); getChildren().add(viewer); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.TOP); legend.setItemFont(new Font("Arial", Font.BOLD, 12)); Color legendBackground = new Color(0, 0, 0, 0); legend.setBackgroundPaint(legendBackground); chartIndicatorBox.getObservableBarSeries().addListener((ob, o, n) -> reloadBarSeries(n)); }
Example #7
Source File: ChartLogicsFX.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * Data width to pixel width on screen * * @param myChart * @param dataWidth width of data * @param axis for width calculation * @return */ public static double calcWidthOnScreen(ChartViewer myChart, double dataWidth, ValueAxis axis, RectangleEdge axisEdge) { XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); // width 2D return axis.lengthToJava2D(dataWidth, dataArea, axisEdge); }
Example #8
Source File: ChartLogics.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * Data width to pixel width on screen * * @param myChart * @param dataWidth width of data * @param axis for width calculation * @return */ public static double calcWidthOnScreen(ChartPanel myChart, double dataWidth, ValueAxis axis, RectangleEdge axisEdge) { XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getChartRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); double width2D = axis.lengthToJava2D(dataWidth, dataArea, axisEdge); return width2D; }
Example #9
Source File: EStandardChartTheme.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * Fixes the legend item's colour after the colours of the datasets/series in the plot were * changed. * * @param chart The chart. */ public static void fixLegend(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); LegendTitle oldLegend = chart.getLegend(); RectangleEdge pos = oldLegend.getPosition(); chart.removeLegend(); LegendTitle newLegend = new LegendTitle(plot); newLegend.setPosition(pos); newLegend.setItemFont(oldLegend.getItemFont()); chart.addLegend(newLegend); newLegend.setVisible(oldLegend.isVisible()); }
Example #10
Source File: ChartLogicsFX.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * Data width to pixel width on screen * * @param myChart * @param dataWidth width of data * @param axis for width calculation * @return */ public static double calcWidthOnScreen(ChartViewer myChart, double dataWidth, ValueAxis axis, RectangleEdge axisEdge) { XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); // width 2D return axis.lengthToJava2D(dataWidth, dataArea, axisEdge); }
Example #11
Source File: ChartLogics.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * Data width to pixel width on screen * * @param myChart * @param dataWidth width of data * @param axis for width calculation * @return */ public static double calcWidthOnScreen(ChartPanel myChart, double dataWidth, ValueAxis axis, RectangleEdge axisEdge) { XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getChartRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); double width2D = axis.lengthToJava2D(dataWidth, dataArea, axisEdge); return width2D; }
Example #12
Source File: ChartLogicsFX.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * Data width to pixel width on screen * * @param myChart * @param dataWidth width of data * @param axis for width calculation * @return */ public static double calcWidthOnScreen(ChartViewer myChart, double dataWidth, ValueAxis axis, RectangleEdge axisEdge) { XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); // width 2D return axis.lengthToJava2D(dataWidth, dataArea, axisEdge); }
Example #13
Source File: ChartLogics.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * Data width to pixel width on screen * * @param myChart * @param dataWidth width of data * @param axis for width calculation * @return */ public static double calcWidthOnScreen(ChartPanel myChart, double dataWidth, ValueAxis axis, RectangleEdge axisEdge) { XYPlot plot = (XYPlot) myChart.getChart().getPlot(); ChartRenderingInfo info = myChart.getChartRenderingInfo(); Rectangle2D dataArea = info.getPlotInfo().getDataArea(); double width2D = axis.lengthToJava2D(dataWidth, dataArea, axisEdge); return width2D; }
Example #14
Source File: TaChartViewer.java From TAcharting with GNU Lesser General Public License v2.1 | 4 votes |
/** * Creates a new viewer instance. * * @param chart the org.sjwimmer.tacharting.chart ({@code null} permitted). * @param contextMenuEnabled enable the context menu? */ public TaChartViewer(JFreeChart chart, boolean contextMenuEnabled) { this.canvas = new TaChartCanvas(chart); this.canvas.setTooltipEnabled(true); this.canvas.addMouseHandler(new TaZoomHandlerFX("zoom", this)); setFocusTraversable(true); getChildren().add(this.canvas); this.zoomRectangle = new Rectangle(0, 0, new Color(0, 0, 1, 0.5)); this.zoomRectangle.setManaged(false); this.zoomRectangle.setVisible(false); getChildren().add(this.zoomRectangle); this.contextMenu = createContextMenu(); setOnContextMenuRequested((ContextMenuEvent event) -> { contextMenu.show(TaChartViewer.this.getScene().getWindow(), event.getScreenX(), event.getScreenY()); }); getContextMenu().setOnShowing( e -> TaChartViewer.this.getCanvas().setTooltipEnabled(false)); getContextMenu().setOnHiding( e -> TaChartViewer.this.getCanvas().setTooltipEnabled(true)); this.xCrosshair = new Line(0,0,this.getPrefWidth(),0); this.yCrosshair = new Line(0,0,0,this.getPrefHeight()); this.xCrosshair.setMouseTransparent(true); this.yCrosshair.setMouseTransparent(true); this.getChildren().add(xCrosshair); this.getChildren().add(yCrosshair); this.xLabel = new Label(""); this.yLabel = new Label(""); this.yLabel.setMouseTransparent(true); this.xLabel.setMouseTransparent(true); this.getChildren().add(xLabel); this.getChildren().add(yLabel); /**Custom Mouse Listener for the CrosshairOverlay */ this.setOnMouseMoved( e ->{ final double x = e.getX(); final double y = e.getY(); Rectangle2D dataArea = getCanvas().getRenderingInfo().getPlotInfo().getDataArea(); if(x > dataArea.getMinX() && y > dataArea.getMinY() && x < dataArea.getMaxX() && y < dataArea.getMaxY()) { setCrosshairVisible(true); CombinedDomainXYPlot combinedDomainXYPlot = (CombinedDomainXYPlot) getCanvas().getChart().getPlot(); XYPlot plot = (XYPlot) combinedDomainXYPlot.getSubplots().get(0); org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); xCrosshair.setStartY(dataArea.getMinY()); xCrosshair.setStartX(x); xCrosshair.setEndY(dataArea.getMaxY()); xCrosshair.setEndX(x); xLabel.setLayoutX(x); xLabel.setLayoutY(dataArea.getMinY()); double value = xAxis.java2DToValue(e.getX(), dataArea, xAxisEdge); long itemLong = (long) (value); Date itemDate = new Date(itemLong); xLabel.setText(String.valueOf(new SimpleDateFormat().format(itemDate))); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); RectangleEdge yAxisEdge = plot.getRangeAxisEdge(); Rectangle2D subDataArea = getCanvas().getRenderingInfo().getPlotInfo().getSubplotInfo(0).getDataArea(); yCrosshair.setStartY(y); yCrosshair.setStartX(dataArea.getMinX()); yCrosshair.setEndX(dataArea.getMaxX()); yCrosshair.setEndY(y); yLabel.setLayoutY(y); yLabel.setLayoutX(dataArea.getMinX()); String yValue = CalculationUtils.roundToString(yAxis.java2DToValue(y, subDataArea, yAxisEdge), 2); yLabel.setText(yValue); } else { setCrosshairVisible(false); } }); }
Example #15
Source File: PieChartFXDemo1.java From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates a chart. * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart( "Smart Phones Manufactured / Q3 2011", dataset); // set a custom background for the chart chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setDefaultSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setDefaultSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
Example #16
Source File: TrafficLoadLineChart.java From EdgeSim with MIT License | 4 votes |
public TrafficLoadLineChart() { this.collection = this.getCollection(); initial(); this.chart = ChartFactory.createXYLineChart( null, "Time Slice", "Traffic Load(100GB)", collection, PlotOrientation.VERTICAL, true, true, false ); this.chart.getPlot().setBackgroundPaint(SystemColor.white); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis(); numberAxisX.setAutoRangeIncludesZero(false); numberAxisX.setAutoRangeMinimumSize(0.1); numberAxisX.setAxisLineVisible(false); numberAxisX.setTickMarkInsideLength(4f); numberAxisX.setTickMarkOutsideLength(0); NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis(); numberAxisY.setTickUnit(new NumberTickUnit(5)); numberAxisY.setRangeWithMargins(0,40); numberAxisY.setAutoRangeIncludesZero(true); numberAxisY.setAxisLineVisible(false); numberAxisY.setTickMarkInsideLength(4f); numberAxisY.setTickMarkOutsideLength(0); numberAxisY.setNumberFormatOverride(NumberFormat.getNumberInstance()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer)plot.getRenderer(); renderer.setDefaultItemLabelsVisible(true); renderer.setDefaultShapesVisible(true); renderer.setDrawOutlines(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(1, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(2, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(3, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(4, new BasicStroke(5F)); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesPaint(2, new Color(53,101,253)); renderer.setSeriesPaint(3, new Color(0,161,59));//����ɫ renderer.setSeriesPaint(4, new Color(148,103,189));//��ɫ renderer.setSeriesPaint(0, new Color(255,125,11));//�ٻ�ɫ renderer.setSeriesStroke(0, new BasicStroke(4.0F)); renderer.setSeriesStroke(1, new BasicStroke(4.0F)); renderer.setSeriesStroke(2, new BasicStroke(4.0F)); renderer.setSeriesStroke(3, new BasicStroke(4.0F)); renderer.setSeriesStroke(4, new BasicStroke(2.0F)); renderer.setSeriesStroke(5, new BasicStroke(2.0F)); // renderer.setUseFillPaint(true); this.chartFrame = new ChartFrame("Line Chart", chart); chartFrame.pack(); chartFrame.setSize(1600,1200); chartFrame.setLocation(300,200); chartFrame.setVisible(true); }
Example #17
Source File: BaseLineChart.java From EdgeSim with MIT License | 4 votes |
protected void generateLineChart(String xAisTitle, String yAisTitle, NumberTickUnit xAisSpace, NumberTickUnit yAisSpace, double yaisMinValue, double yAisMaxValue, XYSeriesCollection collection) { this.chart = ChartFactory.createXYLineChart(null, xAisTitle, yAisTitle, collection, PlotOrientation.VERTICAL, true, true, false); this.chart.getPlot().setBackgroundPaint(SystemColor.white); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis(); numberAxisX.setAutoRangeIncludesZero(false); numberAxisX.setTickUnit(xAisSpace); numberAxisX.setAxisLineVisible(false); numberAxisX.setTickMarkInsideLength(4f); numberAxisX.setTickMarkOutsideLength(0); NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis(); numberAxisY.setTickUnit(yAisSpace); numberAxisY.setRangeWithMargins(yaisMinValue, yAisMaxValue); numberAxisY.setAutoRangeIncludesZero(true); numberAxisY.setAxisLineVisible(false); numberAxisY.setTickMarkInsideLength(4f); numberAxisY.setTickMarkOutsideLength(0); numberAxisY.setNumberFormatOverride(NumberFormat.getNumberInstance()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot .getRenderer(); // renderer.setBaseItemLabelsVisible(true); renderer.setDefaultItemLabelsVisible(true); renderer.setDefaultShapesVisible(true); // renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(1, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(2, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(3, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(4, new BasicStroke(5F)); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.BLUE); renderer.setSeriesPaint(2, new Color(255, 125, 11)); renderer.setSeriesPaint(3, new Color(0, 161, 59)); renderer.setSeriesPaint(4, new Color(148, 103, 189)); renderer.setSeriesStroke(0, new BasicStroke(4.0F)); renderer.setSeriesStroke(1, new BasicStroke(4.0F)); renderer.setSeriesStroke(2, new BasicStroke(4.0F)); renderer.setSeriesStroke(3, new BasicStroke(4.0F)); renderer.setSeriesStroke(4, new BasicStroke(2.0F)); renderer.setSeriesStroke(5, new BasicStroke(2.0F)); // renderer.setUseFillPaint(true); this.chartFrame = new ChartFrame("Line Chart", chart); chartFrame.pack(); chartFrame.setSize(800, 600); chartFrame.setLocation(300, 200); chartFrame.setVisible(true); }
Example #18
Source File: NumberLineChart.java From EdgeSim with MIT License | 4 votes |
public NumberLineChart() { this.collection = this.getCollection(); initial(); this.chart = ChartFactory.createXYLineChart( null, "Request", "Hit Rate", collection, PlotOrientation.VERTICAL, true, true, false ); this.chart.getPlot().setBackgroundPaint(SystemColor.white); LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis(); numberAxisX.setTickUnit(new NumberTickUnit(500)); // numberAxisX.setAutoRangeMinimumSize(0.1); numberAxisX.setAutoRangeIncludesZero(true); numberAxisX.setAxisLineVisible(false); numberAxisX.setTickMarkInsideLength(4f); numberAxisX.setTickMarkOutsideLength(0); NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis(); numberAxisY.setTickUnit(new NumberTickUnit(0.2)); numberAxisY.setRangeWithMargins(0,1); numberAxisY.setAutoRangeIncludesZero(true); numberAxisY.setAxisLineVisible(false); numberAxisY.setTickMarkInsideLength(4f); numberAxisY.setTickMarkOutsideLength(0); // ����Y������Ϊ�ٷֱ� numberAxisY.setNumberFormatOverride(NumberFormat.getPercentInstance()); XYItemRenderer xyitem = plot.getRenderer(); xyitem.setDefaultItemLabelsVisible(true); // ItemLabelsVisible(true); xyitem.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); // xyitem.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); // xyitem.setBaseItemLabelFont(new Font("Dialog", 1, 12)); xyitem.setDefaultItemLabelFont(new Font("Dialog", 1, 12)); plot.setRenderer(xyitem); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer)plot.getRenderer(); renderer.setDefaultItemLabelsVisible(true); renderer.setDefaultShapesVisible(true); renderer.setDrawOutlines(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(1, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(2, new BasicStroke(5F)); renderer.setSeriesOutlineStroke(3, new BasicStroke(5F)); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(53,101,253)); renderer.setSeriesPaint(2, new Color(0,161,59));//����ɫ renderer.setSeriesPaint(3, new Color(148,103,189));//��ɫ renderer.setSeriesStroke(0, new BasicStroke(4.0F)); renderer.setSeriesStroke(1, new BasicStroke(4.0F)); renderer.setSeriesStroke(2, new BasicStroke(4.0F)); renderer.setSeriesStroke(3, new BasicStroke(4.0F)); renderer.setSeriesStroke(4, new BasicStroke(2.0F)); renderer.setSeriesStroke(5, new BasicStroke(2.0F)); this.chartFrame = new ChartFrame("Line Chart", chart); chartFrame.pack(); chartFrame.setSize(1600,1200); chartFrame.setLocation(300,200); chartFrame.setVisible(true); }
Example #19
Source File: Chart.java From freeacs with MIT License | 4 votes |
/** * All params can be null. * * @param min - the minimum number on the left range axis (must be set if max is set) * @param max - the maximum number on the left range axis (must be set if min is set) * @param method2 - the method to run out of Record, and populates a bar series (right range axis) * @param highLightIndex - the index to highlight * @return * @throws Exception */ public JFreeChart makeTimeChart(Double min, Double max, String method2, Integer highLightIndex) throws Exception { startTms = System.currentTimeMillis(); endTms = 0; XYBarRenderer.setDefaultShadowsVisible(false); TimeSeriesCollection data = new TimeSeriesCollection(); Map<String, TimeSeries> timeSeriesMap = makeTimeSeriesMap(method, recordMap, keyNames); for (TimeSeries timeSeries : timeSeriesMap.values()) { data.addSeries(timeSeries); } String yAxisLabel = method; String denominator = Record.getDenominator(report.getRecordClass(), method.toLowerCase()); if (denominator != null) { yAxisLabel += " (" + denominator + ")"; } chart = ChartFactory.createTimeSeriesChart(title, "Time", yAxisLabel, data, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); if (method2 != null) { Map<Key, R> recordMap2 = recordMap; TimeSeriesCollection data2 = new TimeSeriesCollection(); if (keyNames.length > 0) { recordMap2 = report.getMapAggregatedOn(); } Map<String, TimeSeries> timeSeriesMap2 = makeTimeSeriesMap(method2, recordMap2); if (timeSeriesMap2.get("Total (" + method2 + ")") != null) { data2.addSeries(timeSeriesMap2.get("Total (" + method2 + ")")); } String y2AxisLabel = method2; String demoninator2 = Record.getDenominator(report.getRecordClass(), method2.toLowerCase()); if (demoninator2 != null) { y2AxisLabel += " (" + demoninator2 + ")"; } NumberAxis axis2 = new NumberAxis(y2AxisLabel); XYBarRenderer renderer2 = new XYBarRenderer(0.20); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, data2); plot.setRenderer(1, renderer2); plot.mapDatasetToRangeAxis(1, 1); renderer2.setBarPainter(new StandardXYBarPainter()); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); } if (min != null && max != null) { plot.getRangeAxis(0).setRange(min, max); } if (highLightIndex != null) { chart.getXYPlot().getRenderer().setSeriesStroke(highLightIndex, new BasicStroke(5f)); } XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setDefaultShapesVisible(true); renderer.setUseFillPaint(true); renderer.setDefaultFillPaint(Color.white); long diff = endTms - startTms; String format; if (diff > NINTY_DAYS) { format = "MMM-yyyy"; } else if (diff > TWO_DAYS) { format = "dd-MMM"; } else if (diff > TWO_MINUTES) { format = "HH:mm"; } else { format = "HH:mm:ss"; } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat(format)); LegendTitle lt = chart.getLegend(0); lt.setPosition(RectangleEdge.RIGHT); if (displayFrame) { ChartFrame frame = new ChartFrame(title, chart); frame.pack(); frame.setVisible(true); } return chart; }
Example #20
Source File: ChartJFreeChartOutputHeatmap.java From gama with GNU General Public License v3.0 | 4 votes |
protected void resetRenderer(final IScope scope, final String serieid) { final XYBlockRenderer newr = (XYBlockRenderer) this.getOrCreateRenderer(scope, serieid); // newr.setSeriesStroke(0, new BasicStroke(0)); final ChartDataSeries myserie = this.getChartdataset().getDataSeries(scope, serieid); if (myserie.getMycolor() != null) { newr.setSeriesPaint(0, myserie.getMycolor()); } if (myserie.getSValues(scope).size() > 0) { final double maxval = Collections.max(myserie.getSValues(scope)); final double minval = Collections.min(myserie.getSValues(scope)); Color cdeb = new Color(0, 0, 0, 0); if (myserie.getMyMincolor() != null) { cdeb = myserie.getMyMincolor(); } Color cend = new Color(0.9f, 0.9f, 0.9f, 1.0f); if (myserie.getMycolor() != null) { cend = myserie.getMycolor(); } LookupPaintScale paintscale = createLUT(100, (float) minval, (float) maxval, cdeb, cend); if (myserie.getMyMedcolor() != null) { paintscale = createLUT(100, (float) minval, (float) maxval, cdeb, myserie.getMyMedcolor(), cend); } newr.setPaintScale(paintscale); final NumberAxis scaleAxis = new NumberAxis(myserie.getName()); scaleAxis.setAxisLinePaint(this.axesColor); scaleAxis.setTickMarkPaint(this.axesColor); scaleAxis.setTickLabelFont(this.getTickFont()); scaleAxis.setRange(minval, maxval); scaleAxis.setAxisLinePaint(axesColor); scaleAxis.setLabelFont(getLabelFont()); if (textColor != null) { scaleAxis.setLabelPaint(textColor); scaleAxis.setTickLabelPaint(textColor); } if (!this.getXTickValueVisible(scope)) { scaleAxis.setTickMarksVisible(false); scaleAxis.setTickLabelsVisible(false); } final PaintScaleLegend legend = new PaintScaleLegend(paintscale, scaleAxis); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); // legend.setMargin(new RectangleInsets(5, 5, 5, 5)); // legend.setFrame(new BlockBorder(Color.red)); // legend.setPadding(new RectangleInsets(10, 10, 10, 10)); // legend.setStripWidth(10); legend.setPosition(RectangleEdge.RIGHT); legend.setBackgroundPaint(this.backgroundColor); // ArrayList<PaintScaleLegend> caxe=new // ArrayList<PaintScaleLegend>(); // caxe.add(legend); // chart.setSubtitles(caxe); if (!this.series_label_position.equals("none")) { chart.addSubtitle(legend); } } }