X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosUITimeSeries.java;h=4c2f9ba9a85e608b029c5f92d5c24d5f00acc9e7;hp=08f95ca748740f5f26408e46d19919c238dcf5c7;hb=119a829e58aff5dd7801fe7ef8cae886bf31fec1;hpb=a61217f0a6d0ef48b6471f632c4600255867e831 diff --git a/altosuilib/AltosUITimeSeries.java b/altosuilib/AltosUITimeSeries.java index 08f95ca7..4c2f9ba9 100644 --- a/altosuilib/AltosUITimeSeries.java +++ b/altosuilib/AltosUITimeSeries.java @@ -16,14 +16,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_12; +package org.altusmetrum.altosuilib_13; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_12.*; +import org.altusmetrum.altoslib_13.*; import org.jfree.ui.*; import org.jfree.chart.*; @@ -61,16 +61,17 @@ class AltosXYSeries extends XYSeries { } public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher { - Color color; - boolean enable; - AltosUIAxis axis; - boolean marker; - boolean marker_top; - XYItemRenderer renderer; - XYPlot plot; - AltosXYSeries xy_series; + AltosUILineStyle line_style; + boolean enable; + boolean custom_axis_set; + AltosUIAxis axis; + boolean marker; + boolean marker_top; + XYLineAndShapeRenderer renderer; + XYPlot plot; + AltosXYSeries xy_series; ArrayList markers; - + float width; /* AltosUIGrapher interface */ public boolean need_reset() { @@ -89,7 +90,7 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher public void fireSeriesChanged() { } - void set_data() { + public void set_data() { if (marker) { if (markers != null) { for (ValueMarker marker : markers) @@ -107,7 +108,8 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher marker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); marker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } - marker.setPaint(color); + marker.setPaint(line_style.color); + marker.setStroke(new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); if (enable) plot.addDomainMarker(marker); markers.add(marker); @@ -124,6 +126,7 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher } xy_series.setNotify(true); } + clear_changed(); } public void set_units() { @@ -164,37 +167,59 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher } } - public void set_axis(Color color, boolean enable, AltosUIAxis axis) { - this.color = color; + // public BasicStroke(float width, int cap, int join, float miterlimit, + // float dash[], float dash_phase) + + public void set_line_width(float width) { + this.width = width; + if (markers != null) { + for (ValueMarker marker : markers) { + marker.setStroke(new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); + } + } else { + if (line_style.dash[0] == 0.0) + renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + else + renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f, line_style.dash, 0.0f)); + } + } + + public void set_axis(AltosUILineStyle line_style, boolean enable, AltosUIAxis axis) { + this.line_style = line_style; this.enable = enable; this.axis = axis; this.marker = false; + this.width = 1.0f; axis.ref(this.enable); renderer = new XYLineAndShapeRenderer(true, false); - renderer.setSeriesPaint(0, color); - renderer.setSeriesStroke(0, new BasicStroke(2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); + renderer.setSeriesPaint(0, line_style.color); + set_line_width(this.width); renderer.setSeriesVisible(0, enable); xy_series = new AltosXYSeries(label); } - public void set_marker(Color color, boolean enable, XYPlot plot, boolean marker_top) { - this.color = color; + public void set_marker(AltosUILineStyle line_style, boolean enable, XYPlot plot, boolean marker_top) { + this.line_style = line_style; this.enable = enable; this.marker = true; this.plot = plot; this.marker_top = marker_top; } + public void set_shapes_visible(boolean shapes_visible) { + renderer.setSeriesShapesVisible(0, shapes_visible); + } + public AltosUITimeSeries(String label, AltosUnits units) { super(label, units); } public AltosUITimeSeries(String label, AltosUnits units, - Color color, boolean enable, + AltosUILineStyle line_style, boolean enable, AltosUIAxis axis) { this(label, units); - set_axis(color, enable, axis); + set_axis(line_style, enable, axis); } }