diff --git a/CanadaDatamartProvider.jar b/CanadaDatamartProvider.jar index 76803c5..b4a6838 100644 Binary files a/CanadaDatamartProvider.jar and b/CanadaDatamartProvider.jar differ diff --git a/CanadaDatamartProvider.properties b/CanadaDatamartProvider.properties index 01cb82c..0da62c2 100644 --- a/CanadaDatamartProvider.properties +++ b/CanadaDatamartProvider.properties @@ -1,4 +1,4 @@ #VisualForecast 1000 Properties file. Functional provider must be set for successful boot! -#Thu Mar 07 14:12:25 PST 2024 +#Thu Mar 07 16:27:03 PST 2024 towns-by-code= towns-by-name-and-province=Vancouver,BC;Kamloops,BC;Kelowna,BC diff --git a/EnvironmentCanadaProvider.properties b/EnvironmentCanadaProvider.properties deleted file mode 100644 index c19bcfa..0000000 --- a/EnvironmentCanadaProvider.properties +++ /dev/null @@ -1,4 +0,0 @@ -#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 diff --git a/crawl.txt b/crawl.txt new file mode 100644 index 0000000..7e55f2b --- /dev/null +++ b/crawl.txt @@ -0,0 +1 @@ +Datamart information retrieved from ECCC and from TMSC. Information displayed on short-form forecasts may be formatted to fit on screen, however intent was kept as accurate as possible. Weather warnings and alerts displayed are as provided. \ No newline at end of file diff --git a/src/com/flaremicro/visualforecast/RenderPanel.java b/src/com/flaremicro/visualforecast/RenderPanel.java index 4b26f48..37ecee8 100644 --- a/src/com/flaremicro/visualforecast/RenderPanel.java +++ b/src/com/flaremicro/visualforecast/RenderPanel.java @@ -12,12 +12,19 @@ import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.image.BufferedImage; import java.awt.image.VolatileImage; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; import java.util.Calendar; import javax.swing.JPanel; 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; @@ -45,15 +52,23 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener { private Rectangle redrawBound = new Rectangle(0, 0, 1, 1); private Rectangle exclusiveRedrawBound = null; + private Rectangle crawlBound = null; private String currentTown = ""; private String currentForecast = ""; private ForecastProvider forecastProvider = null; - + private PropertyManager propManager; + private String[] crawlStrings = new String[0]; + String currentCrawlString = null; + private int crawlPosition = 0; + private int stringIndex = -1; + private int currentCrawlStringWidth = 0; + public RenderPanel(PropertyManager propManager) { + loadCrawlStrings(); this.addComponentListener(this); this.setDoubleBuffered(true); this.propManager = propManager; @@ -94,8 +109,30 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener { public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = prepareFrameBuffer(); + + if(g.getClipBounds().equals(this.crawlBound)) + { + g2d.setColor(BG_BLUE); + g2d.fillRect(0, H - INFOBAR_HEIGHT, W, INFOBAR_HEIGHT); + + g2d.setColor(Color.DARK_GRAY); + g2d.drawLine(0, H - INFOBAR_HEIGHT + STROKE_OFFSET, W, H - INFOBAR_HEIGHT + STROKE_OFFSET); + + g2d.setColor(Color.WHITE); + g2d.drawLine(0, H - INFOBAR_HEIGHT + STROKE_WIDTH + STROKE_OFFSET, W, H - INFOBAR_HEIGHT + STROKE_WIDTH + STROKE_OFFSET); + if (this.currentCrawlString != null) + { + g2d.setFont(font.deriveFont(26F)); + DrawingUtil.drawOutlinedString(g2d, this.crawlPosition, H - INFOBAR_HEIGHT + 30, this.currentCrawlString, Color.WHITE, Color.BLACK, 2); + } + g2d.dispose(); + g.drawImage(frameBuffer, 0, 0, getWidth(), getHeight(), this); + return; + } + drawMainRegion(g2d); + if (currentFlavour != null) { if (this.getBounds().equals(g.getClipBounds())) @@ -127,16 +164,6 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener { g2d.fillRect(0, TOPBAR_HEIGHT, W, MAINBAR_HEIGHT); g2d.fillRect(0, TOPBAR_HEIGHT, W, MAINBAR_HEIGHT); - - g2d.setColor(BG_BLUE); - g2d.fillRect(0, H - INFOBAR_HEIGHT, W, INFOBAR_HEIGHT); - - g2d.setColor(Color.DARK_GRAY); - g2d.drawLine(0, H - INFOBAR_HEIGHT + STROKE_OFFSET, W, H - INFOBAR_HEIGHT + STROKE_OFFSET); - - g2d.setColor(Color.WHITE); - g2d.drawLine(0, H - INFOBAR_HEIGHT + STROKE_WIDTH + STROKE_OFFSET, W, H - INFOBAR_HEIGHT + STROKE_WIDTH + STROKE_OFFSET); - // g2d.setColor(Color.GRAY); // g2d.drawRect(60, TOPBAR_HEIGHT+2, W-120, MAINBAR_HEIGHT-4); @@ -150,9 +177,20 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener { DrawingUtil.drawOutlinedString(g2d, W - sw - 60, TIMEBAR_Y + 36, timeString, Color.WHITE, Color.BLACK, 2); g2d.setFont(font.deriveFont(36F)); DrawingUtil.drawOutlinedString(g2d, 60, HEADERBAR_Y + 52, currentTown, Color.YELLOW, Color.BLACK, 2); + + g2d.setColor(BG_BLUE); + g2d.fillRect(0, H - INFOBAR_HEIGHT, W, INFOBAR_HEIGHT); - g2d.setFont(font.deriveFont(26F)); - DrawingUtil.drawOutlinedString(g2d, -20, H - INFOBAR_HEIGHT + 30, "Welcome to WeatherBC! Stay tuned for your long range forcast", Color.WHITE, Color.BLACK, 2); + g2d.setColor(Color.DARK_GRAY); + g2d.drawLine(0, H - INFOBAR_HEIGHT + STROKE_OFFSET, W, H - INFOBAR_HEIGHT + STROKE_OFFSET); + + g2d.setColor(Color.WHITE); + g2d.drawLine(0, H - INFOBAR_HEIGHT + STROKE_WIDTH + STROKE_OFFSET, W, H - INFOBAR_HEIGHT + STROKE_WIDTH + STROKE_OFFSET); + if (this.currentCrawlString != null) + { + g2d.setFont(font.deriveFont(26F)); + DrawingUtil.drawOutlinedString(g2d, this.crawlPosition, H - INFOBAR_HEIGHT + 30, this.currentCrawlString, Color.WHITE, Color.BLACK, 2); + } } @@ -168,7 +206,23 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener { } } if (this.currentFlavour != null) + { this.currentFlavour.tick(this, ticks, iconAnimationTicks); + } + if (this.crawlStrings != null && this.crawlStrings.length > 0 && this.crawlPosition + this.currentCrawlStringWidth <= 0) + { + stringIndex = ((stringIndex + 1) % this.crawlStrings.length); + this.currentCrawlString = this.crawlStrings[stringIndex]; + this.crawlPosition = W; + Graphics g = this.getGraphics(); + this.currentCrawlStringWidth = g.getFontMetrics(font.deriveFont(26F)).stringWidth(currentCrawlString); + g.dispose(); + } + else if (this.currentCrawlString != null) + { + this.crawlPosition-=2; + repaint(0, this.crawlBound.x, this.crawlBound.y, this.crawlBound.width, this.crawlBound.height); + } } public BufferedImage getSnapshot() { @@ -199,6 +253,10 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener { public void loseRedrawRegion() { this.redrawBound = null; addRedrawBound(W - TIMEBAR_WIDTH + TIMEBAR_OFFSET, TIMEBAR_Y, TIMEBAR_WIDTH, TIMEBAR_HEIGHT, false); + float wScale = getWidth() / (float) W; + float hScale = getHeight() / (float) H; + this.crawlBound = new Rectangle((int) 0, (int) ((H - INFOBAR_HEIGHT + 8) * hScale), (int) (W * wScale), (int) (30 * hScale)); + if (this.currentFlavour != null) this.currentFlavour.redrawRegionlost(this); } @@ -225,9 +283,8 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener { this.forecastProvider = forecastProvider; this.currentFlavour.notifyForecastProviderUpdate(this, forecastProvider); } - - public void notifyForecastProviderUpdate() - { + + public void notifyForecastProviderUpdate() { this.currentFlavour.notifyForecastProviderUpdate(this, forecastProvider); } @@ -262,6 +319,33 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener { repaint(exclusiveRedrawBound); } + private void loadCrawlStrings() { + File crawl = new File("./crawl.txt"); + ArrayList strings = new ArrayList(); + if (crawl != null) + { + BufferedReader br = null; + try + { + br = new BufferedReader(new FileReader(crawl)); + String line; + while ((line = br.readLine()) != null) + { + strings.add(line); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + Util.cleanClose(br); + } + } + this.crawlStrings = strings.toArray(new String[strings.size()]); + } + /*@Override public void run() { while (true) diff --git a/src/com/flaremicro/visualforecast/displays/DayForecastDisplay.java b/src/com/flaremicro/visualforecast/displays/DayForecastDisplay.java index 92413e6..a4e8614 100644 --- a/src/com/flaremicro/visualforecast/displays/DayForecastDisplay.java +++ b/src/com/flaremicro/visualforecast/displays/DayForecastDisplay.java @@ -217,13 +217,21 @@ public class DayForecastDisplay implements Display { DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + (127 / 2) - (metrics.stringWidth(statLine1) / 2), RenderConstants.TOPBAR_HEIGHT + 170, statLine1, Color.WHITE, Color.BLACK, 2); DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + (127 / 2) - (metrics.stringWidth(statLine2) / 2), RenderConstants.TOPBAR_HEIGHT + 200, statLine2, Color.WHITE, Color.BLACK, 2); - if (!ValueCheck.valueNoData(forecast.hiTemp) && !ValueCheck.valueNoData(forecast.loTemp)) + if (!ValueCheck.valueNoData(forecast.hiTemp)) { + g2d.setFont(font.deriveFont(26F)); DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 30 - (metrics.stringWidth(String.valueOf(forecast.hiTemp)) >> 1), RenderConstants.TOPBAR_HEIGHT + 295, String.valueOf(forecast.hiTemp), Color.WHITE, Color.BLACK, 2); - DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 92 - (metrics.stringWidth(String.valueOf(forecast.loTemp)) >> 1), RenderConstants.TOPBAR_HEIGHT + 295, String.valueOf(forecast.loTemp), Color.WHITE, Color.BLACK, 2); g2d.setFont(smallFont.deriveFont(24F)); DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 20, RenderConstants.TOPBAR_HEIGHT + 270, "Hi", Color.RED, Color.BLACK, 2); + } + + if (!ValueCheck.valueNoData(forecast.loTemp)) + { + g2d.setFont(font.deriveFont(26F)); + DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 92 - (metrics.stringWidth(String.valueOf(forecast.loTemp)) >> 1), RenderConstants.TOPBAR_HEIGHT + 295, String.valueOf(forecast.loTemp), Color.WHITE, Color.BLACK, 2); + + g2d.setFont(smallFont.deriveFont(24F)); DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 82, RenderConstants.TOPBAR_HEIGHT + 270, "Lo", Color.CYAN, Color.BLACK, 2); } diff --git a/vf1000.properties b/vf1000.properties index b1a623c..871d714 100644 --- a/vf1000.properties +++ b/vf1000.properties @@ -1,3 +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 +#Thu Mar 07 16:27:03 PST 2024 +forecast-provider-jar=CanadaDatamartProvider.jar