예제 #1
0
 private void drawHorizontalGradient(
     Graphics2D g, float ratio1, float ratio2, Color c1, Color c2, Color c3, int w, int h) {
   int mid = (int) (ratio1 * w);
   int mid2 = (int) (ratio2 * w);
   if (mid > 0) {
     g.setPaint(getGradient((float) 0, (float) 0, c1, (float) mid, (float) 0, c2));
     g.fillRect(0, 0, mid, h);
   }
   if (mid2 > 0) {
     g.setColor(c2);
     g.fillRect(mid, 0, mid2, h);
   }
   if (mid > 0) {
     g.setPaint(
         getGradient((float) mid + mid2, (float) 0, c2, (float) mid * 2 + mid2, (float) 0, c1));
     g.fillRect(mid + mid2, 0, mid, h);
   }
   if (w - mid * 2 - mid2 > 0) {
     g.setPaint(getGradient((float) mid * 2 + mid2, (float) 0, c1, w, (float) 0, c3));
     g.fillRect(mid * 2 + mid2, 0, w - mid * 2 - mid2, h);
   }
 }
예제 #2
0
 private void drawVerticalGradient(
     Graphics2D g, float ratio1, float ratio2, Color c1, Color c2, Color c3, int w, int h) {
   int mid = (int) (ratio1 * h);
   int mid2 = (int) (ratio2 * h);
   if (mid > 0) {
     g.setPaint(getGradient((float) 0, (float) 0, c1, (float) 0, (float) mid, c2));
     g.fillRect(0, 0, w, mid);
   }
   if (mid2 > 0) {
     g.setColor(c2);
     g.fillRect(0, mid, w, mid2);
   }
   if (mid > 0) {
     g.setPaint(
         getGradient((float) 0, (float) mid + mid2, c2, (float) 0, (float) mid * 2 + mid2, c1));
     g.fillRect(0, mid + mid2, w, mid);
   }
   if (h - mid * 2 - mid2 > 0) {
     g.setPaint(getGradient((float) 0, (float) mid * 2 + mid2, c1, (float) 0, (float) h, c3));
     g.fillRect(0, mid * 2 + mid2, w, h - mid * 2 - mid2);
   }
 }