64 XAxis =
new Axis((NumberAxis) ((XYPlot) chart.getPlot()).getDomainAxis(),
Axis.ORIENTATION_HORIZONTAL);
206 XYSeriesCollection seriesCollection = (XYSeriesCollection) this.dataset.getSeriesCollection();
207 double[] values =
new double[seriesCollection.getItemCount(s)];
209 for (
int i = 0; i < seriesCollection.getItemCount(s); i++)
210 values[i] = seriesCollection.getXValue(s, i);
212 XAxis.setLabels(values);
225 public JFrame
view(
int width,
int height) {
227 if (chart.getTitle() !=
null)
228 myFrame =
new JFrame(
"EmpiricalChart from SSJ : " + chart.getTitle().getText());
230 myFrame =
new JFrame(
"EmpiricalChart from SSJ");
231 ChartPanel chartPanel =
new ChartPanel(chart);
232 chartPanel.setPreferredSize(
new java.awt.Dimension(width, height));
233 myFrame.setContentPane(chartPanel);
235 myFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
236 myFrame.setLocationRelativeTo(
null);
237 myFrame.setVisible(
true);
244 public String
toLatex(
double width,
double height) {
247 if (dataset.getSeriesCollection().getSeriesCount() == 0)
248 throw new IllegalArgumentException(
"Empty chart");
251 double XScale = computeXScale(XAxis.getTwinAxisPosition());
252 double YScale = computeYScale(YAxis.getTwinAxisPosition());
254 xunit = width / ((Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition()) * XScale)
255 - (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition()) * XScale));
257 yunit = height / ((Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition()) * YScale)
258 - (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition()) * YScale));
261 Formatter formatter =
new Formatter(Locale.US);
265 formatter.format(
"\\documentclass[12pt]{article}%n%n");
266 formatter.format(
"\\usepackage{tikz}%n\\usetikzlibrary{plotmarks}%n\\begin{document}%n%n");
268 if (chart.getTitle() !=
null)
269 formatter.format(
"%% PGF/TikZ picture from SSJ : %s%n", chart.getTitle().getText());
271 formatter.format(
"%% PGF/TikZ picture from SSJ %n");
272 formatter.format(
"%% XScale = %s, YScale = %s, XShift = %s, YShift = %s%n", XScale, YScale,
273 XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition());
274 formatter.format(
"%% Therefore, thisFileXValue = (originalSeriesXValue+XShift)*XScale%n");
275 formatter.format(
"%% and thisFileYValue = (originalSeriesYValue+YShift)*YScale%n%n");
276 if (chart.getTitle() !=
null)
277 formatter.format(
"\\begin{figure}%n");
278 formatter.format(
"\\begin{center}%n");
279 formatter.format(
"\\begin{tikzpicture}[x=%scm, y=%scm]%n", xunit, yunit);
280 formatter.format(
"\\footnotesize%n");
282 formatter.format(
"\\draw[color=lightgray] (%s, %s) grid[xstep = %s, ystep=%s] (%s, %s);%n",
283 (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition())
284 - XAxis.getTwinAxisPosition()) * XScale,
285 (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition())
286 - YAxis.getTwinAxisPosition()) * YScale,
287 xstepGrid * XScale, ystepGrid * YScale,
288 (Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
289 - XAxis.getTwinAxisPosition()) * XScale,
290 (Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
291 - YAxis.getTwinAxisPosition()) * YScale);
293 formatter.format(
"%s", XAxis.toLatex(XScale));
294 formatter.format(
"%s", YAxis.toLatex(YScale));
296 formatter.format(
"%s",
297 dataset.toLatex(XScale, YScale, XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition(),
298 XAxis.getAxis().getLowerBound(), XAxis.getAxis().getUpperBound(), YAxis.getAxis().getLowerBound(),
299 YAxis.getAxis().getUpperBound()));
301 formatter.format(
"\\end{tikzpicture}%n");
302 formatter.format(
"\\end{center}%n");
303 if (chart.getTitle() !=
null) {
304 formatter.format(
"\\caption{");
305 formatter.format(chart.getTitle().getText());
306 formatter.format(
"}%n\\end{figure}%n");
309 formatter.format(
"\\end{document}%n");
311 return formatter.toString();