Java Code Examples for org.jfree.chart.title.TextTitle#setText()

The following examples show how to use org.jfree.chart.title.TextTitle#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EStandardChartTheme.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public void applyToTitles(@Nonnull JFreeChart chart) {
    TextTitle title = chart.getTitle();
    if(title != null) {
      title.setVisible(isShowTitle());
      if (isChangeTitle()) {
        title.setText(getTitle());
      }
    }

    chart.getSubtitles().forEach(s -> {
      if (s != chart.getTitle() && s instanceof TextTitle) {
        TextTitle textTitle = (TextTitle)s;
//        ((TextTitle) s).setFont(getRegularFont());
//        ((TextTitle) s).setMargin(TITLE_TOP_MARGIN, 0d, 0d, 0d);
        textTitle.setVisible(isShowSubtitles());
//        ((TextTitle) s).setPaint(subtitleFontColor); // should be set by the theme itself.
//        subtitle color is set by the chart theme parameters

//        if (PaintScaleLegend.class.isAssignableFrom(s.getClass())) {
//          ((PaintScaleLegend) s)
//              .setBackgroundPaint(this.getChartBackgroundPaint());
//        }
      }
      if (s instanceof LegendTitle) {
        LegendTitle legendTitle = (LegendTitle) s;
        legendTitle.setVisible(isShowLegend());
      }
    });
  }
 
Example 2
Source File: DefaultChartService.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private TextTitle getSubTitle( BaseChart chart )
{
    TextTitle textTitle = new TextTitle();

    String title = chart.hasTitle() ? chart.getTitle() : chart.generateTitle();

    textTitle.setFont( SUB_TITLE_FONT );
    textTitle.setText( title );

    return textTitle;
}
 
Example 3
Source File: ChartImageGenerator.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private TextTitle getSubTitle(final Visualization visualization )
{
    TextTitle textTitle = new TextTitle();

    String title = visualization.hasTitle() ? visualization.getTitle() : visualization.generateTitle();

    textTitle.setFont( SUB_TITLE_FONT );
    textTitle.setText( title );

    return textTitle;
}
 
Example 4
Source File: TextTitleTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    TextTitle t1 = new TextTitle();
    TextTitle t2 = new TextTitle();
    assertEquals(t1, t2);
    
    t1.setText("Test 1");
    assertFalse(t1.equals(t2));
    t2.setText("Test 1");
    assertTrue(t1.equals(t2));
    
    Font f = new Font("SansSerif", Font.PLAIN, 15);
    t1.setFont(f);
    assertFalse(t1.equals(t2));
    t2.setFont(f);
    assertTrue(t1.equals(t2));
    
    t1.setTextAlignment(HorizontalAlignment.RIGHT);
    assertFalse(t1.equals(t2));
    t2.setTextAlignment(HorizontalAlignment.RIGHT);
    assertTrue(t1.equals(t2));
    
    // paint
    t1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 
            3.0f, 4.0f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 
            3.0f, 4.0f, Color.blue));
    assertTrue(t1.equals(t2));
    
    // backgroundPaint
    t1.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red, 
            2.0f, 1.0f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red, 
            2.0f, 1.0f, Color.blue));
    assertTrue(t1.equals(t2));
    
}
 
Example 5
Source File: ShollAnalysisDialog.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
protected synchronized void updateResults() {
	JFreeChart chart;

	if (numberOfAllPaths <= 0) {

		makePromptInteractive(false);
		if (graphFrame != null) {
			chart = graphFrame.chartPanel.getChart();
			if (chart != null) {
				chart.setNotify(false);
				final TextTitle currentitle = chart.getTitle();
				if (currentitle != null)
					currentitle.setText("");
				final XYPlot plot = chart.getXYPlot();
				if (plot != null)
					plot.setDataset(null);
				chart.setNotify(true);
			}
		}

	} else { // valid paths to be analyzed

		makePromptInteractive(true);
		final ShollResults results = getCurrentResults();
		resultsPanel.updateFromResults(results);
		chart = results.createGraph();
		if (chart == null)
			return;
		if (graphFrame == null)
			graphFrame = new GraphFrame(chart, results.getSuggestedSuffix());
		else
			graphFrame.updateWithNewChart(chart, results.getSuggestedSuffix());
	}

}
 
Example 6
Source File: TextTitleTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    TextTitle t1 = new TextTitle();
    TextTitle t2 = new TextTitle();
    assertEquals(t1, t2);

    t1.setText("Test 1");
    assertFalse(t1.equals(t2));
    t2.setText("Test 1");
    assertTrue(t1.equals(t2));

    Font f = new Font("SansSerif", Font.PLAIN, 15);
    t1.setFont(f);
    assertFalse(t1.equals(t2));
    t2.setFont(f);
    assertTrue(t1.equals(t2));

    t1.setTextAlignment(HorizontalAlignment.RIGHT);
    assertFalse(t1.equals(t2));
    t2.setTextAlignment(HorizontalAlignment.RIGHT);
    assertTrue(t1.equals(t2));

    // paint
    t1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertTrue(t1.equals(t2));

    // backgroundPaint
    t1.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red,
            2.0f, 1.0f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red,
            2.0f, 1.0f, Color.blue));
    assertTrue(t1.equals(t2));

    // maximumLinesToDisplay
    t1.setMaximumLinesToDisplay(3);
    assertFalse(t1.equals(t2));
    t2.setMaximumLinesToDisplay(3);
    assertTrue(t1.equals(t2));

    // toolTipText
    t1.setToolTipText("TTT");
    assertFalse(t1.equals(t2));
    t2.setToolTipText("TTT");
    assertTrue(t1.equals(t2));

    // urlText
    t1.setURLText(("URL"));
    assertFalse(t1.equals(t2));
    t2.setURLText(("URL"));
    assertTrue(t1.equals(t2));

    // expandToFitSpace
    t1.setExpandToFitSpace(!t1.getExpandToFitSpace());
    assertFalse(t1.equals(t2));
    t2.setExpandToFitSpace(!t2.getExpandToFitSpace());
    assertTrue(t1.equals(t2));

}