001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2022, by David Gilbert and Contributors. 006 * 007 * Project Info: http://www.jfree.org/jfreechart/index.html 008 * 009 * This library is free software; you can redistribute it and/or modify it 010 * under the terms of the GNU Lesser General Public License as published by 011 * the Free Software Foundation; either version 2.1 of the License, or 012 * (at your option) any later version. 013 * 014 * This library is distributed in the hope that it will be useful, but 015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 017 * License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public 020 * License along with this library; if not, write to the Free Software 021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 022 * USA. 023 * 024 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 025 * Other names may be trademarks of their respective owners.] 026 * 027 * ------------------ 028 * RendererState.java 029 * ------------------ 030 * (C) Copyright 2003-2022, by David Gilbert. 031 * 032 * Original Author: David Gilbert; 033 * Contributor(s): -; 034 * 035 */ 036 037package org.jfree.chart.renderer; 038 039import org.jfree.chart.ChartRenderingInfo; 040import org.jfree.chart.entity.EntityCollection; 041import org.jfree.chart.plot.PlotRenderingInfo; 042 043/** 044 * Represents the current state of a renderer. 045 */ 046public class RendererState { 047 048 /** The plot rendering info. */ 049 private PlotRenderingInfo info; 050 051 /** 052 * A flag that indicates whether or not rendering hints should be added to 053 * identify chart elements. It is initialised from the corresponding flag 054 * in the JFreeChart instance. 055 */ 056 private boolean elementHinting; 057 058 /** 059 * Creates a new state object. 060 * 061 * @param info the plot rendering info. 062 */ 063 public RendererState(PlotRenderingInfo info) { 064 this.info = info; 065 this.elementHinting = false; 066 } 067 068 /** 069 * Returns the flag that controls whether or not the renderer should 070 * add rendering hints to the output that identify chart elements. 071 * 072 * @return A boolean. 073 */ 074 public boolean getElementHinting() { 075 return this.elementHinting; 076 } 077 078 /** 079 * Sets the elementHinting flag. 080 * 081 * @param hinting the new flag value. 082 */ 083 public void setElementHinting(boolean hinting) { 084 this.elementHinting = hinting; 085 } 086 087 /** 088 * Returns the plot rendering info. 089 * 090 * @return The info. 091 */ 092 public PlotRenderingInfo getInfo() { 093 return this.info; 094 } 095 096 /** 097 * A convenience method that returns a reference to the entity 098 * collection (may be {@code null}) being used to record 099 * chart entities. 100 * 101 * @return The entity collection (possibly {@code null}). 102 */ 103 public EntityCollection getEntityCollection() { 104 EntityCollection result = null; 105 if (this.info != null) { 106 ChartRenderingInfo owner = this.info.getOwner(); 107 if (owner != null) { 108 result = owner.getEntityCollection(); 109 } 110 } 111 return result; 112 } 113 114}