List of usage examples for org.jfree.chart LegendItem getLinePaint
public Paint getLinePaint()
From source file:ca.nengo.plot.impl.DefaultPlotter.java
private static LegendItem getCopy(LegendItem original, String newLabel) { return new LegendItem(newLabel, null, //description null, //tooltip text null, //URL original.isShapeVisible(), original.getShape(), original.isShapeFilled(), original.getFillPaint(), original.isShapeOutlineVisible(), original.getOutlinePaint(), original.getOutlineStroke(), original.isLineVisible(), original.getLine(), original.getLineStroke(), original.getLinePaint()); }
From source file:gda.plots.SimpleLegendTitle.java
/** * Overrides the super class method to create a SimpleLegendGraphic instead of a LegendGraphic and a * SimpleLegendLabelBlock instead of a LabelBlock (otherwise identical except private field names replaced with * method calls). Assumes it will be passed a SimpleLegendItem and uses it to get the SimpleXYSeries to pass on to * the SimpleLegendGraphic and SimpleLegendLabelBlock. * //from w w w. j a v a 2 s . c o m * @param item * the LegendItem for which the LegendItemBlock is to be created * @return the LegendItemBlock created */ @Override protected Block createLegendItemBlock(LegendItem item) { BlockContainer result = null; if (item instanceof SimpleLegendItem) { LegendGraphic lg = new SimpleLegendGraphic(item.getShape(), item.getFillPaint(), ((SimpleLegendItem) item).getSeries()); lg.setShapeFilled(item.isShapeFilled()); lg.setLine(item.getLine()); lg.setLineStroke(item.getLineStroke()); lg.setLinePaint(item.getLinePaint()); lg.setLineVisible(item.isLineVisible()); lg.setShapeVisible(item.isShapeVisible()); lg.setShapeOutlineVisible(item.isShapeOutlineVisible()); lg.setOutlinePaint(item.getOutlinePaint()); lg.setOutlineStroke(item.getOutlineStroke()); lg.setPadding(getLegendItemGraphicPadding()); BlockContainer legendItem = new BlockContainer(new BorderArrangement()); lg.setShapeAnchor(getLegendItemGraphicAnchor()); lg.setShapeLocation(getLegendItemGraphicLocation()); legendItem.add(lg, getLegendItemGraphicEdge()); LabelBlock labelBlock = new SimpleLegendLabelBlock(item.getLabel(), getItemFont(), getItemPaint(), ((SimpleLegendItem) item).getSeries()); labelBlock.setPadding(getItemLabelPadding()); labelBlock.setToolTipText(item.getLabel()); // labelBlock.setToolTipText("click"); legendItem.add(labelBlock); result = new BlockContainer(new CenterArrangement()); result.add(legendItem); } return result; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.SmartLegendTitle.java
private Block createDefaultLegendItem(LegendItem item) { BlockContainer result = null;/*from w w w .j ava2 s .c o m*/ Shape shape = item.getShape(); if (shape == null) { shape = new Rectangle(); } LegendGraphic lg = new LegendGraphic(shape, item.getFillPaint()); lg.setFillPaintTransformer(item.getFillPaintTransformer()); lg.setShapeFilled(item.isShapeFilled()); lg.setLine(item.getLine()); lg.setLineStroke(item.getLineStroke()); lg.setLinePaint(item.getLinePaint()); lg.setLineVisible(item.isLineVisible()); lg.setShapeVisible(item.isShapeVisible()); lg.setShapeOutlineVisible(item.isShapeOutlineVisible()); lg.setOutlinePaint(item.getOutlinePaint()); lg.setOutlineStroke(item.getOutlineStroke()); lg.setPadding(getLegendItemGraphicPadding()); LegendItemBlockContainer legendItem = new LegendItemBlockContainer(new BorderArrangement(), item.getDataset(), item.getSeriesKey()); lg.setShapeAnchor(getLegendItemGraphicAnchor()); lg.setShapeLocation(getLegendItemGraphicLocation()); legendItem.add(lg, getLegendItemGraphicEdge()); Font textFont = item.getLabelFont(); if (textFont == null) { textFont = getItemFont(); } Paint textPaint = item.getLabelPaint(); if (textPaint == null) { textPaint = getItemPaint(); } LabelBlock labelBlock = new LabelBlock(item.getLabel(), textFont, textPaint); labelBlock.setPadding(getItemLabelPadding()); legendItem.add(labelBlock); legendItem.setToolTipText(item.getToolTipText()); legendItem.setURLText(item.getURLText()); result = new BlockContainer(new CenterArrangement()); result.add(legendItem); return result; }
From source file:gov.llnl.lustre.lwatch.PlotFrame2.java
/** * Define the JFreeChart chart./*from ww w . ja va2s . c om*/ * * @param dataset dataset to be plotted in the chart. */ public JFreeChart createChart(XYDataset dataset) { // Load data for settings from last "Refresh" time String[] selectedRows = lastRefreshPlotParams.getCategories(); String[] selectedVars = lastRefreshPlotParams.getVariables(); String[] selectedCurves = lastRefreshPlotParams.getCurves(); int savedGranularity = granularity; granularity = lastRefreshPlotParams.getGranularity(); boolean showLegend = true; //if (((isAnAggPlot) && (nColsSelected * nCurvesSelected > 8)) || //(nRowsSelected * nColsSelected * nCurvesSelected > 8)) //showLegend = false; if (((isAnAggPlot) && (selectedVars.length * selectedCurves.length > 8)) || (selectedRows.length * selectedVars.length * selectedCurves.length > 8)) showLegend = false; //if (fromRefresh && (nRowsSelected > 0 && nColsSelected > 0 && nCurvesSelected > 0) && //(!noVarSelected)) { if (fromRefresh && (selectedRows.length > 0 && selectedVars.length > 0 && selectedCurves.length > 0) && (!noVarSelected)) { //Debug.out("nRowsSelected = " + nRowsSelected + //" nColsSelected = " + nColsSelected + //" nCurvesSelected = " + nCurvesSelected); pD = new PlotDescriptor(); } chart = ChartFactory.createTimeSeriesChart(fsName + " - " + type + " data", // title "Date", // x-axis label yAxisLabel, // y-axis label dataset, // data showLegend, // create legend false, // generate tooltips false // generate URLs ); chart.setBackgroundPaint(Color.black); //white); // Border color chart.setBorderVisible(true); TextTitle tTitle = chart.getTitle(); tTitle.setPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.black); //lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // Check need for logorihmic axis if (useLogRangeAxis) { LogarithmicAxis rangeAxis2 = new LogarithmicAxis(yAxisLabel); plot.setRangeAxis(0, rangeAxis2); } // Default axis annotation is in black. So if the chart background // Paint was set to black above, we need to set axis labels, // tick labels and tick marks to be a contrasting color. plot.getDomainAxis().setLabelPaint(Color.white); plot.getDomainAxis().setTickLabelPaint(Color.white); plot.getDomainAxis().setTickMarkPaint(Color.white); plot.getRangeAxis().setLabelPaint(Color.white); plot.getRangeAxis().setTickLabelPaint(Color.white); plot.getRangeAxis().setTickMarkPaint(Color.white); // Grab the colors from the legend. //int nCurves = nRowsSelected * nColsSelected * nCurvesSelected; int nCurves = selectedRows.length * selectedVars.length * selectedCurves.length; if (localDebug) { Debug.out("selectedRows.length, selectedVars.length, selectedCurves.length = " + selectedRows.length + ", " + selectedVars.length + ", " + selectedCurves.length); Debug.out("Dimension legendColors to size = " + nCurves); } legendColors = new Color[nCurves]; LegendItemCollection lic = plot.getLegendItems(); for (int i = 0; i < lic.getItemCount(); i++) { LegendItem li = lic.get(i); legendColors[i] = (Color) li.getLinePaint(); //if (localDebug) //Debug.out("Line Paint for legend " + i + " = " + //legendColors[i]); } XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(showIcons); // Controls icons at data pts. renderer.setBaseShapesFilled(false); } DateAxis axis = (DateAxis) plot.getDomainAxis(); if (granularity == Database.HOUR) axis.setDateFormatOverride(new SimpleDateFormat("MM/dd HH")); //("dd-MMM-yy")); else if (granularity == Database.DAY) axis.setDateFormatOverride(new SimpleDateFormat("MM/dd/yy")); //("dd-MMM-yy")); else if (granularity == Database.WEEK) axis.setDateFormatOverride(new SimpleDateFormat("MM/dd/yy")); //("dd-MMM-yy")); else if (granularity == Database.MONTH) axis.setDateFormatOverride(new SimpleDateFormat("MM/yy")); //("dd-MMM-yy")); else if (granularity == Database.YEAR) axis.setDateFormatOverride(new SimpleDateFormat("yyyy HH:mm")); //("dd-MMM-yy")); else // granualrity == Database.RAW or HEARTBEAT axis.setDateFormatOverride(new SimpleDateFormat("MM/dd HH:mm:ss")); //("dd-MMM-yy")); // Reset granularity; granularity = savedGranularity; return chart; }