From 6d0f7f96d070290e5a469fd81920f9804721e702 Mon Sep 17 00:00:00 2001 From: DanielPJFaria Date: Sat, 9 Dec 2017 16:36:51 +0000 Subject: [PATCH] Corrected bug in Graph color scale --- src/graph/Graph.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/graph/Graph.java b/src/graph/Graph.java index 7906697..41af9bc 100644 --- a/src/graph/Graph.java +++ b/src/graph/Graph.java @@ -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); @@ -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" + @@ -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) @@ -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";