/projects/jasperreports-3.7.4/src/net/sf/jasperreports/components/spiderchart/StandardSpiderPlot.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus · Java · 408 lines · 214 code · 68 blank · 126 comment · 2 complexity · e9ad0f5f2275fb0d97052964316e2bfd MD5 · raw file

  1. /*
  2. * JasperReports - Free Java Reporting Library.
  3. * Copyright (C) 2001 - 2009 Jaspersoft Corporation. All rights reserved.
  4. * http://www.jaspersoft.com
  5. *
  6. * Unless you have purchased a commercial license agreement from Jaspersoft,
  7. * the following license terms apply:
  8. *
  9. * This program is part of JasperReports.
  10. *
  11. * JasperReports is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Lesser General Public License as published by
  13. * the Free Software Foundation, either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * JasperReports is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public License
  22. * along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. package net.sf.jasperreports.components.spiderchart;
  25. import java.awt.Color;
  26. import net.sf.jasperreports.components.spiderchart.type.SpiderRotationEnum;
  27. import net.sf.jasperreports.components.spiderchart.type.TableOrderEnum;
  28. import net.sf.jasperreports.engine.JRConstants;
  29. import net.sf.jasperreports.engine.JRExpression;
  30. import net.sf.jasperreports.engine.JRExpressionCollector;
  31. import net.sf.jasperreports.engine.JRFont;
  32. import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
  33. import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
  34. import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
  35. /**
  36. * @author sanda zaharia (shertage@users.sourceforge.net)
  37. * @version $Id: StandardSpiderPlot.java 3889 2010-07-16 10:52:00Z shertage $
  38. */
  39. public class StandardSpiderPlot implements SpiderPlot, JRChangeEventsSupport
  40. {
  41. /**
  42. *
  43. */
  44. private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
  45. public static final String PROPERTY_LABEL_FONT = "labelFont";
  46. public static final String PROPERTY_MAX_VALUE_EXPRESSION = "maxValueExpression";
  47. public static final String PROPERTY_ROTATION = "rotation";
  48. public static final String PROPERTY_TABLE_ORDER = "tableOrder";
  49. public static final String PROPERTY_WEB_FILLED = "webFilled";
  50. public static final String PROPERTY_START_ANGLE = "startAngle";
  51. public static final String PROPERTY_HEAD_PERCENT = "headPercent";
  52. public static final String PROPERTY_INTERIOR_GAP = "interiorGap";
  53. public static final String PROPERTY_AXIS_LINE_COLOR = "axisLineColor";
  54. public static final String PROPERTY_AXIS_LINE_WIDTH = "axisLineWidth";
  55. public static final String PROPERTY_LABEL_GAP = "labelGap";
  56. public static final String PROPERTY_LABEL_COLOR = "labelColor";
  57. public static final String PROPERTY_BACKCOLOR = "backcolor";
  58. public static final String PROPERTY_BACKGROUND_ALPHA = "backgroundAlpha";
  59. public static final String PROPERTY_FOREGROUND_ALPHA = "foregroundAlpha";
  60. protected JRFont labelFont;
  61. protected JRExpression maxValueExpression;
  62. protected SpiderRotationEnum rotation;
  63. protected TableOrderEnum tableOrder;
  64. protected Boolean webFilled;
  65. protected Double startAngle;
  66. protected Double headPercent;
  67. protected Double interiorGap;
  68. protected Color axisLineColor;
  69. protected Float axisLineWidth;
  70. protected Double labelGap;
  71. protected Color labelColor;
  72. protected Color backcolor;
  73. protected Float backgroundAlpha;
  74. protected Float foregroundAlpha;
  75. /**
  76. *
  77. */
  78. public StandardSpiderPlot()
  79. {
  80. }
  81. /**
  82. *
  83. */
  84. public StandardSpiderPlot(SpiderPlot spiderPlot, JRBaseObjectFactory factory)
  85. {
  86. labelFont = spiderPlot.getLabelFont();
  87. rotation = spiderPlot.getRotation();
  88. tableOrder = spiderPlot.getTableOrder();
  89. webFilled = spiderPlot.getWebFilled();
  90. startAngle = spiderPlot.getStartAngle();
  91. headPercent = spiderPlot.getHeadPercent();
  92. interiorGap = spiderPlot.getInteriorGap();
  93. axisLineColor = spiderPlot.getAxisLineColor();
  94. axisLineWidth = spiderPlot.getAxisLineWidth();
  95. labelGap = spiderPlot.getLabelGap();
  96. labelColor = spiderPlot.getLabelColor();
  97. backcolor = spiderPlot.getBackcolor();
  98. backgroundAlpha = spiderPlot.getBackgroundAlpha();
  99. foregroundAlpha = spiderPlot.getForegroundAlpha();
  100. maxValueExpression = factory.getExpression( spiderPlot.getMaxValueExpression() );
  101. }
  102. /**
  103. * @return the labelFont
  104. */
  105. public JRFont getLabelFont() {
  106. return labelFont;
  107. }
  108. /**
  109. * @return the maxValueExpression
  110. */
  111. public JRExpression getMaxValueExpression() {
  112. return maxValueExpression;
  113. }
  114. /**
  115. * @return the rotation
  116. */
  117. public SpiderRotationEnum getRotation() {
  118. return rotation;
  119. }
  120. /**
  121. * @return the tableOrder
  122. */
  123. public TableOrderEnum getTableOrder() {
  124. return tableOrder;
  125. }
  126. /**
  127. * @return the webFilled
  128. */
  129. public Boolean getWebFilled() {
  130. return webFilled;
  131. }
  132. /**
  133. * @return the startAngle
  134. */
  135. public Double getStartAngle() {
  136. return startAngle;
  137. }
  138. /**
  139. * @return the headPercent
  140. */
  141. public Double getHeadPercent() {
  142. return headPercent;
  143. }
  144. /**
  145. * @return the interiorGap
  146. */
  147. public Double getInteriorGap() {
  148. return interiorGap;
  149. }
  150. /**
  151. * @return the axisLineColor
  152. */
  153. public Color getAxisLineColor() {
  154. return axisLineColor;
  155. }
  156. /**
  157. * @return the axisLineWidth
  158. */
  159. public Float getAxisLineWidth() {
  160. return axisLineWidth;
  161. }
  162. /**
  163. * @return the labelGap
  164. */
  165. public Double getLabelGap() {
  166. return labelGap;
  167. }
  168. /**
  169. * @return the labelColor
  170. */
  171. public Color getLabelColor() {
  172. return labelColor;
  173. }
  174. /**
  175. *
  176. */
  177. public void setLabelFont(JRFont labelFont)
  178. {
  179. Object old = this.labelFont;
  180. this.labelFont = labelFont;
  181. getEventSupport().firePropertyChange(PROPERTY_LABEL_FONT, old, this.labelFont);
  182. }
  183. /**
  184. *
  185. */
  186. public void setMaxValueExpression(JRExpression maxValueExpression)
  187. {
  188. Object old = this.maxValueExpression;
  189. this.maxValueExpression = maxValueExpression;
  190. getEventSupport().firePropertyChange(PROPERTY_MAX_VALUE_EXPRESSION, old, this.maxValueExpression);
  191. }
  192. /**
  193. *
  194. */
  195. public void setRotation(SpiderRotationEnum rotation)
  196. {
  197. Object old = this.rotation;
  198. this.rotation = rotation;
  199. getEventSupport().firePropertyChange(PROPERTY_ROTATION, old, this.rotation);
  200. }
  201. /**
  202. *
  203. */
  204. public void setTableOrder(TableOrderEnum tableOrder)
  205. {
  206. Object old = this.tableOrder;
  207. this.tableOrder = tableOrder;
  208. getEventSupport().firePropertyChange(PROPERTY_TABLE_ORDER, old, this.tableOrder);
  209. }
  210. /**
  211. *
  212. */
  213. public void setWebFilled(Boolean webFilled)
  214. {
  215. Object old = this.webFilled;
  216. this.webFilled = webFilled;
  217. getEventSupport().firePropertyChange(PROPERTY_WEB_FILLED, old, this.webFilled);
  218. }
  219. /**
  220. *
  221. */
  222. public void setStartAngle(Double startAngle)
  223. {
  224. Object old = this.startAngle;
  225. this.startAngle = startAngle;
  226. getEventSupport().firePropertyChange(PROPERTY_START_ANGLE, old, this.startAngle);
  227. }
  228. /**
  229. *
  230. */
  231. public void setHeadPercent(Double headPercent)
  232. {
  233. Object old = this.headPercent;
  234. this.headPercent = headPercent;
  235. getEventSupport().firePropertyChange(PROPERTY_HEAD_PERCENT, old, this.headPercent);
  236. }
  237. /**
  238. *
  239. */
  240. public void setInteriorGap(Double interiorGap)
  241. {
  242. Object old = this.interiorGap;
  243. this.interiorGap = interiorGap;
  244. getEventSupport().firePropertyChange(PROPERTY_INTERIOR_GAP, old, this.interiorGap);
  245. }
  246. /**
  247. *
  248. */
  249. public void setAxisLineColor(Color axisLineColor)
  250. {
  251. Object old = this.axisLineColor;
  252. this.axisLineColor = axisLineColor;
  253. getEventSupport().firePropertyChange(PROPERTY_AXIS_LINE_COLOR, old, this.axisLineColor);
  254. }
  255. /**
  256. *
  257. */
  258. public void setAxisLineWidth(Float axisLineWidth)
  259. {
  260. Object old = this.axisLineWidth;
  261. this.axisLineWidth = axisLineWidth;
  262. getEventSupport().firePropertyChange(PROPERTY_AXIS_LINE_WIDTH, old, this.axisLineWidth);
  263. }
  264. /**
  265. *
  266. */
  267. public void setLabelGap(Double labelGap)
  268. {
  269. Object old = this.labelGap;
  270. this.labelGap = labelGap;
  271. getEventSupport().firePropertyChange(PROPERTY_LABEL_GAP, old, this.labelGap);
  272. }
  273. /**
  274. *
  275. */
  276. public void setLabelColor(Color labelColor)
  277. {
  278. Object old = this.labelColor;
  279. this.labelColor = labelColor;
  280. getEventSupport().firePropertyChange(PROPERTY_LABEL_COLOR, old, this.labelColor);
  281. }
  282. /**
  283. * @return the backcolor
  284. */
  285. public Color getBackcolor() {
  286. return backcolor;
  287. }
  288. /**
  289. * @param backcolor the backcolor to set
  290. */
  291. public void setBackcolor(Color backcolor) {
  292. Object old = this.backcolor;
  293. this.backcolor = backcolor;
  294. getEventSupport().firePropertyChange(PROPERTY_BACKCOLOR, old, this.backcolor);
  295. }
  296. /**
  297. * @return the backgroundAlpha
  298. */
  299. public Float getBackgroundAlpha() {
  300. return backgroundAlpha;
  301. }
  302. /**
  303. * @param backgroundAlpha the backgroundAlpha to set
  304. */
  305. public void setBackgroundAlpha(Float backgroundAlpha) {
  306. Object old = this.backgroundAlpha;
  307. this.backgroundAlpha = backgroundAlpha;
  308. getEventSupport().firePropertyChange(PROPERTY_BACKGROUND_ALPHA, old, this.backgroundAlpha);
  309. }
  310. /**
  311. * @return the foregroundAlpha
  312. */
  313. public Float getForegroundAlpha() {
  314. return foregroundAlpha;
  315. }
  316. /**
  317. * @param foregroundAlpha the foregroundAlpha to set
  318. */
  319. public void setForegroundAlpha(Float foregroundAlpha) {
  320. Object old = this.foregroundAlpha;
  321. this.foregroundAlpha = foregroundAlpha;
  322. getEventSupport().firePropertyChange(PROPERTY_FOREGROUND_ALPHA, old, this.foregroundAlpha);
  323. }
  324. public void collectExpressions(JRExpressionCollector collector)
  325. {
  326. SpiderChartCompiler.collectExpressions(this, collector);
  327. }
  328. private transient JRPropertyChangeSupport eventSupport;
  329. public JRPropertyChangeSupport getEventSupport()
  330. {
  331. synchronized (this)
  332. {
  333. if (eventSupport == null)
  334. {
  335. eventSupport = new JRPropertyChangeSupport(this);
  336. }
  337. }
  338. return eventSupport;
  339. }
  340. }