private void doColor(Properties atts, Integer color, boolean fillMode) {
   int c = (0xFFFFFF & color) | 0xFF000000;
   if (searchColor != null && searchColor.intValue() == c) {
     c = replaceColor;
   }
   paint.setColor(c);
   Float opacity = atts.getFloat("opacity", false);
   if (opacity == null) {
     opacity = atts.getFloat(fillMode ? "fill-opacity" : "stroke-opacity", false);
   }
   if (opacity == null) {
     paint.setAlpha(255);
   } else {
     paint.setAlpha((int) (255 * opacity));
   }
 }
 private boolean doFill(Properties atts, HashMap<String, Shader> gradients) {
   if ("none".equals(atts.getString("display"))) {
     return false;
   }
   if (whiteMode) {
     paint.setStyle(Paint.Style.FILL);
     paint.setColor(0xFFFFFFFF);
     return true;
   }
   String fillString = atts.getString("fill");
   if (fillString != null && fillString.startsWith("url(#")) {
     // It's a gradient fill, look it up in our map
     String id = fillString.substring("url(#".length(), fillString.length() - 1);
     Shader shader = gradients.get(id);
     if (shader != null) {
       // Util.debug("Found shader!");
       paint.setShader(shader);
       paint.setStyle(Paint.Style.FILL);
       return true;
     } else {
       // Util.debug("Didn't find shader!");
       return false;
     }
   } else {
     paint.setShader(null);
     Integer color = atts.getHex("fill");
     if (color != null) {
       doColor(atts, color, true);
       paint.setStyle(Paint.Style.FILL);
       return true;
     } else if (atts.getString("fill") == null && atts.getString("stroke") == null) {
       // Default is black fill
       paint.setStyle(Paint.Style.FILL);
       paint.setColor(0xFF000000);
       return true;
     }
   }
   return false;
 }
    private boolean doStroke(Properties atts, HashMap<String, Shader> gradients) {
      if (whiteMode) {
        // Never stroke in white mode
        return false;
      }
      if ("none".equals(atts.getString("display"))) {
        return false;
      }
      String strokeString = atts.getString("stroke");
      if (strokeString == null) return false;
      if (strokeString.startsWith("url(#")) {
        String id = strokeString.substring("url(#".length(), strokeString.length() - 1);
        Shader shader = gradients.get(id);
        if (shader == null) return false;
        paint.setShader(shader);
      } else {
        Integer color = atts.getHex("stroke");
        if (color == null) return false;
        paint.setShader(null);
        doColor(atts, color, false);
      }

      // Check for other stroke attributes
      Float width = atts.getFloat("stroke-width", true);
      // Set defaults

      if (width != null) {
        paint.setStrokeWidth(width);
      }
      String linecap = atts.getString("stroke-linecap");
      if ("round".equals(linecap)) {
        paint.setStrokeCap(Paint.Cap.ROUND);
      } else if ("square".equals(linecap)) {
        paint.setStrokeCap(Paint.Cap.SQUARE);
      } else if ("butt".equals(linecap)) {
        paint.setStrokeCap(Paint.Cap.BUTT);
      }
      String linejoin = atts.getString("stroke-linejoin");
      if ("miter".equals(linejoin)) {
        paint.setStrokeJoin(Paint.Join.MITER);
      } else if ("round".equals(linejoin)) {
        paint.setStrokeJoin(Paint.Join.ROUND);
      } else if ("bevel".equals(linejoin)) {
        paint.setStrokeJoin(Paint.Join.BEVEL);
      }
      paint.setStyle(Paint.Style.STROKE);
      return true;
    }