85 lines
2.0 KiB
Java
85 lines
2.0 KiB
Java
package com.flaremicro.visualforecast.icons.impl;
|
|
|
|
import java.awt.BasicStroke;
|
|
import java.awt.Color;
|
|
import java.awt.Graphics2D;
|
|
import java.awt.geom.Path2D;
|
|
|
|
import com.flaremicro.visualforecast.icons.Icon;
|
|
|
|
public class RainIcon extends Icon {
|
|
private final int rainCount;
|
|
private final float rainSpace;
|
|
private final Icon cloudIcon;
|
|
|
|
Path2D.Float[] rainPath = new Path2D.Float[6];
|
|
Color[] aniColors = new Color[]{
|
|
//new Color(0x0000FF),
|
|
new Color(0x0022FF),
|
|
//new Color(0x0044FF),
|
|
new Color(0x0066FF),
|
|
//new Color(0x0088FF),
|
|
new Color(0x00DDFF),
|
|
//new Color(0x00CCFF),
|
|
new Color(0xFFFFFF),
|
|
//new Color(0x0088FF),
|
|
new Color(0x00DDFF),
|
|
//new Color(0x0044FF),
|
|
new Color(0x0066FF),
|
|
};
|
|
|
|
public RainIcon(int id, int rainCount, float rainSpace, Icon cloudIcon)
|
|
{
|
|
super(id);
|
|
this.rainCount = rainCount;
|
|
this.rainSpace = rainSpace * 0.125F;
|
|
this.cloudIcon = cloudIcon;
|
|
for(int i = 0; i < rainPath.length; i++)
|
|
{
|
|
float ph = 0.075F;
|
|
float pw = 0.1F;
|
|
float poff = 0.037F;
|
|
float xoff = poff*i;
|
|
float yoff = ph*i;
|
|
rainPath[i] = new Path2D.Float();
|
|
rainPath[i].moveTo(0F+xoff, 1F-yoff);
|
|
rainPath[i].lineTo(poff+xoff, 1F-ph-yoff);
|
|
rainPath[i].lineTo(pw+poff+xoff, 1F-ph-yoff);
|
|
rainPath[i].lineTo(pw+xoff, 1F-yoff);
|
|
rainPath[i].closePath();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void drawIcon(Graphics2D g2d, float scale, int animationStep) {
|
|
g2d.setStroke(new BasicStroke(4/scale));
|
|
for(int j = 0; j < rainCount; j++)
|
|
{
|
|
g2d.translate(j*rainSpace, 0F);
|
|
g2d.setColor(Color.BLACK);
|
|
for(int i = 0; i < rainPath.length; i++)
|
|
{
|
|
g2d.draw(rainPath[i]);
|
|
}
|
|
for(int i = 0; i < rainPath.length; i++)
|
|
{
|
|
|
|
g2d.setColor(aniColors[Math.abs(i-j+animationStep) % aniColors.length]);
|
|
g2d.fill(rainPath[i]);
|
|
}
|
|
g2d.translate(-j*rainSpace, 0F);
|
|
}
|
|
g2d.translate(0F, -0.10F);
|
|
g2d.scale(1F, 0.8F);
|
|
cloudIcon.drawIcon(g2d, scale, animationStep);
|
|
g2d.scale(1F, 1.25F);
|
|
g2d.translate(0F, 0.10F);
|
|
}
|
|
|
|
@Override
|
|
public boolean isAnimated() {
|
|
return true;
|
|
}
|
|
|
|
}
|