feature/current_conditions #5
@@ -3,5 +3,6 @@
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="lib" path="jlayer2.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,13 @@
|
||||
#VisualForecast 1000 Properties file. Functional provider must be set for successful boot!
|
||||
#Fri Mar 15 19:46:22 PDT 2024
|
||||
towns-by-code=
|
||||
#Sat Nov 23 19:50:15 PST 2024
|
||||
displays-enabled.town.prince_rupert.bc=7-day,hourly
|
||||
displays-enabled.town.victora.bc=36-hour,7-day,hourly
|
||||
displays-enabled.town.nanaimo.bc=7-day,hourly
|
||||
displays-enabled.town.prince\ rupert.bc=
|
||||
displays-enabled.town.kelowna.bc=7-day,hourly
|
||||
displays-enabled.town.prince_george.bc=36-hour,7-day,hourly
|
||||
displays-enabled.town.prince\ george.bc=
|
||||
towns-by-name-and-province=Vancouver,BC;Victora,BC;Kelowna,BC;Nanaimo,BC;Squamish,BC;Prince George,BC;Prince Rupert,BC
|
||||
displays-enabled.town.squamish.bc=7-day,hourly
|
||||
towns-by-code=
|
||||
displays-enabled.town.vancouver.bc=
|
||||
|
||||
@@ -18,10 +18,11 @@ public class PropertyManager {
|
||||
}
|
||||
|
||||
public PropertyManager(String filename) {
|
||||
propFile = new File("./"+filename+".properties");
|
||||
propFile = new File("./" + filename + ".properties");
|
||||
}
|
||||
|
||||
public boolean load() {
|
||||
synchronized(prop){
|
||||
Reader reader = null;
|
||||
try
|
||||
{
|
||||
@@ -43,8 +44,10 @@ public class PropertyManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean store() {
|
||||
synchronized(prop){
|
||||
Writer writer = null;
|
||||
try
|
||||
{
|
||||
@@ -62,11 +65,47 @@ public class PropertyManager {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
public String getStringNoSet(String key, String fallback) {
|
||||
String result = prop.getProperty(key, fallback);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getInteger(String key, int fallback) {
|
||||
String resultString = getString(key, String.valueOf(fallback));
|
||||
int resultInt = fallback;
|
||||
try
|
||||
{
|
||||
resultInt = Integer.parseInt(resultString);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
}
|
||||
prop.setProperty(key, String.valueOf(resultInt));
|
||||
return resultInt;
|
||||
}
|
||||
|
||||
public void setString(String key, String value) {
|
||||
if (value == null)
|
||||
prop.remove(key);
|
||||
else prop.setProperty(key, value);
|
||||
}
|
||||
|
||||
public void setInteger(String key, int value) {
|
||||
prop.setProperty(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
public File getFile(String key, File fallback) {
|
||||
String resultString = getString(key, fallback.toString());
|
||||
if (resultString == null)
|
||||
return fallback;
|
||||
else return new File(resultString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,9 @@ import static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||
|
||||
import com.flaremicro.util.Util;
|
||||
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.displays.DisplayFactory;
|
||||
import com.flaremicro.visualforecast.displays.HourlyForecastDisplay;
|
||||
import com.flaremicro.visualforecast.displays.ThirtySixHourDisplay;
|
||||
import com.flaremicro.visualforecast.displays.impl.BootupDisplay;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
@@ -73,6 +70,8 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
|
||||
DisplayFactory displayFactory;
|
||||
|
||||
AudioManager audioManager;
|
||||
|
||||
public RenderPanel(PropertyManager propManager) {
|
||||
loadCrawlStrings();
|
||||
this.addComponentListener(this);
|
||||
@@ -81,6 +80,7 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
||||
currentFlavour.initDisplay(this, null, ticks, iconAnimationTicks);
|
||||
displayFactory = new DisplayFactory(propManager);
|
||||
audioManager = new AudioManager(propManager);
|
||||
//new Thread(new TickThread(this, 30)).start();
|
||||
}
|
||||
|
||||
@@ -209,9 +209,8 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
currentBound = this.getBounds();
|
||||
}
|
||||
|
||||
|
||||
public void requestRepaint(Rectangle bound) {
|
||||
if(currentBound.width == 0)
|
||||
if (currentBound.width == 0)
|
||||
currentBound = new Rectangle(bound);
|
||||
else currentBound.add(bound);
|
||||
}
|
||||
@@ -230,7 +229,7 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
this.crawlPosition -= 2;
|
||||
requestRepaint(crawlBound);
|
||||
}
|
||||
if(this.currentBound.width != 0)
|
||||
if (this.currentBound.width != 0)
|
||||
{
|
||||
repaint(currentBound);
|
||||
currentBound.width = 0;
|
||||
@@ -305,14 +304,25 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
}
|
||||
|
||||
public void nextDisplay() {
|
||||
/*if(this.currentFlavour instanceof DayForecastDisplay)
|
||||
this.currentFlavour = new HourlyForecastDisplay();
|
||||
else
|
||||
this.currentFlavour = new DayForecastDisplay();*/
|
||||
if (this.currentFlavour instanceof BootupDisplay)
|
||||
{
|
||||
audioManager.startPlaylist();
|
||||
}
|
||||
|
||||
this.currentFlavour = displayFactory.nextDisplay();
|
||||
/*this.currentFlavour = new ThirtySixHourDisplay();
|
||||
*/
|
||||
|
||||
this.currentFlavour.initDisplay(this, forecastProvider, ticks, iconAnimationTicks);
|
||||
|
||||
File announcementDirectory = this.propManager.getFile("announcement-dir", new File("Announcements"));
|
||||
if (announcementDirectory != null && announcementDirectory.isDirectory())
|
||||
{
|
||||
File file = new File(announcementDirectory, currentFlavour.getDisplayName() + ".wav");
|
||||
if(file.exists())
|
||||
{
|
||||
this.audioManager.playAnnouncement(file);
|
||||
}
|
||||
}
|
||||
|
||||
this.loseRedrawRegion();
|
||||
this.requestFullRepaint();
|
||||
}
|
||||
@@ -352,6 +362,10 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
this.crawlStrings = strings.toArray(new String[strings.size()]);
|
||||
}
|
||||
|
||||
public void end() {
|
||||
this.audioManager.end();
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void run() {
|
||||
while (true)
|
||||
|
||||
@@ -31,7 +31,7 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
private Executor executor;
|
||||
private PropertyManager propertyManager = new PropertyManager();
|
||||
private Timer timer;
|
||||
private Timer timer2;
|
||||
//private Timer timer2;
|
||||
private boolean isFullscreen = false;
|
||||
|
||||
/**
|
||||
@@ -87,6 +87,7 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
{
|
||||
timer.stop();
|
||||
}
|
||||
renderPane.end();
|
||||
if (forecastProviderManager != null)
|
||||
forecastProviderManager.end();
|
||||
propertyManager.store();
|
||||
@@ -106,7 +107,6 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
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));
|
||||
@@ -121,8 +121,9 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
* Create the frame.
|
||||
*/
|
||||
public VisualForecastFrame() {
|
||||
propertyManager.load();
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 640 * 2, 480 * 2);
|
||||
setBounds(100, 100, 640, 480);
|
||||
renderPane = new RenderPanel(propertyManager);
|
||||
//renderPane.setBorder(null);
|
||||
//renderPane.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
@@ -13,4 +13,6 @@ public interface Display {
|
||||
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);
|
||||
|
||||
public String getDisplayName();
|
||||
}
|
||||
|
||||
@@ -1,27 +1,67 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.flaremicro.visualforecast.PropertyManager;
|
||||
import com.flaremicro.visualforecast.displays.impl.SevenDayForecastDisplay;
|
||||
import com.flaremicro.visualforecast.displays.impl.HourlyForecastDisplay;
|
||||
import com.flaremicro.visualforecast.displays.impl.MessageForecastDisplay;
|
||||
import com.flaremicro.visualforecast.displays.impl.ThirtySixHourForecastDisplay;
|
||||
|
||||
public class DisplayFactory {
|
||||
private static final int CURRENT_SELECTION = 1;
|
||||
int currentIndex = -1;
|
||||
String indexValue = "";
|
||||
PropertyManager propertyManager;
|
||||
|
||||
private List<String> nameOrder = new ArrayList<String>();
|
||||
private Map<String, Display> displays = new HashMap<String, Display>();
|
||||
|
||||
public DisplayFactory(PropertyManager propertyManager)
|
||||
public DisplayFactory(PropertyManager propertyManager) {
|
||||
this.propertyManager = propertyManager;
|
||||
nameOrder.add(register(new MessageForecastDisplay()));
|
||||
//nameOrder.add(register(new CurrentForecastDisplay()));
|
||||
nameOrder.add(register(new ThirtySixHourForecastDisplay()));
|
||||
nameOrder.add(register(new SevenDayForecastDisplay()));
|
||||
nameOrder.add(register(new HourlyForecastDisplay()));
|
||||
int selection = propertyManager.getInteger("current-display-version", -1);
|
||||
|
||||
String nameOrderString = getCurrentNameOrder();
|
||||
if ((selection >= 0 && selection != CURRENT_SELECTION))
|
||||
{
|
||||
displays.put("message", new MessageForecastDisplay());
|
||||
displays.put("day", new DayForecastDisplay());
|
||||
displays.put("hourly", new HourlyForecastDisplay());
|
||||
nameOrder.add("message");
|
||||
nameOrder.add("day");
|
||||
nameOrder.add("hourly");
|
||||
propertyManager.setInteger("current-display-version", CURRENT_SELECTION);
|
||||
propertyManager.setString("display-selection", nameOrderString);
|
||||
propertyManager.store();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("got good order: " + propertyManager.getString("display-selection", "oh no"));
|
||||
nameOrder.clear();
|
||||
String[] s = propertyManager.getString("display-selection", nameOrderString).split(",");
|
||||
nameOrder.addAll(Arrays.asList(s));
|
||||
}
|
||||
}
|
||||
|
||||
private String getCurrentNameOrder() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < nameOrder.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(nameOrder.get(i));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String register(Display display) {
|
||||
displays.put(display.getDisplayName(), display);
|
||||
return display.getDisplayName();
|
||||
}
|
||||
|
||||
public Display nextDisplay() {
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
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 static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||
|
||||
public class TextDisplay implements Display {
|
||||
|
||||
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);
|
||||
|
||||
g2d.setFont(font.deriveFont(30F));
|
||||
for (int i = 0; i < testString.length; i++)
|
||||
{
|
||||
drawOutlinedString(g2d, 90, TOPBAR_HEIGHT + 78 + 25 * i, testString[i], Color.WHITE, Color.BLACK, 1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redrawRegionlost(RenderPanel renderer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||
|
||||
public class ThirtySixHourDisplay implements Display {
|
||||
|
||||
private String[] lines = new String[0];
|
||||
private Font font;
|
||||
|
||||
|
||||
public ThirtySixHourDisplay() {
|
||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf")).deriveFont(30F);
|
||||
|
||||
/*
|
||||
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);
|
||||
|
||||
g2d.setFont(font.deriveFont(30F));
|
||||
for (int i = 0; i < testString.length; i++)
|
||||
{
|
||||
drawOutlinedString(g2d, 90, TOPBAR_HEIGHT + 78 + 25 * i, testString[i], Color.WHITE, Color.BLACK, 1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||
String test = "*IMPORTANT NOTICE*\n*POWER OUTAGE POSSIBLE*\n*DUE TO EXTREME WINDS*\n\nHurricane-force winds capable of reaching 127km/h will be hitting the east coast around noon tomorrow. Keep windows and doors barricaded to prevent";
|
||||
ArrayList<String> linesList = new ArrayList<String>();
|
||||
|
||||
BufferedImage disposableImage = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY);
|
||||
Graphics2D g = disposableImage.createGraphics();
|
||||
FontMetrics f = g.getFontMetrics(font);
|
||||
System.out.println("yas2");
|
||||
String[] lines = test.split("\n");
|
||||
for(int i = 0; i < lines.length; i++)
|
||||
{
|
||||
splitText(lines[i], W - 150 - STROKE_WIDTH, f, linesList);
|
||||
//if(words[i])
|
||||
}
|
||||
|
||||
g.dispose();
|
||||
disposableImage.flush();
|
||||
|
||||
System.out.println("yas");
|
||||
|
||||
this.lines = linesList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private void splitText(String text, int maxWidth, FontMetrics fontMetrics, ArrayList<String> lineList) {
|
||||
|
||||
text = text.trim();
|
||||
//this.text.add(text);
|
||||
if (fontMetrics.stringWidth(text) <= maxWidth)
|
||||
lineList.add(text);
|
||||
else
|
||||
{
|
||||
while (text.length() > 0)
|
||||
{
|
||||
int idx = binSearch(text, fontMetrics, maxWidth, 1, text.length());
|
||||
if (idx <= 0)
|
||||
break;
|
||||
String texPart = text.substring(0, idx).trim();
|
||||
if (fontMetrics.stringWidth(text.substring(0, Math.min(text.length(), idx + 1))) > maxWidth && texPart.contains(" "))
|
||||
{
|
||||
idx = texPart.lastIndexOf(" ");
|
||||
texPart = texPart.substring(0, idx);
|
||||
}
|
||||
lineList.add(texPart);
|
||||
text = text.substring(idx).trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int binSearch(String string, FontMetrics fontMetrics, int key, int low, int high) {
|
||||
int index = 0;
|
||||
|
||||
while (low <= high)
|
||||
{
|
||||
int mid = low + ((high - low) / 2);
|
||||
int midmetric = fontMetrics.stringWidth(string.substring(0, mid));
|
||||
if (midmetric < key)
|
||||
{
|
||||
low = mid + 1;
|
||||
index = mid;
|
||||
}
|
||||
else if (midmetric > key)
|
||||
{
|
||||
high = mid - 1;
|
||||
}
|
||||
else if (midmetric == key)
|
||||
{
|
||||
index = mid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
@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) {
|
||||
DrawingUtil.drawGradientRect(g2d, 60, TOPBAR_HEIGHT, W - 120, MAINBAR_HEIGHT, 20, BG_BLUE.brighter(), BG_BLUE.darker());
|
||||
g2d.setFont(font);
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
g2d.setColor(BG_BLUE.brighter());
|
||||
g2d.drawRect(60 + STROKE_OFFSET, TOPBAR_HEIGHT + STROKE_OFFSET, W - 120 - STROKE_WIDTH, MAINBAR_HEIGHT - STROKE_WIDTH);
|
||||
for(int i = 0; i < lines.length; i++)
|
||||
{
|
||||
if(lines[i].startsWith("*") && lines[i].endsWith("*"))
|
||||
{
|
||||
String line = lines[i].substring(1, lines[i].length()-1);
|
||||
DrawingUtil.drawOutlinedString(g2d, 60 + 20 + STROKE_OFFSET, TOPBAR_HEIGHT + STROKE_OFFSET + 40 + i*30, "*", Color.WHITE, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, 60 + 20 + STROKE_OFFSET + (W - 150 - STROKE_WIDTH)/2 - fontMetrics.stringWidth(line)/2, TOPBAR_HEIGHT + STROKE_OFFSET + 40 + i*30, line, Color.WHITE, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, W - 95 - STROKE_WIDTH, TOPBAR_HEIGHT + STROKE_OFFSET + 40 + i*30, "*", Color.WHITE, Color.BLACK, 2);
|
||||
}
|
||||
else if(lines[i].startsWith("[") && lines[i].endsWith("]"))
|
||||
{
|
||||
String line = lines[i].substring(1, lines[i].length()-1);
|
||||
DrawingUtil.drawOutlinedString(g2d, 60 + 20 + STROKE_OFFSET + (W - 150 - STROKE_WIDTH)/2 - fontMetrics.stringWidth(line)/2, TOPBAR_HEIGHT + STROKE_OFFSET + 40 + i*30, line, Color.WHITE, Color.BLACK, 2);
|
||||
}
|
||||
else
|
||||
DrawingUtil.drawOutlinedString(g2d, 60 + 20 + STROKE_OFFSET, TOPBAR_HEIGHT + STROKE_OFFSET + 40 + i*30, lines[i], Color.WHITE, Color.BLACK, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redrawRegionlost(RenderPanel renderer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
package com.flaremicro.visualforecast.displays.impl;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
@@ -7,6 +7,7 @@ import java.awt.Rectangle;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.visualforecast.graphics.RenderConstants;
|
||||
@@ -64,7 +65,7 @@ public class BootupDisplay implements Display {
|
||||
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);
|
||||
//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)
|
||||
{
|
||||
@@ -102,4 +103,9 @@ public class BootupDisplay implements Display {
|
||||
this.forecastReady = provider.isForecastReady();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "bootup";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
package com.flaremicro.visualforecast.displays.impl;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
@@ -10,6 +10,7 @@ import java.util.ArrayList;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
|
||||
@@ -63,8 +64,8 @@ public class CurrentForecastDisplay implements Display {
|
||||
String test = "*IMPORTANT NOTICE*\n*THIS BETA IS UNFINISHED*\n\nThis is a Beta version of the VisualForeast 1000! Many things are not finished, and only the hourly and 7 day forecasts are ready. There will be a lot more to come!\nPlease note that there are some issues with data collection from Environment Canada resulting in missing or potentially incorrect information around midnight hours. This will be fixed as the project continues and the disclaimer will be removed.";
|
||||
ArrayList<String> linesList = new ArrayList<String>();
|
||||
|
||||
renderer.setCurrentForecast("Welcome to the");
|
||||
renderer.setCurrentTown("VisualForecast 1000");
|
||||
renderer.setCurrentForecast("Current Conditions");
|
||||
renderer.setCurrentTown("TOWN NAME HERE");
|
||||
|
||||
BufferedImage disposableImage = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY);
|
||||
Graphics2D g = disposableImage.createGraphics();
|
||||
@@ -172,4 +173,8 @@ public class CurrentForecastDisplay implements Display {
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "current";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
package com.flaremicro.visualforecast.displays.impl;
|
||||
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.BG_BLUE;
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.MAINBAR_HEIGHT;
|
||||
@@ -9,18 +9,13 @@ import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.forecast.HourlyForecast;
|
||||
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||
@@ -70,7 +65,7 @@ public class HourlyForecastDisplay implements Display {
|
||||
}
|
||||
this.currentTown = details.getTownForecast()[townIndex];
|
||||
}
|
||||
while (this.currentTown == null || currentTown.getHourlyForecast() == null || currentTown.getHourlyForecast().length == 0);
|
||||
while (this.currentTown == null || !currentTown.isDisplaySupported(this.getDisplayName()) || currentTown.getHourlyForecast() == null || currentTown.getHourlyForecast().length == 0);
|
||||
renderer.setCurrentTown(currentTown.getTownName());
|
||||
setGraphValues(currentTown);
|
||||
renderer.requestFullRepaint();
|
||||
@@ -346,4 +341,9 @@ public class HourlyForecastDisplay implements Display {
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "hourly";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
package com.flaremicro.visualforecast.displays.impl;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
@@ -10,6 +10,7 @@ import java.util.ArrayList;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
|
||||
@@ -172,4 +173,8 @@ public class MessageForecastDisplay implements Display {
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "message";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
package com.flaremicro.visualforecast.displays.impl;
|
||||
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.MAINBAR_HEIGHT;
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.Locale;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||
@@ -25,7 +26,7 @@ import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.visualforecast.graphics.RenderConstants;
|
||||
import com.flaremicro.visualforecast.icons.IconProvider;
|
||||
|
||||
public class DayForecastDisplay implements Display {
|
||||
public class SevenDayForecastDisplay implements Display {
|
||||
private int dayOffset = 0;
|
||||
private Font font;
|
||||
private Font smallFont;
|
||||
@@ -40,14 +41,19 @@ public class DayForecastDisplay implements Display {
|
||||
private int ticksBeforeChange = 200;
|
||||
private int animationTicks = -1;
|
||||
|
||||
public DayForecastDisplay() {
|
||||
public SevenDayForecastDisplay() {
|
||||
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"));
|
||||
}
|
||||
|
||||
//TODO improve
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
if (animationTicks >= 0)
|
||||
if(details == null || details.getTownForecast() == null){
|
||||
renderer.nextDisplay();
|
||||
return;
|
||||
}
|
||||
else if (animationTicks >= 0)
|
||||
{
|
||||
animationTicks += 8;
|
||||
if (animationTicks > RenderConstants.W - 60)
|
||||
@@ -69,6 +75,8 @@ public class DayForecastDisplay implements Display {
|
||||
ticksBeforeChange = 200;
|
||||
dayOffset = dayOffset + 4;
|
||||
if (dayOffset >= 8)
|
||||
{
|
||||
do
|
||||
{
|
||||
dayOffset = 0;
|
||||
townIndex++;
|
||||
@@ -84,6 +92,8 @@ public class DayForecastDisplay implements Display {
|
||||
renderer.setCurrentTown(currentTown.getTownName());
|
||||
}
|
||||
}
|
||||
while (this.currentTown != null && !this.currentTown.isDisplaySupported(this.getDisplayName()));
|
||||
}
|
||||
|
||||
animationTicks = 0;
|
||||
if (prevBound != null)
|
||||
@@ -296,4 +306,9 @@ public class DayForecastDisplay implements Display {
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "7-day";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
package com.flaremicro.visualforecast.displays.impl;
|
||||
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.MAINBAR_HEIGHT;
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.Locale;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||
@@ -25,7 +26,7 @@ import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.visualforecast.graphics.RenderConstants;
|
||||
import com.flaremicro.visualforecast.icons.IconProvider;
|
||||
|
||||
public class DayForecastDisplayOldAnimation implements Display {
|
||||
public class SevenDayForecastDisplayOldAnimation implements Display {
|
||||
private int dayOffset = 0;
|
||||
private Font font;
|
||||
private Font smallFont;
|
||||
@@ -39,7 +40,7 @@ public class DayForecastDisplayOldAnimation implements Display {
|
||||
private int ticksBeforeChange = 200;
|
||||
private int animationTicks = -1;
|
||||
|
||||
public DayForecastDisplayOldAnimation() {
|
||||
public SevenDayForecastDisplayOldAnimation() {
|
||||
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"));
|
||||
}
|
||||
@@ -263,4 +264,9 @@ public class DayForecastDisplayOldAnimation implements Display {
|
||||
@Override
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "7-day-old";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.flaremicro.visualforecast.forecast;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class CurrentConditions {
|
||||
String station;
|
||||
String stationCode;
|
||||
Date timeObserved;
|
||||
String condition;
|
||||
byte icon;
|
||||
byte temperature;
|
||||
byte dewPoint;
|
||||
short pressure;
|
||||
short visibility;
|
||||
float relativeHumidity;
|
||||
short windSpeed;
|
||||
short windGust;
|
||||
float windBearing;
|
||||
String windDirection;
|
||||
}
|
||||
@@ -6,17 +6,21 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TownForecast {
|
||||
|
||||
private String townName;
|
||||
private DayForecast[] dayForecast;
|
||||
private Set<String> displays = new HashSet<String>();
|
||||
private HourlyForecast[] hourlyForecast;
|
||||
private DetailedForecast[] detailedForecast;
|
||||
|
||||
public TownForecast(String townName, DayForecast[] dayForecast) {
|
||||
this.townName = townName;
|
||||
this.dayForecast = dayForecast;
|
||||
}
|
||||
|
||||
private final String townName;
|
||||
private final DayForecast[] dayForecast;
|
||||
private Set<String> displays = new HashSet<String>();
|
||||
|
||||
|
||||
private HourlyForecast[] hourlyForecast;
|
||||
public void setDayForecast(DayForecast[] dayForecast){
|
||||
this.dayForecast = dayForecast;
|
||||
}
|
||||
|
||||
public boolean isDisplaySupported(String displayName)
|
||||
{
|
||||
@@ -47,4 +51,12 @@ public class TownForecast {
|
||||
public String getTownName() {
|
||||
return townName;
|
||||
}
|
||||
|
||||
public DetailedForecast[] getDetailedForecast() {
|
||||
return detailedForecast;
|
||||
}
|
||||
|
||||
public void setDetailedForecast(DetailedForecast[] detailedForecast) {
|
||||
this.detailedForecast = detailedForecast;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class IconProvider {
|
||||
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)));
|
||||
public static final Icon INVALID_RAIN = registerIcon(new LightningOverlay(28, SUN, BUTTER, new BlizzardIcon(-1, LIGHTNING_BOLT, INVALID)));
|
||||
|
||||
private static Icon registerIcon(Icon icon)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ public class ButterIcon extends Icon {
|
||||
};
|
||||
Color[] iceShineAnimation = new Color[] {
|
||||
new Color(0xFFFFFF),
|
||||
new Color(0xFFFFFF),
|
||||
};
|
||||
|
||||
public ButterIcon(int id) {
|
||||
|
||||
@@ -19,6 +19,7 @@ public class InvalidIcon extends Icon {
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, float scale, int animationStep) {
|
||||
g2d.getTransform();
|
||||
g2d.setFont(fnt.deriveFont(0.8F));
|
||||
g2d.translate(0.2F, 0.8F);
|
||||
DrawingUtil.drawOutlinedString(g2d, 0, 0, "X", Color.YELLOW, Color.BLACK, 1, 2/scale);
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#VisualForecast 1000 Properties file. Functional provider must be set for successful boot!
|
||||
#Fri Mar 15 19:46:22 PDT 2024
|
||||
#Sat Nov 23 19:50:15 PST 2024
|
||||
announcement-dir=Announcements
|
||||
display-selection=36-hour,7-day,hourly
|
||||
music-dir=./Music
|
||||
current-display-version=1
|
||||
forecast-provider-jar=CanadaDatamartProvider.jar
|
||||
|
||||
Reference in New Issue
Block a user