X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosUITimeSeries.java;h=4c2f9ba9a85e608b029c5f92d5c24d5f00acc9e7;hp=7c48264e25092953bbfbb9a4caef7cecb351ee2e;hb=119a829e58aff5dd7801fe7ef8cae886bf31fec1;hpb=222158581887b5f9e8b9843d14321c313fa023fa diff --git a/altosuilib/AltosUITimeSeries.java b/altosuilib/AltosUITimeSeries.java index 7c48264e..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_11; +package org.altusmetrum.altosuilib_13; import java.io.*; import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib_11.*; +import org.altusmetrum.altoslib_13.*; import org.jfree.ui.*; import org.jfree.chart.*; @@ -35,6 +35,24 @@ import org.jfree.chart.labels.*; import org.jfree.data.xy.*; import org.jfree.data.*; +class AltosUITime extends AltosUnits { + public double value(double v, boolean imperial_units) { return v; } + + public double inverse(double v, boolean imperial_unis) { return v; } + + public String show_units(boolean imperial_units) { return "s"; } + + public String say_units(boolean imperial_units) { return "seconds"; } + + public int show_fraction(int width, boolean imperial_units) { + if (width < 5) + return 0; + return width - 5; + } + + public int say_fraction(boolean imperial_units) { return 0; } +} + class AltosXYSeries extends XYSeries { public AltosXYSeries(String label) { @@ -43,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() { @@ -71,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) @@ -89,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); @@ -106,6 +126,7 @@ public class AltosUITimeSeries extends AltosTimeSeries implements AltosUIGrapher } xy_series.setNotify(true); } + clear_changed(); } public void set_units() { @@ -146,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); } }