Skip to content

Commit 69e0f59

Browse files
author
David Baum
committed
simplify rd color handling
1 parent d4976a5 commit 69e0f59

2 files changed

Lines changed: 35 additions & 82 deletions

File tree

generator2/org.getaviz.generator/src/main/java/org/getaviz/generator/SettingsConfiguration.java

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -423,44 +423,31 @@ public double getRDDataTransparency() {
423423
return config.getDouble("rd.data_transparency", 0);
424424
}
425425

426-
public Color getRDClassColor() {
427-
return getColor(getRDClassColorHex());
428-
}
429-
430-
public String getRDClassColorHex() {
431-
return config.getString("rd.color.class", "#353559");
432-
}
433-
434-
public String getRDClassColorAsPercentage() {
435-
return getColorFormatted(getRDClassColor());
436-
}
437-
438-
public Color getRDDataColor() {
439-
return getColor(getRDDataColorHex());
440-
}
441-
442-
public String getRDDataColorHex() {
443-
return config.getString("rd.color.data", "#fffc19");
444-
}
445-
446-
public String getRDDataColorAsPercentage() {
447-
return getColorFormatted(getRDDataColor());
448-
}
449-
450-
public Color getRDMethodColor() {
451-
return getColor(getRDMethodColorHex());
452-
}
453-
454-
public String getRDMethodColorHex() {
455-
return config.getString("rd.color.method", "#1485cc");
426+
public String getRDClassColor() {
427+
final String color = config.getString("rd.color.class", "#353559");
428+
if(this.getOutputFormat() == OutputFormat.AFrame) {
429+
return color;
430+
} else {
431+
return getColorFormatted(getColor(color));
432+
}
456433
}
457434

458-
public String getRDMethodColorAsPercentage() {
459-
return getColorFormatted(getRDMethodColor());
435+
public String getRDDataColor() {
436+
final String color = config.getString("rd.color.data", "#fffc19");
437+
if(this.getOutputFormat() == OutputFormat.AFrame) {
438+
return color;
439+
} else {
440+
return getColorFormatted(getColor(color));
441+
}
460442
}
461443

462-
public Color getRDNamespaceColor() {
463-
return getColor(getRDNamespaceColorHex());
444+
public String getRDMethodColor() {
445+
final String color = config.getString("rd.color.method", "#1485cc");
446+
if(this.getOutputFormat() == OutputFormat.AFrame) {
447+
return color;
448+
} else {
449+
return getColorFormatted(getColor(color));
450+
}
464451
}
465452

466453
public String getRDNamespaceColorHex() {

generator2/org.getaviz.generator/src/main/java/org/getaviz/generator/rd/s2m/JQA2RD.java

Lines changed: 14 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,19 @@
1414
public class JQA2RD implements Step {
1515
private DatabaseConnector connector = DatabaseConnector.getInstance();
1616
private Log log = LogFactory.getLog(this.getClass());
17-
private OutputFormat outputFormat;
1817

1918
private double namespaceTransparency;
2019

21-
private String classColorAsPercentage;
22-
private String classColorHex;
20+
private String classColor;
2321
private double classTransparency;
2422

25-
private String methodColorHex;
23+
private String methodColor;
2624
private double methodTransparency;
27-
private String methodColorAsPercentage;
2825
private boolean methodTypeMode;
2926
private boolean methodDisks;
3027

31-
private String dataColorHex;
28+
private String dataColor;
3229
private double dataTransparency;
33-
private String dataColorAsPercentage;
3430
private double ringWidthAD;
3531
private boolean dataDisks;
3632

@@ -45,18 +41,14 @@ public JQA2RD(SettingsConfiguration config) {
4541
this.height = config.getRDHeight();
4642
this.namespaceTransparency = config.getRDNamespaceTransparency();
4743
this.ringWidth = config.getRDRingWidth();
48-
this.classColorAsPercentage = config.getRDClassColorAsPercentage();
49-
this.outputFormat = config.getOutputFormat();
50-
this.classColorHex = config.getClassColorHex();
44+
this.classColor = config.getRDClassColor();
5145
this.classTransparency = config.getRDClassTransparency();
52-
this.methodColorHex = config.getRDMethodColorHex();
46+
this.methodColor = config.getRDMethodColor();
5347
this.methodTransparency = config.getRDMethodTransparency();
54-
this.methodColorAsPercentage = config.getRDMethodColorAsPercentage();
5548
this.minArea = config.getRDMinArea();
56-
this.dataColorHex = config.getRDDataColorHex();
49+
this.dataColor = config.getRDDataColor();
5750
this.dataTransparency = config.getRDDataTransparency();
5851
this.ringWidthAD = config.getRDRingWidthAD();
59-
this.dataColorAsPercentage = config.getRDDataColorAsPercentage();
6052
}
6153

6254
public void run() {
@@ -95,12 +87,8 @@ private void namespaceToDisk(Long namespace, Long parent) {
9587
}
9688

9789
private void structureToDisk(Node structure, Long parent) {
98-
String color = classColorAsPercentage;
99-
if (outputFormat == OutputFormat.AFrame) {
100-
color = classColorHex;
101-
}
10290
String properties = String.format("ringWidth: %f, height: %f, transparency: %f, color: \'%s\'", ringWidth,
103-
height, classTransparency, color);
91+
height, classTransparency, classColor);
10492
long disk = connector.addNode(cypherCreateNode(parent, structure.id(), Labels.Disk.name(), properties), "n").id();
10593
StatementResult methods = connector.executeRead("MATCH (n)-[:DECLARES]->(m:Method) WHERE ID(n) = " + structure.id() +
10694
" AND EXISTS(m.hash) RETURN m");
@@ -159,22 +147,16 @@ private void structureToDisk(Node structure, Long parent) {
159147
}
160148

161149
private void methodToDisk(Long method, Long parent) {
162-
String color = 153 / 255.0 + " " + 0 / 255.0 + " " + 0 / 255.0;
163-
if (outputFormat == OutputFormat.AFrame) {
164-
color = methodColorHex;
165-
}
166150
String properties = String.format("ringWidth: %f, height: %f, transparency: %f, color: \'%s\'", ringWidth,
167-
height, methodTransparency, color);
151+
height, methodTransparency, methodColor);
168152
connector.executeWrite(cypherCreateNode(parent, method, Labels.Disk.name(), properties));
169153
}
170154

171155
private void methodToDiskSegment(Node method, Long parent) {
172156
double frequency = 0.0;
173157
double luminance = 0.0;
174-
String color = methodColorAsPercentage;
175-
if (outputFormat == OutputFormat.AFrame) {
176-
color = methodColorHex;
177-
}
158+
String color = methodColor;
159+
178160
Integer numberOfStatements = method.get("effectiveLineCount").asInt(0);
179161
double size = numberOfStatements.doubleValue();
180162
if (numberOfStatements <= minArea) {
@@ -187,42 +169,26 @@ private void methodToDiskSegment(Node method, Long parent) {
187169
}
188170

189171
private void attributeToDisk(Long attribute, Long parent) {
190-
String color = 153 / 255.0 + " " + 0 / 255.0 + " " + 0 / 255.0;
191-
if (outputFormat == OutputFormat.AFrame) {
192-
color = dataColorHex;
193-
}
194172
String properties = String.format("ringWidth: %f, height: %f, transparency: %f, color: \'%s\'",
195-
ringWidthAD, height, dataTransparency, color);
173+
ringWidthAD, height, dataTransparency, dataColor);
196174
connector.executeWrite(cypherCreateNode(parent, attribute, Labels.Disk.name(), properties));
197175
}
198176

199177
private void attributeToDiskSegment(Long attribute, Long parent) {
200-
String color = dataColorAsPercentage;
201-
if (outputFormat == OutputFormat.AFrame) {
202-
color = dataColorHex;
203-
}
204178
String properties = String.format("size: %f, height: %f, transparency: %f, color: \'%s\'", 1.0, height,
205-
dataTransparency, color);
179+
dataTransparency, dataColor);
206180
connector.executeWrite(cypherCreateNode(parent, attribute, Labels.DiskSegment.name(), properties));
207181
}
208182

209183
private void enumValueToDisk(Long enumValue, Long parent) {
210-
String color = 153 / 255.0 + " " + 0 / 255.0 + " " + 0 / 255.0;
211-
if (outputFormat == OutputFormat.AFrame) {
212-
color = dataColorHex;
213-
}
214184
String properties = String.format("ringWidth: %f, height: %f, transparency: %f, color: \'%s\'",
215-
ringWidthAD, height, dataTransparency, color);
185+
ringWidthAD, height, dataTransparency, dataColor);
216186
connector.executeWrite(cypherCreateNode(parent, enumValue, Labels.Disk.name(), properties));
217187
}
218188

219189
private void enumValueToDiskSegment(Long enumValue, Long parent) {
220-
String color = dataColorAsPercentage;
221-
if (outputFormat == OutputFormat.AFrame) {
222-
color = dataColorHex;
223-
}
224190
String properties = String.format("size: %f, height: %f, transparency: %f, color: \'%s\'", 1.0, height,
225-
dataTransparency, color);
191+
dataTransparency, dataColor);
226192
connector.executeWrite(cypherCreateNode(parent, enumValue, Labels.DiskSegment.name(), properties));
227193

228194
}

0 commit comments

Comments
 (0)