altos/stm: Note that ao_i2c_recv_dma_isr isn't actually used
[fw/altos] / altosuilib / AltosUILineStyle.java
1 /*
2  * Copyright © 2017 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  */
14
15 package org.altusmetrum.altosuilib_13;
16
17 import java.io.*;
18 import java.util.ArrayList;
19
20 import java.awt.*;
21 import javax.swing.*;
22 import org.altusmetrum.altoslib_13.*;
23
24 import org.jfree.ui.*;
25 import org.jfree.chart.*;
26 import org.jfree.chart.plot.*;
27 import org.jfree.chart.axis.*;
28 import org.jfree.chart.renderer.*;
29 import org.jfree.chart.renderer.xy.*;
30 import org.jfree.chart.labels.*;
31 import org.jfree.data.xy.*;
32 import org.jfree.data.*;
33
34 public class AltosUILineStyle {
35         public Color    color;
36         public float[]  dash;
37
38         static private Color color(int r, int g, int b) {
39                 return new Color(r,g,b);
40         }
41
42         static final private Color[] colors = {
43                 new Color(0,0,0),
44                 new Color(230,0,0),     // red
45                 new Color(216,103,0),   // orange
46                 new Color(200,200,0),   // yellow
47                 new Color(0,180,0),     // green
48                 new Color(0,140,140),   // cyan
49                 new Color(130,0,0),     // dark red
50                 new Color(0,100,0),     // dark green
51                 new Color(0,0,255),     // blue
52                 new Color(140,0,140),   // magenta
53                 new Color(150,150,150), // gray
54         };
55
56         static final private float[][] dashes = {
57                 { 0 },
58                 { 2, 4 },
59                 { 4, 4 },
60                 { 6, 4 },
61                 { 6, 4, 2, 4 }
62         };
63
64         static int color_index, dash_index;
65
66         public AltosUILineStyle () {
67                 color = colors[color_index];
68                 dash = dashes[dash_index];
69                 color_index = (color_index + 1) % colors.length;
70                 if (color_index == 0) {
71                         dash_index = (dash_index + 1) % dashes.length;
72                         if (dash_index == 0)
73                                 System.out.printf("too many line styles\n");
74                 }
75         }
76
77         public AltosUILineStyle(int index) {
78                 index = index % (colors.length * dashes.length);
79                 int c = index % colors.length;
80                 int d = index / colors.length;
81                 color = colors[c];
82                 dash = dashes[d];
83         }
84 }