summaryrefslogtreecommitdiff
path: root/altosuilib/AltosUILineStyle.java
diff options
context:
space:
mode:
authorBdale Garbee <bdale@gag.com>2017-12-11 21:39:38 -0700
committerBdale Garbee <bdale@gag.com>2017-12-11 21:39:38 -0700
commit8e0b575ad1dfd5a49136d3fe945d27f6afda1178 (patch)
tree74657870764e6a3792bdd7e90acd725353c20904 /altosuilib/AltosUILineStyle.java
parent132b92a95bdebabf573a680301bfb1e93eaa6721 (diff)
parentfe38c22595b050435dbacd35f1baae064fb7de75 (diff)
Merge branch 'branch-1.8' into debian
Diffstat (limited to 'altosuilib/AltosUILineStyle.java')
-rw-r--r--altosuilib/AltosUILineStyle.java84
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];
+ }
+}