Compare commits
16 Commits
feature/bu
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f854c3ffb8 | ||
| e418e91fb5 | |||
|
|
655aa74f12 | ||
|
|
1653dd9ce6 | ||
| 2b3f1b8c93 | |||
|
|
4786cb7bd7 | ||
|
|
0648a0178c | ||
|
|
8da8621d9b | ||
|
|
0b4ca18c69 | ||
|
|
fee43c3ee2 | ||
|
|
28e19dd91c | ||
|
|
5628a5b76e | ||
|
|
107f83084e | ||
|
|
e0ef9e61f8 | ||
|
|
0564334f93 | ||
|
|
701db6e22c |
@@ -3,5 +3,6 @@
|
|||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="resources"/>
|
<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="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||||
|
<classpathentry kind="lib" path="jlayer-1.0.4.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -24,3 +24,6 @@ bin/
|
|||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
*.dat
|
*.dat
|
||||||
|
|
||||||
|
#Can contain copyrighted music!
|
||||||
|
Music/
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||||
@@ -7,5 +8,8 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
|||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
org.eclipse.jdt.core.compiler.source=1.6
|
org.eclipse.jdt.core.compiler.source=1.6
|
||||||
|
|||||||
BIN
CanadaDatamartProvider.jar
Normal file
BIN
CanadaDatamartProvider.jar
Normal file
Binary file not shown.
13
CanadaDatamartProvider.properties
Normal file
13
CanadaDatamartProvider.properties
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#VisualForecast 1000 Properties file. Functional provider must be set for successful boot!
|
||||||
|
#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=
|
||||||
339
LICENCE
Normal file
339
LICENCE
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
||||||
BIN
MockForecastProvider.jar
Normal file
BIN
MockForecastProvider.jar
Normal file
Binary file not shown.
1
crawl.txt
Normal file
1
crawl.txt
Normal file
@@ -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.
|
||||||
BIN
jlayer-1.0.4.jar
Normal file
BIN
jlayer-1.0.4.jar
Normal file
Binary file not shown.
286
src/com/flaremicro/audio/AgnosticAudioSystem.java
Normal file
286
src/com/flaremicro/audio/AgnosticAudioSystem.java
Normal file
@@ -0,0 +1,286 @@
|
|||||||
|
package com.flaremicro.audio;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import javax.sound.sampled.AudioFormat;
|
||||||
|
import javax.sound.sampled.AudioInputStream;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.DataLine;
|
||||||
|
import javax.sound.sampled.FloatControl;
|
||||||
|
import javax.sound.sampled.SourceDataLine;
|
||||||
|
|
||||||
|
import javazoom.jl.decoder.JavaLayerException;
|
||||||
|
import javazoom.jl.player.Player;
|
||||||
|
|
||||||
|
import com.flaremicro.util.Util;
|
||||||
|
|
||||||
|
public class AgnosticAudioSystem implements GameAudioSystem {
|
||||||
|
|
||||||
|
private Collection<AudioFinishedListener> listeners = new ArrayList<AudioFinishedListener>();
|
||||||
|
private HashMap<String, AudioSystemThread> threads = new HashMap<String, AudioSystemThread>();
|
||||||
|
private Random random = new Random();
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAudioFinishedListener(AudioFinishedListener listener) {
|
||||||
|
this.listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAudioFinishedListener(AudioFinishedListener listener) {
|
||||||
|
this.listeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAudioFinishedListeners() {
|
||||||
|
this.listeners.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String play(URL res) {
|
||||||
|
if (res.getPath().contains("."))
|
||||||
|
{
|
||||||
|
String key = String.valueOf(random.nextLong());
|
||||||
|
String ext = res.getPath().substring(res.getPath().lastIndexOf(".") + 1).toLowerCase();
|
||||||
|
AudioSystemThread audioSystemThread = null;
|
||||||
|
if (ext.equalsIgnoreCase("mp3"))
|
||||||
|
audioSystemThread = new AgnosticMp3AudioSystemThread(res, key, this, false);
|
||||||
|
if (ext.equalsIgnoreCase("wav"))
|
||||||
|
audioSystemThread = new AgnosticWavAudioSystemThread(res, key, this, false);
|
||||||
|
|
||||||
|
if (audioSystemThread != null)
|
||||||
|
{
|
||||||
|
synchronized (threads)
|
||||||
|
{
|
||||||
|
threads.put(key, audioSystemThread);
|
||||||
|
}
|
||||||
|
new Thread(audioSystemThread).start();
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playbg(URL res) {
|
||||||
|
stopbg();
|
||||||
|
if (res.getPath().contains("."))
|
||||||
|
{
|
||||||
|
String ext = res.getPath().substring(res.getPath().lastIndexOf(".") + 1).toLowerCase();
|
||||||
|
AudioSystemThread audioSystemThread = null;
|
||||||
|
if (ext.equalsIgnoreCase("mp3"))
|
||||||
|
audioSystemThread = new AgnosticMp3AudioSystemThread(res, "bg", this, true);
|
||||||
|
if (ext.equalsIgnoreCase("wav"))
|
||||||
|
audioSystemThread = new AgnosticWavAudioSystemThread(res, "bg", this, true);
|
||||||
|
|
||||||
|
if (audioSystemThread != null)
|
||||||
|
{
|
||||||
|
synchronized (threads)
|
||||||
|
{
|
||||||
|
threads.put("bg", audioSystemThread);
|
||||||
|
}
|
||||||
|
new Thread(audioSystemThread).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopbg() {
|
||||||
|
if (threads.containsKey("bg"))
|
||||||
|
threads.get("bg").stopMusic();
|
||||||
|
stopped("bg", threads.get("bg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopped(String threadName, AudioSystemThread audioSystemThread) {
|
||||||
|
synchronized (threads)
|
||||||
|
{
|
||||||
|
if (audioSystemThread != null && audioSystemThread == threads.get(threadName))
|
||||||
|
{
|
||||||
|
threads.remove(threadName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (AudioFinishedListener listener : listeners)
|
||||||
|
{
|
||||||
|
listener.audioFinished(threadName, audioSystemThread.resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolume(float percent, String key) {
|
||||||
|
AudioSystemThread ast = threads.get(key);
|
||||||
|
if (ast != null)
|
||||||
|
{
|
||||||
|
ast.setVolume(percent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop(String currentKey) {
|
||||||
|
AudioSystemThread ast = threads.get(currentKey);
|
||||||
|
if (ast != null)
|
||||||
|
{
|
||||||
|
ast.stopMusic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class AudioSystemThread implements Runnable {
|
||||||
|
protected final boolean looping;
|
||||||
|
protected final AgnosticAudioSystem system;
|
||||||
|
protected final URL resource;
|
||||||
|
protected final String threadName;
|
||||||
|
|
||||||
|
public AudioSystemThread(URL resource, String threadName, AgnosticAudioSystem system, boolean looping) {
|
||||||
|
this.resource = resource;
|
||||||
|
this.looping = looping;
|
||||||
|
this.threadName = threadName;
|
||||||
|
this.system = system;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void setVolume(float percent);
|
||||||
|
|
||||||
|
public abstract void stopMusic();
|
||||||
|
|
||||||
|
public final void onStop() {
|
||||||
|
this.system.stopped(threadName, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class AgnosticMp3AudioSystemThread extends AudioSystemThread {
|
||||||
|
private boolean running = true;
|
||||||
|
private Player player = null;
|
||||||
|
private static final int FRAME_BUFFER = 2;
|
||||||
|
private float volume = 1F;
|
||||||
|
|
||||||
|
public AgnosticMp3AudioSystemThread(URL resource, String threadName, AgnosticAudioSystem system, boolean looping) {
|
||||||
|
super(resource, threadName, system, looping);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
do
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
player = new Player(new BufferedInputStream(resource.openStream()));
|
||||||
|
player.setVolume(volume);
|
||||||
|
while (running && player.play(FRAME_BUFFER));
|
||||||
|
}
|
||||||
|
catch (JavaLayerException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (running && looping);
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopMusic() {
|
||||||
|
this.running = false;
|
||||||
|
if (player != null)
|
||||||
|
player.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVolume(float percent) {
|
||||||
|
volume = percent;
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.setVolume(volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class AgnosticWavAudioSystemThread extends AudioSystemThread {
|
||||||
|
private boolean running = true;
|
||||||
|
private SourceDataLine sourceLine = null;
|
||||||
|
private float volume = 1.0F;
|
||||||
|
|
||||||
|
public AgnosticWavAudioSystemThread(URL resource, String threadName, AgnosticAudioSystem system, boolean looping) {
|
||||||
|
super(resource, threadName, system, looping);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
AudioInputStream audioStream = null;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
audioStream = AudioSystem.getAudioInputStream(resource);
|
||||||
|
AudioFormat audioFormat = audioStream.getFormat();
|
||||||
|
DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
|
||||||
|
|
||||||
|
sourceLine = (SourceDataLine) AudioSystem.getLine(info);
|
||||||
|
sourceLine.open();
|
||||||
|
sourceLine.start();
|
||||||
|
|
||||||
|
FloatControl volume = (FloatControl) sourceLine.getControl(FloatControl.Type.MASTER_GAIN);
|
||||||
|
volume.setValue(this.volume);
|
||||||
|
|
||||||
|
int nBytesRead = 0;
|
||||||
|
byte[] abData = new byte[4096];
|
||||||
|
while (nBytesRead != -1 && running)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
nBytesRead = audioStream.read(abData, 0, abData.length);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (nBytesRead >= 0)
|
||||||
|
{
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
int nBytesWritten = sourceLine.write(abData, 0, nBytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Util.cleanClose(audioStream);
|
||||||
|
if (sourceLine != null)
|
||||||
|
{
|
||||||
|
sourceLine.drain();
|
||||||
|
sourceLine.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (running && looping);
|
||||||
|
onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopMusic() {
|
||||||
|
this.running = false;
|
||||||
|
if (sourceLine != null)
|
||||||
|
{
|
||||||
|
sourceLine.drain();
|
||||||
|
sourceLine.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVolume(float percent) {
|
||||||
|
if (sourceLine != null)
|
||||||
|
{
|
||||||
|
this.volume = percent;
|
||||||
|
FloatControl volume = (FloatControl) sourceLine.getControl(FloatControl.Type.MASTER_GAIN);
|
||||||
|
volume.setValue(percent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
src/com/flaremicro/audio/AudioFinishedListener.java
Normal file
7
src/com/flaremicro/audio/AudioFinishedListener.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package com.flaremicro.audio;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public interface AudioFinishedListener {
|
||||||
|
public void audioFinished(String key, URL resource);
|
||||||
|
}
|
||||||
83
src/com/flaremicro/audio/AudioPlaylist.java
Normal file
83
src/com/flaremicro/audio/AudioPlaylist.java
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package com.flaremicro.audio;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class AudioPlaylist implements AudioFinishedListener{
|
||||||
|
|
||||||
|
|
||||||
|
private final AgnosticAudioSystem aas;
|
||||||
|
|
||||||
|
public AudioPlaylist(AgnosticAudioSystem aas)
|
||||||
|
{
|
||||||
|
this.aas = aas;
|
||||||
|
}
|
||||||
|
|
||||||
|
String currentKey = null;
|
||||||
|
int currentPlaylistIndex = 0;
|
||||||
|
URL[] playlist = null;
|
||||||
|
|
||||||
|
float currVol = 1F;
|
||||||
|
private boolean stopped = true;
|
||||||
|
|
||||||
|
public void setPlaylist(URL[] url)
|
||||||
|
{
|
||||||
|
this.playlist = url;
|
||||||
|
this.currentPlaylistIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shuffle(){
|
||||||
|
Random rand = new Random();
|
||||||
|
|
||||||
|
for (int i = 0; i < playlist.length; i++) {
|
||||||
|
int randomIndexToSwap = rand.nextInt(playlist.length);
|
||||||
|
URL temp = playlist[randomIndexToSwap];
|
||||||
|
playlist[randomIndexToSwap] = playlist[i];
|
||||||
|
playlist[i] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start()
|
||||||
|
{
|
||||||
|
stopped = false;
|
||||||
|
currentPlaylistIndex = 0;
|
||||||
|
aas.addAudioFinishedListener(this);
|
||||||
|
if(currentKey == null && playlist != null && playlist.length > 0)
|
||||||
|
{
|
||||||
|
currentKey = aas.play(playlist[0]);
|
||||||
|
aas.setVolume(currVol, currentKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void next()
|
||||||
|
{
|
||||||
|
if(playlist != null && playlist.length > 0)
|
||||||
|
{
|
||||||
|
currentPlaylistIndex = (currentPlaylistIndex + 1 ) % playlist.length;
|
||||||
|
currentKey = aas.play(playlist[currentPlaylistIndex]);
|
||||||
|
aas.setVolume(currVol, currentKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void audioFinished(String key, URL resource) {
|
||||||
|
if(!stopped && key == currentKey)
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolume(float volume) {
|
||||||
|
currVol = volume;
|
||||||
|
aas.setVolume(currVol, currentKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
stopped = true;
|
||||||
|
aas.stop(currentKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getVolume() {
|
||||||
|
return currVol;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
16
src/com/flaremicro/audio/GameAudioSystem.java
Normal file
16
src/com/flaremicro/audio/GameAudioSystem.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.flaremicro.audio;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public interface GameAudioSystem {
|
||||||
|
|
||||||
|
public void init();
|
||||||
|
|
||||||
|
public void destroy();
|
||||||
|
|
||||||
|
public void playbg(URL res);
|
||||||
|
|
||||||
|
public String play(URL res);
|
||||||
|
|
||||||
|
public void stopbg();
|
||||||
|
}
|
||||||
@@ -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,149 +0,0 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.KeyListener;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.awt.event.WindowListener;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.providerapi.ForecastProviderManager;
|
|
||||||
|
|
||||||
public class VisualForecastFrame extends JFrame implements WindowListener, KeyListener{
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private RenderPanel renderPane;
|
|
||||||
private ForecastProviderManager forecastProviderManager;
|
|
||||||
private Executor executor;
|
|
||||||
private PropertyManager propertyManager;
|
|
||||||
private boolean isFullscreen = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch the application.
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
EventQueue.invokeLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
VisualForecastFrame frame = new VisualForecastFrame();
|
|
||||||
frame.setVisible(true);
|
|
||||||
frame.init();
|
|
||||||
//GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[1].setFullScreenWindow(frame);
|
|
||||||
frame.createBufferStrategy(2);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void end()
|
|
||||||
{
|
|
||||||
if(executor != null)
|
|
||||||
executor.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init()
|
|
||||||
{
|
|
||||||
end();
|
|
||||||
executor = new Executor(this.renderPane, 30);
|
|
||||||
executor.begin();
|
|
||||||
|
|
||||||
forecastProviderManager = new ForecastProviderManager();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the frame.
|
|
||||||
*/
|
|
||||||
public VisualForecastFrame() {
|
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
||||||
setBounds(100, 100, 640*2, 480*2);
|
|
||||||
renderPane = new RenderPanel();
|
|
||||||
renderPane.setBorder(null);
|
|
||||||
renderPane.setLayout(new BorderLayout(0, 0));
|
|
||||||
setContentPane(renderPane);
|
|
||||||
setUndecorated(true);
|
|
||||||
addWindowListener(this);
|
|
||||||
addKeyListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowOpened(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowClosing(WindowEvent e) {
|
|
||||||
|
|
||||||
end();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowClosed(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowIconified(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowDeiconified(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowActivated(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowDeactivated(WindowEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyTyped(KeyEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyPressed(KeyEvent e) {
|
|
||||||
if(e.getKeyCode() == KeyEvent.VK_F11)
|
|
||||||
{
|
|
||||||
if(isFullscreen)
|
|
||||||
{
|
|
||||||
isFullscreen = false;
|
|
||||||
this.getGraphicsConfiguration().getDevice().setFullScreenWindow(null);
|
|
||||||
setBounds(100, 100, 640*2, 480*2);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
isFullscreen = true;
|
|
||||||
this.getGraphicsConfiguration().getDevice().setFullScreenWindow(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyReleased(KeyEvent e) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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,61 +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;
|
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
|
||||||
|
|
||||||
import static com.flaremicro.flaretv.visualforecast.graphics.RenderConstants.*;
|
|
||||||
|
|
||||||
public class TextFlavour implements Flavour{
|
|
||||||
|
|
||||||
public TextFlavour(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) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initFlavour(RenderPanel renderer, ForecastDetails details, long ticks, int iconTicks) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawFlavour(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 drawBoundLimitedFlavour(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void redrawRegionlost(RenderPanel renderer) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast.forecast;
|
|
||||||
|
|
||||||
public class TownForecast {
|
|
||||||
public TownForecast(String townName, DayForecast[] dayForecast){
|
|
||||||
this.townName = townName;
|
|
||||||
this.dayForecast = dayForecast;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final String townName;
|
|
||||||
private final DayForecast[] dayForecast;
|
|
||||||
|
|
||||||
public DayForecast[] getDayForecast() {
|
|
||||||
return dayForecast;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTownName() {
|
|
||||||
return townName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
127
src/com/flaremicro/visualforecast/AudioManager.java
Normal file
127
src/com/flaremicro/visualforecast/AudioManager.java
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
package com.flaremicro.visualforecast;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import com.flaremicro.audio.AgnosticAudioSystem;
|
||||||
|
import com.flaremicro.audio.AudioFinishedListener;
|
||||||
|
import com.flaremicro.audio.AudioPlaylist;
|
||||||
|
|
||||||
|
public class AudioManager implements AudioFinishedListener {
|
||||||
|
|
||||||
|
private PropertyManager propertyManager;
|
||||||
|
private AgnosticAudioSystem aas;
|
||||||
|
private AudioPlaylist audioPlaylist;
|
||||||
|
|
||||||
|
private File playlistDirectory = new File("./Music");
|
||||||
|
|
||||||
|
HashSet<String> playingKeys = new HashSet<String>();
|
||||||
|
|
||||||
|
public AudioManager(PropertyManager propertyManager) {
|
||||||
|
this.propertyManager = propertyManager;
|
||||||
|
this.aas = new AgnosticAudioSystem();
|
||||||
|
this.aas.addAudioFinishedListener(this);
|
||||||
|
this.audioPlaylist = new AudioPlaylist(aas);
|
||||||
|
updatePlaylist();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePlaylist() {
|
||||||
|
playlistDirectory = propertyManager.getFile("music-dir", playlistDirectory);
|
||||||
|
if (playlistDirectory == null || !playlistDirectory.isDirectory())
|
||||||
|
return;
|
||||||
|
File[] files = playlistDirectory.listFiles();
|
||||||
|
URL[] urls = new URL[files.length];
|
||||||
|
for (int i = 0; i < files.length; i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
urls[i] = files[i].toURI().toURL();
|
||||||
|
}
|
||||||
|
catch (MalformedURLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
audioPlaylist.setPlaylist(urls);
|
||||||
|
audioPlaylist.shuffle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void audioFinished(String key, URL resource) {
|
||||||
|
playingKeys.remove(key);
|
||||||
|
if (playingKeys.size() == 0)
|
||||||
|
rampVolume(1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startPlaylist() {
|
||||||
|
if (playlistDirectory == null || !playlistDirectory.isDirectory())
|
||||||
|
return;
|
||||||
|
audioPlaylist.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopPlaylist() {
|
||||||
|
audioPlaylist.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void end() {
|
||||||
|
audioPlaylist.stop();
|
||||||
|
aas.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playAnnouncement(File file) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
URL url = file.toURI().toURL();
|
||||||
|
rampVolume(-10F);
|
||||||
|
playingKeys.add(aas.play(url));
|
||||||
|
}
|
||||||
|
catch (MalformedURLException e)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread currThread = null;
|
||||||
|
private float volume = 1F;
|
||||||
|
|
||||||
|
//***horrible***
|
||||||
|
private void rampVolume(float newVolume) {
|
||||||
|
this.volume = newVolume;
|
||||||
|
if (currThread != null)
|
||||||
|
return;
|
||||||
|
currThread = new Thread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (volume < audioPlaylist.getVolume())
|
||||||
|
{
|
||||||
|
while (audioPlaylist.getVolume() > volume)
|
||||||
|
{
|
||||||
|
audioPlaylist.setVolume(audioPlaylist.getVolume() - 0.1F);
|
||||||
|
Thread.sleep(10L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (volume > audioPlaylist.getVolume())
|
||||||
|
{
|
||||||
|
while (audioPlaylist.getVolume() < volume)
|
||||||
|
{
|
||||||
|
audioPlaylist.setVolume(audioPlaylist.getVolume() + 0.1F);
|
||||||
|
Thread.sleep(10L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InterruptedException ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
audioPlaylist.setVolume(volume);
|
||||||
|
currThread = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
currThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast;
|
package com.flaremicro.visualforecast;
|
||||||
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.interfaces.Tickable;
|
import com.flaremicro.visualforecast.interfaces.Tickable;
|
||||||
|
|
||||||
public class Executor {
|
public class Executor {
|
||||||
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||||
111
src/com/flaremicro/visualforecast/PropertyManager.java
Normal file
111
src/com/flaremicro/visualforecast/PropertyManager.java
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
package com.flaremicro.visualforecast;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
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() {
|
||||||
|
synchronized(prop){
|
||||||
|
InputStream reader = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (propFile.exists())
|
||||||
|
{
|
||||||
|
reader = new FileInputStream(propFile);
|
||||||
|
prop.load(reader);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Util.cleanClose(reader);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean store() {
|
||||||
|
synchronized(prop){
|
||||||
|
OutputStream writer = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
writer = new FileOutputStream(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);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast;
|
package com.flaremicro.visualforecast;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@@ -12,18 +12,26 @@ import java.awt.event.ComponentEvent;
|
|||||||
import java.awt.event.ComponentListener;
|
import java.awt.event.ComponentListener;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
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.util.Util;
|
||||||
import com.flaremicro.flaretv.visualforecast.flavour.Flavour;
|
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
import com.flaremicro.visualforecast.displays.Display;
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.FontManager;
|
import com.flaremicro.visualforecast.displays.DisplayFactory;
|
||||||
import com.flaremicro.flaretv.visualforecast.interfaces.Tickable;
|
import com.flaremicro.visualforecast.displays.impl.BootupDisplay;
|
||||||
import com.flaremicro.flaretv.visualforecast.providerapi.MockForecastProvider;
|
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 {
|
public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||||
|
|
||||||
@@ -36,22 +44,43 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
|||||||
|
|
||||||
private Font font = null;
|
private Font font = null;
|
||||||
|
|
||||||
private Flavour currentFlavour = new DayForecastFlavour();
|
private Display currentFlavour = new BootupDisplay();
|
||||||
|
|
||||||
private int iconAnimationTicks = 0;
|
private int iconAnimationTicks = 0;
|
||||||
private long ticks = 0;
|
private long ticks = 0;
|
||||||
|
|
||||||
private Rectangle redrawBound = new Rectangle(0, 0, 1, 1);
|
private Rectangle redrawBound = new Rectangle(0, 0, 1, 1);
|
||||||
private Rectangle exclusiveRedrawBound = null;
|
private Rectangle exclusiveRedrawBound = null;
|
||||||
|
private Rectangle crawlBound = null;
|
||||||
|
|
||||||
|
private Rectangle currentBound = new Rectangle(0, 0, 0, 0);
|
||||||
|
|
||||||
private String currentTown = "";
|
private String currentTown = "";
|
||||||
private String currentForecast = "";
|
private String currentForecast = "";
|
||||||
|
|
||||||
public RenderPanel() {
|
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;
|
||||||
|
|
||||||
|
DisplayFactory displayFactory;
|
||||||
|
|
||||||
|
AudioManager audioManager;
|
||||||
|
|
||||||
|
public RenderPanel(PropertyManager propManager) {
|
||||||
|
loadCrawlStrings();
|
||||||
this.addComponentListener(this);
|
this.addComponentListener(this);
|
||||||
this.setDoubleBuffered(true);
|
this.setDoubleBuffered(true);
|
||||||
|
this.propManager = propManager;
|
||||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
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);
|
||||||
|
displayFactory = new DisplayFactory(propManager);
|
||||||
|
audioManager = new AudioManager(propManager);
|
||||||
//new Thread(new TickThread(this, 30)).start();
|
//new Thread(new TickThread(this, 30)).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,14 +116,14 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
|||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
Graphics2D g2d = prepareFrameBuffer();
|
Graphics2D g2d = prepareFrameBuffer();
|
||||||
|
|
||||||
drawMainRegion(g2d);
|
drawMainRegion(g2d);
|
||||||
|
|
||||||
if (currentFlavour != null)
|
if (currentFlavour != null)
|
||||||
{
|
{
|
||||||
if (this.getBounds().equals(g.getClipBounds()))
|
if (this.getBounds().equals(g.getClipBounds()))
|
||||||
this.currentFlavour.drawFlavour(this, g2d, ticks, iconAnimationTicks);
|
this.currentFlavour.drawDisplay(this, g2d, ticks, iconAnimationTicks);
|
||||||
if (g.getClipBounds() != null)
|
if (g.getClipBounds() != null)
|
||||||
this.currentFlavour.drawBoundLimitedFlavour(this, g2d, g.getClipBounds(), ticks, iconAnimationTicks);
|
this.currentFlavour.drawBoundLimitedDisplay(this, g2d, g.getClipBounds(), ticks, iconAnimationTicks);
|
||||||
}
|
}
|
||||||
g2d.dispose();
|
g2d.dispose();
|
||||||
g.drawImage(frameBuffer, 0, 0, getWidth(), getHeight(), this);
|
g.drawImage(frameBuffer, 0, 0, getWidth(), getHeight(), this);
|
||||||
@@ -108,7 +137,7 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
|||||||
g2d.setColor(BG_PURPLE);
|
g2d.setColor(BG_PURPLE);
|
||||||
g2d.fillRect(0, 0, W, TOPBAR_HEIGHT);
|
g2d.fillRect(0, 0, W, TOPBAR_HEIGHT);
|
||||||
|
|
||||||
g2d.setPaint(new GradientPaint(0, HEADERBAR_Y, BG_OORANGE, 0, HEADERBAR_Y + (HEADERBAR_HEIGHT + 10), BG_PURPLE));
|
g2d.setPaint(new GradientPaint(0, HEADERBAR_Y, BG_ORANGE, 0, HEADERBAR_Y + (HEADERBAR_HEIGHT + 10), BG_PURPLE));
|
||||||
g2d.shear(HEADERBAR_SHEAR, 0);
|
g2d.shear(HEADERBAR_SHEAR, 0);
|
||||||
g2d.fillRect(-HEADERBAR_OFFSET, HEADERBAR_Y, HEADERBAR_WIDTH, HEADERBAR_HEIGHT);
|
g2d.fillRect(-HEADERBAR_OFFSET, HEADERBAR_Y, HEADERBAR_WIDTH, HEADERBAR_HEIGHT);
|
||||||
|
|
||||||
@@ -116,20 +145,10 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
|||||||
g2d.fillRect(W - TIMEBAR_WIDTH + TIMEBAR_OFFSET, TIMEBAR_Y, TIMEBAR_WIDTH, TIMEBAR_HEIGHT);
|
g2d.fillRect(W - TIMEBAR_WIDTH + TIMEBAR_OFFSET, TIMEBAR_Y, TIMEBAR_WIDTH, TIMEBAR_HEIGHT);
|
||||||
g2d.shear(-HEADERBAR_SHEAR, 0);
|
g2d.shear(-HEADERBAR_SHEAR, 0);
|
||||||
|
|
||||||
g2d.setPaint(new GradientPaint(0, TOPBAR_HEIGHT, BG_PURPLE, 0, MAINBAR_HEIGHT, BG_OORANGE));
|
g2d.setPaint(new GradientPaint(0, TOPBAR_HEIGHT, BG_PURPLE, 0, MAINBAR_HEIGHT, BG_ORANGE));
|
||||||
g2d.fillRect(0, TOPBAR_HEIGHT, W, MAINBAR_HEIGHT);
|
g2d.fillRect(0, TOPBAR_HEIGHT, W, MAINBAR_HEIGHT);
|
||||||
|
|
||||||
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.setColor(Color.GRAY);
|
||||||
// g2d.drawRect(60, TOPBAR_HEIGHT+2, W-120, MAINBAR_HEIGHT-4);
|
// g2d.drawRect(60, TOPBAR_HEIGHT+2, W-120, MAINBAR_HEIGHT-4);
|
||||||
|
|
||||||
@@ -144,8 +163,19 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
|||||||
g2d.setFont(font.deriveFont(36F));
|
g2d.setFont(font.deriveFont(36F));
|
||||||
DrawingUtil.drawOutlinedString(g2d, 60, HEADERBAR_Y + 52, currentTown, Color.YELLOW, Color.BLACK, 2);
|
DrawingUtil.drawOutlinedString(g2d, 60, HEADERBAR_Y + 52, currentTown, Color.YELLOW, Color.BLACK, 2);
|
||||||
|
|
||||||
g2d.setFont(font.deriveFont(26F));
|
g2d.setColor(BG_BLUE);
|
||||||
DrawingUtil.drawOutlinedString(g2d, -20, H - INFOBAR_HEIGHT + 30, "Welcome to WeatherBC! Stay tuned for your long range forcast", Color.WHITE, Color.BLACK, 2);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,23 +187,65 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
|||||||
//Clock and icon animations, should use repaint regions later
|
//Clock and icon animations, should use repaint regions later
|
||||||
if (getWidth() > 0 && getHeight() > 0)
|
if (getWidth() > 0 && getHeight() > 0)
|
||||||
{
|
{
|
||||||
repaint(this.redrawBound);
|
requestRepaint(this.redrawBound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.currentFlavour != null)
|
if (this.currentFlavour != null)
|
||||||
|
{
|
||||||
this.currentFlavour.tick(this, ticks, iconAnimationTicks);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void requestFullRepaint() {
|
||||||
|
currentBound = this.getBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void requestRepaint(Rectangle bound) {
|
||||||
|
if (currentBound.width == 0)
|
||||||
|
currentBound = new Rectangle(bound);
|
||||||
|
else currentBound.add(bound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void requestBoundedRepaint() {
|
||||||
|
requestRepaint(this.redrawBound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void requestExclusiveBoundedRepaint() {
|
||||||
|
requestRepaint(exclusiveRedrawBound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void performPaintIfNeeded() {
|
||||||
|
if (this.currentCrawlString != null)
|
||||||
|
{
|
||||||
|
this.crawlPosition -= 2;
|
||||||
|
requestRepaint(crawlBound);
|
||||||
|
}
|
||||||
|
if (this.currentBound.width != 0)
|
||||||
|
{
|
||||||
|
repaint(currentBound);
|
||||||
|
currentBound.width = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getSnapshot() {
|
public BufferedImage getSnapshot() {
|
||||||
return frameBuffer.getSnapshot();
|
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 wScale = getWidth() / (float) W;
|
||||||
float hScale = getHeight() / (float) H;
|
float hScale = getHeight() / (float) H;
|
||||||
Rectangle rect = new Rectangle((int) (x * wScale), (int) (y * hScale), (int) (w * wScale), (int) (h * hScale));
|
Rectangle rect = new Rectangle((int) (x * wScale), (int) (y * hScale), (int) (w * wScale), (int) (h * hScale));
|
||||||
if(isExclusive)
|
if (isExclusive)
|
||||||
this.exclusiveRedrawBound = rect;
|
this.exclusiveRedrawBound = rect;
|
||||||
if (redrawBound == null)
|
if (redrawBound == null)
|
||||||
this.redrawBound = new Rectangle((int) (x * wScale), (int) (y * hScale), (int) (w * wScale), (int) (h * hScale));
|
this.redrawBound = new Rectangle((int) (x * wScale), (int) (y * hScale), (int) (w * wScale), (int) (h * hScale));
|
||||||
@@ -184,7 +256,6 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
|||||||
addRedrawBound(x, y, w, h, true);
|
addRedrawBound(x, y, w, h, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void componentResized(ComponentEvent e) {
|
public void componentResized(ComponentEvent e) {
|
||||||
loseRedrawRegion();
|
loseRedrawRegion();
|
||||||
}
|
}
|
||||||
@@ -192,51 +263,103 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
|||||||
public void loseRedrawRegion() {
|
public void loseRedrawRegion() {
|
||||||
this.redrawBound = null;
|
this.redrawBound = null;
|
||||||
addRedrawBound(W - TIMEBAR_WIDTH + TIMEBAR_OFFSET, TIMEBAR_Y, TIMEBAR_WIDTH, TIMEBAR_HEIGHT, false);
|
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)
|
if (this.currentFlavour != null)
|
||||||
this.currentFlavour.redrawRegionlost(this);
|
this.currentFlavour.redrawRegionlost(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void componentMoved(ComponentEvent e) {
|
public void componentMoved(ComponentEvent e) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void componentShown(ComponentEvent e) {
|
public void componentShown(ComponentEvent e) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void componentHidden(ComponentEvent e) {
|
public void componentHidden(ComponentEvent e) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextFlavour() {
|
public void setForecastProvider(ForecastProvider forecastProvider) {
|
||||||
this.currentFlavour = new DayForecastFlavour();
|
this.forecastProvider = forecastProvider;
|
||||||
this.currentFlavour.initFlavour(this, MockForecastProvider.provideMockForecast(), ticks, iconAnimationTicks);
|
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() {
|
||||||
|
if (this.currentFlavour instanceof BootupDisplay)
|
||||||
|
{
|
||||||
|
audioManager.startPlaylist();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.currentFlavour = displayFactory.nextDisplay();
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentTown(String currentTown) {
|
||||||
this.currentTown = currentTown;
|
this.currentTown = currentTown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentForecast(String currentForecast){
|
public void setCurrentForecast(String currentForecast) {
|
||||||
this.currentForecast = currentForecast;
|
this.currentForecast = currentForecast;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestFullRepaint() {
|
private void loadCrawlStrings() {
|
||||||
repaint();
|
File crawl = new File("./crawl.txt");
|
||||||
|
ArrayList<String> strings = new ArrayList<String>();
|
||||||
|
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()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestBoundedRepaint() {
|
public void end() {
|
||||||
repaint(redrawBound);
|
this.audioManager.end();
|
||||||
}
|
|
||||||
|
|
||||||
public void requestExclusiveBoundedRepaint() {
|
|
||||||
repaint(exclusiveRedrawBound);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
/*@Override
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast;
|
package com.flaremicro.visualforecast;
|
||||||
|
|
||||||
import java.util.concurrent.locks.LockSupport;
|
import java.util.concurrent.locks.LockSupport;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.interfaces.Tickable;
|
import com.flaremicro.visualforecast.interfaces.Tickable;
|
||||||
|
|
||||||
public class TickThread implements Runnable {
|
public class TickThread implements Runnable {
|
||||||
private final Tickable tickable;
|
private final Tickable tickable;
|
||||||
198
src/com/flaremicro/visualforecast/VisualForecastFrame.java
Normal file
198
src/com/flaremicro/visualforecast/VisualForecastFrame.java
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
package com.flaremicro.visualforecast;
|
||||||
|
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
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 java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.Timer;
|
||||||
|
|
||||||
|
import com.flaremicro.util.Util;
|
||||||
|
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||||
|
import com.flaremicro.visualforecast.api.ForecastProviderManager;
|
||||||
|
|
||||||
|
public class VisualForecastFrame extends JFrame implements WindowListener, KeyListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private RenderPanel renderPane;
|
||||||
|
private ForecastProviderManager forecastProviderManager;
|
||||||
|
private Executor executor;
|
||||||
|
private PropertyManager propertyManager = new PropertyManager();
|
||||||
|
private Timer timer;
|
||||||
|
//private Timer timer2;
|
||||||
|
private boolean isFullscreen = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch the application.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
final Map<String, String> arguments = Util.parseArgs(args, true);
|
||||||
|
EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
VisualForecastFrame frame = new VisualForecastFrame();
|
||||||
|
frame.setVisible(true);
|
||||||
|
frame.init();
|
||||||
|
|
||||||
|
if (arguments.containsKey("fullscreen"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
int index = Integer.parseInt(arguments.get("fullscreen"));
|
||||||
|
|
||||||
|
GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
|
||||||
|
if(index < 0 || devices.length < index)
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog(frame, arguments.get("fullscreen") + " does not exist as a screen index");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
devices[index].setFullScreenWindow(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog(frame, arguments.get("fullscreen") + " is not a valid screen index");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[1].setFullScreenWindow(frame);
|
||||||
|
//frame.createBufferStrategy(2);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void end() {
|
||||||
|
if (executor != null)
|
||||||
|
executor.end();
|
||||||
|
if (timer != null)
|
||||||
|
{
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
renderPane.end();
|
||||||
|
if (forecastProviderManager != null)
|
||||||
|
forecastProviderManager.end();
|
||||||
|
propertyManager.store();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
executor = new Executor(this.renderPane, 30);
|
||||||
|
executor.begin();
|
||||||
|
timer = new Timer(33, new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
renderPane.performPaintIfNeeded();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
timer.start();
|
||||||
|
|
||||||
|
new Thread() {
|
||||||
|
public void run() {
|
||||||
|
forecastProviderManager = new ForecastProviderManager(renderPane);
|
||||||
|
String forecastProvider = propertyManager.getString("forecast-provider-jar", "");
|
||||||
|
propertyManager.store();
|
||||||
|
ForecastProvider provider = forecastProviderManager.loadProvider(new File(forecastProvider));
|
||||||
|
renderPane.setForecastProvider(provider);
|
||||||
|
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the frame.
|
||||||
|
*/
|
||||||
|
public VisualForecastFrame() {
|
||||||
|
propertyManager.load();
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 640, 480);
|
||||||
|
renderPane = new RenderPanel(propertyManager);
|
||||||
|
//renderPane.setBorder(null);
|
||||||
|
//renderPane.setLayout(new BorderLayout(0, 0));
|
||||||
|
add(renderPane);
|
||||||
|
setUndecorated(true);
|
||||||
|
addWindowListener(this);
|
||||||
|
addKeyListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void windowOpened(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void windowClosing(WindowEvent e) {
|
||||||
|
|
||||||
|
end();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void windowIconified(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void windowDeiconified(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void windowActivated(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void windowDeactivated(WindowEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyTyped(KeyEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_F11)
|
||||||
|
{
|
||||||
|
if (isFullscreen)
|
||||||
|
{
|
||||||
|
isFullscreen = false;
|
||||||
|
this.getGraphicsConfiguration().getDevice().setFullScreenWindow(null);
|
||||||
|
setBounds(100, 100, 640 * 2, 480 * 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isFullscreen = true;
|
||||||
|
this.getGraphicsConfiguration().getDevice().setFullScreenWindow(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
18
src/com/flaremicro/visualforecast/displays/Display.java
Normal file
18
src/com/flaremicro/visualforecast/displays/Display.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
public String getDisplayName();
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
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) {
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
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() {
|
||||||
|
currentIndex = (currentIndex + 1) % nameOrder.size();
|
||||||
|
return displays.get(nameOrder.get(currentIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package com.flaremicro.visualforecast.displays.impl;
|
||||||
|
|
||||||
|
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.displays.Display;
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "bootup";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
package com.flaremicro.visualforecast.displays.impl;
|
||||||
|
|
||||||
|
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.displays.Display;
|
||||||
|
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||||
|
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||||
|
|
||||||
|
import static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||||
|
|
||||||
|
public class CurrentForecastDisplay implements Display {
|
||||||
|
|
||||||
|
private String[] lines = new String[0];
|
||||||
|
private Font font;
|
||||||
|
|
||||||
|
private int stringOffset = 0;
|
||||||
|
private int ticksBeforeChange = 0;
|
||||||
|
|
||||||
|
public CurrentForecastDisplay() {
|
||||||
|
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) {
|
||||||
|
ticksBeforeChange--;
|
||||||
|
if (ticksBeforeChange <= 0)
|
||||||
|
{
|
||||||
|
stringOffset += 9;
|
||||||
|
if (stringOffset < lines.length)
|
||||||
|
{
|
||||||
|
ticksBeforeChange = 200;
|
||||||
|
renderer.requestExclusiveBoundedRepaint();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
renderer.nextDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||||
|
ticksBeforeChange = 200;
|
||||||
|
stringOffset = 0;
|
||||||
|
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("Current Conditions");
|
||||||
|
renderer.setCurrentTown("TOWN NAME HERE");
|
||||||
|
|
||||||
|
BufferedImage disposableImage = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY);
|
||||||
|
Graphics2D g = disposableImage.createGraphics();
|
||||||
|
FontMetrics f = g.getFontMetrics(font);
|
||||||
|
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();
|
||||||
|
|
||||||
|
redrawRegionlost(renderer);
|
||||||
|
|
||||||
|
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.darker(), BG_BLUE.brighter());
|
||||||
|
g2d.setFont(font);
|
||||||
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
|
g2d.setColor(BG_BLUE.darker());
|
||||||
|
g2d.drawRect(60 + STROKE_OFFSET, TOPBAR_HEIGHT + STROKE_OFFSET, W - 120 - STROKE_WIDTH, MAINBAR_HEIGHT - STROKE_WIDTH);
|
||||||
|
for (int i = 0; i < Math.min(9, lines.length - this.stringOffset); i++)
|
||||||
|
{
|
||||||
|
if (lines[i + stringOffset].startsWith("*") && lines[i].endsWith("*"))
|
||||||
|
{
|
||||||
|
String line = lines[i + stringOffset].substring(1, lines[i + stringOffset].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 + stringOffset].startsWith("[") && lines[i].endsWith("]"))
|
||||||
|
{
|
||||||
|
String line = lines[i + stringOffset].substring(1, lines[i + stringOffset].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 + stringOffset], Color.WHITE, Color.BLACK, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void redrawRegionlost(RenderPanel renderer) {
|
||||||
|
renderer.addRedrawBound(TOPBAR_HEIGHT, W - 120, MAINBAR_HEIGHT, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "current";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,349 @@
|
|||||||
|
package com.flaremicro.visualforecast.displays.impl;
|
||||||
|
|
||||||
|
import static com.flaremicro.visualforecast.graphics.RenderConstants.BG_BLUE;
|
||||||
|
import static com.flaremicro.visualforecast.graphics.RenderConstants.MAINBAR_HEIGHT;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.GradientPaint;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import com.flaremicro.visualforecast.RenderPanel;
|
||||||
|
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||||
|
import com.flaremicro.visualforecast.displays.Display;
|
||||||
|
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||||
|
import com.flaremicro.visualforecast.forecast.HourlyForecast;
|
||||||
|
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 HourlyForecastDisplay implements Display {
|
||||||
|
private Font font;
|
||||||
|
private Font smallFont;
|
||||||
|
private ForecastDetails details;
|
||||||
|
private TownForecast currentTown = null;
|
||||||
|
private int townIndex;
|
||||||
|
|
||||||
|
private int ticksBeforeChange = 200;
|
||||||
|
// private int animationTicks = -1;
|
||||||
|
|
||||||
|
private byte[] windchill = null;
|
||||||
|
private byte[] tempval = null;
|
||||||
|
private float[] percipval = null;
|
||||||
|
|
||||||
|
DateFormat simpleDateFormat = new SimpleDateFormat("ha");
|
||||||
|
|
||||||
|
BufferedImage lastBuffer = null;
|
||||||
|
|
||||||
|
public HourlyForecastDisplay() {
|
||||||
|
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) {
|
||||||
|
ticksBeforeChange--;
|
||||||
|
if (ticksBeforeChange <= 0)
|
||||||
|
{
|
||||||
|
ticksBeforeChange = 200;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
townIndex++;
|
||||||
|
if (details == null || townIndex >= details.getTownForecast().length)
|
||||||
|
{
|
||||||
|
renderer.nextDisplay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.currentTown = details.getTownForecast()[townIndex];
|
||||||
|
}
|
||||||
|
while (this.currentTown == null || !currentTown.isDisplaySupported(this.getDisplayName()) || currentTown.getHourlyForecast() == null || currentTown.getHourlyForecast().length == 0);
|
||||||
|
renderer.setCurrentTown(currentTown.getTownName());
|
||||||
|
setGraphValues(currentTown);
|
||||||
|
renderer.requestFullRepaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGraphValues(TownForecast town) {
|
||||||
|
if (town != null)
|
||||||
|
{
|
||||||
|
HourlyForecast[] forecast = town.getHourlyForecast();
|
||||||
|
if (forecast != null && forecast.length > 0)
|
||||||
|
{
|
||||||
|
int size = Math.min(12, forecast.length);
|
||||||
|
windchill = new byte[size];
|
||||||
|
tempval = new byte[size];
|
||||||
|
percipval = new float[size];
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
windchill[i] = forecast[i].windChill;
|
||||||
|
tempval[i] = forecast[i].temp;
|
||||||
|
percipval[i] = forecast[i].percip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||||
|
this.details = forecastProvider != null ? forecastProvider.getForecast() : null;
|
||||||
|
renderer.setCurrentForecast("12 Hour Forecast");
|
||||||
|
if (details == null || details.getTownForecast() == null || details.getTownForecast().length <= 0)
|
||||||
|
this.details = null;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
townIndex = 0;
|
||||||
|
currentTown = details.getTownForecast()[townIndex];
|
||||||
|
renderer.setCurrentTown(currentTown.getTownName());
|
||||||
|
setGraphValues(currentTown);
|
||||||
|
}
|
||||||
|
redrawRegionlost(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawDisplay(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||||
|
HourlyForecast[] forecast = currentTown.getHourlyForecast();
|
||||||
|
if (forecast == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g2d.setColor(RenderConstants.BG_BLUE);
|
||||||
|
//g2d.fillRect(RenderConstants.SIDE_OFFSET, RenderConstants.TOPBAR_HEIGHT + 20, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2, RenderConstants.MAINBAR_HEIGHT - 40);
|
||||||
|
|
||||||
|
DrawingUtil.drawGradientRect(g2d, RenderConstants.SIDE_OFFSET, RenderConstants.TOPBAR_HEIGHT + 20, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2, RenderConstants.MAINBAR_HEIGHT - 40, 15, BG_BLUE.darker(), BG_BLUE.brighter());
|
||||||
|
|
||||||
|
int min = minTemp(forecast);
|
||||||
|
int max = maxTemp(forecast);
|
||||||
|
|
||||||
|
int range = max - min;
|
||||||
|
|
||||||
|
if (range == 0)
|
||||||
|
{
|
||||||
|
min -= 1;
|
||||||
|
max += 1;
|
||||||
|
range = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
g2d.setPaint(new GradientPaint(0, RenderConstants.TOPBAR_HEIGHT + 40, RenderConstants.BG_ORANGE, 0, RenderConstants.MAINBAR_HEIGHT, RenderConstants.BG_PURPLE));
|
||||||
|
g2d.fillRect(RenderConstants.SIDE_OFFSET + 40, RenderConstants.TOPBAR_HEIGHT + 40, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 60, RenderConstants.MAINBAR_HEIGHT - 124);
|
||||||
|
|
||||||
|
g2d.setColor(Color.BLACK);
|
||||||
|
g2d.drawRect(RenderConstants.SIDE_OFFSET, RenderConstants.TOPBAR_HEIGHT + 20, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2, RenderConstants.MAINBAR_HEIGHT - 40);
|
||||||
|
|
||||||
|
/*float lineHeight = (RenderConstants.MAINBAR_HEIGHT - 104) / 9F;
|
||||||
|
for(int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
g2d.drawLine(RenderConstants.SIDE_OFFSET + 36, (int)(RenderConstants.TOPBAR_HEIGHT + 40 + lineHeight * i), RenderConstants.W - RenderConstants.SIDE_OFFSET - 36, (int) (RenderConstants.TOPBAR_HEIGHT + 40 + lineHeight * i));
|
||||||
|
}*/
|
||||||
|
g2d.setFont(smallFont.deriveFont(20F));
|
||||||
|
FontMetrics fm = g2d.getFontMetrics();
|
||||||
|
|
||||||
|
DrawingUtil.drawOutlinedString(g2d, 100, RenderConstants.TOPBAR_HEIGHT + 35, "Temperature\u00B0c", Color.RED, Color.BLACK, 2);
|
||||||
|
DrawingUtil.drawOutlinedString(g2d, 260, RenderConstants.TOPBAR_HEIGHT + 35, "Wind Chill\u00B0c", Color.WHITE, Color.BLACK, 2);
|
||||||
|
DrawingUtil.drawOutlinedString(g2d, 410, RenderConstants.TOPBAR_HEIGHT + 35, "Precipitation%", Color.CYAN, Color.BLACK, 2);
|
||||||
|
|
||||||
|
g2d.setFont(font.deriveFont(20F));
|
||||||
|
String minText = min + "\u00B0";
|
||||||
|
String maxText = max + "\u00B0";
|
||||||
|
|
||||||
|
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 38 - fm.stringWidth(maxText), RenderConstants.TOPBAR_HEIGHT + 53, maxText, Color.YELLOW, Color.BLACK, 2);
|
||||||
|
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 38 - fm.stringWidth(minText), RenderConstants.TOPBAR_HEIGHT + MAINBAR_HEIGHT - 92, minText, Color.YELLOW, Color.BLACK, 2);
|
||||||
|
|
||||||
|
g2d.setFont(font.deriveFont(20F));
|
||||||
|
g2d.setColor(RenderConstants.BG_ORANGE.darker());
|
||||||
|
g2d.drawLine(RenderConstants.SIDE_OFFSET + 40, (RenderConstants.TOPBAR_HEIGHT + 50), (RenderConstants.W - RenderConstants.SIDE_OFFSET - 20), (RenderConstants.TOPBAR_HEIGHT + 50));
|
||||||
|
|
||||||
|
g2d.setColor(RenderConstants.BG_PURPLE.brighter());
|
||||||
|
g2d.drawLine(RenderConstants.SIDE_OFFSET + 40, RenderConstants.TOPBAR_HEIGHT + 50 + RenderConstants.MAINBAR_HEIGHT - 144, (RenderConstants.W - RenderConstants.SIDE_OFFSET - 20), RenderConstants.TOPBAR_HEIGHT + 50 + RenderConstants.MAINBAR_HEIGHT - 144);
|
||||||
|
|
||||||
|
//BlackLines
|
||||||
|
|
||||||
|
g2d.setFont(smallFont.deriveFont(20F));
|
||||||
|
if (max > 0 && min < 0)
|
||||||
|
{
|
||||||
|
int nextTemp = (RenderConstants.TOPBAR_HEIGHT + RenderConstants.MAINBAR_HEIGHT - 94) + (int) (((min) / (float) range) * (RenderConstants.MAINBAR_HEIGHT - 144));
|
||||||
|
g2d.setColor(Color.LIGHT_GRAY);
|
||||||
|
g2d.drawLine(RenderConstants.SIDE_OFFSET + 40, nextTemp, RenderConstants.W - RenderConstants.SIDE_OFFSET - 20, nextTemp);
|
||||||
|
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 40 - fm.stringWidth("0\u00B0"), nextTemp + 4, "0\u00B0", Color.YELLOW, Color.BLACK, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int slotWidth = (RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 60) / 12;
|
||||||
|
|
||||||
|
g2d.setClip(RenderConstants.SIDE_OFFSET + 40, RenderConstants.TOPBAR_HEIGHT + 40, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 60, RenderConstants.MAINBAR_HEIGHT - 124);
|
||||||
|
|
||||||
|
g2d.translate(RenderConstants.SIDE_OFFSET + 40, RenderConstants.TOPBAR_HEIGHT + RenderConstants.MAINBAR_HEIGHT - 94);
|
||||||
|
|
||||||
|
g2d.translate(2, 2);
|
||||||
|
g2d.setColor(Color.BLACK);
|
||||||
|
this.graphTemp(g2d, this.windchill, min, slotWidth, range, RenderConstants.MAINBAR_HEIGHT - 144);
|
||||||
|
g2d.setColor(Color.WHITE);
|
||||||
|
g2d.translate(-2, -2);
|
||||||
|
this.graphTemp(g2d, this.windchill, min, slotWidth, range, RenderConstants.MAINBAR_HEIGHT - 144);
|
||||||
|
|
||||||
|
g2d.translate(2, 2);
|
||||||
|
g2d.setColor(Color.BLACK);
|
||||||
|
this.graphPercent(g2d, this.percipval, slotWidth, 100F, RenderConstants.MAINBAR_HEIGHT - 144);
|
||||||
|
g2d.setColor(Color.CYAN);
|
||||||
|
g2d.translate(-2, -2);
|
||||||
|
this.graphPercent(g2d, this.percipval, slotWidth, 100F, RenderConstants.MAINBAR_HEIGHT - 144);
|
||||||
|
|
||||||
|
g2d.translate(2, 2);
|
||||||
|
g2d.setColor(Color.BLACK);
|
||||||
|
this.graphTemp(g2d, this.tempval, min, slotWidth, range, RenderConstants.MAINBAR_HEIGHT - 144);
|
||||||
|
g2d.setColor(Color.RED);
|
||||||
|
g2d.translate(-2, -2);
|
||||||
|
this.graphTemp(g2d, this.tempval, min, slotWidth, range, RenderConstants.MAINBAR_HEIGHT - 144);
|
||||||
|
|
||||||
|
g2d.translate(-RenderConstants.SIDE_OFFSET - 40, 94 - RenderConstants.TOPBAR_HEIGHT - RenderConstants.MAINBAR_HEIGHT);
|
||||||
|
|
||||||
|
g2d.setClip(null);
|
||||||
|
|
||||||
|
g2d.setStroke(new BasicStroke(2));
|
||||||
|
g2d.setColor(Color.BLACK);
|
||||||
|
g2d.drawRect(RenderConstants.SIDE_OFFSET + 40, RenderConstants.TOPBAR_HEIGHT + 40, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 60, RenderConstants.MAINBAR_HEIGHT - 124);
|
||||||
|
|
||||||
|
for (int i = 0; i < Math.min(12, forecast.length); i++)
|
||||||
|
{
|
||||||
|
String timeString = simpleDateFormat.format(forecast[i].hour);
|
||||||
|
timeString = timeString.substring(0, timeString.length() - 1);
|
||||||
|
if ((i % 2) == 0)
|
||||||
|
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 40 + slotWidth / 2 + (slotWidth * i) - fm.stringWidth(timeString) / 2, RenderConstants.TOPBAR_HEIGHT + MAINBAR_HEIGHT - 70, timeString, Color.YELLOW, Color.BLACK, 2);
|
||||||
|
else DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 40 + slotWidth / 2 + (slotWidth * i) - fm.stringWidth(timeString) / 2, RenderConstants.TOPBAR_HEIGHT + MAINBAR_HEIGHT - 60, timeString, Color.YELLOW, Color.BLACK, 2);
|
||||||
|
IconProvider.drawIcon(g2d, IconProvider.INDEXED_ICONS[forecast[i].iconId], RenderConstants.SIDE_OFFSET + 45 + i * slotWidth, RenderConstants.TOPBAR_HEIGHT + MAINBAR_HEIGHT - 55, slotWidth - 10, iconTicks);
|
||||||
|
}
|
||||||
|
lastBuffer = renderer.getSnapshot().getSubimage(RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 19, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 + 2, RenderConstants.MAINBAR_HEIGHT - 38);
|
||||||
|
lastBuffer.setAccelerationPriority(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int minTemp(HourlyForecast[] forecast) {
|
||||||
|
int min = Integer.MAX_VALUE;
|
||||||
|
for (int i = 0; i < forecast.length; i++)
|
||||||
|
{
|
||||||
|
int currMin;
|
||||||
|
if (ValueCheck.valueNoData(forecast[i].windChill) && ValueCheck.valueNoData(forecast[i].temp))
|
||||||
|
continue;
|
||||||
|
else if (ValueCheck.valueNoData(forecast[i].windChill))
|
||||||
|
currMin = forecast[i].temp;
|
||||||
|
else if (ValueCheck.valueNoData(forecast[i].temp))
|
||||||
|
currMin = forecast[i].windChill;
|
||||||
|
else currMin = Math.min(forecast[i].temp, forecast[i].windChill);
|
||||||
|
if (currMin < min)
|
||||||
|
min = currMin;
|
||||||
|
}
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int maxTemp(HourlyForecast[] forecast) {
|
||||||
|
int max = Integer.MIN_VALUE;
|
||||||
|
for (int i = 0; i < forecast.length; i++)
|
||||||
|
{
|
||||||
|
int currMax;
|
||||||
|
if (ValueCheck.valueNoData(forecast[i].windChill) && ValueCheck.valueNoData(forecast[i].temp))
|
||||||
|
continue;
|
||||||
|
else if (ValueCheck.valueNoData(forecast[i].windChill))
|
||||||
|
currMax = forecast[i].temp;
|
||||||
|
else if (ValueCheck.valueNoData(forecast[i].temp))
|
||||||
|
currMax = forecast[i].windChill;
|
||||||
|
else currMax = Math.max(forecast[i].temp, forecast[i].windChill);
|
||||||
|
if (currMax > max)
|
||||||
|
max = currMax;
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||||
|
HourlyForecast[] forecast = currentTown.getHourlyForecast();
|
||||||
|
if (forecast == null)
|
||||||
|
return;
|
||||||
|
if (this.lastBuffer != null)
|
||||||
|
{
|
||||||
|
g2d.drawImage(lastBuffer, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 19, renderer);
|
||||||
|
}
|
||||||
|
int slotWidth = (RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 60) / 12;
|
||||||
|
for (int i = 0; i < Math.min(12, forecast.length); i++)
|
||||||
|
{
|
||||||
|
if (IconProvider.INDEXED_ICONS[forecast[i].iconId].isAnimated())
|
||||||
|
IconProvider.drawIcon(g2d, IconProvider.INDEXED_ICONS[forecast[i].iconId], RenderConstants.SIDE_OFFSET + 45 + i * slotWidth, RenderConstants.TOPBAR_HEIGHT + MAINBAR_HEIGHT - 55, slotWidth - 10, iconTicks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void graphTemp(Graphics2D g2d, byte[] tempVal, int min, int slotWidth, float range, float multiplier) {
|
||||||
|
int lastTemp = ValueCheck.NO_DATA_INT;
|
||||||
|
for (int i = 0; i < tempVal.length; i++)
|
||||||
|
{
|
||||||
|
if (ValueCheck.valueNoData(tempVal[i]))
|
||||||
|
{
|
||||||
|
lastTemp = ValueCheck.NO_DATA_INT;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int nextTemp = -(int) (((tempVal[i] - min) / range) * multiplier);
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
lastTemp = nextTemp;
|
||||||
|
}
|
||||||
|
if (ValueCheck.valueNoData(lastTemp))
|
||||||
|
{
|
||||||
|
lastTemp = nextTemp;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
g2d.drawLine(slotWidth / 2 + (slotWidth * (i - 1)), lastTemp, slotWidth / 2 + (slotWidth * i), nextTemp);
|
||||||
|
if (i == Math.min(12, tempVal.length) - 1)
|
||||||
|
{
|
||||||
|
g2d.drawLine(slotWidth / 2 + (slotWidth * (i)), nextTemp, slotWidth / 2 + (slotWidth * (i + 1)), nextTemp);
|
||||||
|
}
|
||||||
|
lastTemp = nextTemp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void graphPercent(Graphics2D g2d, float[] precVal, int slotWidth, float range, float multiplier) {
|
||||||
|
int lastTemp = ValueCheck.NO_DATA_INT;
|
||||||
|
for (int i = 0; i < tempval.length; i++)
|
||||||
|
{
|
||||||
|
if (ValueCheck.valueNoData(precVal[i]))
|
||||||
|
{
|
||||||
|
lastTemp = ValueCheck.NO_DATA_INT;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int nextTemp = -(int) (((precVal[i]) / range) * multiplier);
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
lastTemp = nextTemp;
|
||||||
|
}
|
||||||
|
if (ValueCheck.valueNoData(lastTemp))
|
||||||
|
{
|
||||||
|
lastTemp = nextTemp;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
g2d.drawLine(slotWidth / 2 + (slotWidth * (i - 1)), lastTemp, slotWidth / 2 + (slotWidth * i), nextTemp);
|
||||||
|
if (i == Math.min(12, precVal.length) - 1)
|
||||||
|
{
|
||||||
|
g2d.drawLine(slotWidth / 2 + (slotWidth * (i)), nextTemp, slotWidth / 2 + (slotWidth * (i + 1)), nextTemp);
|
||||||
|
}
|
||||||
|
lastTemp = nextTemp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void redrawRegionlost(RenderPanel renderer) {
|
||||||
|
int slotWidth = (RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 60) / 12;
|
||||||
|
renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 45, RenderConstants.TOPBAR_HEIGHT + MAINBAR_HEIGHT - 55, slotWidth * 12 - 10, slotWidth - 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "hourly";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
package com.flaremicro.visualforecast.displays.impl;
|
||||||
|
|
||||||
|
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.displays.Display;
|
||||||
|
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||||
|
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||||
|
|
||||||
|
import static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||||
|
|
||||||
|
public class MessageForecastDisplay implements Display {
|
||||||
|
|
||||||
|
private String[] lines = new String[0];
|
||||||
|
private Font font;
|
||||||
|
|
||||||
|
private int stringOffset = 0;
|
||||||
|
private int ticksBeforeChange = 0;
|
||||||
|
|
||||||
|
public MessageForecastDisplay() {
|
||||||
|
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) {
|
||||||
|
ticksBeforeChange--;
|
||||||
|
if (ticksBeforeChange <= 0)
|
||||||
|
{
|
||||||
|
stringOffset += 9;
|
||||||
|
if (stringOffset < lines.length)
|
||||||
|
{
|
||||||
|
ticksBeforeChange = 200;
|
||||||
|
renderer.requestExclusiveBoundedRepaint();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
renderer.nextDisplay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||||
|
ticksBeforeChange = 200;
|
||||||
|
stringOffset = 0;
|
||||||
|
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");
|
||||||
|
|
||||||
|
BufferedImage disposableImage = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY);
|
||||||
|
Graphics2D g = disposableImage.createGraphics();
|
||||||
|
FontMetrics f = g.getFontMetrics(font);
|
||||||
|
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();
|
||||||
|
|
||||||
|
redrawRegionlost(renderer);
|
||||||
|
|
||||||
|
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.darker(), BG_BLUE.brighter());
|
||||||
|
g2d.setFont(font);
|
||||||
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
|
g2d.setColor(BG_BLUE.darker());
|
||||||
|
g2d.drawRect(60 + STROKE_OFFSET, TOPBAR_HEIGHT + STROKE_OFFSET, W - 120 - STROKE_WIDTH, MAINBAR_HEIGHT - STROKE_WIDTH);
|
||||||
|
for (int i = 0; i < Math.min(9, lines.length - this.stringOffset); i++)
|
||||||
|
{
|
||||||
|
if (lines[i + stringOffset].startsWith("*") && lines[i].endsWith("*"))
|
||||||
|
{
|
||||||
|
String line = lines[i + stringOffset].substring(1, lines[i + stringOffset].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 + stringOffset].startsWith("[") && lines[i].endsWith("]"))
|
||||||
|
{
|
||||||
|
String line = lines[i + stringOffset].substring(1, lines[i + stringOffset].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 + stringOffset], Color.WHITE, Color.BLACK, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void redrawRegionlost(RenderPanel renderer) {
|
||||||
|
renderer.addRedrawBound(TOPBAR_HEIGHT, W - 120, MAINBAR_HEIGHT, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "message";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast.flavour;
|
package com.flaremicro.visualforecast.displays.impl;
|
||||||
|
|
||||||
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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@@ -14,17 +14,19 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.RenderPanel;
|
import com.flaremicro.visualforecast.RenderPanel;
|
||||||
import com.flaremicro.flaretv.visualforecast.forecast.DayForecast;
|
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||||
import com.flaremicro.flaretv.visualforecast.forecast.ForecastDetails;
|
import com.flaremicro.visualforecast.displays.Display;
|
||||||
import com.flaremicro.flaretv.visualforecast.forecast.TownForecast;
|
import com.flaremicro.visualforecast.forecast.DayForecast;
|
||||||
import com.flaremicro.flaretv.visualforecast.forecast.ValueCheck;
|
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.FontManager;
|
import com.flaremicro.visualforecast.forecast.ValueCheck;
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.RenderConstants;
|
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.IconProvider;
|
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 SevenDayForecastDisplay implements Display {
|
||||||
private int dayOffset = 0;
|
private int dayOffset = 0;
|
||||||
private Font font;
|
private Font font;
|
||||||
private Font smallFont;
|
private Font smallFont;
|
||||||
@@ -39,17 +41,22 @@ public class DayForecastFlavour implements Flavour {
|
|||||||
private int ticksBeforeChange = 200;
|
private int ticksBeforeChange = 200;
|
||||||
private int animationTicks = -1;
|
private int animationTicks = -1;
|
||||||
|
|
||||||
public DayForecastFlavour() {
|
public SevenDayForecastDisplay() {
|
||||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
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"));
|
smallFont = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000 Small.ttf"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO improve
|
||||||
@Override
|
@Override
|
||||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
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;
|
animationTicks += 8;
|
||||||
if(animationTicks > RenderConstants.W - 60)
|
if (animationTicks > RenderConstants.W - 60)
|
||||||
{
|
{
|
||||||
animationTicks = -1;
|
animationTicks = -1;
|
||||||
prevBound.flush();
|
prevBound.flush();
|
||||||
@@ -64,41 +71,47 @@ public class DayForecastFlavour implements Flavour {
|
|||||||
ticksBeforeChange--;
|
ticksBeforeChange--;
|
||||||
if (ticksBeforeChange < 0)
|
if (ticksBeforeChange < 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ticksBeforeChange = 200;
|
||||||
|
dayOffset = dayOffset + 4;
|
||||||
|
if (dayOffset >= 8)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
dayOffset = 0;
|
||||||
|
townIndex++;
|
||||||
|
if (townIndex >= details.getTownForecast().length)
|
||||||
|
{
|
||||||
|
renderer.nextDisplay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
previousTown = currentTown;
|
||||||
|
currentTown = details.getTownForecast()[townIndex];
|
||||||
|
renderer.setCurrentTown(currentTown.getTownName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (this.currentTown != null && !this.currentTown.isDisplaySupported(this.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
animationTicks = 0;
|
animationTicks = 0;
|
||||||
if(prevBound != null)
|
if (prevBound != null)
|
||||||
prevBound.flush();
|
prevBound.flush();
|
||||||
if(mainBound != null)
|
if (mainBound != null)
|
||||||
mainBound.flush();
|
mainBound.flush();
|
||||||
prevBound = renderer.getGraphicsConfiguration().createCompatibleImage(526, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
prevBound = renderer.getGraphicsConfiguration().createCompatibleImage(526, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
||||||
mainBound = renderer.getGraphicsConfiguration().createCompatibleImage(526, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
mainBound = renderer.getGraphicsConfiguration().createCompatibleImage(526, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
||||||
mainBound.setAccelerationPriority(1);
|
mainBound.setAccelerationPriority(1);
|
||||||
prevBound.setAccelerationPriority(1);
|
prevBound.setAccelerationPriority(1);
|
||||||
|
|
||||||
ticksBeforeChange = 200;
|
|
||||||
dayOffset = dayOffset + 4;
|
|
||||||
if (dayOffset >= 8)
|
|
||||||
{
|
|
||||||
dayOffset = 0;
|
|
||||||
townIndex++;
|
|
||||||
if (townIndex >= details.getTownForecast().length)
|
|
||||||
{
|
|
||||||
renderer.nextFlavour();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
previousTown = currentTown;
|
|
||||||
currentTown = details.getTownForecast()[townIndex];
|
|
||||||
renderer.setCurrentTown(currentTown.getTownName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Flicker workaround
|
//Flicker workaround
|
||||||
BufferedImage throwaway = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
|
BufferedImage throwaway = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
|
||||||
Graphics2D g2d = throwaway.createGraphics();
|
Graphics2D g2d = throwaway.createGraphics();
|
||||||
this.drawFlavour(renderer, g2d, ticks, iconTicks);
|
this.drawDisplay(renderer, g2d, ticks, iconTicks);
|
||||||
g2d.dispose();
|
g2d.dispose();
|
||||||
throwaway.flush();
|
throwaway.flush();
|
||||||
|
|
||||||
renderer.loseRedrawRegion();
|
renderer.loseRedrawRegion();
|
||||||
renderer.requestFullRepaint();
|
renderer.requestFullRepaint();
|
||||||
}
|
}
|
||||||
@@ -106,8 +119,8 @@ public class DayForecastFlavour implements Flavour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initFlavour(RenderPanel renderer, ForecastDetails details, long ticks, int iconTicks) {
|
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||||
this.details = details;
|
this.details = forecastProvider != null ? forecastProvider.getForecast() : null;
|
||||||
renderer.setCurrentForecast("7 Day Forecast");
|
renderer.setCurrentForecast("7 Day Forecast");
|
||||||
if (details == null || details.getTownForecast() == null || details.getTownForecast().length <= 0)
|
if (details == null || details.getTownForecast() == null || details.getTownForecast().length <= 0)
|
||||||
this.details = null;
|
this.details = null;
|
||||||
@@ -129,7 +142,7 @@ public class DayForecastFlavour implements Flavour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
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));
|
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 +152,7 @@ public class DayForecastFlavour implements Flavour {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(animationTicks < 0)
|
if (animationTicks < 0)
|
||||||
{
|
{
|
||||||
drawTownForecast(g2d, currentTown, dayOffset);
|
drawTownForecast(g2d, currentTown, dayOffset);
|
||||||
}
|
}
|
||||||
@@ -147,38 +160,39 @@ public class DayForecastFlavour implements Flavour {
|
|||||||
{
|
{
|
||||||
Graphics2D gimg = prevBound.createGraphics();
|
Graphics2D gimg = prevBound.createGraphics();
|
||||||
Graphics2D gimg2 = mainBound.createGraphics();
|
Graphics2D gimg2 = mainBound.createGraphics();
|
||||||
gimg.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);
|
gimg2.translate(-RenderConstants.SIDE_OFFSET + 1, -RenderConstants.TOPBAR_HEIGHT - 14);
|
||||||
gimg.setStroke(new BasicStroke(2));
|
gimg.setStroke(new BasicStroke(2));
|
||||||
gimg2.setStroke(new BasicStroke(2));
|
gimg2.setStroke(new BasicStroke(2));
|
||||||
if(dayOffset == 0)
|
if (dayOffset == 0)
|
||||||
{
|
{
|
||||||
drawTownForecast(gimg, previousTown, dayOffset + 4);
|
drawTownForecast(gimg, previousTown, dayOffset + 4);
|
||||||
drawTownForecast(gimg2, currentTown, dayOffset);
|
drawTownForecast(gimg2, currentTown, dayOffset);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
drawTownForecast(gimg, currentTown, dayOffset - 4);
|
drawTownForecast(gimg, currentTown, dayOffset - 4);
|
||||||
drawTownForecast(gimg2, currentTown, dayOffset);
|
drawTownForecast(gimg2, currentTown, dayOffset);
|
||||||
}
|
}
|
||||||
gimg.dispose();
|
gimg.dispose();
|
||||||
gimg2.dispose();
|
gimg2.dispose();
|
||||||
|
|
||||||
g2d.setClip(animationTicks + RenderConstants.SIDE_OFFSET, RenderConstants.TOPBAR_HEIGHT+14, 526-animationTicks, MAINBAR_HEIGHT - 28);
|
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.drawImage(prevBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||||
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT+15, animationTicks, MAINBAR_HEIGHT - 28);
|
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT + 15, animationTicks, MAINBAR_HEIGHT - 28);
|
||||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||||
g2d.setClip(null);
|
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);
|
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++)
|
for (int i = 0; i < Math.min(4, townForecast.getDayForecast().length - dayOffset); i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -213,13 +227,21 @@ public class DayForecastFlavour implements Flavour {
|
|||||||
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(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);
|
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) + 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));
|
g2d.setFont(smallFont.deriveFont(24F));
|
||||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 20, RenderConstants.TOPBAR_HEIGHT + 270, "Hi", Color.RED, Color.BLACK, 2);
|
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);
|
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 82, RenderConstants.TOPBAR_HEIGHT + 270, "Lo", Color.CYAN, Color.BLACK, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,38 +255,38 @@ public class DayForecastFlavour implements Flavour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 (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);
|
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g2d.setClip(animationTicks + RenderConstants.SIDE_OFFSET-1, RenderConstants.TOPBAR_HEIGHT+14, 526, MAINBAR_HEIGHT - 28);
|
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);
|
g2d.drawImage(prevBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||||
if(dayOffset == 0)
|
if (dayOffset == 0)
|
||||||
{
|
{
|
||||||
drawIcons(g2d, previousTown, dayOffset + 4, iconTicks);
|
drawIcons(g2d, previousTown, dayOffset + 4, iconTicks);
|
||||||
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT+14, animationTicks, MAINBAR_HEIGHT - 28);
|
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT + 14, animationTicks, MAINBAR_HEIGHT - 28);
|
||||||
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);
|
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawIcons(g2d, currentTown, dayOffset - 4, iconTicks);
|
drawIcons(g2d, currentTown, dayOffset - 4, iconTicks);
|
||||||
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT+14, animationTicks, MAINBAR_HEIGHT - 28);
|
g2d.setClip(0, RenderConstants.TOPBAR_HEIGHT + 14, animationTicks, MAINBAR_HEIGHT - 28);
|
||||||
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);
|
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||||
}
|
}
|
||||||
g2d.setClip(null);
|
g2d.setClip(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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++)
|
for (int i = 0; i < Math.min(4, currentTown.getDayForecast().length - dayOffset); i++)
|
||||||
{
|
{
|
||||||
@@ -275,9 +297,18 @@ public class DayForecastFlavour implements Flavour {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void redrawRegionlost(RenderPanel renderer) {
|
public void redrawRegionlost(RenderPanel renderer) {
|
||||||
if(animationTicks >= 0)
|
if (animationTicks >= 0)
|
||||||
renderer.addRedrawBound(0, RenderConstants.TOPBAR_HEIGHT, RenderConstants.W, RenderConstants.MAINBAR_HEIGHT);
|
renderer.addRedrawBound(0, RenderConstants.TOPBAR_HEIGHT, RenderConstants.W, RenderConstants.MAINBAR_HEIGHT);
|
||||||
else
|
else renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 24, RenderConstants.TOPBAR_HEIGHT + 60, 604, 84);
|
||||||
renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 24, RenderConstants.TOPBAR_HEIGHT + 60, 604, 84);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "7-day";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast.flavour;
|
package com.flaremicro.visualforecast.displays.impl;
|
||||||
|
|
||||||
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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@@ -14,17 +14,19 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.RenderPanel;
|
import com.flaremicro.visualforecast.RenderPanel;
|
||||||
import com.flaremicro.flaretv.visualforecast.forecast.DayForecast;
|
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||||
import com.flaremicro.flaretv.visualforecast.forecast.ForecastDetails;
|
import com.flaremicro.visualforecast.displays.Display;
|
||||||
import com.flaremicro.flaretv.visualforecast.forecast.TownForecast;
|
import com.flaremicro.visualforecast.forecast.DayForecast;
|
||||||
import com.flaremicro.flaretv.visualforecast.forecast.ValueCheck;
|
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.FontManager;
|
import com.flaremicro.visualforecast.forecast.ValueCheck;
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.RenderConstants;
|
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.IconProvider;
|
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 SevenDayForecastDisplayOldAnimation implements Display {
|
||||||
private int dayOffset = 0;
|
private int dayOffset = 0;
|
||||||
private Font font;
|
private Font font;
|
||||||
private Font smallFont;
|
private Font smallFont;
|
||||||
@@ -38,17 +40,17 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
private int ticksBeforeChange = 200;
|
private int ticksBeforeChange = 200;
|
||||||
private int animationTicks = -1;
|
private int animationTicks = -1;
|
||||||
|
|
||||||
public DayForecastFlavourOldAnimation() {
|
public SevenDayForecastDisplayOldAnimation() {
|
||||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
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"));
|
smallFont = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000 Small.ttf"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||||
if(animationTicks >= 0)
|
if (animationTicks >= 0)
|
||||||
{
|
{
|
||||||
animationTicks += 8;
|
animationTicks += 8;
|
||||||
if(animationTicks > RenderConstants.W - 60)
|
if (animationTicks > RenderConstants.W - 60)
|
||||||
{
|
{
|
||||||
animationTicks = -1;
|
animationTicks = -1;
|
||||||
renderer.requestFullRepaint();
|
renderer.requestFullRepaint();
|
||||||
@@ -62,7 +64,7 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
if (ticksBeforeChange < 0)
|
if (ticksBeforeChange < 0)
|
||||||
{
|
{
|
||||||
animationTicks = 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);
|
lastBound.setAccelerationPriority(1);
|
||||||
ticksBeforeChange = 200;
|
ticksBeforeChange = 200;
|
||||||
dayOffset = dayOffset + 4;
|
dayOffset = dayOffset + 4;
|
||||||
@@ -72,7 +74,7 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
townIndex++;
|
townIndex++;
|
||||||
if (townIndex >= details.getTownForecast().length)
|
if (townIndex >= details.getTownForecast().length)
|
||||||
{
|
{
|
||||||
renderer.nextFlavour();
|
renderer.nextDisplay();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -88,8 +90,8 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initFlavour(RenderPanel renderer, ForecastDetails details, long ticks, int iconTicks) {
|
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||||
this.details = details;
|
this.details = forecastProvider != null ? forecastProvider.getForecast() : null;
|
||||||
renderer.setCurrentForecast("7 Day Forecast");
|
renderer.setCurrentForecast("7 Day Forecast");
|
||||||
if (details == null || details.getTownForecast() == null || details.getTownForecast().length <= 0)
|
if (details == null || details.getTownForecast() == null || details.getTownForecast().length <= 0)
|
||||||
this.details = null;
|
this.details = null;
|
||||||
@@ -111,7 +113,7 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
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));
|
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 +123,24 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(animationTicks < 0)
|
if (animationTicks < 0)
|
||||||
{
|
{
|
||||||
drawTownForecast(g2d, currentTown, dayOffset);
|
drawTownForecast(g2d, currentTown, dayOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Graphics2D gimg = lastBound.createGraphics();
|
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));
|
gimg.setStroke(new BasicStroke(2));
|
||||||
if(dayOffset == 0)
|
if (dayOffset == 0)
|
||||||
{
|
{
|
||||||
drawTownForecast(gimg, previousTown, dayOffset + 4);
|
drawTownForecast(gimg, previousTown, dayOffset + 4);
|
||||||
gimg.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
gimg.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
||||||
drawTownForecast(gimg, currentTown, dayOffset);
|
drawTownForecast(gimg, currentTown, dayOffset);
|
||||||
gimg.translate(RenderConstants.SIDE_OFFSET - RenderConstants.W, 0);
|
gimg.translate(RenderConstants.SIDE_OFFSET - RenderConstants.W, 0);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
drawTownForecast(gimg, currentTown, dayOffset - 4);
|
drawTownForecast(gimg, currentTown, dayOffset - 4);
|
||||||
gimg.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
gimg.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
||||||
drawTownForecast(gimg, currentTown, dayOffset);
|
drawTownForecast(gimg, currentTown, dayOffset);
|
||||||
@@ -149,15 +153,14 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
g2d.translate(animationTicks, 0);
|
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);
|
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++)
|
for (int i = 0; i < Math.min(4, townForecast.getDayForecast().length - dayOffset); i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -212,19 +215,19 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 (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);
|
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g2d.translate(-animationTicks, 0);
|
g2d.translate(-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);
|
||||||
if(dayOffset == 0)
|
if (dayOffset == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
drawIcons(g2d, previousTown, dayOffset + 4, iconTicks);
|
drawIcons(g2d, previousTown, dayOffset + 4, iconTicks);
|
||||||
@@ -232,7 +235,7 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawIcons(g2d, currentTown, dayOffset - 4, iconTicks);
|
drawIcons(g2d, currentTown, dayOffset - 4, iconTicks);
|
||||||
g2d.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
g2d.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
||||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||||
@@ -241,8 +244,8 @@ 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++)
|
for (int i = 0; i < Math.min(4, currentTown.getDayForecast().length - dayOffset); i++)
|
||||||
{
|
{
|
||||||
@@ -253,9 +256,17 @@ public class DayForecastFlavourOldAnimation implements Flavour {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void redrawRegionlost(RenderPanel renderer) {
|
public void redrawRegionlost(RenderPanel renderer) {
|
||||||
if(animationTicks >= 0)
|
if (animationTicks >= 0)
|
||||||
renderer.addRedrawBound(0, RenderConstants.TOPBAR_HEIGHT, RenderConstants.W, RenderConstants.MAINBAR_HEIGHT);
|
renderer.addRedrawBound(0, RenderConstants.TOPBAR_HEIGHT, RenderConstants.W, RenderConstants.MAINBAR_HEIGHT);
|
||||||
else
|
else renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 24, RenderConstants.TOPBAR_HEIGHT + 60, 604, 84);
|
||||||
renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 24, RenderConstants.TOPBAR_HEIGHT + 60, 604, 84);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "7-day-old";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,232 @@
|
|||||||
|
package com.flaremicro.visualforecast.displays.impl;
|
||||||
|
|
||||||
|
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.displays.Display;
|
||||||
|
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||||
|
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||||
|
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||||
|
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||||
|
|
||||||
|
import static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||||
|
|
||||||
|
public class ThirtySixHourForecastDisplay implements Display {
|
||||||
|
|
||||||
|
private int townIndex = 0;
|
||||||
|
private TownForecast[] townForecasts;
|
||||||
|
private String[] lines = new String[0];
|
||||||
|
private Font font;
|
||||||
|
|
||||||
|
private int stringOffset = 0;
|
||||||
|
private int ticksBeforeChange = 0;
|
||||||
|
|
||||||
|
public ThirtySixHourForecastDisplay() {
|
||||||
|
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) {
|
||||||
|
ticksBeforeChange--;
|
||||||
|
if (ticksBeforeChange <= 0)
|
||||||
|
{
|
||||||
|
stringOffset += 9;
|
||||||
|
if (stringOffset < lines.length)
|
||||||
|
{
|
||||||
|
ticksBeforeChange = 200;
|
||||||
|
renderer.requestExclusiveBoundedRepaint();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!setNextTown(renderer))
|
||||||
|
{
|
||||||
|
renderer.nextDisplay();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ticksBeforeChange = 200;
|
||||||
|
renderer.requestExclusiveBoundedRepaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||||
|
ForecastDetails details = forecastProvider != null ? forecastProvider.getForecast() : null;
|
||||||
|
renderer.setCurrentForecast("36 Hour Detailed Forecast");
|
||||||
|
townIndex = -1;
|
||||||
|
if(details == null || details.getTownForecast() == null || details.getTownForecast().length <= 0)
|
||||||
|
{
|
||||||
|
renderer.nextDisplay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
townForecasts = details.getTownForecast();
|
||||||
|
if(!setNextTown(renderer))
|
||||||
|
{
|
||||||
|
renderer.nextDisplay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setNextTown(RenderPanel renderer)
|
||||||
|
{
|
||||||
|
townIndex++;
|
||||||
|
if(townIndex >= townForecasts.length)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TownForecast town = townForecasts[townIndex];
|
||||||
|
|
||||||
|
if(!town.isDisplaySupported(getDisplayName()) || town.getDetailedForecast() == null || town.getDetailedForecast().length <= 0)
|
||||||
|
{
|
||||||
|
return setNextTown(renderer);
|
||||||
|
}
|
||||||
|
ticksBeforeChange = 200;
|
||||||
|
stringOffset = 0;
|
||||||
|
|
||||||
|
StringBuilder forecastBuilder = new StringBuilder();
|
||||||
|
for(int i = 0; i < town.getDetailedForecast().length; i++)
|
||||||
|
{
|
||||||
|
if(i > 0)
|
||||||
|
forecastBuilder.append("\n\n");
|
||||||
|
forecastBuilder.append(town.getDetailedForecast()[i].title + ":\n");
|
||||||
|
forecastBuilder.append(town.getDetailedForecast()[i].status);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<String> linesList = new ArrayList<String>();
|
||||||
|
|
||||||
|
renderer.setCurrentTown(town.getTownName());
|
||||||
|
|
||||||
|
BufferedImage disposableImage = new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_GRAY);
|
||||||
|
Graphics2D g = disposableImage.createGraphics();
|
||||||
|
FontMetrics f = g.getFontMetrics(font);
|
||||||
|
String[] lines = forecastBuilder.toString().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();
|
||||||
|
|
||||||
|
redrawRegionlost(renderer);
|
||||||
|
|
||||||
|
this.lines = linesList.toArray(new String[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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.darker(), BG_BLUE.brighter());
|
||||||
|
g2d.setFont(font);
|
||||||
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
|
g2d.setColor(BG_BLUE.darker());
|
||||||
|
g2d.drawRect(60 + STROKE_OFFSET, TOPBAR_HEIGHT + STROKE_OFFSET, W - 120 - STROKE_WIDTH, MAINBAR_HEIGHT - STROKE_WIDTH);
|
||||||
|
for (int i = 0; i < Math.min(9, lines.length - this.stringOffset); i++)
|
||||||
|
{
|
||||||
|
if (lines[i + stringOffset].startsWith("*") && lines[i].endsWith("*"))
|
||||||
|
{
|
||||||
|
String line = lines[i + stringOffset].substring(1, lines[i + stringOffset].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 + stringOffset].startsWith("[") && lines[i].endsWith("]"))
|
||||||
|
{
|
||||||
|
String line = lines[i + stringOffset].substring(1, lines[i + stringOffset].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 + stringOffset], Color.WHITE, Color.BLACK, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void redrawRegionlost(RenderPanel renderer) {
|
||||||
|
renderer.addRedrawBound(TOPBAR_HEIGHT, W - 120, MAINBAR_HEIGHT, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDisplayName() {
|
||||||
|
return "36-hour";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast.forecast;
|
package com.flaremicro.visualforecast.forecast;
|
||||||
|
|
||||||
|
import com.flaremicro.visualforecast.icons.IconProvider;
|
||||||
|
|
||||||
public class DayForecast {
|
public class DayForecast {
|
||||||
public byte hiTemp;
|
public byte hiTemp;
|
||||||
@@ -11,9 +13,18 @@ public class DayForecast {
|
|||||||
public DayForecast(byte hiTemp, byte loTemp, byte iconId, String weatherLine1, String weatherLine2, float percipPercent){
|
public DayForecast(byte hiTemp, byte loTemp, byte iconId, String weatherLine1, String weatherLine2, float percipPercent){
|
||||||
this.hiTemp = hiTemp;
|
this.hiTemp = hiTemp;
|
||||||
this.loTemp = loTemp;
|
this.loTemp = loTemp;
|
||||||
this.iconId = (byte)(iconId & 63);
|
this.iconId = (byte)(iconId % IconProvider.INDEXED_ICONS.length);
|
||||||
this.weatherLine1 = weatherLine1;
|
this.weatherLine1 = weatherLine1;
|
||||||
this.weatherLine2 = weatherLine2;
|
this.weatherLine2 = weatherLine2;
|
||||||
this.percipPercent = percipPercent;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.flaremicro.visualforecast.forecast;
|
||||||
|
|
||||||
|
public class DetailedForecast {
|
||||||
|
public final String title;
|
||||||
|
public final String status;
|
||||||
|
|
||||||
|
public DetailedForecast(String title, String status)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast.forecast;
|
package com.flaremicro.visualforecast.forecast;
|
||||||
|
|
||||||
public class ForecastDetails {
|
public class ForecastDetails {
|
||||||
//Perhaps could be hashmap?
|
//Perhaps could be hashmap?
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.flaremicro.visualforecast.forecast;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.flaremicro.visualforecast.icons.IconProvider;
|
||||||
|
|
||||||
|
public class HourlyForecast {
|
||||||
|
public final Date hour;
|
||||||
|
public final byte iconId;
|
||||||
|
public final byte temp;
|
||||||
|
public final short windSpeed;
|
||||||
|
public final float percip;
|
||||||
|
public final byte windChill;
|
||||||
|
|
||||||
|
public HourlyForecast(Date hour, byte iconId, byte temp, short windSpeed, float percip, byte windChill)
|
||||||
|
{
|
||||||
|
this.hour = hour;
|
||||||
|
this.iconId = (byte) (iconId % IconProvider.INDEXED_ICONS.length);
|
||||||
|
this.temp = temp;
|
||||||
|
this.windSpeed = windSpeed;
|
||||||
|
this.percip = percip;
|
||||||
|
this.windChill = windChill;
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/com/flaremicro/visualforecast/forecast/TownForecast.java
Normal file
62
src/com/flaremicro/visualforecast/forecast/TownForecast.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package com.flaremicro.visualforecast.forecast;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDayForecast(DayForecast[] dayForecast){
|
||||||
|
this.dayForecast = dayForecast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisplaySupported(String displayName)
|
||||||
|
{
|
||||||
|
return displays.size() == 0 || displays.contains(displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSupportedDisplays(String ... displays){
|
||||||
|
setSupportedDisplays(Arrays.asList(displays));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSupportedDisplays(Collection<String> displays){
|
||||||
|
this.displays.clear();
|
||||||
|
this.displays.addAll(displays);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHourlyForecast(HourlyForecast[] forecast) {
|
||||||
|
this.hourlyForecast = forecast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HourlyForecast[] getHourlyForecast() {
|
||||||
|
return this.hourlyForecast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DayForecast[] getDayForecast() {
|
||||||
|
return dayForecast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTownName() {
|
||||||
|
return townName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetailedForecast[] getDetailedForecast() {
|
||||||
|
return detailedForecast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDetailedForecast(DetailedForecast[] detailedForecast) {
|
||||||
|
this.detailedForecast = detailedForecast;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast.forecast;
|
package com.flaremicro.visualforecast.forecast;
|
||||||
|
|
||||||
public class ValueCheck {
|
public class ValueCheck {
|
||||||
//Utility for no data
|
//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.Color;
|
||||||
import java.awt.GradientPaint;
|
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.Font;
|
||||||
import java.awt.FontFormatException;
|
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.awt.Color;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
@@ -31,6 +31,6 @@ public class RenderConstants {
|
|||||||
|
|
||||||
|
|
||||||
public static final Color BG_PURPLE = new Color(0x2b29b3);
|
public static final Color BG_PURPLE = new Color(0x2b29b3);
|
||||||
public static final Color BG_OORANGE = new Color(0xff8c00);
|
public static final Color BG_ORANGE = new Color(0xff8c00);
|
||||||
public static final Color BG_BLUE = new Color(0x394aa8);
|
public static final Color BG_BLUE = new Color(0x394aa8);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast.icons;
|
package com.flaremicro.visualforecast.icons;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
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.Graphics2D;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.BlizzardIcon;
|
import com.flaremicro.visualforecast.icons.impl.BlizzardIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.ButterIcon;
|
import com.flaremicro.visualforecast.icons.impl.ButterIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.CloudIcon;
|
import com.flaremicro.visualforecast.icons.impl.CloudIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.FogIcon;
|
import com.flaremicro.visualforecast.icons.impl.FogIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.IceCubeIcon;
|
import com.flaremicro.visualforecast.icons.impl.IceCubeIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.InvalidIcon;
|
import com.flaremicro.visualforecast.icons.impl.InvalidIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.LightningIcon;
|
import com.flaremicro.visualforecast.icons.impl.LightningIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.LightningOverlay;
|
import com.flaremicro.visualforecast.icons.impl.LightningOverlay;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.LightningStormIcon;
|
import com.flaremicro.visualforecast.icons.impl.LightningStormIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.PartlyCloudyIcon;
|
import com.flaremicro.visualforecast.icons.impl.PartlyCloudyIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.RainIcon;
|
import com.flaremicro.visualforecast.icons.impl.RainIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.RainSnowIcon;
|
import com.flaremicro.visualforecast.icons.impl.RainSnowIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.SmallCloudIcon;
|
import com.flaremicro.visualforecast.icons.impl.SmallCloudIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.SnowIcon;
|
import com.flaremicro.visualforecast.icons.impl.SnowIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.SnowflakeIcon;
|
import com.flaremicro.visualforecast.icons.impl.SnowflakeIcon;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.impl.SunIcon;
|
import com.flaremicro.visualforecast.icons.impl.SunIcon;
|
||||||
|
|
||||||
public class IconProvider {
|
public class IconProvider {
|
||||||
|
|
||||||
@@ -51,7 +51,9 @@ public class IconProvider {
|
|||||||
public static final Icon HAIL = registerIcon(new BlizzardIcon(24, CLOUD, ICE_CUBE));
|
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 = registerIcon(new ButterIcon(25));
|
||||||
public static final Icon BUTTER_RAIN = registerIcon(new BlizzardIcon(26, CLOUD, BUTTER));
|
public static final Icon BUTTER_RAIN = registerIcon(new BlizzardIcon(26, CLOUD, BUTTER));
|
||||||
//public static final Icon INVALID_RAIN = registerIcon(new LightningOverlay(27, SUN, BUTTER, new BlizzardIcon(-1, LIGHTNING_BOLT, INVALID)));
|
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(28, SUN, BUTTER, new BlizzardIcon(-1, LIGHTNING_BOLT, INVALID)));
|
||||||
|
|
||||||
private static Icon registerIcon(Icon icon)
|
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.Graphics2D;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class BlizzardIcon extends Icon {
|
public class BlizzardIcon extends Icon {
|
||||||
private final Icon cloudIcon;
|
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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class ButterIcon extends Icon {
|
public class ButterIcon extends Icon {
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@ public class ButterIcon extends Icon {
|
|||||||
};
|
};
|
||||||
Color[] iceShineAnimation = new Color[] {
|
Color[] iceShineAnimation = new Color[] {
|
||||||
new Color(0xFFFFFF),
|
new Color(0xFFFFFF),
|
||||||
|
new Color(0xFFFFFF),
|
||||||
};
|
};
|
||||||
|
|
||||||
public ButterIcon(int id) {
|
public ButterIcon(int id) {
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
package com.flaremicro.visualforecast.icons.impl;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class CloudIcon extends Icon {
|
public class CloudIcon extends Icon {
|
||||||
private final Ellipse2D.Float[] cloudCircles = new Ellipse2D.Float[]{
|
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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class FogIcon extends Icon {
|
public class FogIcon extends Icon {
|
||||||
private final Icon cloudIcon;
|
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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class IceCubeIcon extends 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.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.DrawingUtil;
|
|
||||||
import com.flaremicro.flaretv.visualforecast.graphics.FontManager;
|
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||||
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class InvalidIcon extends Icon {
|
public class InvalidIcon extends Icon {
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ public class InvalidIcon extends Icon {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, float scale, int animationStep) {
|
public void drawIcon(Graphics2D g2d, float scale, int animationStep) {
|
||||||
|
g2d.getTransform();
|
||||||
g2d.setFont(fnt.deriveFont(0.8F));
|
g2d.setFont(fnt.deriveFont(0.8F));
|
||||||
g2d.translate(0.2F, 0.8F);
|
g2d.translate(0.2F, 0.8F);
|
||||||
DrawingUtil.drawOutlinedString(g2d, 0, 0, "X", Color.YELLOW, Color.BLACK, 1, 2/scale);
|
DrawingUtil.drawOutlinedString(g2d, 0, 0, "X", Color.YELLOW, Color.BLACK, 1, 2/scale);
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.flaremicro.flaretv.visualforecast.icons.impl;
|
package com.flaremicro.visualforecast.icons.impl;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
|
||||||
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class LightningCloudIcon extends 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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class LightningIcon extends Icon {
|
public class LightningIcon extends Icon {
|
||||||
Path2D.Float boltPath = new Path2D.Float();
|
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 java.awt.Graphics2D;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
|
||||||
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class LightningOverlay extends 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.BasicStroke;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
|
||||||
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class LightningStormIcon extends Icon {
|
public class LightningStormIcon extends Icon {
|
||||||
private final Icon boltIcon;
|
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 java.awt.Graphics2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class PartlyCloudyIcon extends Icon {
|
public class PartlyCloudyIcon extends Icon {
|
||||||
private Icon cloud;
|
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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class RainIcon extends Icon {
|
public class RainIcon extends Icon {
|
||||||
private final int rainCount;
|
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 java.awt.Graphics2D;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
|
||||||
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class RainSnowIcon extends Icon {
|
public class RainSnowIcon extends Icon {
|
||||||
private final Icon rainIcon;
|
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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class SleetIcon extends 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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
|
||||||
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class SmallCloudIcon extends Icon {
|
public class SmallCloudIcon extends Icon {
|
||||||
public SmallCloudIcon(int id) {
|
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.Graphics2D;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class SnowIcon extends Icon {
|
public class SnowIcon extends Icon {
|
||||||
private final Icon cloudIcon;
|
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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class SnowflakeIcon extends Icon {
|
public class SnowflakeIcon extends Icon {
|
||||||
Path2D.Float flakePath = new Path2D.Float();
|
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.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@@ -6,7 +6,7 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
|
|
||||||
import com.flaremicro.flaretv.visualforecast.icons.Icon;
|
import com.flaremicro.visualforecast.icons.Icon;
|
||||||
|
|
||||||
public class SunIcon extends Icon {
|
public class SunIcon extends Icon {
|
||||||
Path2D.Float sunPath = new Path2D.Float();
|
Path2D.Float sunPath = new Path2D.Float();
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.flaremicro.visualforecast.interfaces;
|
||||||
|
|
||||||
|
public interface Tickable {
|
||||||
|
public void tick();
|
||||||
|
}
|
||||||
7
vf1000.properties
Normal file
7
vf1000.properties
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#VisualForecast 1000 Properties file. Functional provider must be set for successful boot!
|
||||||
|
#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