Added title font property to plots.
This commit is contained in:
@@ -17,10 +17,10 @@ import javax.swing.JPanel;
|
||||
/**
|
||||
* TODO: FDA calls to .update -> requestUpdate()
|
||||
*/
|
||||
abstract public class LinePlotBase extends PlotBase<LinePlotSeries> implements LinePlot {
|
||||
|
||||
abstract public class LinePlotBase extends PlotBase<LinePlotSeries> implements LinePlot {
|
||||
private String xAxisLabel = "X";
|
||||
private String yAxisLabel = "Y";
|
||||
|
||||
|
||||
protected LinePlotBase() {
|
||||
this(null);
|
||||
@@ -31,6 +31,7 @@ abstract public class LinePlotBase extends PlotBase<LinePlotSeries> implements L
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void createChart() {
|
||||
super.createChart();
|
||||
@@ -122,6 +123,8 @@ abstract public class LinePlotBase extends PlotBase<LinePlotSeries> implements L
|
||||
try {
|
||||
LinePlot p = newPlot(e.getActionCommand());
|
||||
p.setTitle(getTitle());
|
||||
if (getTitleFont()!=null)
|
||||
p.setTitleFont(getTitleFont());
|
||||
p.getAxis(AxisId.X).setLabel(getAxis(AxisId.X).getLabel());
|
||||
p.getAxis(AxisId.Y).setLabel(getAxis(AxisId.Y).getLabel());
|
||||
for (LinePlotSeries series : getAllSeries()) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
package ch.psi.plot;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.swing.JPanel;
|
||||
@@ -21,8 +22,9 @@ public interface Plot<T extends PlotSeries>{
|
||||
|
||||
//Generic properties
|
||||
public void setTitle(String title);
|
||||
|
||||
public String getTitle();
|
||||
public void setTitleFont(Font font);
|
||||
public Font getTitleFont();
|
||||
|
||||
//Generic operations
|
||||
public void saveData(String filename) throws IOException;
|
||||
|
||||
@@ -8,6 +8,7 @@ import ch.psi.plot.utils.MonitoredPanel;
|
||||
import ch.psi.plot.utils.SwingUtils;
|
||||
import ch.psi.plot.utils.SwingUtils.ExtensionFileFilter;
|
||||
import ch.psi.plot.utils.SwingUtils.ImageTransferHandler;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Toolkit;
|
||||
@@ -87,6 +88,19 @@ abstract public class PlotBase<T extends PlotSeries> extends MonitoredPanel impl
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
Font titleFont;
|
||||
|
||||
public void setTitleFont(Font font) {
|
||||
this.titleFont = font;
|
||||
if (instantiated)
|
||||
onTitleChanged();
|
||||
}
|
||||
|
||||
public Font getTitleFont() {
|
||||
return titleFont;
|
||||
}
|
||||
|
||||
volatile boolean bUpdating;
|
||||
|
||||
|
||||
@@ -202,7 +202,10 @@ public class LinePlot extends LinePlotBase {
|
||||
@Override
|
||||
protected void onTitleChanged() {
|
||||
chartPanel.setName(getTitle());
|
||||
chart.setTitle(getTitle());
|
||||
chart.setTitle(getTitle());
|
||||
if(getTitleFont()!=null)
|
||||
chart.getTitle().setFont(getTitleFont());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -99,6 +99,8 @@ public class MatrixPlot extends MatrixPlotBase {
|
||||
protected void onTitleChanged() {
|
||||
chartPanel.setName(getTitle());
|
||||
chart.setTitle(getTitle());
|
||||
if(getTitleFont()!=null)
|
||||
chart.getTitle().setFont(getTitleFont());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -185,6 +185,8 @@ public class LinePlot extends LinePlotBase {
|
||||
@Override
|
||||
protected void onTitleChanged() {
|
||||
plot.setHeader(getTitle());
|
||||
if(getTitleFont()!=null)
|
||||
plot.setHeaderFont(getTitleFont());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,8 +20,8 @@ public class LinePlotTest {
|
||||
//for(int i=0;i<10;i++)
|
||||
{
|
||||
//LinePlot linePlot = ServiceLoader.load(LinePlot.class).iterator().next();
|
||||
//LinePlot linePlot = new ch.psi.plot.jlchart.LinePlot();
|
||||
LinePlot linePlot = new ch.psi.plot.jfree.LinePlot();
|
||||
LinePlot linePlot = new ch.psi.plot.jlchart.LinePlot();
|
||||
//LinePlot linePlot = new ch.psi.plot.jfree.LinePlot();
|
||||
//LinePlot linePlot = new ch.psi.plot.javafx.LinePlot() ;
|
||||
|
||||
linePlot.setTitle("Title");
|
||||
|
||||
Reference in New Issue
Block a user