Added providers #3
BIN
CanadaDatamartProvider.jar
Normal file
BIN
CanadaDatamartProvider.jar
Normal file
Binary file not shown.
4
CanadaDatamartProvider.properties
Normal file
4
CanadaDatamartProvider.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
#VisualForecast 1000 Properties file. Functional provider must be set for successful boot!
|
||||
#Thu Mar 07 14:12:25 PST 2024
|
||||
towns-by-code=
|
||||
towns-by-name-and-province=Vancouver,BC;Kamloops,BC;Kelowna,BC
|
||||
4
EnvironmentCanadaProvider.properties
Normal file
4
EnvironmentCanadaProvider.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
#VisualForecast 1000 Properties file. Functional provider must be set for successful boot!
|
||||
#Thu Mar 07 14:12:28 PST 2024
|
||||
towns-by-code=
|
||||
towns-by-name-and-province=Vancouver,BC;Kamloops,BC;Kelowna,BC
|
||||
BIN
MockForecastProvider.jar
Normal file
BIN
MockForecastProvider.jar
Normal file
Binary file not shown.
@@ -1,53 +0,0 @@
|
||||
package com.flaremicro.flaretv.visualforecast;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.flaremicro.util.Util;
|
||||
|
||||
public class PropertyManager {
|
||||
private final Properties underlyingProperties = new Properties();
|
||||
private static File propFile = new File("./vf1000.properties");
|
||||
|
||||
public boolean load() {
|
||||
Reader reader = null;
|
||||
try
|
||||
{
|
||||
reader = new FileReader(propFile);
|
||||
underlyingProperties.load(reader);
|
||||
return true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Util.cleanClose(reader);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean store() {
|
||||
Writer writer = null;
|
||||
try
|
||||
{
|
||||
writer = new FileWriter(propFile);
|
||||
underlyingProperties.store(writer, "VisualForecast 1000 Properties file. Functional provider must be set for successful boot!");
|
||||
return true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally{
|
||||
Util.cleanClose(writer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.flaremicro.flaretv.visualforecast.flavour;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.RenderPanel;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.ForecastDetails;
|
||||
|
||||
public interface Flavour {
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks);
|
||||
public void initFlavour(RenderPanel renderer, ForecastDetails details, long ticks, int iconTicks);
|
||||
public void drawFlavour(RenderPanel renderer, Graphics2D g, long ticks, int iconTicks);
|
||||
public void drawBoundLimitedFlavour(RenderPanel renderer, Graphics2D g, Rectangle bounds, long ticks, int iconTicks);
|
||||
public void redrawRegionlost(RenderPanel renderer);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.flaremicro.flaretv.visualforecast.interfaces;
|
||||
|
||||
public interface Tickable {
|
||||
public void tick();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.flaremicro.flaretv.visualforecast.providerapi;
|
||||
|
||||
public abstract class ForecastProvider {
|
||||
ForecastProviderManager pluginManager;
|
||||
|
||||
protected final void setAsProvider(String authority)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract void init();
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.flaremicro.flaretv.visualforecast.providerapi;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.flaremicro.util.Util;
|
||||
|
||||
public class ForecastProviderManager {
|
||||
public static final float API_VERSION = 0.0F;
|
||||
private Logger log = Util.getDefaultLogger();
|
||||
private ForecastProvider loadedProvider;
|
||||
|
||||
public void loadProviders(File file) {
|
||||
Util.getDefaultLogger().info("Loading provider " + file.getName());
|
||||
|
||||
try
|
||||
{
|
||||
URLClassLoader classLoader = new URLClassLoader(new URL[] { file.toURI().toURL() });
|
||||
Properties properties = new Properties();
|
||||
InputStream propStream = classLoader.getResourceAsStream("provider.inf");
|
||||
properties.load(propStream);
|
||||
Util.cleanClose(propStream);
|
||||
|
||||
String mainClassStr = properties.getProperty("main-class", "");
|
||||
Class<?> mainClass = classLoader.loadClass(mainClassStr);
|
||||
Object instance = mainClass.newInstance();
|
||||
if (instance instanceof ForecastProvider)
|
||||
{
|
||||
loadedProvider = (ForecastProvider) instance;
|
||||
loadedProvider.init();
|
||||
log.info("Provider " + file.getName() + " loaded!");
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("Provider " + file.getName() + " main class is wrong object type");
|
||||
log.info("(Does main class not extend ForecastProvider?)");
|
||||
}
|
||||
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " main class not found:");
|
||||
e.printStackTrace();
|
||||
log.info("(Is the information file invalid?)");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed to read information file:");
|
||||
e.printStackTrace();
|
||||
log.info("(Is the information file defined?)");
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed to instantiate main class:");
|
||||
e.printStackTrace();
|
||||
log.info("(Does main class not implement empty constructor?)");
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package com.flaremicro.flaretv.visualforecast.providerapi;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.TownForecast;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.ValueCheck;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.IconProvider;
|
||||
|
||||
public class MockForecastProvider {
|
||||
|
||||
|
||||
private static final String[] townNames = {
|
||||
"Vancouver",
|
||||
"Burnaby",
|
||||
"Kamloops",
|
||||
"Kelona",
|
||||
"Lytton"
|
||||
};
|
||||
|
||||
private final static WeatherType[] possibleWeather = {
|
||||
new WeatherType(IconProvider.BLIZZARD.id, "Blizzard", true),
|
||||
new WeatherType(IconProvider.CLOUD.id, "Cloudy", false),
|
||||
new WeatherType(IconProvider.CLOUDY_CLOUDY.id, "Very", "Cloudy", false),
|
||||
new WeatherType(IconProvider.FREEZING_RAIN.id, "Freezing", "Rain", true),
|
||||
new WeatherType(IconProvider.LIGHTNING_STORM.id, "Thunder", "Storm", true),
|
||||
new WeatherType(IconProvider.LIGHTNING_BLIZZARD.id, "Blizzard", "T'Storm", true),
|
||||
new WeatherType(IconProvider.PARTLY_CLOUDY.id, "Partly", "Cloudy", false),
|
||||
new WeatherType(IconProvider.RAIN.id, "Rain", true),
|
||||
new WeatherType(IconProvider.RAIN_HEAVIEST.id, "Extreme","Rain", true),
|
||||
new WeatherType(IconProvider.RAIN_HEAVY.id, "Heavy","Rain", true),
|
||||
new WeatherType(IconProvider.RAIN_LIGHT.id, "Light","Rain", true),
|
||||
new WeatherType(IconProvider.RAIN_LIGHTEST.id, "Drizzle", true),
|
||||
new WeatherType(IconProvider.RAIN_SNOW.id, "Rain","Snow", true),
|
||||
new WeatherType(IconProvider.RAIN_VANCOUVER.id, "Vancouver","Rain", true),
|
||||
new WeatherType(IconProvider.SCATTERD_SHOWERS.id, "Scattered","Showers", true),
|
||||
new WeatherType(IconProvider.SCATTERD_THUNDERSTORMS.id, "Scattered","T'Storms", true),
|
||||
new WeatherType(IconProvider.SNOW.id, "Snow", true),
|
||||
new WeatherType(IconProvider.SUN.id, "Sun", false),
|
||||
new WeatherType(IconProvider.FOG.id, "Fog", false),
|
||||
new WeatherType(IconProvider.HAIL.id, "Hail", false),
|
||||
new WeatherType(IconProvider.BUTTER_RAIN.id, "Paula", "Dean", false),
|
||||
new WeatherType(IconProvider.BUTTER.id, "Unsalted", "Butter", false),
|
||||
//new WeatherType(IconProvider.INVALID_RAIN.id, "Your", "Mom", false),
|
||||
};
|
||||
|
||||
|
||||
public static ForecastDetails provideMockForecast()
|
||||
{
|
||||
Random random = new Random();
|
||||
ForecastDetails fd = new ForecastDetails();
|
||||
fd.setTownForecast(provideTownForecast(random));
|
||||
return fd;
|
||||
|
||||
}
|
||||
|
||||
private static TownForecast[] provideTownForecast(Random random) {
|
||||
TownForecast[] tf = new TownForecast[townNames.length];
|
||||
for(int i = 0; i < tf.length; i++)
|
||||
{
|
||||
tf[i] = new TownForecast(townNames[i], provideDayForecast(random));
|
||||
}
|
||||
return tf;
|
||||
}
|
||||
|
||||
private static DayForecast[] provideDayForecast(Random random)
|
||||
{
|
||||
DayForecast[] df = new DayForecast[8];
|
||||
for(int i = 0; i < df.length; i++)
|
||||
{
|
||||
if(random.nextInt(11) == 10)
|
||||
{
|
||||
df[i] = new DayForecast(ValueCheck.NO_DATA_BYTE, ValueCheck.NO_DATA_BYTE, (byte)0, null, null, ValueCheck.NO_DATA_FLOAT);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte hiTemp = (byte)(random.nextInt(60)-20);
|
||||
byte loTemp = (byte)(random.nextInt(60)-20);
|
||||
if(hiTemp < loTemp)
|
||||
{
|
||||
byte temp = hiTemp;
|
||||
hiTemp = loTemp;
|
||||
loTemp = temp;
|
||||
}
|
||||
|
||||
byte iconId = 0;
|
||||
String weatherLine1 = null;
|
||||
String weatherLine2 = null;
|
||||
float percipPercent = ValueCheck.NO_DATA_FLOAT;
|
||||
|
||||
WeatherType wt = possibleWeather[random.nextInt(possibleWeather.length)];
|
||||
iconId = wt.iconId;
|
||||
weatherLine1 = wt.line1;
|
||||
weatherLine2 = wt.line2;
|
||||
|
||||
if(wt.hasPercipitation)
|
||||
{
|
||||
percipPercent = random.nextFloat() * 100;
|
||||
}
|
||||
|
||||
df[i] = new DayForecast(hiTemp, loTemp, iconId, weatherLine1, weatherLine2, percipPercent);
|
||||
}
|
||||
}
|
||||
return df;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WeatherType{
|
||||
byte iconId;
|
||||
String line1;
|
||||
String line2;
|
||||
boolean hasPercipitation;
|
||||
|
||||
public WeatherType(byte iconId, String line1, boolean hasPercipitation){
|
||||
this(iconId, line1, null, hasPercipitation);
|
||||
}
|
||||
public WeatherType(byte iconId, String line1, String line2, boolean hasPercipitation){
|
||||
this.iconId = iconId;
|
||||
this.line1 = line1;
|
||||
this.line2 = line2;
|
||||
this.hasPercipitation = hasPercipitation;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.flaremicro.flaretv.visualforecast;
|
||||
package com.flaremicro.visualforecast;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.interfaces.Tickable;
|
||||
import com.flaremicro.visualforecast.interfaces.Tickable;
|
||||
|
||||
public class Executor {
|
||||
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
72
src/com/flaremicro/visualforecast/PropertyManager.java
Normal file
72
src/com/flaremicro/visualforecast/PropertyManager.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.flaremicro.visualforecast;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.flaremicro.util.Util;
|
||||
|
||||
public class PropertyManager {
|
||||
private final Properties prop = new Properties();
|
||||
private File propFile = new File("./vf1000.properties");
|
||||
|
||||
public PropertyManager() {
|
||||
}
|
||||
|
||||
public PropertyManager(String filename) {
|
||||
propFile = new File("./"+filename+".properties");
|
||||
}
|
||||
|
||||
public boolean load() {
|
||||
Reader reader = null;
|
||||
try
|
||||
{
|
||||
if (propFile.exists())
|
||||
{
|
||||
reader = new FileReader(propFile);
|
||||
prop.load(reader);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Util.cleanClose(reader);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean store() {
|
||||
Writer writer = null;
|
||||
try
|
||||
{
|
||||
writer = new FileWriter(propFile);
|
||||
prop.store(writer, "VisualForecast 1000 Properties file. Functional provider must be set for successful boot!");
|
||||
return true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Util.cleanClose(writer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getString(String key, String fallback) {
|
||||
String result = prop.getProperty(key, fallback);
|
||||
System.out.println(result);
|
||||
prop.setProperty(key, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast;
|
||||
package com.flaremicro.visualforecast;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
@@ -16,14 +16,16 @@ import java.util.Calendar;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import static com.flaremicro.flaretv.visualforecast.graphics.RenderConstants.*;
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.flavour.DayForecastFlavour;
|
||||
import com.flaremicro.flaretv.visualforecast.flavour.Flavour;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.flaretv.visualforecast.interfaces.Tickable;
|
||||
import com.flaremicro.flaretv.visualforecast.providerapi.MockForecastProvider;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.displays.BootupDisplay;
|
||||
import com.flaremicro.visualforecast.displays.DayForecastDisplay;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.visualforecast.interfaces.Tickable;
|
||||
|
||||
public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
|
||||
@@ -36,7 +38,7 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
|
||||
private Font font = null;
|
||||
|
||||
private Flavour currentFlavour = new DayForecastFlavour();
|
||||
private Display currentFlavour = new BootupDisplay();
|
||||
|
||||
private int iconAnimationTicks = 0;
|
||||
private long ticks = 0;
|
||||
@@ -47,11 +49,16 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
private String currentTown = "";
|
||||
private String currentForecast = "";
|
||||
|
||||
public RenderPanel() {
|
||||
private ForecastProvider forecastProvider = null;
|
||||
|
||||
private PropertyManager propManager;
|
||||
|
||||
public RenderPanel(PropertyManager propManager) {
|
||||
this.addComponentListener(this);
|
||||
this.setDoubleBuffered(true);
|
||||
this.propManager = propManager;
|
||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
||||
currentFlavour.initFlavour(this, MockForecastProvider.provideMockForecast(), ticks, iconAnimationTicks);
|
||||
currentFlavour.initDisplay(this, null, ticks, iconAnimationTicks);
|
||||
//new Thread(new TickThread(this, 30)).start();
|
||||
}
|
||||
|
||||
@@ -92,9 +99,9 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
if (currentFlavour != null)
|
||||
{
|
||||
if (this.getBounds().equals(g.getClipBounds()))
|
||||
this.currentFlavour.drawFlavour(this, g2d, ticks, iconAnimationTicks);
|
||||
this.currentFlavour.drawDisplay(this, g2d, ticks, iconAnimationTicks);
|
||||
if (g.getClipBounds() != null)
|
||||
this.currentFlavour.drawBoundLimitedFlavour(this, g2d, g.getClipBounds(), ticks, iconAnimationTicks);
|
||||
this.currentFlavour.drawBoundLimitedDisplay(this, g2d, g.getClipBounds(), ticks, iconAnimationTicks);
|
||||
}
|
||||
g2d.dispose();
|
||||
g.drawImage(frameBuffer, 0, 0, getWidth(), getHeight(), this);
|
||||
@@ -168,12 +175,12 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
return frameBuffer.getSnapshot();
|
||||
}
|
||||
|
||||
private void addRedrawBound(int x, int y, int w, int h, boolean isExclusive){
|
||||
private void addRedrawBound(int x, int y, int w, int h, boolean isExclusive) {
|
||||
|
||||
float wScale = getWidth() / (float) W;
|
||||
float hScale = getHeight() / (float) H;
|
||||
Rectangle rect = new Rectangle((int) (x * wScale), (int) (y * hScale), (int) (w * wScale), (int) (h * hScale));
|
||||
if(isExclusive)
|
||||
if (isExclusive)
|
||||
this.exclusiveRedrawBound = rect;
|
||||
if (redrawBound == null)
|
||||
this.redrawBound = new Rectangle((int) (x * wScale), (int) (y * hScale), (int) (w * wScale), (int) (h * hScale));
|
||||
@@ -214,16 +221,32 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
|
||||
}
|
||||
|
||||
public void nextFlavour() {
|
||||
this.currentFlavour = new DayForecastFlavour();
|
||||
this.currentFlavour.initFlavour(this, MockForecastProvider.provideMockForecast(), ticks, iconAnimationTicks);
|
||||
public void setForecastProvider(ForecastProvider forecastProvider) {
|
||||
this.forecastProvider = forecastProvider;
|
||||
this.currentFlavour.notifyForecastProviderUpdate(this, forecastProvider);
|
||||
}
|
||||
|
||||
public void setCurrentTown(String currentTown){
|
||||
public void notifyForecastProviderUpdate()
|
||||
{
|
||||
this.currentFlavour.notifyForecastProviderUpdate(this, forecastProvider);
|
||||
}
|
||||
|
||||
public ForecastDetails getForecast() {
|
||||
return forecastProvider.getForecast();
|
||||
}
|
||||
|
||||
public void nextDisplay() {
|
||||
this.currentFlavour = new DayForecastDisplay();
|
||||
this.currentFlavour.initDisplay(this, forecastProvider, ticks, iconAnimationTicks);
|
||||
this.loseRedrawRegion();
|
||||
this.requestFullRepaint();
|
||||
}
|
||||
|
||||
public void setCurrentTown(String currentTown) {
|
||||
this.currentTown = currentTown;
|
||||
}
|
||||
|
||||
public void setCurrentForecast(String currentForecast){
|
||||
public void setCurrentForecast(String currentForecast) {
|
||||
this.currentForecast = currentForecast;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.flaremicro.flaretv.visualforecast;
|
||||
package com.flaremicro.visualforecast;
|
||||
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.interfaces.Tickable;
|
||||
import com.flaremicro.visualforecast.interfaces.Tickable;
|
||||
|
||||
public class TickThread implements Runnable {
|
||||
private final Tickable tickable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast;
|
||||
package com.flaremicro.visualforecast;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.EventQueue;
|
||||
@@ -6,12 +6,14 @@ import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.providerapi.ForecastProviderManager;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.api.ForecastProviderManager;
|
||||
|
||||
public class VisualForecastFrame extends JFrame implements WindowListener, KeyListener{
|
||||
public class VisualForecastFrame extends JFrame implements WindowListener, KeyListener {
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -20,7 +22,7 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
private RenderPanel renderPane;
|
||||
private ForecastProviderManager forecastProviderManager;
|
||||
private Executor executor;
|
||||
private PropertyManager propertyManager;
|
||||
private PropertyManager propertyManager = new PropertyManager();
|
||||
private boolean isFullscreen = false;
|
||||
|
||||
/**
|
||||
@@ -29,32 +31,44 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
public static void main(String[] args) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
try
|
||||
{
|
||||
VisualForecastFrame frame = new VisualForecastFrame();
|
||||
frame.setVisible(true);
|
||||
frame.init();
|
||||
//GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[1].setFullScreenWindow(frame);
|
||||
frame.createBufferStrategy(2);
|
||||
} catch (Exception e) {
|
||||
frame.createBufferStrategy(2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void end()
|
||||
{
|
||||
if(executor != null)
|
||||
public void end() {
|
||||
if (executor != null)
|
||||
executor.end();
|
||||
if (forecastProviderManager != null)
|
||||
forecastProviderManager.end();
|
||||
propertyManager.store();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
end();
|
||||
public void init() {
|
||||
executor = new Executor(this.renderPane, 30);
|
||||
executor.begin();
|
||||
|
||||
forecastProviderManager = new ForecastProviderManager();
|
||||
new Thread() {
|
||||
public void run() {
|
||||
forecastProviderManager = new ForecastProviderManager(renderPane);
|
||||
propertyManager.load();
|
||||
String forecastProvider = propertyManager.getString("forecast-provider-jar", "");
|
||||
propertyManager.store();
|
||||
ForecastProvider provider = forecastProviderManager.loadProvider(new File(forecastProvider));
|
||||
renderPane.setForecastProvider(provider);
|
||||
}
|
||||
}.start();
|
||||
|
||||
}
|
||||
|
||||
@@ -63,8 +77,8 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
*/
|
||||
public VisualForecastFrame() {
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 640*2, 480*2);
|
||||
renderPane = new RenderPanel();
|
||||
setBounds(100, 100, 640 * 2, 480 * 2);
|
||||
renderPane = new RenderPanel(propertyManager);
|
||||
renderPane.setBorder(null);
|
||||
renderPane.setLayout(new BorderLayout(0, 0));
|
||||
setContentPane(renderPane);
|
||||
@@ -123,13 +137,13 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if(e.getKeyCode() == KeyEvent.VK_F11)
|
||||
if (e.getKeyCode() == KeyEvent.VK_F11)
|
||||
{
|
||||
if(isFullscreen)
|
||||
if (isFullscreen)
|
||||
{
|
||||
isFullscreen = false;
|
||||
this.getGraphicsConfiguration().getDevice().setFullScreenWindow(null);
|
||||
setBounds(100, 100, 640*2, 480*2);
|
||||
setBounds(100, 100, 640 * 2, 480 * 2);
|
||||
|
||||
}
|
||||
else
|
||||
59
src/com/flaremicro/visualforecast/api/ForecastProvider.java
Normal file
59
src/com/flaremicro/visualforecast/api/ForecastProvider.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.flaremicro.visualforecast.api;
|
||||
|
||||
import com.flaremicro.visualforecast.PropertyManager;
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
|
||||
public abstract class ForecastProvider {
|
||||
ForecastProviderManager forecastProviderManager;
|
||||
/**
|
||||
* Initialize the provider. This is called in a separate thread to any other function call.
|
||||
* The VisualForecast 1000 software will wait on the BootupDisplay until this function completes.
|
||||
*/
|
||||
public abstract void init();
|
||||
|
||||
/**
|
||||
* Get the current forecast.
|
||||
* This should delay as little as possible, as this is called in the main action thread.
|
||||
*
|
||||
* @return ForecastDetails
|
||||
*/
|
||||
public abstract ForecastDetails getForecast();
|
||||
|
||||
/**
|
||||
* Should generally be true unless forecast information is collected somewhere other than init.
|
||||
* In the case that forecast information is still unavailable by the time this is called,
|
||||
* this should return false and upon completion and state change, should notify listeners by calling
|
||||
* notifyForecastProviderUpdate()
|
||||
* @return
|
||||
*/
|
||||
public abstract boolean isForecastReady();
|
||||
|
||||
public abstract void deinit();
|
||||
|
||||
public final void notifyForecastProviderUpdate()
|
||||
{
|
||||
getRenderPanel().notifyForecastProviderUpdate();
|
||||
}
|
||||
|
||||
public final ForecastProviderManager getManager()
|
||||
{
|
||||
return forecastProviderManager;
|
||||
}
|
||||
|
||||
public final RenderPanel getRenderPanel()
|
||||
{
|
||||
return forecastProviderManager.getRenderPanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a property manager specific to the forecast provider.
|
||||
* The property manager is already loaded.
|
||||
* @return
|
||||
*/
|
||||
public PropertyManager getOwnPropertyManager() {
|
||||
PropertyManager propertyManager = new PropertyManager(forecastProviderManager.getProviderName(this));
|
||||
propertyManager.load();
|
||||
return propertyManager;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.flaremicro.visualforecast.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.flaremicro.util.Util;
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
|
||||
public class ForecastProviderManager {
|
||||
public static final float API_VERSION = 0.0F;
|
||||
private Logger log = Util.getDefaultLogger();
|
||||
private ForecastProvider loadedProvider;
|
||||
private String loadedProviderName;
|
||||
private RenderPanel mainPanel;
|
||||
|
||||
public ForecastProviderManager(RenderPanel mainPanel)
|
||||
{
|
||||
this.mainPanel = mainPanel;
|
||||
}
|
||||
|
||||
public RenderPanel getRenderPanel()
|
||||
{
|
||||
return this.mainPanel;
|
||||
}
|
||||
|
||||
public ForecastProvider loadProvider(File file) {
|
||||
Util.getDefaultLogger().info("Loading provider " + file.getName());
|
||||
try
|
||||
{
|
||||
URLClassLoader classLoader = new URLClassLoader(new URL[] { file.toURI().toURL() });
|
||||
Properties properties = new Properties();
|
||||
InputStream propStream = classLoader.getResourceAsStream("provider.properties");
|
||||
if (propStream != null)
|
||||
{
|
||||
properties.load(propStream);
|
||||
Util.cleanClose(propStream);
|
||||
|
||||
String mainClassStr = properties.getProperty("main-class", "");
|
||||
Class<?> mainClass = classLoader.loadClass(mainClassStr);
|
||||
Object instance = mainClass.newInstance();
|
||||
if (instance instanceof ForecastProvider)
|
||||
{
|
||||
loadedProvider = (ForecastProvider) instance;
|
||||
loadedProvider.forecastProviderManager = this;
|
||||
loadedProviderName = file.getName().substring(0, file.getName().length() - 4);
|
||||
loadedProvider.init();
|
||||
log.info("Provider " + file.getName() + " loaded! (Name set to " + loadedProviderName +")");
|
||||
return loadedProvider;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("Provider " + file.getName() + " main class is wrong object type");
|
||||
log.info("(Does main class not extend ForecastProvider?)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info("Provider " + file.getName() + " properties file was not found");
|
||||
log.info("(Is the jar path correct?)");
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " main class not found:");
|
||||
e.printStackTrace();
|
||||
log.info("(Is the information file invalid?)");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed to read information file:");
|
||||
e.printStackTrace();
|
||||
log.info("(Is the information file defined?)");
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed to instantiate main class:");
|
||||
e.printStackTrace();
|
||||
log.info("(Does main class not implement empty constructor?)");
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed to instantiate main class:");
|
||||
e.printStackTrace();
|
||||
log.info("(Does the program have reflection permission?)");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed while loading:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed catastrophically while loading:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void end() {
|
||||
if (loadedProvider != null)
|
||||
this.loadedProvider.deinit();
|
||||
}
|
||||
|
||||
public String getProviderName(ForecastProvider forecastProvider) {
|
||||
return loadedProviderName;
|
||||
}
|
||||
|
||||
}
|
||||
105
src/com/flaremicro/visualforecast/displays/BootupDisplay.java
Normal file
105
src/com/flaremicro/visualforecast/displays/BootupDisplay.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.visualforecast.graphics.RenderConstants;
|
||||
import com.flaremicro.visualforecast.icons.IconProvider;
|
||||
|
||||
public class BootupDisplay implements Display {
|
||||
private Font font;
|
||||
//private Font smallFont;
|
||||
|
||||
private long ticks = 0;
|
||||
private boolean forecastReady = false;
|
||||
|
||||
private boolean failed = false;
|
||||
|
||||
public BootupDisplay() {
|
||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
||||
//smallFont = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000 Small.ttf"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
|
||||
this.ticks++;
|
||||
if (this.ticks <= 92)
|
||||
{
|
||||
renderer.requestFullRepaint();
|
||||
}
|
||||
if (forecastReady)
|
||||
{
|
||||
renderer.nextDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initDisplay(RenderPanel renderer, ForecastProvider provider, long ticks, int iconTicks) {
|
||||
renderer.setCurrentForecast("Welcome to the");
|
||||
renderer.setCurrentTown("VisualForecast 1000");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawDisplay(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
if (this.ticks < 80)
|
||||
{
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.fillRect(0, 0, RenderConstants.W, RenderConstants.H);
|
||||
for (int i = 0; i < Math.min(this.ticks, IconProvider.INDEXED_ICONS.length); i++)
|
||||
{
|
||||
int x = (i % 8) * 80;
|
||||
int y = (i / 8) * 80;
|
||||
IconProvider.drawIcon(g2d, IconProvider.INDEXED_ICONS[i], x, y, 80, iconTicks);
|
||||
}
|
||||
g2d.setFont(font.deriveFont(40F));
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.W / 2 - g2d.getFontMetrics().stringWidth("VisualForecast 1000") / 2, RenderConstants.H / 2, "VisualForecast 1000", Color.WHITE, Color.BLACK, 2);
|
||||
}
|
||||
else if (this.ticks > 90)
|
||||
{
|
||||
if (!failed)
|
||||
{
|
||||
DrawingUtil.drawGradientRect(g2d, RenderConstants.SIDE_OFFSET + 80, RenderConstants.TOPBAR_HEIGHT + 90, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 160, (RenderConstants.TOPBAR_HEIGHT + 20), 10, new Color(0x220088), new Color(0x110055));
|
||||
g2d.setFont(font.deriveFont(26F));
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 60 + (RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 120) / 2 - (g2d.getFontMetrics().stringWidth("VisualForecast 1000") / 2), RenderConstants.TOPBAR_HEIGHT + 130, "VisualForecast 1000", Color.WHITE, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 60 + (RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 120) / 2 - (g2d.getFontMetrics().stringWidth("Waiting for forecast data") / 2), RenderConstants.TOPBAR_HEIGHT + 160, "Waiting for forecast data", Color.WHITE, Color.BLACK, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawingUtil.drawGradientRect(g2d, RenderConstants.SIDE_OFFSET + 80, RenderConstants.TOPBAR_HEIGHT + 90, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 160, (RenderConstants.TOPBAR_HEIGHT + 20), 10, new Color(0x220088), new Color(0x110055));
|
||||
g2d.setFont(font.deriveFont(26F));
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 60 + (RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 120) / 2 - (g2d.getFontMetrics().stringWidth("Forecast provider failure") / 2), RenderConstants.TOPBAR_HEIGHT + 130, "Forecast provider failure", Color.WHITE, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 60 + (RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 120) / 2 - (g2d.getFontMetrics().stringWidth("Provider failed to load") / 2), RenderConstants.TOPBAR_HEIGHT + 160, "Provider failed to load", Color.WHITE, Color.BLACK, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redrawRegionlost(RenderPanel renderer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider provider) {
|
||||
if (provider == null)
|
||||
{
|
||||
this.failed = true;
|
||||
renderer.requestFullRepaint();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.forecastReady = provider.isForecastReady();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.flaremicro.flaretv.visualforecast.flavour;
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import static com.flaremicro.flaretv.visualforecast.graphics.RenderConstants.MAINBAR_HEIGHT;
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.MAINBAR_HEIGHT;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
@@ -14,17 +14,18 @@ import java.awt.image.BufferedImage;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.RenderPanel;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.TownForecast;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.ValueCheck;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.RenderConstants;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.IconProvider;
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||
import com.flaremicro.visualforecast.forecast.ValueCheck;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.visualforecast.graphics.RenderConstants;
|
||||
import com.flaremicro.visualforecast.icons.IconProvider;
|
||||
|
||||
public class DayForecastFlavour implements Flavour {
|
||||
public class DayForecastDisplay implements Display {
|
||||
private int dayOffset = 0;
|
||||
private Font font;
|
||||
private Font smallFont;
|
||||
@@ -39,17 +40,17 @@ public class DayForecastFlavour implements Flavour {
|
||||
private int ticksBeforeChange = 200;
|
||||
private int animationTicks = -1;
|
||||
|
||||
public DayForecastFlavour() {
|
||||
public DayForecastDisplay() {
|
||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
||||
smallFont = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000 Small.ttf"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
if(animationTicks >= 0)
|
||||
if (animationTicks >= 0)
|
||||
{
|
||||
animationTicks += 8;
|
||||
if(animationTicks > RenderConstants.W - 60)
|
||||
if (animationTicks > RenderConstants.W - 60)
|
||||
{
|
||||
animationTicks = -1;
|
||||
prevBound.flush();
|
||||
@@ -64,15 +65,6 @@ public class DayForecastFlavour implements Flavour {
|
||||
ticksBeforeChange--;
|
||||
if (ticksBeforeChange < 0)
|
||||
{
|
||||
animationTicks = 0;
|
||||
if(prevBound != null)
|
||||
prevBound.flush();
|
||||
if(mainBound != null)
|
||||
mainBound.flush();
|
||||
prevBound = renderer.getGraphicsConfiguration().createCompatibleImage(526, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
||||
mainBound = renderer.getGraphicsConfiguration().createCompatibleImage(526, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
||||
mainBound.setAccelerationPriority(1);
|
||||
prevBound.setAccelerationPriority(1);
|
||||
|
||||
ticksBeforeChange = 200;
|
||||
dayOffset = dayOffset + 4;
|
||||
@@ -82,7 +74,8 @@ public class DayForecastFlavour implements Flavour {
|
||||
townIndex++;
|
||||
if (townIndex >= details.getTownForecast().length)
|
||||
{
|
||||
renderer.nextFlavour();
|
||||
renderer.nextDisplay();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -92,10 +85,20 @@ public class DayForecastFlavour implements Flavour {
|
||||
}
|
||||
}
|
||||
|
||||
animationTicks = 0;
|
||||
if (prevBound != null)
|
||||
prevBound.flush();
|
||||
if (mainBound != null)
|
||||
mainBound.flush();
|
||||
prevBound = renderer.getGraphicsConfiguration().createCompatibleImage(526, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
||||
mainBound = renderer.getGraphicsConfiguration().createCompatibleImage(526, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
||||
mainBound.setAccelerationPriority(1);
|
||||
prevBound.setAccelerationPriority(1);
|
||||
|
||||
//Flicker workaround
|
||||
BufferedImage throwaway = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
|
||||
Graphics2D g2d = throwaway.createGraphics();
|
||||
this.drawFlavour(renderer, g2d, ticks, iconTicks);
|
||||
this.drawDisplay(renderer, g2d, ticks, iconTicks);
|
||||
g2d.dispose();
|
||||
throwaway.flush();
|
||||
|
||||
@@ -106,8 +109,8 @@ public class DayForecastFlavour implements Flavour {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initFlavour(RenderPanel renderer, ForecastDetails details, long ticks, int iconTicks) {
|
||||
this.details = details;
|
||||
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||
this.details = forecastProvider != null ? forecastProvider.getForecast() : null;
|
||||
renderer.setCurrentForecast("7 Day Forecast");
|
||||
if (details == null || details.getTownForecast() == null || details.getTownForecast().length <= 0)
|
||||
this.details = null;
|
||||
@@ -129,7 +132,7 @@ public class DayForecastFlavour implements Flavour {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFlavour(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
public void drawDisplay(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
if (details == null || currentTown == null || currentTown.getDayForecast() == null || currentTown.getDayForecast().length <= 0)
|
||||
{
|
||||
DrawingUtil.drawGradientRect(g2d, RenderConstants.SIDE_OFFSET + 80, RenderConstants.TOPBAR_HEIGHT + 90, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 160, (RenderConstants.TOPBAR_HEIGHT + 20), 10, new Color(0x220088), new Color(0x110055));
|
||||
@@ -139,7 +142,7 @@ public class DayForecastFlavour implements Flavour {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(animationTicks < 0)
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
drawTownForecast(g2d, currentTown, dayOffset);
|
||||
}
|
||||
@@ -147,38 +150,39 @@ public class DayForecastFlavour implements Flavour {
|
||||
{
|
||||
Graphics2D gimg = prevBound.createGraphics();
|
||||
Graphics2D gimg2 = mainBound.createGraphics();
|
||||
gimg.translate(-RenderConstants.SIDE_OFFSET+1, -RenderConstants.TOPBAR_HEIGHT - 14);
|
||||
gimg2.translate(-RenderConstants.SIDE_OFFSET+1, -RenderConstants.TOPBAR_HEIGHT - 14);
|
||||
gimg.translate(-RenderConstants.SIDE_OFFSET + 1, -RenderConstants.TOPBAR_HEIGHT - 14);
|
||||
gimg2.translate(-RenderConstants.SIDE_OFFSET + 1, -RenderConstants.TOPBAR_HEIGHT - 14);
|
||||
gimg.setStroke(new BasicStroke(2));
|
||||
gimg2.setStroke(new BasicStroke(2));
|
||||
if(dayOffset == 0)
|
||||
if (dayOffset == 0)
|
||||
{
|
||||
drawTownForecast(gimg, previousTown, dayOffset + 4);
|
||||
drawTownForecast(gimg2, currentTown, dayOffset);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
drawTownForecast(gimg, currentTown, dayOffset - 4);
|
||||
drawTownForecast(gimg2, currentTown, dayOffset);
|
||||
}
|
||||
gimg.dispose();
|
||||
gimg2.dispose();
|
||||
|
||||
g2d.setClip(animationTicks + RenderConstants.SIDE_OFFSET, RenderConstants.TOPBAR_HEIGHT+14, 526-animationTicks, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(prevBound, RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT+15, animationTicks, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
g2d.setClip(animationTicks + RenderConstants.SIDE_OFFSET, RenderConstants.TOPBAR_HEIGHT + 14, 526 - animationTicks, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(prevBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT + 15, animationTicks, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
g2d.setClip(null);
|
||||
|
||||
}
|
||||
}
|
||||
if(animationTicks < 0)
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
mainBound = renderer.getSnapshot().getSubimage(RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, 526, MAINBAR_HEIGHT - 28);
|
||||
mainBound = renderer.getSnapshot().getSubimage(RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, 526, MAINBAR_HEIGHT - 28);
|
||||
mainBound.setAccelerationPriority(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawTownForecast(Graphics2D g2d, TownForecast townForecast, int dayOffset)
|
||||
{
|
||||
private void drawTownForecast(Graphics2D g2d, TownForecast townForecast, int dayOffset) {
|
||||
for (int i = 0; i < Math.min(4, townForecast.getDayForecast().length - dayOffset); i++)
|
||||
{
|
||||
|
||||
@@ -233,30 +237,30 @@ public class DayForecastFlavour implements Flavour {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBoundLimitedFlavour(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
if (details != null && currentTown != null && currentTown.getDayForecast() != null && currentTown.getDayForecast().length > 0)
|
||||
{
|
||||
if(animationTicks < 0)
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||
}
|
||||
else
|
||||
{
|
||||
g2d.setClip(animationTicks + RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT+14, 526, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(prevBound, RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
if(dayOffset == 0)
|
||||
g2d.setClip(animationTicks + RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, 526, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(prevBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
if (dayOffset == 0)
|
||||
{
|
||||
drawIcons(g2d, previousTown, dayOffset + 4, iconTicks);
|
||||
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT+14, animationTicks, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT + 14, animationTicks, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawIcons(g2d, currentTown, dayOffset - 4, iconTicks);
|
||||
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT+14, animationTicks, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT + 14, animationTicks, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||
}
|
||||
g2d.setClip(null);
|
||||
@@ -264,7 +268,7 @@ public class DayForecastFlavour implements Flavour {
|
||||
}
|
||||
}
|
||||
|
||||
private void drawIcons(Graphics2D g2d, TownForecast currentTown, int dayOffset, int iconTicks){
|
||||
private void drawIcons(Graphics2D g2d, TownForecast currentTown, int dayOffset, int iconTicks) {
|
||||
|
||||
for (int i = 0; i < Math.min(4, currentTown.getDayForecast().length - dayOffset); i++)
|
||||
{
|
||||
@@ -275,9 +279,13 @@ public class DayForecastFlavour implements Flavour {
|
||||
|
||||
@Override
|
||||
public void redrawRegionlost(RenderPanel renderer) {
|
||||
if(animationTicks >= 0)
|
||||
if (animationTicks >= 0)
|
||||
renderer.addRedrawBound(0, RenderConstants.TOPBAR_HEIGHT, RenderConstants.W, RenderConstants.MAINBAR_HEIGHT);
|
||||
else
|
||||
renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 24, RenderConstants.TOPBAR_HEIGHT + 60, 604, 84);
|
||||
else renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 24, RenderConstants.TOPBAR_HEIGHT + 60, 604, 84);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.flaremicro.flaretv.visualforecast.flavour;
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import static com.flaremicro.flaretv.visualforecast.graphics.RenderConstants.MAINBAR_HEIGHT;
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.MAINBAR_HEIGHT;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
@@ -14,17 +14,18 @@ import java.awt.image.BufferedImage;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.RenderPanel;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.TownForecast;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.ValueCheck;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.RenderConstants;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.IconProvider;
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||
import com.flaremicro.visualforecast.forecast.ValueCheck;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.visualforecast.graphics.RenderConstants;
|
||||
import com.flaremicro.visualforecast.icons.IconProvider;
|
||||
|
||||
public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
public class DayForecastDisplayOldAnimation implements Display {
|
||||
private int dayOffset = 0;
|
||||
private Font font;
|
||||
private Font smallFont;
|
||||
@@ -38,17 +39,17 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
private int ticksBeforeChange = 200;
|
||||
private int animationTicks = -1;
|
||||
|
||||
public DayForecastFlavourOldAnimation() {
|
||||
public DayForecastDisplayOldAnimation() {
|
||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
||||
smallFont = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000 Small.ttf"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
if(animationTicks >= 0)
|
||||
if (animationTicks >= 0)
|
||||
{
|
||||
animationTicks += 8;
|
||||
if(animationTicks > RenderConstants.W - 60)
|
||||
if (animationTicks > RenderConstants.W - 60)
|
||||
{
|
||||
animationTicks = -1;
|
||||
renderer.requestFullRepaint();
|
||||
@@ -62,7 +63,7 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
if (ticksBeforeChange < 0)
|
||||
{
|
||||
animationTicks = 0;
|
||||
lastBound = renderer.getGraphicsConfiguration().createCompatibleImage(526*2+RenderConstants.SIDE_OFFSET, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
||||
lastBound = renderer.getGraphicsConfiguration().createCompatibleImage(526 * 2 + RenderConstants.SIDE_OFFSET, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
||||
lastBound.setAccelerationPriority(1);
|
||||
ticksBeforeChange = 200;
|
||||
dayOffset = dayOffset + 4;
|
||||
@@ -72,7 +73,7 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
townIndex++;
|
||||
if (townIndex >= details.getTownForecast().length)
|
||||
{
|
||||
renderer.nextFlavour();
|
||||
renderer.nextDisplay();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -88,8 +89,8 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initFlavour(RenderPanel renderer, ForecastDetails details, long ticks, int iconTicks) {
|
||||
this.details = details;
|
||||
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||
this.details = forecastProvider != null ? forecastProvider.getForecast() : null;
|
||||
renderer.setCurrentForecast("7 Day Forecast");
|
||||
if (details == null || details.getTownForecast() == null || details.getTownForecast().length <= 0)
|
||||
this.details = null;
|
||||
@@ -111,7 +112,7 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFlavour(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
public void drawDisplay(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
if (details == null || currentTown == null || currentTown.getDayForecast() == null || currentTown.getDayForecast().length <= 0)
|
||||
{
|
||||
DrawingUtil.drawGradientRect(g2d, RenderConstants.SIDE_OFFSET + 80, RenderConstants.TOPBAR_HEIGHT + 90, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 160, (RenderConstants.TOPBAR_HEIGHT + 20), 10, new Color(0x220088), new Color(0x110055));
|
||||
@@ -121,22 +122,24 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(animationTicks < 0)
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
drawTownForecast(g2d, currentTown, dayOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics2D gimg = lastBound.createGraphics();
|
||||
gimg.translate(-RenderConstants.SIDE_OFFSET+1, -RenderConstants.TOPBAR_HEIGHT - 14);
|
||||
gimg.translate(-RenderConstants.SIDE_OFFSET + 1, -RenderConstants.TOPBAR_HEIGHT - 14);
|
||||
gimg.setStroke(new BasicStroke(2));
|
||||
if(dayOffset == 0)
|
||||
if (dayOffset == 0)
|
||||
{
|
||||
drawTownForecast(gimg, previousTown, dayOffset + 4);
|
||||
gimg.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
||||
drawTownForecast(gimg, currentTown, dayOffset);
|
||||
gimg.translate(RenderConstants.SIDE_OFFSET - RenderConstants.W, 0);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
drawTownForecast(gimg, currentTown, dayOffset - 4);
|
||||
gimg.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
||||
drawTownForecast(gimg, currentTown, dayOffset);
|
||||
@@ -149,15 +152,14 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
g2d.translate(animationTicks, 0);
|
||||
}
|
||||
}
|
||||
if(animationTicks < 0)
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
lastBound = renderer.getSnapshot().getSubimage(RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, 526, MAINBAR_HEIGHT - 28);
|
||||
lastBound = renderer.getSnapshot().getSubimage(RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, 526, MAINBAR_HEIGHT - 28);
|
||||
lastBound.setAccelerationPriority(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawTownForecast(Graphics2D g2d, TownForecast townForecast, int dayOffset)
|
||||
{
|
||||
private void drawTownForecast(Graphics2D g2d, TownForecast townForecast, int dayOffset) {
|
||||
for (int i = 0; i < Math.min(4, townForecast.getDayForecast().length - dayOffset); i++)
|
||||
{
|
||||
|
||||
@@ -212,19 +214,19 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBoundLimitedFlavour(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
if (details != null && currentTown != null && currentTown.getDayForecast() != null && currentTown.getDayForecast().length > 0)
|
||||
{
|
||||
if(animationTicks < 0)
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
g2d.drawImage(lastBound, RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
g2d.drawImage(lastBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||
}
|
||||
else
|
||||
{
|
||||
g2d.translate(-animationTicks, 0);
|
||||
g2d.drawImage(lastBound, RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
if(dayOffset == 0)
|
||||
g2d.drawImage(lastBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
if (dayOffset == 0)
|
||||
{
|
||||
|
||||
drawIcons(g2d, previousTown, dayOffset + 4, iconTicks);
|
||||
@@ -242,7 +244,7 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
}
|
||||
}
|
||||
|
||||
private void drawIcons(Graphics2D g2d, TownForecast currentTown, int dayOffset, int iconTicks){
|
||||
private void drawIcons(Graphics2D g2d, TownForecast currentTown, int dayOffset, int iconTicks) {
|
||||
|
||||
for (int i = 0; i < Math.min(4, currentTown.getDayForecast().length - dayOffset); i++)
|
||||
{
|
||||
@@ -253,9 +255,12 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
||||
|
||||
@Override
|
||||
public void redrawRegionlost(RenderPanel renderer) {
|
||||
if(animationTicks >= 0)
|
||||
if (animationTicks >= 0)
|
||||
renderer.addRedrawBound(0, RenderConstants.TOPBAR_HEIGHT, RenderConstants.W, RenderConstants.MAINBAR_HEIGHT);
|
||||
else
|
||||
renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 24, RenderConstants.TOPBAR_HEIGHT + 60, 604, 84);
|
||||
else renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 24, RenderConstants.TOPBAR_HEIGHT + 60, 604, 84);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
}
|
||||
}
|
||||
16
src/com/flaremicro/visualforecast/displays/Display.java
Normal file
16
src/com/flaremicro/visualforecast/displays/Display.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
|
||||
public interface Display {
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks);
|
||||
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks);
|
||||
public void drawDisplay(RenderPanel renderer, Graphics2D g, long ticks, int iconTicks);
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g, Rectangle bounds, long ticks, int iconTicks);
|
||||
public void redrawRegionlost(RenderPanel renderer);
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderPanel, ForecastProvider forecastProvider);
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.flaremicro.flaretv.visualforecast.flavour;
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.RenderPanel;
|
||||
import com.flaremicro.flaretv.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
|
||||
import static com.flaremicro.flaretv.visualforecast.graphics.RenderConstants.*;
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||
|
||||
public class TextFlavour implements Flavour{
|
||||
public class TextDisplay implements Display {
|
||||
|
||||
public TextFlavour(String title, String scrollText)
|
||||
{
|
||||
public TextDisplay(String title, String scrollText) {
|
||||
/*
|
||||
int w2 = g2d.getFontMetrics().stringWidth("EXTREME WEATHER ADVISORY");
|
||||
drawOutlinedString(g2d, (W >> 1) - (w2 >> 1), TOPBAR_HEIGHT + 48, "EXTREME WEATHER ADVISORY", Color.RED, Color.BLACK, 2);
|
||||
@@ -27,18 +26,14 @@ public class TextFlavour implements Flavour{
|
||||
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initFlavour(RenderPanel renderer, ForecastDetails details, long ticks, int iconTicks) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFlavour(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
public void drawDisplay(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
DrawingUtil.drawGradientRect(g2d, 60, TOPBAR_HEIGHT, W - 120, MAINBAR_HEIGHT, 20, BG_BLUE.brighter(), BG_BLUE.darker());
|
||||
g2d.setColor(BG_BLUE.brighter());
|
||||
g2d.drawRect(60 + STROKE_OFFSET, TOPBAR_HEIGHT + STROKE_OFFSET, W - 120 - STROKE_WIDTH, MAINBAR_HEIGHT - STROKE_WIDTH);
|
||||
@@ -46,16 +41,15 @@ public class TextFlavour implements Flavour{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBoundLimitedFlavour(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redrawRegionlost(RenderPanel renderer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast.forecast;
|
||||
package com.flaremicro.visualforecast.forecast;
|
||||
|
||||
public class DayForecast {
|
||||
public byte hiTemp;
|
||||
@@ -16,4 +16,13 @@ public class DayForecast {
|
||||
this.weatherLine2 = weatherLine2;
|
||||
this.percipPercent = percipPercent;
|
||||
}
|
||||
|
||||
public DayForecast() {
|
||||
this.hiTemp = ValueCheck.NO_DATA_BYTE;
|
||||
this.loTemp = ValueCheck.NO_DATA_BYTE;
|
||||
this.iconId = 0;
|
||||
this.weatherLine1 = null;
|
||||
this.weatherLine2 = null;
|
||||
this.percipPercent = ValueCheck.NO_DATA_FLOAT;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast.forecast;
|
||||
package com.flaremicro.visualforecast.forecast;
|
||||
|
||||
public class ForecastDetails {
|
||||
//Perhaps could be hashmap?
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast.forecast;
|
||||
package com.flaremicro.visualforecast.forecast;
|
||||
|
||||
public class TownForecast {
|
||||
public TownForecast(String townName, DayForecast[] dayForecast){
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast.forecast;
|
||||
package com.flaremicro.visualforecast.forecast;
|
||||
|
||||
public class ValueCheck {
|
||||
//Utility for no data
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast.graphics;
|
||||
package com.flaremicro.visualforecast.graphics;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.GradientPaint;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast.graphics;
|
||||
package com.flaremicro.visualforecast.graphics;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast.graphics;
|
||||
package com.flaremicro.visualforecast.graphics;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.text.DateFormat;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons;
|
||||
package com.flaremicro.visualforecast.icons;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons;
|
||||
package com.flaremicro.visualforecast.icons;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.BlizzardIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.ButterIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.CloudIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.FogIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.IceCubeIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.InvalidIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.LightningIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.LightningOverlay;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.LightningStormIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.PartlyCloudyIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.RainIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.RainSnowIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.SmallCloudIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.SnowIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.SnowflakeIcon;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.impl.SunIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.BlizzardIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.ButterIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.CloudIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.FogIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.IceCubeIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.InvalidIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.LightningIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.LightningOverlay;
|
||||
import com.flaremicro.visualforecast.icons.impl.LightningStormIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.PartlyCloudyIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.RainIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.RainSnowIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.SmallCloudIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.SnowIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.SnowflakeIcon;
|
||||
import com.flaremicro.visualforecast.icons.impl.SunIcon;
|
||||
|
||||
public class IconProvider {
|
||||
|
||||
@@ -51,6 +51,8 @@ public class IconProvider {
|
||||
public static final Icon HAIL = registerIcon(new BlizzardIcon(24, CLOUD, ICE_CUBE));
|
||||
public static final Icon BUTTER = registerIcon(new ButterIcon(25));
|
||||
public static final Icon BUTTER_RAIN = registerIcon(new BlizzardIcon(26, CLOUD, BUTTER));
|
||||
public static final Icon RAIN_STORM = registerIcon(new LightningOverlay(27, SMALL_CLOUD, LIGHTNING_BOLT, RAIN_HEAVY));
|
||||
|
||||
//public static final Icon INVALID_RAIN = registerIcon(new LightningOverlay(27, SUN, BUTTER, new BlizzardIcon(-1, LIGHTNING_BOLT, INVALID)));
|
||||
|
||||
private static Icon registerIcon(Icon icon)
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class BlizzardIcon extends Icon {
|
||||
private final Icon cloudIcon;
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
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.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class ButterIcon extends Icon {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class CloudIcon extends Icon {
|
||||
private final Ellipse2D.Float[] cloudCircles = new Ellipse2D.Float[]{
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
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.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class FogIcon extends Icon {
|
||||
private final Icon cloudIcon;
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
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.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class IceCubeIcon extends Icon {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.flaretv.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class InvalidIcon extends Icon {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class LightningCloudIcon extends Icon {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
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.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class LightningIcon extends Icon {
|
||||
Path2D.Float boltPath = new Path2D.Float();
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class LightningOverlay extends Icon {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Graphics2D;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class LightningStormIcon extends Icon {
|
||||
private final Icon boltIcon;
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class PartlyCloudyIcon extends Icon {
|
||||
private Icon cloud;
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
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.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class RainIcon extends Icon {
|
||||
private final int rainCount;
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class RainSnowIcon extends Icon {
|
||||
private final Icon rainIcon;
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
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.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class SleetIcon extends Icon {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class SmallCloudIcon extends Icon {
|
||||
public SmallCloudIcon(int id) {
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class SnowIcon extends Icon {
|
||||
private final Icon cloudIcon;
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
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.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class SnowflakeIcon extends Icon {
|
||||
Path2D.Float flakePath = new Path2D.Float();
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
||||
package com.flaremicro.visualforecast.icons.impl;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
@@ -6,7 +6,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
||||
import com.flaremicro.visualforecast.icons.Icon;
|
||||
|
||||
public class SunIcon extends Icon {
|
||||
Path2D.Float sunPath = new Path2D.Float();
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.flaremicro.visualforecast.interfaces;
|
||||
|
||||
public interface Tickable {
|
||||
public void tick();
|
||||
}
|
||||
3
vf1000.properties
Normal file
3
vf1000.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
#VisualForecast 1000 Properties file. Functional provider must be set for successful boot!
|
||||
#Thu Mar 07 14:12:28 PST 2024
|
||||
forecast-provider-jar=EnvironmentCanadaProvider.jar
|
||||
Reference in New Issue
Block a user