1 package org.catacomb.dataview.model;
2
3
4 import java.util.ArrayList;
5
6 import org.catacomb.datalish.SColor;
7 import org.catacomb.dataview.display.Displayable;
8 import org.catacomb.numeric.data.AsciiIO;
9 import org.catacomb.report.E;
10
11
12 import java.awt.Color;
13
14 import java.io.File;
15
16 public abstract class Plottable {
17
18 public String file;
19 public SColor color;
20 public double width;
21 public String rescale;
22 public String label;
23 public String function;
24
25 public abstract ArrayList<Displayable> getDisplayables(File fdir);
26
27
28
29 public Color getColor() {
30 Color ret = Color.white;
31 if (color != null) {
32 ret = color.getColor();
33 }
34 return ret;
35 }
36
37
38
39 public double[] getScaleFactors(int nsf) {
40 double[] ret = new double[nsf];
41 for (int i = 0; i < nsf; i++) {
42 ret[i] = 1.;
43 }
44 if (rescale == null) {
45
46
47 } else {
48 double[] row = AsciiIO.readRow(rescale);
49 if (row == null) {
50 E.warning("cant read scale factors from " + rescale);
51 } else {
52 for (int i = 0; i < nsf && i < row.length; i++) {
53 ret[i] = row[i];
54 }
55
56 }
57 }
58 return ret;
59 }
60
61
62 protected double[] scaleColumn(double[] d, double sf) {
63 double[] ret = new double[d.length];
64 for (int i = 0; i < d.length; i++) {
65 ret[i] = sf * d[i];
66 }
67 return ret;
68 }
69
70 }