22 package com.realtime.crossfire.jxclient.gui.button;
24 import java.awt.Graphics;
25 import java.awt.Image;
26 import org.jetbrains.annotations.NotNull;
65 public ButtonImages(@NotNull
final Image imageLeft, @NotNull
final Image imageMiddle, @NotNull
final Image imageRight) {
66 if (imageLeft.getHeight(null) != imageMiddle.getHeight(null)) {
67 throw new IllegalArgumentException(
"left image height is "+imageLeft.getHeight(null)+
" but middle image height is "+imageMiddle.getHeight(null));
69 if (imageMiddle.getHeight(null) != imageRight.getHeight(null)) {
70 throw new IllegalArgumentException(
"middle image height is "+imageMiddle.getHeight(null)+
" but right image height is "+imageRight.getHeight(null));
76 height = imageMiddle.getHeight(null);
92 public void render(@NotNull
final Graphics g,
final int w) {
93 g.drawImage(imageLeft, 0, 0, null);
94 g.drawImage(imageRight, w-imageRight.getWidth(null), 0, null);
96 final int middleWidth = imageMiddle.getWidth(null);
97 int tmpWidth = w-imageLeft.getWidth(null)-imageRight.getWidth(null);
98 int tmpX = imageLeft.getWidth(null);
99 while (tmpWidth > 0) {
100 final int thisWidth = Math.min(tmpWidth, middleWidth);
101 g.drawImage(imageMiddle, tmpX, 0, tmpX+thisWidth, height, 0, 0, thisWidth, height, null);
103 tmpWidth -= thisWidth;