MCPcopy Create free account
hub / github.com/benfry/processing4 / Handle

Method Handle

java/src/processing/mode/java/tweak/Handle.java:62–116  ·  view source on GitHub ↗
(String t, String n, int vi, String v, int ti, int l, int sc,
                int ec, int dp)

Source from the content-addressed store, hash-verified

60
61
62 public Handle(String t, String n, int vi, String v, int ti, int l, int sc,
63 int ec, int dp) {
64 type = t;
65 name = n;
66 varIndex = vi;
67 strValue = v;
68 tabIndex = ti;
69 line = l;
70 startChar = sc;
71 endChar = ec;
72 decimalPlaces = dp;
73
74 incValue = (float) (1 / Math.pow(10, decimalPlaces));
75
76 if ("int".equals(type)) {
77 value = newValue = Integer.parseInt(strValue);
78 strNewValue = strValue;
79 textFormat = "%d";
80
81 } else if ("hex".equals(type)) {
82 Long val = Long.parseLong(strValue.substring(2, strValue.length()), 16);
83 value = newValue = val.intValue();
84 strNewValue = strValue;
85 textFormat = "0x%x";
86
87 } else if ("webcolor".equals(type)) {
88 Long val;
89 String prefix;
90 if (strValue.length() == 7) {
91 val = Long.parseLong(strValue.substring(1, strValue.length()), 16);
92 prefix = "";
93 } else {
94 String valStr = strValue.substring(
95 strValue.length() - 6,
96 strValue.length()
97 );
98 val = Long.parseLong(valStr, 16);
99 prefix = strValue.substring(
100 1,
101 strValue.length() - 6
102 );
103 }
104 val = val | 0xff000000;
105 value = newValue = val.intValue();
106 strNewValue = strValue;
107 textFormat = "#" + prefix + "%06x";
108 } else if ("float".equals(type)) {
109 value = newValue = Float.parseFloat(strValue);
110 strNewValue = strValue;
111 textFormat = "%.0" + decimalPlaces + "f";
112 }
113
114 newStartChar = startChar;
115 newEndChar = endChar;
116 }
117
118
119 public void initInterface(int x, int y, int width, int height) {

Callers

nothing calls this directly

Calls 4

powMethod · 0.80
parseIntMethod · 0.80
parseFloatMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected