PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/jasperreports/src/net/sf/jasperreports/charts/fill/JRFillXyzSeries.java

https://gitlab.com/samuel-davis/JasperReports-OSGI
Java | 142 lines | 95 code | 21 blank | 26 comment | 1 complexity | f750713a94a7a6e3f5af16e6ca47f971 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.charts.fill;
  25. import net.sf.jasperreports.charts.JRXyzSeries;
  26. import net.sf.jasperreports.engine.JRException;
  27. import net.sf.jasperreports.engine.JRExpression;
  28. import net.sf.jasperreports.engine.JRHyperlink;
  29. import net.sf.jasperreports.engine.JRHyperlinkHelper;
  30. import net.sf.jasperreports.engine.JRPrintHyperlink;
  31. import net.sf.jasperreports.engine.JRRuntimeException;
  32. import net.sf.jasperreports.engine.fill.JRCalculator;
  33. import net.sf.jasperreports.engine.fill.JRExpressionEvalException;
  34. import net.sf.jasperreports.engine.fill.JRFillHyperlinkHelper;
  35. import net.sf.jasperreports.engine.fill.JRFillObjectFactory;
  36. /**
  37. * @author Flavius Sana (flavius_sana@users.sourceforge.net)
  38. */
  39. public class JRFillXyzSeries implements JRXyzSeries {
  40. JRXyzSeries parent;
  41. private Comparable<?> series;
  42. private Number xValue;
  43. private Number yValue;
  44. private Number zValue;
  45. private JRPrintHyperlink itemHyperlink;
  46. public JRFillXyzSeries( JRXyzSeries xyzSeries, JRFillObjectFactory factory ){
  47. factory.put( xyzSeries, this );
  48. parent = xyzSeries;
  49. }
  50. @Override
  51. public JRExpression getSeriesExpression(){
  52. return parent.getSeriesExpression();
  53. }
  54. @Override
  55. public JRExpression getXValueExpression(){
  56. return parent.getXValueExpression();
  57. }
  58. @Override
  59. public JRExpression getYValueExpression(){
  60. return parent.getYValueExpression();
  61. }
  62. @Override
  63. public JRExpression getZValueExpression(){
  64. return parent.getZValueExpression();
  65. }
  66. protected Comparable<?> getSeries(){
  67. return series;
  68. }
  69. protected Number getXValue(){
  70. return xValue;
  71. }
  72. protected Number getYValue(){
  73. return yValue;
  74. }
  75. protected Number getZValue(){
  76. return zValue;
  77. }
  78. protected JRPrintHyperlink getPrintItemHyperlink()
  79. {
  80. return itemHyperlink;
  81. }
  82. protected void evaluate( JRCalculator calculator ) throws JRExpressionEvalException {
  83. series = (Comparable<?>)calculator.evaluate( getSeriesExpression() );
  84. xValue = (Number)calculator.evaluate( getXValueExpression() );
  85. yValue = (Number)calculator.evaluate( getYValueExpression() );
  86. zValue = (Number)calculator.evaluate( getZValueExpression() );
  87. if (hasItemHyperlinks())
  88. {
  89. evaluateItemHyperlink(calculator);
  90. }
  91. }
  92. protected void evaluateItemHyperlink(JRCalculator calculator) throws JRExpressionEvalException
  93. {
  94. try
  95. {
  96. itemHyperlink = JRFillHyperlinkHelper.evaluateHyperlink(getItemHyperlink(), calculator, JRExpression.EVALUATION_DEFAULT);
  97. }
  98. catch (JRExpressionEvalException e)
  99. {
  100. throw e;
  101. }
  102. catch (JRException e)
  103. {
  104. throw new JRRuntimeException(e);
  105. }
  106. }
  107. @Override
  108. public JRHyperlink getItemHyperlink()
  109. {
  110. return parent.getItemHyperlink();
  111. }
  112. public boolean hasItemHyperlinks()
  113. {
  114. return !JRHyperlinkHelper.isEmpty(getItemHyperlink());
  115. }
  116. @Override
  117. public Object clone()
  118. {
  119. throw new UnsupportedOperationException();
  120. }
  121. }