← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16595: PNG charts, respecting chart title and hideTitle options

 

------------------------------------------------------------
revno: 16595
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-08-31 22:38:25 +0200
message:
  PNG charts, respecting chart title and hideTitle options
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/BaseChart.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/BaseChart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/BaseChart.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/BaseChart.java	2014-08-31 20:38:25 +0000
@@ -196,6 +196,11 @@
     {
         return getAnalyticsType().equals( type );
     }
+    
+    public boolean hasTitle()
+    {
+        return title != null && !title.isEmpty();
+    }
 
     // -------------------------------------------------------------------------
     // Getters and setters for transient properties

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2014-08-31 20:38:25 +0000
@@ -709,10 +709,15 @@
     private void setBasicConfig( JFreeChart jFreeChart, BaseChart chart)
     {
         jFreeChart.getTitle().setFont( TITLE_FONT );
-        jFreeChart.addSubtitle( getSubTitle( chart ) );
+        
         jFreeChart.setBackgroundPaint( COLOR_TRANSPARENT );
         jFreeChart.setAntiAlias( true );
         
+        if ( !chart.isHideTitle() )
+        {
+            jFreeChart.addSubtitle( getSubTitle( chart ) );
+        }
+        
         Plot plot = jFreeChart.getPlot();
         plot.setBackgroundPaint( COLOR_TRANSPARENT );
         plot.setOutlinePaint( COLOR_TRANSPARENT );
@@ -720,12 +725,14 @@
 
     private TextTitle getSubTitle( BaseChart chart )
     {
-        TextTitle title = new TextTitle();
-
-        title.setFont( SUB_TITLE_FONT );
-        title.setText( chart.generateTitle() );
-
-        return title;
+        TextTitle textTitle = new TextTitle();
+
+        String title = chart.hasTitle() ? chart.getTitle() : chart.generateTitle();
+        
+        textTitle.setFont( SUB_TITLE_FONT );
+        textTitle.setText( title );
+        
+        return textTitle;
     }
 
     private CategoryDataset[] getCategoryDataSet( BaseChart chart )