/** * Handle opacity customization requested. * - get customization parameters from parameter Map and modify plot accordingly * @param opacity value to set to the chart * @param plot chart plot * @throws MacroExecutionException */ void handleOpacityCustomization(String opacity, Plot plot) throws MacroExecutionException { if (opacity != null) { try { Integer iOpacity = new Integer(opacity); if ((iOpacity < 0) || (iOpacity > 100)) { throw new MacroExecutionException("opacity parameter value '" + opacity + "' not between 0 and 100"); } plot.setForegroundAlpha(iOpacity.floatValue()/100); } catch (NumberFormatException exception) { // error out on illegal integer value throw new MacroExecutionException("opacity parameter value '" + opacity + "' not a number between 0 and 100"); } } }
/** * Sets properties common to all plots of this plug-in. * * @param plot * the plot to set the properties for */ // CHECKSTYLE:OFF protected void setPlotProperties(final Plot plot) { plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); } // CHECKSTYLE:ON
/** * Sets properties common to all plots of this plug-in. * * @param plot * the plot to set the properties for */ // CHECKSTYLE:OFF protected void setPlotProperties(final Plot plot) { plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); } // CHECKSTYLE:ON
public static void customizePlot(Plot plot, ChartParams params) { if (params.get(ChartParams.PLOT_BACKGROUND_COLOR) != null) { plot.setBackgroundPaint(params.getColor(ChartParams.PLOT_BACKGROUND_COLOR)); } if (params.get(ChartParams.PLOT_BACKGROUND_ALPHA) != null) { plot.setBackgroundAlpha(params.getFloat(ChartParams.PLOT_BACKGROUND_ALPHA).floatValue()); } if (params.get(ChartParams.PLOT_FOREGROUND_ALPHA) != null) { plot.setForegroundAlpha(params.getFloat(ChartParams.PLOT_FOREGROUND_ALPHA).floatValue()); } if (params.get(ChartParams.PLOT_INSERTS) != null) { plot.setInsets(params.getRectangleInsets(ChartParams.PLOT_INSERTS)); } if (params.get(ChartParams.PLOT_OUTLINE_COLOR) != null) { plot.setOutlinePaint(params.getColor(ChartParams.PLOT_OUTLINE_COLOR)); } if (params.get(ChartParams.PLOT_OUTLINE_STROKE) != null) { plot.setOutlineStroke(params.getStroke(ChartParams.PLOT_OUTLINE_STROKE)); } }
float foregroundAlpha = getPlot().getForegroundAlphaFloat() == null ? 1f : getPlot().getForegroundAlphaFloat().floatValue(); plot.setBackgroundAlpha(backgroundAlpha); plot.setForegroundAlpha(foregroundAlpha);
public void configurePlot(Plot plot) { if (getPlotBackgroundAlpha() != null) { plot.setBackgroundAlpha(getPlotBackgroundAlpha()); } if (getPlotForegroundAlpha() != null) { plot.setForegroundAlpha(getPlotForegroundAlpha()); } if (getPlotBackgroundPaint() != null) { plot.setBackgroundPaint(findColor(getPlotBackgroundPaint())); } if (getPlotOutlinePaint() != null) { plot.setOutlinePaint(findColor(getPlotOutlinePaint())); } if (getPlotOutlineStroke() != null) { plot.setOutlineStroke(findStroke(getPlotOutlineStroke())); } }
Plot plot = (Plot) jfchart.getPlot(); float alpha = (float)(((float)chart.getFgAlpha()) / 255); plot.setForegroundAlpha(alpha);