@Override public void setBounds(final int X, final int Y, final int WIDTH, final int HEIGHT) { if (WIDTH <= HEIGHT) { // vertical int yNew; switch (verticalAlignment) { case SwingConstants.TOP: yNew = Y; break; case SwingConstants.BOTTOM: yNew = Y + (HEIGHT - WIDTH); break; case SwingConstants.CENTER: default: yNew = Y + ((HEIGHT - WIDTH) / 2); break; } super.setBounds(X, yNew, WIDTH, WIDTH); } else { // horizontal int xNew; switch (horizontalAlignment) { case SwingConstants.LEFT: xNew = X; break; case SwingConstants.RIGHT: xNew = X + (WIDTH - HEIGHT); break; case SwingConstants.CENTER: default: xNew = X + ((WIDTH - HEIGHT) / 2); break; } super.setBounds(xNew, Y, HEIGHT, HEIGHT); } calcInnerBounds(); init(getGaugeBounds().width, getGaugeBounds().height); setInitialized(true); }
@Override public void setBounds(final Rectangle BOUNDS) { if (BOUNDS.width <= BOUNDS.height) { // vertical int yNew; switch (verticalAlignment) { case SwingConstants.TOP: yNew = BOUNDS.y; break; case SwingConstants.BOTTOM: yNew = BOUNDS.y + (BOUNDS.height - BOUNDS.width); break; case SwingConstants.CENTER: default: yNew = BOUNDS.y + ((BOUNDS.height - BOUNDS.width) / 2); break; } super.setBounds(BOUNDS.x, yNew, BOUNDS.width, BOUNDS.width); } else { // horizontal int xNew; switch (horizontalAlignment) { case SwingConstants.LEFT: xNew = BOUNDS.x; break; case SwingConstants.RIGHT: xNew = BOUNDS.x + (BOUNDS.width - BOUNDS.height); break; case SwingConstants.CENTER: default: xNew = BOUNDS.x + ((BOUNDS.width - BOUNDS.height) / 2); break; } super.setBounds(xNew, BOUNDS.y, BOUNDS.height, BOUNDS.height); } calcInnerBounds(); init(getGaugeBounds().width, getGaugeBounds().height); setInitialized(true); }