1 | /**
|
---|
2 | * Polar.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.items.widgets.charts;
|
---|
20 |
|
---|
21 | import org.expeditee.core.Colour;
|
---|
22 | import org.expeditee.gio.swing.SwingConversions;
|
---|
23 | import org.expeditee.items.Text;
|
---|
24 | import org.jfree.chart.ChartFactory;
|
---|
25 | import org.jfree.chart.JFreeChart;
|
---|
26 | import org.jfree.chart.axis.Axis;
|
---|
27 | import org.jfree.chart.plot.PolarPlot;
|
---|
28 |
|
---|
29 | public class Polar extends AbstractXY {
|
---|
30 |
|
---|
31 | public Polar(Text source, String[] args) {
|
---|
32 | super(source, args);
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | protected JFreeChart createNewChart() {
|
---|
37 | return ChartFactory.createPolarChart(DEFAULT_TITLE, getChartData(),
|
---|
38 | true, // legend?
|
---|
39 | true, // tooltips?
|
---|
40 | false // URLs?
|
---|
41 | );
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public void setSourceColor(Colour c) {
|
---|
46 | super.setSourceColor(c);
|
---|
47 | if (getChart() == null)
|
---|
48 | return;
|
---|
49 |
|
---|
50 | PolarPlot plot = ((PolarPlot) getChart().getPlot());
|
---|
51 |
|
---|
52 | if (c == null) {
|
---|
53 | plot.setAngleLabelPaint(Axis.DEFAULT_AXIS_LABEL_PAINT);
|
---|
54 | } else {
|
---|
55 | plot.setAngleLabelPaint(SwingConversions.toSwingColor(c));
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | @Override
|
---|
60 | public void setSourceThickness(float newThickness, boolean setConnected) {
|
---|
61 | super.setSourceThickness(newThickness, setConnected);
|
---|
62 | if (getChart() == null)
|
---|
63 | return;
|
---|
64 | PolarPlot plot = ((PolarPlot) getChart().getPlot());
|
---|
65 | plot.setAngleLabelFont(plot.getAngleLabelFont().deriveFont(getFontSize(newThickness, Axis.DEFAULT_TICK_LABEL_FONT.getSize2D())));
|
---|
66 | }
|
---|
67 | }
|
---|