diff options
| author | Bdale Garbee <bdale@gag.com> | 2017-12-11 21:37:48 -0700 | 
|---|---|---|
| committer | Bdale Garbee <bdale@gag.com> | 2017-12-11 21:37:48 -0700 | 
| commit | ea0aa97fb93e669868a6f2c49c5d4b46e7615b1f (patch) | |
| tree | f16b9a9ccd8b4a7bcde7d5cc64e6f0a52c4f3436 /altosuilib/AltosUILineStyle.java | |
| parent | 216ea6388a75c46891dc4687a2eb0c97dc63b136 (diff) | |
| parent | 9adf8b23aac8256f230b10adcab9dd323266caaa (diff) | |
Merge branch 'master' into branch-1.8
Diffstat (limited to 'altosuilib/AltosUILineStyle.java')
| -rw-r--r-- | altosuilib/AltosUILineStyle.java | 84 | 
1 files changed, 84 insertions, 0 deletions
diff --git a/altosuilib/AltosUILineStyle.java b/altosuilib/AltosUILineStyle.java new file mode 100644 index 00000000..387281a3 --- /dev/null +++ b/altosuilib/AltosUILineStyle.java @@ -0,0 +1,84 @@ +/* + * Copyright © 2017 Keith Packard <keithp@keithp.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + */ + +package org.altusmetrum.altosuilib_12; + +import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_12.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +public class AltosUILineStyle { +	public Color	color; +	public float[]	dash; + +	static private Color color(int r, int g, int b) { +		return new Color(r,g,b); +	} + +	static final private Color[] colors = { +		new Color(0,0,0), +		new Color(230,0,0),	// red +		new Color(216,103,0),	// orange +		new Color(200,200,0),	// yellow +		new Color(0,180,0),	// green +		new Color(0,140,140),	// cyan +		new Color(130,0,0),	// dark red +		new Color(0,100,0),	// dark green +		new Color(0,0,255),	// blue +		new Color(140,0,140),	// magenta +		new Color(150,150,150),	// gray +	}; + +	static final private float[][] dashes = { +		{ 0 }, +		{ 2, 4 }, +		{ 4, 4 }, +		{ 6, 4 }, +		{ 6, 4, 2, 4 } +	}; + +	static int color_index, dash_index; + +	public AltosUILineStyle () { +		color = colors[color_index]; +		dash = dashes[dash_index]; +		color_index = (color_index + 1) % colors.length; +		if (color_index == 0) { +			dash_index = (dash_index + 1) % dashes.length; +			if (dash_index == 0) +				System.out.printf("too many line styles\n"); +		} +	} + +	public AltosUILineStyle(int index) { +		index = index % (colors.length * dashes.length); +		int c = index % colors.length; +		int d = index / colors.length; +		color = colors[c]; +		dash = dashes[d]; +	} +}  | 
