diff --git a/Frameworks/Misc/ERProfiling/Sources/er/profiling/delegates/PFHeatMap.java b/Frameworks/Misc/ERProfiling/Sources/er/profiling/delegates/PFHeatMap.java index 25110612c2a..1de4fb2418b 100644 --- a/Frameworks/Misc/ERProfiling/Sources/er/profiling/delegates/PFHeatMap.java +++ b/Frameworks/Misc/ERProfiling/Sources/er/profiling/delegates/PFHeatMap.java @@ -60,24 +60,19 @@ protected void appendHeatStyles(PFStatsNode stats, WOResponse response, WOContex } if ("appendToResponse".equals(stats.name())) { double fValue = stats.percentage(); - int r = 0; - int g = 0; + int r = 255; + int g = (int) (255 * (1.0 - fValue * fValue)); int b = 0; - int a = 1; - if (fValue <= 0.01) { - // r = 255; - // g = 255; - // b = 255; - // response.appendContentString(".wo_p_" + - // duration.getKey() + " { background-color: rgba(" + r - // + "," + g + "," + b + "," + a + ") !important; }\n"); - } else { - int value = (int) (255 * (1.0 - fValue * fValue)); - r = 255; - g = value; - b = 0; - response.appendContentString("." + stats.cssID() + " { !important; border: 3px solid rgba(" + r + "," + g + "," + b + "," + a + ") !important; }\n"); + int w = 1; + if (fValue > 0.75) { + w = 4; + } else if (fValue > 0.4) { + w = 3; + } else if (fValue > 0.1) { + w = 2; } + response.appendContentString("." + stats.cssID() + " { outline: " + w + "px solid rgb(" + r + + "," + g + "," + b + ") !important; outline-offset: -" + w + "px !important }\n"); } } diff --git a/Frameworks/Misc/ERProfiling/Sources/er/profiling/delegates/PFMarkup.java b/Frameworks/Misc/ERProfiling/Sources/er/profiling/delegates/PFMarkup.java index d4114fc9dde..e3529a95d96 100644 --- a/Frameworks/Misc/ERProfiling/Sources/er/profiling/delegates/PFMarkup.java +++ b/Frameworks/Misc/ERProfiling/Sources/er/profiling/delegates/PFMarkup.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.regex.Pattern; +import org.apache.commons.lang3.StringUtils; + import com.webobjects.appserver.WOContext; import com.webobjects.appserver.WOElement; import com.webobjects.appserver.WOMessage; @@ -137,7 +139,7 @@ public void didAppendToResponse(WOElement element, WOResponse response, WOContex for (int i = startIndex; i < endIndex; i++) { char ch = contentStr.charAt(i); if (ch == '<') { - if (i < endIndex - 1 && contentStr.charAt(i + 1) != '/') { + if (i < endIndex - 1 && contentStr.charAt(i + 1) != '/' && contentStr.charAt(i + 1) != '!') { tagIndex = i; break; } @@ -145,33 +147,27 @@ public void didAppendToResponse(WOElement element, WOResponse response, WOContex } if (tagIndex != -1) { - int attributeOffset = -1; - boolean spacesFound = false; - for (int i = tagIndex; i < endIndex; i++) { - char ch = contentStr.charAt(i); - if (ch == ' ') { - spacesFound = true; - } else if (ch == '>' || ch == '/') { - if (attributeOffset > tagIndex + 1) { - attributeOffset = i; - } - break; - } else if (spacesFound) { - attributeOffset = i; - break; - } - } - if (attributeOffset != -1) { - String profilerID = markerStats._stats.cssID(); - String profilerIDAttributeName = "class"; - if (regionMatches(contentStr, attributeOffset, profilerIDAttributeName, 0, profilerIDAttributeName.length())) { - int openQuoteIndex = indexOf(contentStr, "\"", attributeOffset); - if (openQuoteIndex != -1) { - insert(contentStr, openQuoteIndex + 1, profilerID + " "); - } + String profilerIDAttributeName = "class"; + String profilerIDAttributeStart = " " + profilerIDAttributeName + "=\""; + boolean foundClassAttribute = false; + int closeOffset = StringUtils.indexOf(contentStr, '>', tagIndex); + int attributeOffset = StringUtils.indexOf(contentStr, profilerIDAttributeName, tagIndex); + if (attributeOffset == -1 || attributeOffset > closeOffset) { + char ch = contentStr.charAt(closeOffset - 1); + if (ch == '/') { + attributeOffset = closeOffset - 1; } else { - insert(contentStr, attributeOffset, " " + profilerIDAttributeName + "=\"" + profilerID + "\" "); + attributeOffset = closeOffset; } + } else { + attributeOffset += profilerIDAttributeStart.length() -1; + foundClassAttribute = true; + } + String profilerID = markerStats._stats.cssID(); + if (foundClassAttribute) { + insert(contentStr, attributeOffset, profilerID + " "); + } else { + insert(contentStr, attributeOffset, profilerIDAttributeStart + profilerID + "\""); } } }