(Graphics g)
| 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 | } |
nothing calls this directly
no test coverage detected