PageRenderTime 89ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/jasperreports/src/net/sf/jasperreports/components/spiderchart/StandardSpiderPlot.java

https://gitlab.com/samuel-davis/JasperReports-OSGI
Java | 450 lines | 252 code | 73 blank | 125 comment | 2 complexity | 9c3289101f1c18d331ed88dc3afca659 MD5 | raw file
  1. /*
  2. * JasperReports - Free Java Reporting Library.
  3. * Copyright (C) 2001 - 2016 TIBCO Software Inc. 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.JRRuntimeException;
  33. import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
  34. import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
  35. import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
  36. import org.jfree.chart.plot.PlotOrientation;
  37. /**
  38. * @author sanda zaharia (shertage@users.sourceforge.net)
  39. */
  40. public class StandardSpiderPlot implements SpiderPlot, JRChangeEventsSupport
  41. {
  42. /**
  43. *
  44. */
  45. private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
  46. public static final String PROPERTY_LABEL_FONT = "labelFont";
  47. public static final String PROPERTY_MAX_VALUE_EXPRESSION = "maxValueExpression";
  48. public static final String PROPERTY_ROTATION = "rotation";
  49. public static final String PROPERTY_TABLE_ORDER = "tableOrder";
  50. public static final String PROPERTY_WEB_FILLED = "webFilled";
  51. public static final String PROPERTY_START_ANGLE = "startAngle";
  52. public static final String PROPERTY_HEAD_PERCENT = "headPercent";
  53. public static final String PROPERTY_INTERIOR_GAP = "interiorGap";
  54. public static final String PROPERTY_AXIS_LINE_COLOR = "axisLineColor";
  55. public static final String PROPERTY_AXIS_LINE_WIDTH = "axisLineWidth";
  56. public static final String PROPERTY_LABEL_GAP = "labelGap";
  57. public static final String PROPERTY_LABEL_COLOR = "labelColor";
  58. public static final String PROPERTY_BACKCOLOR = "backcolor";
  59. public static final String PROPERTY_BACKGROUND_ALPHA = "backgroundAlpha";
  60. public static final String PROPERTY_FOREGROUND_ALPHA = "foregroundAlpha";
  61. protected JRFont labelFont;
  62. protected JRExpression maxValueExpression;
  63. protected SpiderRotationEnum rotation;
  64. protected TableOrderEnum tableOrder;
  65. protected Boolean webFilled;
  66. protected Double startAngle;
  67. protected Double headPercent;
  68. protected Double interiorGap;
  69. protected Color axisLineColor;
  70. protected Float axisLineWidth;
  71. protected Double labelGap;
  72. protected Color labelColor;
  73. protected Color backcolor;
  74. protected Float backgroundAlpha;
  75. protected Float foregroundAlpha;
  76. /**
  77. *
  78. */
  79. public StandardSpiderPlot()
  80. {
  81. }
  82. /**
  83. *
  84. */
  85. public StandardSpiderPlot(SpiderPlot spiderPlot, JRBaseObjectFactory factory)
  86. {
  87. labelFont = spiderPlot.getLabelFont();
  88. rotation = spiderPlot.getRotation();
  89. tableOrder = spiderPlot.getTableOrder();
  90. webFilled = spiderPlot.getWebFilled();
  91. startAngle = spiderPlot.getStartAngle();
  92. headPercent = spiderPlot.getHeadPercent();
  93. interiorGap = spiderPlot.getInteriorGap();
  94. axisLineColor = spiderPlot.getAxisLineColor();
  95. axisLineWidth = spiderPlot.getAxisLineWidth();
  96. labelGap = spiderPlot.getLabelGap();
  97. labelColor = spiderPlot.getLabelColor();
  98. backcolor = spiderPlot.getBackcolor();
  99. backgroundAlpha = spiderPlot.getBackgroundAlpha();
  100. foregroundAlpha = spiderPlot.getForegroundAlpha();
  101. maxValueExpression = factory.getExpression( spiderPlot.getMaxValueExpression() );
  102. }
  103. /**
  104. * @return the labelFont
  105. */
  106. @Override
  107. public JRFont getLabelFont() {
  108. return labelFont;
  109. }
  110. /**
  111. * @return the maxValueExpression
  112. */
  113. @Override
  114. public JRExpression getMaxValueExpression() {
  115. return maxValueExpression;
  116. }
  117. /**
  118. * @return the rotation
  119. */
  120. @Override
  121. public SpiderRotationEnum getRotation() {
  122. return rotation;
  123. }
  124. /**
  125. * @return the tableOrder
  126. */
  127. @Override
  128. public TableOrderEnum getTableOrder() {
  129. return tableOrder;
  130. }
  131. /**
  132. * @return the webFilled
  133. */
  134. @Override
  135. public Boolean getWebFilled() {
  136. return webFilled;
  137. }
  138. /**
  139. * @return the startAngle
  140. */
  141. @Override
  142. public Double getStartAngle() {
  143. return startAngle;
  144. }
  145. /**
  146. * @return the headPercent
  147. */
  148. @Override
  149. public Double getHeadPercent() {
  150. return headPercent;
  151. }
  152. /**
  153. * @return the interiorGap
  154. */
  155. @Override
  156. public Double getInteriorGap() {
  157. return interiorGap;
  158. }
  159. /**
  160. * @return the axisLineColor
  161. */
  162. @Override
  163. public Color getAxisLineColor() {
  164. return axisLineColor;
  165. }
  166. /**
  167. * @return the axisLineWidth
  168. */
  169. @Override
  170. public Float getAxisLineWidth() {
  171. return axisLineWidth;
  172. }
  173. /**
  174. * @return the labelGap
  175. */
  176. @Override
  177. public Double getLabelGap() {
  178. return labelGap;
  179. }
  180. /**
  181. * @return the labelColor
  182. */
  183. @Override
  184. public Color getLabelColor() {
  185. return labelColor;
  186. }
  187. /**
  188. *
  189. */
  190. public void setLabelFont(JRFont labelFont)
  191. {
  192. Object old = this.labelFont;
  193. this.labelFont = labelFont;
  194. getEventSupport().firePropertyChange(PROPERTY_LABEL_FONT, old, this.labelFont);
  195. }
  196. /**
  197. *
  198. */
  199. public void setMaxValueExpression(JRExpression maxValueExpression)
  200. {
  201. Object old = this.maxValueExpression;
  202. this.maxValueExpression = maxValueExpression;
  203. getEventSupport().firePropertyChange(PROPERTY_MAX_VALUE_EXPRESSION, old, this.maxValueExpression);
  204. }
  205. /**
  206. *
  207. */
  208. public void setRotation(SpiderRotationEnum rotation)
  209. {
  210. Object old = this.rotation;
  211. this.rotation = rotation;
  212. getEventSupport().firePropertyChange(PROPERTY_ROTATION, old, this.rotation);
  213. }
  214. /**
  215. *
  216. */
  217. public void setTableOrder(TableOrderEnum tableOrder)
  218. {
  219. Object old = this.tableOrder;
  220. this.tableOrder = tableOrder;
  221. getEventSupport().firePropertyChange(PROPERTY_TABLE_ORDER, old, this.tableOrder);
  222. }
  223. /**
  224. *
  225. */
  226. public void setWebFilled(Boolean webFilled)
  227. {
  228. Object old = this.webFilled;
  229. this.webFilled = webFilled;
  230. getEventSupport().firePropertyChange(PROPERTY_WEB_FILLED, old, this.webFilled);
  231. }
  232. /**
  233. *
  234. */
  235. public void setStartAngle(Double startAngle)
  236. {
  237. Object old = this.startAngle;
  238. this.startAngle = startAngle;
  239. getEventSupport().firePropertyChange(PROPERTY_START_ANGLE, old, this.startAngle);
  240. }
  241. /**
  242. *
  243. */
  244. public void setHeadPercent(Double headPercent)
  245. {
  246. Object old = this.headPercent;
  247. this.headPercent = headPercent;
  248. getEventSupport().firePropertyChange(PROPERTY_HEAD_PERCENT, old, this.headPercent);
  249. }
  250. /**
  251. *
  252. */
  253. public void setInteriorGap(Double interiorGap)
  254. {
  255. Object old = this.interiorGap;
  256. this.interiorGap = interiorGap;
  257. getEventSupport().firePropertyChange(PROPERTY_INTERIOR_GAP, old, this.interiorGap);
  258. }
  259. /**
  260. *
  261. */
  262. public void setAxisLineColor(Color axisLineColor)
  263. {
  264. Object old = this.axisLineColor;
  265. this.axisLineColor = axisLineColor;
  266. getEventSupport().firePropertyChange(PROPERTY_AXIS_LINE_COLOR, old, this.axisLineColor);
  267. }
  268. /**
  269. *
  270. */
  271. public void setAxisLineWidth(Float axisLineWidth)
  272. {
  273. Object old = this.axisLineWidth;
  274. this.axisLineWidth = axisLineWidth;
  275. getEventSupport().firePropertyChange(PROPERTY_AXIS_LINE_WIDTH, old, this.axisLineWidth);
  276. }
  277. /**
  278. *
  279. */
  280. public void setLabelGap(Double labelGap)
  281. {
  282. Object old = this.labelGap;
  283. this.labelGap = labelGap;
  284. getEventSupport().firePropertyChange(PROPERTY_LABEL_GAP, old, this.labelGap);
  285. }
  286. /**
  287. *
  288. */
  289. public void setLabelColor(Color labelColor)
  290. {
  291. Object old = this.labelColor;
  292. this.labelColor = labelColor;
  293. getEventSupport().firePropertyChange(PROPERTY_LABEL_COLOR, old, this.labelColor);
  294. }
  295. /**
  296. * @return the backcolor
  297. */
  298. @Override
  299. public Color getBackcolor() {
  300. return backcolor;
  301. }
  302. /**
  303. * @param backcolor the backcolor to set
  304. */
  305. public void setBackcolor(Color backcolor) {
  306. Object old = this.backcolor;
  307. this.backcolor = backcolor;
  308. getEventSupport().firePropertyChange(PROPERTY_BACKCOLOR, old, this.backcolor);
  309. }
  310. /**
  311. * @return the backgroundAlpha
  312. */
  313. @Override
  314. public Float getBackgroundAlpha() {
  315. return backgroundAlpha;
  316. }
  317. /**
  318. * @param backgroundAlpha the backgroundAlpha to set
  319. */
  320. public void setBackgroundAlpha(Float backgroundAlpha) {
  321. Object old = this.backgroundAlpha;
  322. this.backgroundAlpha = backgroundAlpha;
  323. getEventSupport().firePropertyChange(PROPERTY_BACKGROUND_ALPHA, old, this.backgroundAlpha);
  324. }
  325. /**
  326. * @return the foregroundAlpha
  327. */
  328. @Override
  329. public Float getForegroundAlpha() {
  330. return foregroundAlpha;
  331. }
  332. /**
  333. * @param foregroundAlpha the foregroundAlpha to set
  334. */
  335. public void setForegroundAlpha(Float foregroundAlpha) {
  336. Object old = this.foregroundAlpha;
  337. this.foregroundAlpha = foregroundAlpha;
  338. getEventSupport().firePropertyChange(PROPERTY_FOREGROUND_ALPHA, old, this.foregroundAlpha);
  339. }
  340. @Override
  341. public PlotOrientation getOrientation()
  342. {
  343. return null;
  344. }
  345. public void collectExpressions(JRExpressionCollector collector)
  346. {
  347. SpiderChartCompiler.collectExpressions(this, collector);
  348. }
  349. @Override
  350. public Object clone()
  351. {
  352. StandardSpiderPlot clone = null;
  353. try
  354. {
  355. clone = (StandardSpiderPlot)super.clone();
  356. clone.eventSupport = null;
  357. }
  358. catch (CloneNotSupportedException e)
  359. {
  360. throw new JRRuntimeException(e);
  361. }
  362. return clone;
  363. }
  364. private transient JRPropertyChangeSupport eventSupport;
  365. @Override
  366. public JRPropertyChangeSupport getEventSupport()
  367. {
  368. synchronized (this)
  369. {
  370. if (eventSupport == null)
  371. {
  372. eventSupport = new JRPropertyChangeSupport(this);
  373. }
  374. }
  375. return eventSupport;
  376. }
  377. }