[Swift-commit] r4183 - in usertools/plotter: samples/lines src/plotter
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Mon Mar 14 22:21:08 CDT 2011
Author: wozniak
Date: 2011-03-14 22:21:07 -0500 (Mon, 14 Mar 2011)
New Revision: 4183
Modified:
usertools/plotter/samples/lines/plot.cfg
usertools/plotter/src/plotter/Lines.java
Log:
Allow user to set font
Modified: usertools/plotter/samples/lines/plot.cfg
===================================================================
--- usertools/plotter/samples/lines/plot.cfg 2011-03-15 02:56:57 UTC (rev 4182)
+++ usertools/plotter/samples/lines/plot.cfg 2011-03-15 03:21:07 UTC (rev 4183)
@@ -5,3 +5,5 @@
label.set1.data = Set 1
label.set2.data = Set 2
+
+legend.font = Lucida Sans Unicode Regular
Modified: usertools/plotter/src/plotter/Lines.java
===================================================================
--- usertools/plotter/src/plotter/Lines.java 2011-03-15 02:56:57 UTC (rev 4182)
+++ usertools/plotter/src/plotter/Lines.java 2011-03-15 03:21:07 UTC (rev 4183)
@@ -3,6 +3,7 @@
import gnu.getopt.Getopt;
import java.awt.Color;
+import java.awt.Font;
import java.awt.geom.Rectangle2D;
import java.io.*;
import java.util.*;
@@ -15,6 +16,7 @@
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
+import org.jfree.chart.title.LegendTitle;
import org.jfree.data.Range;
import org.jfree.data.general.Series;
import org.jfree.data.xy.XYSeriesCollection;
@@ -111,17 +113,23 @@
{
Series series = collection.getSeries(i);
if (! showShape(series.getDescription()))
- {
- // System.out.println("invis");
renderer.setSeriesShapesVisible(i, false);
- }
}
+ setupLegend(chart);
setAxes(plot);
plot.setRenderer(renderer);
plot.setBackgroundPaint(Color.WHITE);
}
+ private static void setupLegend(JFreeChart chart)
+ {
+ LegendTitle legend = chart.getLegend();
+ Font font = getLegendFont();
+ if (font != null)
+ legend.setItemFont(font);
+ }
+
static void setAxes(XYPlot plot)
{
// Actual values: modify if necessary
@@ -328,6 +336,17 @@
return true;
}
+ static Font getLegendFont()
+ {
+ Font result = null;
+ String name = properties.getProperty("legend.font");
+ if (name == null)
+ return null;
+ System.out.println(name);
+ result = new Font(name, Font.PLAIN, 12);
+ return result;
+ }
+
static String toString(double[][] array)
{
StringBuilder sb = new StringBuilder();
More information about the Swift-commit
mailing list