MCPcopy Create free account
hub / github.com/Card-Forge/forge / draw

Method draw

forge-gui-mobile/src/forge/toolbox/FToggleSwitch.java:158–186  ·  view source on GitHub ↗
(Graphics g)

Source from the content-addressed store, hash-verified

156 }
157
158 @Override
159 public void draw(Graphics g) {
160 float x = BORDER_THICKNESS; //leave a pixel so border displays in full
161 float y = BORDER_THICKNESS;
162 float w = getWidth() - 2 * x;
163 float h = getHeight() - 2 * y;
164
165 g.fillRect(getInactiveColor(), x, y, w, h);
166 g.drawRect(BORDER_THICKNESS, getForeColor(), x, y, w, h);
167
168 final String text;
169 float switchWidth = w - h + PADDING;
170 if (toggled) {
171 x = w - switchWidth + 1;
172 text = onText;
173 }
174 else {
175 text = offText;
176 }
177 x += INSETS;
178 y += INSETS;
179 h -= 2 * INSETS;
180 w = switchWidth - 2 * INSETS;
181 g.fillRect(pressed ? getPressedColor() : getActiveColor(), x, y, w, h);
182
183 x += PADDING;
184 w -= 2 * PADDING;
185 g.drawText(text, font, getForeColor(), x, y, w, h, false, Align.center, true);
186 }
187}

Callers

nothing calls this directly

Calls 9

getInactiveColorMethod · 0.95
getForeColorMethod · 0.95
getPressedColorMethod · 0.95
getActiveColorMethod · 0.95
fillRectMethod · 0.80
drawRectMethod · 0.80
getWidthMethod · 0.65
getHeightMethod · 0.65
drawTextMethod · 0.45

Tested by

no test coverage detected