MCPcopy Index your code
hub / github.com/benfry/processing4 / getColor

Method getColor

app/src/processing/app/Settings.java:178–196  ·  view source on GitHub ↗

Parse a color from a Settings file. Values are hexadecimal in either #RRGGBB (for opaque) or 0xAARRGGBB format (to include alpha).

(String attribute)

Source from the content-addressed store, hash-verified

176 * #RRGGBB (for opaque) or 0xAARRGGBB format (to include alpha).
177 */
178 public Color getColor(String attribute) {
179 Color outgoing = null;
180 String s = get(attribute);
181 if (s != null) {
182 try {
183 if (s.startsWith("#")) {
184 // parse a 6-digit hex color
185 outgoing = new Color(Integer.parseInt(s.substring(1), 16));
186 } else if (s.startsWith("0x")) {
187 int v = Integer.parseInt(s.substring(2), 16);
188 outgoing = new Color(v, true);
189 }
190 } catch (Exception ignored) { }
191 }
192 if (outgoing == null) {
193 System.err.println("Could not parse color " + s + " for " + attribute);
194 }
195 return outgoing;
196 }
197
198
199 public void setColor(String attr, Color what) {

Callers

nothing calls this directly

Calls 3

getMethod · 0.95
parseIntMethod · 0.80
printlnMethod · 0.45

Tested by

no test coverage detected