]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10266 Add SonarCloud icon on measure badges
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 18 Jan 2018 09:21:27 +0000 (10:21 +0100)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 25 Jan 2018 14:16:50 +0000 (15:16 +0100)
server/sonar-server/src/main/java/org/sonar/server/badge/ws/SvgGenerator.java
server/sonar-server/src/main/resources/org/sonar/server/badge/ws/measure-example.svg
server/sonar-server/src/main/resources/org/sonar/server/badge/ws/templates/badge.svg

index bbe633aea05580f3122924eb6b9f93a139600180..146127df9381cc16f08ac90bf0f9fa1186111b33 100644 (file)
@@ -43,11 +43,12 @@ public class SvgGenerator {
   private static final Font FONT = new Font("Verdana", Font.PLAIN, 11);
 
   private static final int MARGIN = 6;
+  private static final int ICON_WIDTH = 20;
 
-  private static final String PARAMETER_MARGIN = "margin";
+  private static final String PARAMETER_ICON_WIDTH_PLUS_MARGIN = "iconWidthPlusMargin";
   private static final String PARAMETER_TOTAL_WIDTH = "totalWidth";
   private static final String PARAMETER_LABEL_WIDTH = "labelWidth";
-  private static final String PARAMETER_LABEL_WIDTH_PLUS_MARGIN = "LabelWidthPlusMargin";
+  private static final String PARAMETER_LABEL_WIDTH_PLUS_MARGIN = "labelWidthPlusMargin";
   private static final String PARAMETER_VALUE_WIDTH = "valueWidth";
   private static final String PARAMETER_COLOR = "color";
   private static final String PARAMETER_LABEL = "label";
@@ -71,10 +72,10 @@ public class SvgGenerator {
     int valueWidth = computeWidth(value);
 
     Map<String, String> values = ImmutableMap.<String, String>builder()
-      .put(PARAMETER_MARGIN, valueOf(MARGIN))
-      .put(PARAMETER_TOTAL_WIDTH, valueOf(MARGIN * 4 + labelWidth + valueWidth))
-      .put(PARAMETER_LABEL_WIDTH, valueOf(MARGIN * 2 + labelWidth))
-      .put(PARAMETER_LABEL_WIDTH_PLUS_MARGIN, valueOf(MARGIN * 3 + labelWidth))
+      .put(PARAMETER_ICON_WIDTH_PLUS_MARGIN, valueOf(MARGIN + ICON_WIDTH))
+      .put(PARAMETER_TOTAL_WIDTH, valueOf(MARGIN * 4 + ICON_WIDTH + labelWidth + valueWidth))
+      .put(PARAMETER_LABEL_WIDTH, valueOf(MARGIN * 2 + ICON_WIDTH + labelWidth))
+      .put(PARAMETER_LABEL_WIDTH_PLUS_MARGIN, valueOf( MARGIN * 3 + ICON_WIDTH + labelWidth))
       .put(PARAMETER_VALUE_WIDTH, valueOf(MARGIN * 2 + valueWidth))
       .put(PARAMETER_COLOR, backgroundValueColor.getValue())
       .put(PARAMETER_LABEL, label)
index 3c1c4f97ecf39005db4d8ff4e809491a09cb4b27..c40fc8c06e81437e71f6e435bb97b2dec226fa41 100644 (file)
@@ -1,20 +1,22 @@
-<svg xmlns="http://www.w3.org/2000/svg" height="20" width="127">
+<svg xmlns="http://www.w3.org/2000/svg" height="20" width="147">
     <linearGradient id="b" x2="0" y2="100%">
         <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
         <stop offset="1" stop-opacity=".1"/>
     </linearGradient>
     <clipPath id="a">
-        <rect width="127" height="20" rx="3" fill="#fff"/>
+        <rect width="147" height="20" rx="3" fill="#fff"/>
     </clipPath>
     <g clip-path="url(#a)">
-        <rect fill="#555" height="20" width="77"/>
-        <rect fill="#4c1" height="20" width="50" x="77"/>
-        <rect fill="url(#b)" height="20" width="127"/>
+        <rect fill="#555" height="20" width="97"/>
+        <rect fill="#4c1" height="20" width="50" x="97"/>
+        <rect fill="url(#b)" height="20" width="147"/>
     </g>
     <g fill="#fff" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11" text-anchor="left">
-        <text x="6" y="15" fill="#010101" fill-opacity=".3">quality gate</text>
-        <text x="6" y="14">quality gate</text>
-        <text x="83" y="15" fill="#010101" fill-opacity=".3">passed</text>
-        <text x="83" y="14">passed</text>
+        <text x="26" y="15" fill="#010101" fill-opacity=".3">quality gate</text>
+        <text x="26" y="14">quality gate</text>
+        <text x="103" y="15" fill="#010101" fill-opacity=".3">passed</text>
+        <text x="103" y="14">passed</text>
     </g>
+    <path fill="#010101" fill-opacity=".3" d="M19.58682 9.81722A3.78893 3.78893 0 0 0 17.78048 8.603v-.04378a3.77165 3.77165 0 1 0-7.5433 0v.05069a3.77165 3.77165 0 1 0 3.78317 6.28186 3.7705 3.7705 0 0 0 5.56416-5.0688zm-2.91802 5.21164a2.8247 2.8247 0 0 1-2.8224-2.82124.47463.47463 0 0 0-.94925 0 3.7486 3.7486 0 0 0 .53223 1.9296 2.8201 2.8201 0 1 1-1.08058-4.57805h.01152a1.3202 1.3202 0 0 1 .30758.14745.4747.4747 0 0 0 .61748-.72115 2.1266 2.1266 0 0 0-.61402-.32371 3.75898 3.75898 0 0 0-1.29946-.2304h-.182a2.82125 2.82125 0 1 1 4.45478 2.4192.47462.47462 0 1 0 .55066.773 3.78317 3.78317 0 0 0 1.44806-2.0736 2.8224 2.8224 0 0 1-.97574 5.46969z"/>
+    <path fill="#f3702a" d="M19.58682 9.09722A3.78893 3.78893 0 0 0 17.78048 7.883v-.04378a3.77165 3.77165 0 1 0-7.5433 0v.05069a3.77165 3.77165 0 1 0 3.78317 6.28186 3.7705 3.7705 0 0 0 5.56416-5.0688zm-2.91802 5.21164a2.8247 2.8247 0 0 1-2.8224-2.82124.47463.47463 0 0 0-.94925 0 3.7486 3.7486 0 0 0 .53223 1.9296 2.8201 2.8201 0 1 1-1.08058-4.57805h.01152a1.3202 1.3202 0 0 1 .30758.14745.4747.4747 0 0 0 .61748-.72115 2.1266 2.1266 0 0 0-.61402-.32371 3.75898 3.75898 0 0 0-1.29946-.2304h-.182a2.82125 2.82125 0 1 1 4.45478 2.4192.47462.47462 0 1 0 .55066.773 3.78317 3.78317 0 0 0 1.44806-2.0736 2.8224 2.8224 0 0 1-.97574 5.46969z"/>
 </svg>
\ No newline at end of file
index 672699b421fae5810326c9fa81d1226e7af186c0..a25766b1e9e53f99df87aa4e27007e3517a01f00 100644 (file)
         <rect fill="url(#b)" height="20" width="${totalWidth}"/>
     </g>
     <g fill="#fff" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11" text-anchor="left">
-        <text x="${margin}" y="15" fill="#010101" fill-opacity=".3">${label}</text>
-        <text x="${margin}" y="14">${label}</text>
-        <text x="${LabelWidthPlusMargin}" y="15" fill="#010101" fill-opacity=".3">${value}</text>
-        <text x="${LabelWidthPlusMargin}" y="14">${value}</text>
+        <text x="${iconWidthPlusMargin}" y="15" fill="#010101" fill-opacity=".3">${label}</text>
+        <text x="${iconWidthPlusMargin}" y="14">${label}</text>
+        <text x="${labelWidthPlusMargin}" y="15" fill="#010101" fill-opacity=".3">${value}</text>
+        <text x="${labelWidthPlusMargin}" y="14">${value}</text>
     </g>
+    <path fill="#010101" fill-opacity=".3" d="M19.58682 9.81722A3.78893 3.78893 0 0 0 17.78048 8.603v-.04378a3.77165 3.77165 0 1 0-7.5433 0v.05069a3.77165 3.77165 0 1 0 3.78317 6.28186 3.7705 3.7705 0 0 0 5.56416-5.0688zm-2.91802 5.21164a2.8247 2.8247 0 0 1-2.8224-2.82124.47463.47463 0 0 0-.94925 0 3.7486 3.7486 0 0 0 .53223 1.9296 2.8201 2.8201 0 1 1-1.08058-4.57805h.01152a1.3202 1.3202 0 0 1 .30758.14745.4747.4747 0 0 0 .61748-.72115 2.1266 2.1266 0 0 0-.61402-.32371 3.75898 3.75898 0 0 0-1.29946-.2304h-.182a2.82125 2.82125 0 1 1 4.45478 2.4192.47462.47462 0 1 0 .55066.773 3.78317 3.78317 0 0 0 1.44806-2.0736 2.8224 2.8224 0 0 1-.97574 5.46969z"/>
+    <path fill="#f3702a" d="M19.58682 9.09722A3.78893 3.78893 0 0 0 17.78048 7.883v-.04378a3.77165 3.77165 0 1 0-7.5433 0v.05069a3.77165 3.77165 0 1 0 3.78317 6.28186 3.7705 3.7705 0 0 0 5.56416-5.0688zm-2.91802 5.21164a2.8247 2.8247 0 0 1-2.8224-2.82124.47463.47463 0 0 0-.94925 0 3.7486 3.7486 0 0 0 .53223 1.9296 2.8201 2.8201 0 1 1-1.08058-4.57805h.01152a1.3202 1.3202 0 0 1 .30758.14745.4747.4747 0 0 0 .61748-.72115 2.1266 2.1266 0 0 0-.61402-.32371 3.75898 3.75898 0 0 0-1.29946-.2304h-.182a2.82125 2.82125 0 1 1 4.45478 2.4192.47462.47462 0 1 0 .55066.773 3.78317 3.78317 0 0 0 1.44806-2.0736 2.8224 2.8224 0 0 1-.97574 5.46969z"/>
 </svg>
\ No newline at end of file