public void doPaintSquare(Graphics g) { int h = height; g.setColor(bgColor); int bx = text.length() == 0 ? 0 : 2; int by = text.length() == 0 ? 0 : (h - boxWidth) / 2 + 1; g.fillRect(bx + 2, by + 2, boxWidth - 4, boxWidth - 4); if (state || pressState) { Color c = Color.LightGray; if (!pressState) { if (!state) c = bgColor; else c = Color.Black; } Pen oldpen = g.setPen(new Pen(c, Pen.SOLID, 2)); g.drawLine(bx + 4, by + boxWidth - 5, bx + boxWidth - 5, by + 4); g.drawLine(bx + 4, by + boxWidth - 5, bx + 4, by + boxWidth - 10); // g.drawLine(bx+3,by+3,bx+boxWidth-5,by+boxWidth-5); // g.drawLine(bx+3,by+boxWidth-5,bx+boxWidth-5,by+3); g.setPen(oldpen); } g.draw3DRect( new Rect(bx, by, boxWidth, boxWidth), ButtonObject.checkboxEdge, true, null, Color.DarkGray); }
private void drawArrows(Graphics g) { if (g != null) { // select moveDirColor according to difference to gotoDir Color moveDirColor = RED; if (gotoDir < 360 && gotoDir > -360 && moveDir < 360 && moveDir > -360) { float diff = java.lang.Math.abs(moveDir - gotoDir); while (diff > 360) { diff -= 360.0f; } if (diff > 180.0f) { diff = 360.0f - diff; } if (diff <= 12.25f) { moveDirColor = GREEN; } else if (diff <= 22.5f) { moveDirColor = CYAN; } else if (diff <= 45.0f) { moveDirColor = ORANGE; } else if (diff <= 90.0f) { moveDirColor = MAGENTA; } } // draw only valid arrows if (northCentered) { if (gotoDir < 360 && gotoDir > -360) drawThickArrow(g, gotoDir, Color.DarkBlue, 1.0f); if (moveDir < 360 && moveDir > -360) drawThinArrow(g, moveDir, RED, moveDirColor, 1.0f); if (sunDir < 360 && sunDir > -360) drawSunArrow(g, sunDir, YELLOW, 0.75f); } else { // moveDir centered if (moveDir < 360 && moveDir > -360) { // drawDoubleArrow(g, 360 - moveDir, BLUE, new Color(175,0,0), 1.0f); // drawRose(g, 360 - moveDir, new Color(100,100,100), new Color(200,200,200), 1.0f); drawFullRose( g, 360 - moveDir, new Color(255, 255, 255), new Color(200, 200, 200), new Color(150, 150, 150), new Color(200, 200, 200), new Color(200, 200, 200), new Color(75, 75, 75), 1.0f, false, false); int radius = (int) (roseRadius * 0.75f); g.setPen(new Pen(RED, Pen.SOLID, 3)); g.drawLine( location.width / 2, location.height / 2 - radius, location.width / 2, location.height / 2 + radius); if (gotoDir < 360 && gotoDir > -360) drawThinArrow(g, gotoDir - moveDir, Color.DarkBlue, moveDirColor, 1.0f); if (sunDir < 360 && sunDir > -360) drawSunArrow(g, sunDir - moveDir, YELLOW, 0.75f); } } } }