Skip to content

Commit

Permalink
Corrected bug in Graph color scale
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielPJFaria committed Dec 9, 2017
1 parent 14bcecd commit 6d0f7f9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/graph/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private static void addNode(int term, double fraction, String color)
nodes.put(term, go.getLocalName(term));
else
{
String label = formatLabel(term) + "\n(" + NumberFormatter.formatPercent(fraction) + ")";
String label = formatLabel(go.getLabel(term)) + "\n(" + NumberFormatter.formatPercent(fraction) + ")";
mxCell node = (mxCell) graph.insertVertex(parent, ""+term, label, 0.0, 0.0, 0.0, 0.0, "strokeColor=#000000;fillColor="+color);
mxRectangle rect = graph.getPreferredSizeForCell(node);
rect.setHeight(rect.getHeight()+4.0);
Expand All @@ -181,7 +181,7 @@ private static void addNode(int term, double fraction, String color)
private static void addEdge(int descendant, int ancestor)
{
int relId = go.getRelationship(descendant, ancestor).getProperty();
String label = go.getPropertyName(relId);
String label = formatLabel(go.getPropertyName(relId));
if(gf.equals(GraphFormat.TXT))
{
edges.add(nodes.get(descendant) + "\t" + label + "\t" +
Expand All @@ -205,17 +205,17 @@ private static void addEdge(int descendant, int ancestor)
}
}

private static String formatLabel(int term)
private static String formatLabel(String s)
{
//Get and format the label
String[] words = go.getLabel(term).split("[ -]");
String[] words = s.split("[ -]");
int limit = 15;
for(String w : words)
limit = Math.max(limit, w.length());
String label = words[0];
for(int i = 1; i < words.length; i++)
{
if(go.getLabel(term).charAt(label.length()) == '-')
if(s.charAt(label.length()) == '-')
label += "-";
String lastWord = label.substring(label.lastIndexOf("\n")+1);
if(!lastWord.matches("[0-9]{1}\\-") && !words[i].matches("[0-9]{1}") && !words[i].matches("I{1,3}|IV|V") && lastWord.length() + words[i].length() > limit)
Expand All @@ -230,8 +230,8 @@ else if(!label.endsWith("-"))
private static String getColor(double pValue)
{
String color;
double order = -Math.log(pValue)/Math.log(10);
if(pValue < cutOff)
double order = -Math.log10(pValue);
if(pValue > cutOff)
color = "#FFFFFF";
else if(order < 3)
color = "#FFFFCC";
Expand Down

0 comments on commit 6d0f7f9

Please sign in to comment.