Compare commits
1 Commits
feature/cu
...
feature/bu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81d81bebae |
@@ -3,6 +3,5 @@
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="lib" path="jlayer-1.0.4.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -24,6 +24,3 @@ bin/
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
*.dat
|
||||
|
||||
#Can contain copyrighted music!
|
||||
Music/
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
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.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
@@ -8,8 +7,5 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
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.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,13 +1,4 @@
|
||||
#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
|
||||
#Thu Mar 07 19:30:06 PST 2024
|
||||
towns-by-code=
|
||||
displays-enabled.town.vancouver.bc=
|
||||
towns-by-name-and-province=Vancouver,BC;Kamloops,BC;Kelowna,BC
|
||||
|
||||
339
LICENCE
339
LICENCE
@@ -1,339 +0,0 @@
|
||||
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.
|
||||
Binary file not shown.
BIN
jlayer-1.0.4.jar
BIN
jlayer-1.0.4.jar
Binary file not shown.
@@ -1,286 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.flaremicro.audio;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public interface AudioFinishedListener {
|
||||
public void audioFinished(String key, URL resource);
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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();
|
||||
}
|
||||
@@ -9,34 +9,10 @@ import java.util.Random;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.flaremicro.util.logging.LogFormatter;
|
||||
import com.flaremicro.util.logging.LogOutputStream;
|
||||
|
||||
|
||||
public class Util {
|
||||
public static final long INSTANCE_ID = Math.abs(new Random().nextLong());
|
||||
public static final String LOGGER_NAME = "VisualForecast 1000 Logger";
|
||||
|
||||
static
|
||||
{
|
||||
initLogger();
|
||||
}
|
||||
|
||||
public static Logger getDefaultLogger() {
|
||||
return Logger.getLogger(LOGGER_NAME);
|
||||
}
|
||||
|
||||
public static void initLogger() {
|
||||
Logger log = getDefaultLogger();
|
||||
log.setUseParentHandlers(false);
|
||||
ConsoleHandler handler = new ConsoleHandler();
|
||||
handler.setFormatter(new LogFormatter());
|
||||
log.addHandler(handler);
|
||||
System.setErr(new PrintStream(new LogOutputStream(log, java.util.logging.Level.SEVERE)));
|
||||
System.setOut(new PrintStream(new LogOutputStream(log, java.util.logging.Level.INFO)));
|
||||
log.info("Initialized logger successfully");
|
||||
log.info("Using native Java logger, ID 0J3QvtGCINGD0YHQtdC70LXRgdGBINCbNNCI");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse arguments, in arg=value format, or just arg for arguments with no
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.flaremicro.util.logging;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
|
||||
public class LogFormatter extends Formatter {
|
||||
String sep = System.getProperty("line.separator");
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
String fmessage = "";
|
||||
if(record.getLevel() == Level.SEVERE)
|
||||
fmessage += "["+format.format(System.currentTimeMillis())+"][SEVERE]";
|
||||
else if(record.getLevel() == Level.WARNING)
|
||||
fmessage += "["+format.format(System.currentTimeMillis())+"][WARNING]";
|
||||
else if(record.getLevel() == Level.INFO)
|
||||
fmessage += "["+format.format(System.currentTimeMillis())+"][INFO]";
|
||||
return fmessage += this.formatMessage(record) + sep;
|
||||
}
|
||||
public String getHead(Handler h) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getTail(Handler h) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.flaremicro.util.logging;
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class LogOutputStream extends OutputStream {
|
||||
|
||||
String buffer = "";
|
||||
Logger logger;
|
||||
Level level;
|
||||
|
||||
public LogOutputStream(Logger logger, Level level)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
buffer += (char)((byte)b);
|
||||
if(buffer.endsWith("\n") || buffer.endsWith("\r\n"))
|
||||
{
|
||||
buffer = buffer.replace("\r", "").replace("\n", "");
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
public void flush()
|
||||
{
|
||||
logger.log(level, buffer);
|
||||
buffer = "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
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,11 +1,11 @@
|
||||
package com.flaremicro.visualforecast;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.flaremicro.util.Util;
|
||||
@@ -18,17 +18,16 @@ public class PropertyManager {
|
||||
}
|
||||
|
||||
public PropertyManager(String filename) {
|
||||
propFile = new File("./" + filename + ".properties");
|
||||
propFile = new File("./"+filename+".properties");
|
||||
}
|
||||
|
||||
public boolean load() {
|
||||
synchronized(prop){
|
||||
InputStream reader = null;
|
||||
Reader reader = null;
|
||||
try
|
||||
{
|
||||
if (propFile.exists())
|
||||
{
|
||||
reader = new FileInputStream(propFile);
|
||||
reader = new FileReader(propFile);
|
||||
prop.load(reader);
|
||||
return true;
|
||||
}
|
||||
@@ -44,14 +43,12 @@ public class PropertyManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean store() {
|
||||
synchronized(prop){
|
||||
OutputStream writer = null;
|
||||
Writer writer = null;
|
||||
try
|
||||
{
|
||||
writer = new FileOutputStream(propFile);
|
||||
writer = new FileWriter(propFile);
|
||||
prop.store(writer, "VisualForecast 1000 Properties file. Functional provider must be set for successful boot!");
|
||||
return true;
|
||||
}
|
||||
@@ -65,47 +62,11 @@ public class PropertyManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String key, String fallback) {
|
||||
String result = prop.getProperty(key, fallback);
|
||||
System.out.println(result);
|
||||
prop.setProperty(key, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getStringNoSet(String key, String fallback) {
|
||||
String result = prop.getProperty(key, fallback);
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getInteger(String key, int fallback) {
|
||||
String resultString = getString(key, String.valueOf(fallback));
|
||||
int resultInt = fallback;
|
||||
try
|
||||
{
|
||||
resultInt = Integer.parseInt(resultString);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
}
|
||||
prop.setProperty(key, String.valueOf(resultInt));
|
||||
return resultInt;
|
||||
}
|
||||
|
||||
public void setString(String key, String value) {
|
||||
if (value == null)
|
||||
prop.remove(key);
|
||||
else prop.setProperty(key, value);
|
||||
}
|
||||
|
||||
public void setInteger(String key, int value) {
|
||||
prop.setProperty(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
public File getFile(String key, File fallback) {
|
||||
String resultString = getString(key, fallback.toString());
|
||||
if (resultString == null)
|
||||
return fallback;
|
||||
else return new File(resultString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -25,9 +26,9 @@ import static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||
|
||||
import com.flaremicro.util.Util;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.displays.BootupDisplay;
|
||||
import com.flaremicro.visualforecast.displays.DayForecastDisplay;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.displays.DisplayFactory;
|
||||
import com.flaremicro.visualforecast.displays.impl.BootupDisplay;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
@@ -40,7 +41,7 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private VolatileImage frameBuffer = null;
|
||||
private BufferedImage frameBuffer = null;
|
||||
|
||||
private Font font = null;
|
||||
|
||||
@@ -51,9 +52,6 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
|
||||
private Rectangle redrawBound = new Rectangle(0, 0, 1, 1);
|
||||
private Rectangle exclusiveRedrawBound = null;
|
||||
private Rectangle crawlBound = null;
|
||||
|
||||
private Rectangle currentBound = new Rectangle(0, 0, 0, 0);
|
||||
|
||||
private String currentTown = "";
|
||||
private String currentForecast = "";
|
||||
@@ -62,34 +60,21 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
|
||||
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 Rectangle nextRedrawBound = null;
|
||||
|
||||
public RenderPanel(PropertyManager propManager) {
|
||||
loadCrawlStrings();
|
||||
//loadCrawlStrings();
|
||||
this.addComponentListener(this);
|
||||
this.setDoubleBuffered(true);
|
||||
this.propManager = propManager;
|
||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
||||
currentFlavour.initDisplay(this, null, ticks, iconAnimationTicks);
|
||||
displayFactory = new DisplayFactory(propManager);
|
||||
audioManager = new AudioManager(propManager);
|
||||
//new Thread(new TickThread(this, 30)).start();
|
||||
}
|
||||
|
||||
private Graphics2D prepareFrameBuffer() {
|
||||
GraphicsConfiguration gc = this.getGraphicsConfiguration();
|
||||
if (frameBuffer == null || frameBuffer.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE)
|
||||
private Graphics2D getBuffer() {
|
||||
if (frameBuffer == null)
|
||||
{
|
||||
System.out.println("new image req'd");
|
||||
frameBuffer = gc.createCompatibleVolatileImage(W, H);
|
||||
frameBuffer = this.getGraphicsConfiguration().createCompatibleImage(W, H);
|
||||
}
|
||||
return (Graphics2D) frameBuffer.getGraphics();
|
||||
}
|
||||
@@ -115,54 +100,67 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d = prepareFrameBuffer();
|
||||
drawMainRegion(g2d);
|
||||
|
||||
if (currentFlavour != null)
|
||||
if(frameBuffer == null)
|
||||
{
|
||||
if (this.getBounds().equals(g.getClipBounds()))
|
||||
this.currentFlavour.drawDisplay(this, g2d, ticks, iconAnimationTicks);
|
||||
if (g.getClipBounds() != null)
|
||||
this.currentFlavour.drawBoundLimitedDisplay(this, g2d, g.getClipBounds(), ticks, iconAnimationTicks);
|
||||
initBuffer();
|
||||
}
|
||||
g2d.dispose();
|
||||
g.drawImage(frameBuffer, 0, 0, getWidth(), getHeight(), this);
|
||||
}
|
||||
|
||||
private void drawMainRegion(Graphics2D g2d) {
|
||||
public void initBuffer() {
|
||||
Graphics2D g2d = getBuffer();
|
||||
this.drawEntireMainRegion(g2d);
|
||||
g2d.dispose();
|
||||
}
|
||||
|
||||
private void drawTitleHeader(Graphics2D g2d)
|
||||
{
|
||||
g2d.setFont(font.deriveFont(24F));
|
||||
|
||||
g2d.setStroke(new BasicStroke(2));
|
||||
|
||||
g2d.setColor(BG_PURPLE);
|
||||
g2d.fillRect(0, 0, W, TOPBAR_HEIGHT);
|
||||
|
||||
g2d.setPaint(new GradientPaint(0, HEADERBAR_Y, BG_ORANGE, 0, HEADERBAR_Y + (HEADERBAR_HEIGHT + 10), BG_PURPLE));
|
||||
g2d.setPaint(new GradientPaint(0, HEADERBAR_Y, BG_OORANGE, 0, HEADERBAR_Y + (HEADERBAR_HEIGHT + 10), BG_PURPLE));
|
||||
g2d.shear(HEADERBAR_SHEAR, 0);
|
||||
g2d.fillRect(-HEADERBAR_OFFSET, HEADERBAR_Y, HEADERBAR_WIDTH, HEADERBAR_HEIGHT);
|
||||
|
||||
g2d.setPaint(new GradientPaint(0, HEADERBAR_Y, BG_PURPLE.brighter().brighter().brighter(), 0, HEADERBAR_Y + (HEADERBAR_HEIGHT + 10), BG_PURPLE));
|
||||
g2d.fillRect(W - TIMEBAR_WIDTH + TIMEBAR_OFFSET, TIMEBAR_Y, TIMEBAR_WIDTH, TIMEBAR_HEIGHT);
|
||||
g2d.shear(-HEADERBAR_SHEAR, 0);
|
||||
|
||||
g2d.setPaint(new GradientPaint(0, TOPBAR_HEIGHT, BG_PURPLE, 0, MAINBAR_HEIGHT, BG_ORANGE));
|
||||
g2d.fillRect(0, TOPBAR_HEIGHT, W, MAINBAR_HEIGHT);
|
||||
DrawingUtil.drawOutlinedString(g2d, 60, HEADERBAR_Y + 18, currentForecast, Color.WHITE, Color.BLACK, 2);
|
||||
|
||||
g2d.fillRect(0, TOPBAR_HEIGHT, W, MAINBAR_HEIGHT);
|
||||
// g2d.setColor(Color.GRAY);
|
||||
// g2d.drawRect(60, TOPBAR_HEIGHT+2, W-120, MAINBAR_HEIGHT-4);
|
||||
g2d.setFont(font.deriveFont(36F));
|
||||
DrawingUtil.drawOutlinedString(g2d, 60, HEADERBAR_Y + 52, currentTown, Color.YELLOW, Color.BLACK, 2);
|
||||
}
|
||||
|
||||
private void drawTimeHeader(Graphics2D g2d)
|
||||
{
|
||||
g2d.setFont(font.deriveFont(24F));
|
||||
g2d.setPaint(new GradientPaint(0, HEADERBAR_Y, BG_PURPLE.brighter().brighter().brighter(), 0, HEADERBAR_Y + (HEADERBAR_HEIGHT + 10), BG_PURPLE));
|
||||
g2d.shear(HEADERBAR_SHEAR, 0);
|
||||
g2d.fillRect(W - TIMEBAR_WIDTH + TIMEBAR_OFFSET, TIMEBAR_Y, TIMEBAR_WIDTH, TIMEBAR_HEIGHT);
|
||||
g2d.shear(-HEADERBAR_SHEAR, 0);
|
||||
|
||||
String dateString = DATE_FORMAT.format(System.currentTimeMillis()) + getDayOfMonthSuffix();
|
||||
String timeString = TIME_FORMAT.format(System.currentTimeMillis());
|
||||
|
||||
DrawingUtil.drawOutlinedString(g2d, 60, HEADERBAR_Y + 18, currentForecast, Color.WHITE, Color.BLACK, 2);
|
||||
int sw = g2d.getFontMetrics().stringWidth(dateString);
|
||||
DrawingUtil.drawOutlinedString(g2d, W - sw - 60, TIMEBAR_Y + 18, dateString, Color.WHITE, Color.BLACK, 2);
|
||||
sw = g2d.getFontMetrics().stringWidth(timeString);
|
||||
DrawingUtil.drawOutlinedString(g2d, W - sw - 60, TIMEBAR_Y + 36, timeString, Color.WHITE, Color.BLACK, 2);
|
||||
g2d.setFont(font.deriveFont(36F));
|
||||
DrawingUtil.drawOutlinedString(g2d, 60, HEADERBAR_Y + 52, currentTown, Color.YELLOW, Color.BLACK, 2);
|
||||
|
||||
}
|
||||
|
||||
private void drawHeader(Graphics2D g2d)
|
||||
{
|
||||
g2d.setColor(BG_PURPLE);
|
||||
g2d.fillRect(0, 0, W, TOPBAR_HEIGHT);
|
||||
drawTitleHeader(g2d);
|
||||
drawTimeHeader(g2d);
|
||||
}
|
||||
|
||||
public void drawMainGradient(Graphics2D g2d)
|
||||
{
|
||||
g2d.setPaint(new GradientPaint(0, TOPBAR_HEIGHT, BG_PURPLE, 0, MAINBAR_HEIGHT, BG_OORANGE));
|
||||
g2d.fillRect(0, TOPBAR_HEIGHT, W, MAINBAR_HEIGHT);
|
||||
}
|
||||
|
||||
private void drawCrawlBar(Graphics2D g2d){
|
||||
g2d.setStroke(new BasicStroke(2));
|
||||
g2d.setColor(BG_BLUE);
|
||||
g2d.fillRect(0, H - INFOBAR_HEIGHT, W, INFOBAR_HEIGHT);
|
||||
|
||||
@@ -171,12 +169,17 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
|
||||
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)
|
||||
/*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);
|
||||
}*/
|
||||
}
|
||||
|
||||
private void drawEntireMainRegion(Graphics2D g2d) {
|
||||
drawHeader(g2d);
|
||||
drawMainGradient(g2d);
|
||||
drawCrawlBar(g2d);
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@@ -187,59 +190,30 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
//Clock and icon animations, should use repaint regions later
|
||||
if (getWidth() > 0 && getHeight() > 0)
|
||||
{
|
||||
requestRepaint(this.redrawBound);
|
||||
Graphics2D g2d = this.getBuffer();
|
||||
this.drawTimeHeader(g2d);
|
||||
g2d.dispose();
|
||||
requestBoundedRepaint();
|
||||
//repaint(this.redrawBound);
|
||||
}
|
||||
}
|
||||
if (this.currentFlavour != null)
|
||||
{
|
||||
this.currentFlavour.tick(this, ticks, iconAnimationTicks);
|
||||
}
|
||||
if (this.crawlStrings != null && this.crawlStrings.length > 0 && this.crawlPosition + this.currentCrawlStringWidth <= 0)
|
||||
if(this.nextRedrawBound != null)
|
||||
{
|
||||
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)
|
||||
Graphics2D g2d = this.getBuffer();
|
||||
if(nextRedrawBound.equals(this.getBounds()))
|
||||
{
|
||||
this.crawlPosition -= 2;
|
||||
requestRepaint(crawlBound);
|
||||
this.currentFlavour.drawDisplay(this, g2d, ticks, iconAnimationTicks);
|
||||
}
|
||||
if (this.currentBound.width != 0)
|
||||
{
|
||||
repaint(currentBound);
|
||||
currentBound.width = 0;
|
||||
this.currentFlavour.drawBoundLimitedDisplay(this, g2d, nextRedrawBound, ticks, iconAnimationTicks);
|
||||
g2d.dispose();
|
||||
repaint(nextRedrawBound);
|
||||
}
|
||||
}
|
||||
|
||||
public BufferedImage getSnapshot() {
|
||||
return frameBuffer.getSnapshot();
|
||||
}
|
||||
|
||||
private void addRedrawBound(int x, int y, int w, int h, boolean isExclusive) {
|
||||
|
||||
float wScale = getWidth() / (float) W;
|
||||
@@ -256,6 +230,7 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
addRedrawBound(x, y, w, h, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
loseRedrawRegion();
|
||||
}
|
||||
@@ -263,24 +238,23 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
public void loseRedrawRegion() {
|
||||
this.redrawBound = null;
|
||||
addRedrawBound(W - TIMEBAR_WIDTH + TIMEBAR_OFFSET, TIMEBAR_Y, TIMEBAR_WIDTH, TIMEBAR_HEIGHT, false);
|
||||
float wScale = getWidth() / (float) W;
|
||||
float hScale = getHeight() / (float) H;
|
||||
this.crawlBound = new Rectangle((int) 0, (int) ((H - INFOBAR_HEIGHT + 8) * hScale), (int) (W * wScale), (int) (30 * hScale));
|
||||
|
||||
if (this.currentFlavour != null)
|
||||
this.currentFlavour.redrawRegionlost(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -300,25 +274,9 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
}
|
||||
|
||||
public void nextDisplay() {
|
||||
if (this.currentFlavour instanceof BootupDisplay)
|
||||
{
|
||||
audioManager.startPlaylist();
|
||||
}
|
||||
|
||||
this.currentFlavour = displayFactory.nextDisplay();
|
||||
|
||||
this.currentFlavour = new DayForecastDisplay();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
initBuffer();
|
||||
this.loseRedrawRegion();
|
||||
this.requestFullRepaint();
|
||||
}
|
||||
@@ -331,7 +289,26 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
this.currentForecast = currentForecast;
|
||||
}
|
||||
|
||||
private void loadCrawlStrings() {
|
||||
public void requestFullRepaint() {
|
||||
this.nextRedrawBound = this.getBounds();
|
||||
}
|
||||
|
||||
public void requestBoundedRepaint() {
|
||||
if(nextRedrawBound == null)
|
||||
nextRedrawBound = redrawBound;
|
||||
else
|
||||
nextRedrawBound.add(redrawBound);
|
||||
}
|
||||
|
||||
public void requestExclusiveBoundedRepaint() {
|
||||
if(nextRedrawBound == null)
|
||||
nextRedrawBound = exclusiveRedrawBound;
|
||||
else
|
||||
nextRedrawBound.add(exclusiveRedrawBound);
|
||||
//repaint(exclusiveRedrawBound);
|
||||
}
|
||||
|
||||
/*private void loadCrawlStrings() {
|
||||
File crawl = new File("./crawl.txt");
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
if (crawl != null)
|
||||
@@ -356,11 +333,7 @@ public class RenderPanel extends JPanel implements Tickable, ComponentListener {
|
||||
}
|
||||
}
|
||||
this.crawlStrings = strings.toArray(new String[strings.size()]);
|
||||
}
|
||||
|
||||
public void end() {
|
||||
this.audioManager.end();
|
||||
}
|
||||
}*/
|
||||
|
||||
/*@Override
|
||||
public void run() {
|
||||
|
||||
57
src/com/flaremicro/visualforecast/Timer.java
Normal file
57
src/com/flaremicro/visualforecast/Timer.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.flaremicro.visualforecast;
|
||||
/**
|
||||
* TImer class, deals with ticks, game speedup, and slowdown
|
||||
* @author Vulpovile
|
||||
*
|
||||
*/
|
||||
public class Timer {
|
||||
private final int ticksPerSecond;
|
||||
private long lastTickTime = 0;
|
||||
private long currentTime = 0;
|
||||
private long ticksPassed = 0;
|
||||
/**
|
||||
* Creates a timer with a set amount ticks per second
|
||||
* @param ticksPerSecond
|
||||
*/
|
||||
public Timer(int ticksPerSecond)
|
||||
{
|
||||
this.ticksPerSecond = 1000/ticksPerSecond;
|
||||
currentTime = System.currentTimeMillis();
|
||||
lastTickTime = currentTime;
|
||||
}
|
||||
/**
|
||||
* Resets the timer, prevents the superspeed bug when loading or generating levels
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
currentTime = System.currentTimeMillis();
|
||||
lastTickTime = currentTime;
|
||||
}
|
||||
/**
|
||||
* Ticks the timer and returns how many ticks were missed by the game (to catch up with bad framerates)
|
||||
* @return ticks passed
|
||||
*/
|
||||
public long tick()
|
||||
{
|
||||
if(ticksPassed > 0) ticksPassed--;
|
||||
currentTime = System.currentTimeMillis();
|
||||
if(lastTickTime < currentTime-ticksPerSecond)
|
||||
{
|
||||
ticksPassed = (currentTime-lastTickTime)/ticksPerSecond;
|
||||
lastTickTime = currentTime - (currentTime-lastTickTime)%ticksPerSecond;
|
||||
}
|
||||
if(ticksPassed > 200L)
|
||||
{
|
||||
System.out.println("Time moving too fast! Did the system time change or is the game overloaded?");
|
||||
System.out.println("Moving time forward " + ticksPassed + " ticks");
|
||||
ticksPassed = 0;
|
||||
}
|
||||
else if(ticksPassed < 0L)
|
||||
{
|
||||
System.out.println("Time moved backwards! Did the system time change?");
|
||||
System.out.println("Moving time backwards " + -ticksPassed + " ticks");
|
||||
ticksPassed = 0;
|
||||
}
|
||||
return ticksPassed;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,15 @@
|
||||
package com.flaremicro.visualforecast;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
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;
|
||||
|
||||
@@ -30,15 +23,12 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
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
|
||||
@@ -46,31 +36,8 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
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);
|
||||
frame.createBufferStrategy(2);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -83,11 +50,6 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
public void end() {
|
||||
if (executor != null)
|
||||
executor.end();
|
||||
if (timer != null)
|
||||
{
|
||||
timer.stop();
|
||||
}
|
||||
renderPane.end();
|
||||
if (forecastProviderManager != null)
|
||||
forecastProviderManager.end();
|
||||
propertyManager.store();
|
||||
@@ -96,21 +58,15 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
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);
|
||||
propertyManager.load();
|
||||
String forecastProvider = propertyManager.getString("forecast-provider-jar", "");
|
||||
propertyManager.store();
|
||||
ForecastProvider provider = forecastProviderManager.loadProvider(new File(forecastProvider));
|
||||
renderPane.setForecastProvider(provider);
|
||||
|
||||
}
|
||||
}.start();
|
||||
|
||||
@@ -120,58 +76,66 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
* Create the frame.
|
||||
*/
|
||||
public VisualForecastFrame() {
|
||||
propertyManager.load();
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 640, 480);
|
||||
setBounds(100, 100, 640 * 2, 480 * 2);
|
||||
renderPane = new RenderPanel(propertyManager);
|
||||
//renderPane.setBorder(null);
|
||||
//renderPane.setLayout(new BorderLayout(0, 0));
|
||||
add(renderPane);
|
||||
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)
|
||||
{
|
||||
@@ -190,6 +154,7 @@ public class VisualForecastFrame extends JFrame implements WindowListener, KeyLi
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
@@ -6,14 +6,12 @@ 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;
|
||||
@@ -29,7 +27,7 @@ public class ForecastProviderManager {
|
||||
}
|
||||
|
||||
public ForecastProvider loadProvider(File file) {
|
||||
Util.getDefaultLogger().info("Loading provider " + file.getName());
|
||||
//Util.getDefaultLogger().info("Loading provider " + file.getName());
|
||||
try
|
||||
{
|
||||
URLClassLoader classLoader = new URLClassLoader(new URL[] { file.toURI().toURL() });
|
||||
@@ -49,53 +47,53 @@ public class ForecastProviderManager {
|
||||
loadedProvider.forecastProviderManager = this;
|
||||
loadedProviderName = file.getName().substring(0, file.getName().length() - 4);
|
||||
loadedProvider.init();
|
||||
log.info("Provider " + file.getName() + " loaded! (Name set to " + loadedProviderName +")");
|
||||
//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?)");
|
||||
//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?)");
|
||||
//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:");
|
||||
//log.info("Provider " + file.getName() + " main class not found:");
|
||||
e.printStackTrace();
|
||||
log.info("(Is the information file invalid?)");
|
||||
//log.info("(Is the information file invalid?)");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed to read information file:");
|
||||
//log.info("Provider " + file.getName() + " failed to read information file:");
|
||||
e.printStackTrace();
|
||||
log.info("(Is the information file defined?)");
|
||||
//log.info("(Is the information file defined?)");
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed to instantiate main class:");
|
||||
//log.info("Provider " + file.getName() + " failed to instantiate main class:");
|
||||
e.printStackTrace();
|
||||
log.info("(Does main class not implement empty constructor?)");
|
||||
//log.info("(Does main class not implement empty constructor?)");
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed to instantiate main class:");
|
||||
//log.info("Provider " + file.getName() + " failed to instantiate main class:");
|
||||
e.printStackTrace();
|
||||
log.info("(Does the program have reflection permission?)");
|
||||
//log.info("(Does the program have reflection permission?)");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed while loading:");
|
||||
//log.info("Provider " + file.getName() + " failed while loading:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
log.info("Provider " + file.getName() + " failed catastrophically while loading:");
|
||||
//log.info("Provider " + file.getName() + " failed catastrophically while loading:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.visualforecast.displays.impl;
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
@@ -7,7 +7,6 @@ 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;
|
||||
@@ -65,7 +64,7 @@ public class BootupDisplay implements Display {
|
||||
IconProvider.drawIcon(g2d, IconProvider.INDEXED_ICONS[i], x, y, 80, iconTicks);
|
||||
}
|
||||
g2d.setFont(font.deriveFont(40F));
|
||||
//DrawingUtil.drawOutlinedString(g2d, RenderConstants.W / 2 - g2d.getFontMetrics().stringWidth("VisualForecast 1000") / 2, RenderConstants.H / 2, "VisualForecast 1000", Color.WHITE, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.W / 2 - g2d.getFontMetrics().stringWidth("VisualForecast 1000") / 2, RenderConstants.H / 2, "VisualForecast 1000", Color.WHITE, Color.BLACK, 2);
|
||||
}
|
||||
else if (this.ticks > 90)
|
||||
{
|
||||
@@ -103,9 +102,4 @@ public class BootupDisplay implements Display {
|
||||
this.forecastReady = provider.isForecastReady();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "bootup";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.flaremicro.visualforecast.displays.impl;
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.MAINBAR_HEIGHT;
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.Locale;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||
@@ -26,7 +25,7 @@ import com.flaremicro.visualforecast.graphics.FontManager;
|
||||
import com.flaremicro.visualforecast.graphics.RenderConstants;
|
||||
import com.flaremicro.visualforecast.icons.IconProvider;
|
||||
|
||||
public class SevenDayForecastDisplay implements Display {
|
||||
public class DayForecastDisplay implements Display {
|
||||
private int dayOffset = 0;
|
||||
private Font font;
|
||||
private Font smallFont;
|
||||
@@ -41,19 +40,14 @@ public class SevenDayForecastDisplay implements Display {
|
||||
private int ticksBeforeChange = 200;
|
||||
private int animationTicks = -1;
|
||||
|
||||
public SevenDayForecastDisplay() {
|
||||
public DayForecastDisplay() {
|
||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
||||
smallFont = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000 Small.ttf"));
|
||||
}
|
||||
|
||||
//TODO improve
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
if(details == null || details.getTownForecast() == null){
|
||||
renderer.nextDisplay();
|
||||
return;
|
||||
}
|
||||
else if (animationTicks >= 0)
|
||||
if (animationTicks >= 0)
|
||||
{
|
||||
animationTicks += 8;
|
||||
if (animationTicks > RenderConstants.W - 60)
|
||||
@@ -75,8 +69,6 @@ public class SevenDayForecastDisplay implements Display {
|
||||
ticksBeforeChange = 200;
|
||||
dayOffset = dayOffset + 4;
|
||||
if (dayOffset >= 8)
|
||||
{
|
||||
do
|
||||
{
|
||||
dayOffset = 0;
|
||||
townIndex++;
|
||||
@@ -92,8 +84,6 @@ public class SevenDayForecastDisplay implements Display {
|
||||
renderer.setCurrentTown(currentTown.getTownName());
|
||||
}
|
||||
}
|
||||
while (this.currentTown != null && !this.currentTown.isDisplaySupported(this.getDisplayName()));
|
||||
}
|
||||
|
||||
animationTicks = 0;
|
||||
if (prevBound != null)
|
||||
@@ -143,6 +133,7 @@ public class SevenDayForecastDisplay implements Display {
|
||||
|
||||
@Override
|
||||
public void drawDisplay(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
g2d.setStroke(new BasicStroke(2));
|
||||
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));
|
||||
@@ -185,11 +176,6 @@ public class SevenDayForecastDisplay implements Display {
|
||||
|
||||
}
|
||||
}
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
mainBound = renderer.getSnapshot().getSubimage(RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, 526, MAINBAR_HEIGHT - 28);
|
||||
mainBound.setAccelerationPriority(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawTownForecast(Graphics2D g2d, TownForecast townForecast, int dayOffset) {
|
||||
@@ -256,15 +242,17 @@ public class SevenDayForecastDisplay implements Display {
|
||||
|
||||
@Override
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
g2d.setStroke(new BasicStroke(2));
|
||||
if (details != null && currentTown != null && currentTown.getDayForecast() != null && currentTown.getDayForecast().length > 0)
|
||||
{
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
g2d.drawImage(mainBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||
}
|
||||
else
|
||||
{
|
||||
g2d.setClip(animationTicks, RenderConstants.TOPBAR_HEIGHT + 14, RenderConstants.SIDE_OFFSET, MAINBAR_HEIGHT - 28);
|
||||
renderer.drawMainGradient(g2d);
|
||||
g2d.setClip(animationTicks + RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, 526, MAINBAR_HEIGHT - 28);
|
||||
g2d.drawImage(prevBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
if (dayOffset == 0)
|
||||
@@ -306,9 +294,4 @@ public class SevenDayForecastDisplay implements Display {
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "7-day";
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,4 @@ public interface Display {
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g, Rectangle bounds, long ticks, int iconTicks);
|
||||
public void redrawRegionlost(RenderPanel renderer);
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderPanel, ForecastProvider forecastProvider);
|
||||
|
||||
public String getDisplayName();
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
55
src/com/flaremicro/visualforecast/displays/TextDisplay.java
Normal file
55
src/com/flaremicro/visualforecast/displays/TextDisplay.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.flaremicro.visualforecast.displays;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.graphics.DrawingUtil;
|
||||
|
||||
import static com.flaremicro.visualforecast.graphics.RenderConstants.*;
|
||||
|
||||
public class TextDisplay implements Display {
|
||||
|
||||
public TextDisplay(String title, String scrollText) {
|
||||
/*
|
||||
int w2 = g2d.getFontMetrics().stringWidth("EXTREME WEATHER ADVISORY");
|
||||
drawOutlinedString(g2d, (W >> 1) - (w2 >> 1), TOPBAR_HEIGHT + 48, "EXTREME WEATHER ADVISORY", Color.RED, Color.BLACK, 2);
|
||||
|
||||
g2d.setFont(font.deriveFont(30F));
|
||||
for (int i = 0; i < testString.length; i++)
|
||||
{
|
||||
drawOutlinedString(g2d, 90, TOPBAR_HEIGHT + 78 + 25 * i, testString[i], Color.WHITE, Color.BLACK, 1);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawDisplay(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
DrawingUtil.drawGradientRect(g2d, 60, TOPBAR_HEIGHT, W - 120, MAINBAR_HEIGHT, 20, BG_BLUE.brighter(), BG_BLUE.darker());
|
||||
g2d.setColor(BG_BLUE.brighter());
|
||||
g2d.drawRect(60 + STROKE_OFFSET, TOPBAR_HEIGHT + STROKE_OFFSET, W - 120 - STROKE_WIDTH, MAINBAR_HEIGHT - STROKE_WIDTH);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redrawRegionlost(RenderPanel renderer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
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,272 +0,0 @@
|
||||
package com.flaremicro.visualforecast.displays.impl;
|
||||
|
||||
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.Transparency;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.flaremicro.visualforecast.RenderPanel;
|
||||
import com.flaremicro.visualforecast.api.ForecastProvider;
|
||||
import com.flaremicro.visualforecast.displays.Display;
|
||||
import com.flaremicro.visualforecast.forecast.DayForecast;
|
||||
import com.flaremicro.visualforecast.forecast.ForecastDetails;
|
||||
import com.flaremicro.visualforecast.forecast.TownForecast;
|
||||
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 SevenDayForecastDisplayOldAnimation implements Display {
|
||||
private int dayOffset = 0;
|
||||
private Font font;
|
||||
private Font smallFont;
|
||||
private ForecastDetails details;
|
||||
private TownForecast currentTown = null;
|
||||
private TownForecast previousTown = null;
|
||||
private int townIndex;
|
||||
|
||||
private BufferedImage lastBound = null;
|
||||
|
||||
private int ticksBeforeChange = 200;
|
||||
private int animationTicks = -1;
|
||||
|
||||
public SevenDayForecastDisplayOldAnimation() {
|
||||
font = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000.ttf"));
|
||||
smallFont = FontManager.getInstance().getOrCreateFont(Font.TRUETYPE_FONT, this.getClass().getResource("/Star4000 Small.ttf"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(RenderPanel renderer, long ticks, int iconTicks) {
|
||||
if (animationTicks >= 0)
|
||||
{
|
||||
animationTicks += 8;
|
||||
if (animationTicks > RenderConstants.W - 60)
|
||||
{
|
||||
animationTicks = -1;
|
||||
renderer.requestFullRepaint();
|
||||
renderer.loseRedrawRegion();
|
||||
}
|
||||
else renderer.requestExclusiveBoundedRepaint();
|
||||
}
|
||||
else
|
||||
{
|
||||
ticksBeforeChange--;
|
||||
if (ticksBeforeChange < 0)
|
||||
{
|
||||
animationTicks = 0;
|
||||
lastBound = renderer.getGraphicsConfiguration().createCompatibleImage(526 * 2 + RenderConstants.SIDE_OFFSET, MAINBAR_HEIGHT - 28, Transparency.BITMASK);
|
||||
lastBound.setAccelerationPriority(1);
|
||||
ticksBeforeChange = 200;
|
||||
dayOffset = dayOffset + 4;
|
||||
if (dayOffset >= 8)
|
||||
{
|
||||
dayOffset = 0;
|
||||
townIndex++;
|
||||
if (townIndex >= details.getTownForecast().length)
|
||||
{
|
||||
renderer.nextDisplay();
|
||||
}
|
||||
else
|
||||
{
|
||||
previousTown = currentTown;
|
||||
currentTown = details.getTownForecast()[townIndex];
|
||||
renderer.setCurrentTown(currentTown.getTownName());
|
||||
}
|
||||
}
|
||||
renderer.loseRedrawRegion();
|
||||
renderer.requestFullRepaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initDisplay(RenderPanel renderer, ForecastProvider forecastProvider, long ticks, int iconTicks) {
|
||||
this.details = forecastProvider != null ? forecastProvider.getForecast() : null;
|
||||
renderer.setCurrentForecast("7 Day Forecast");
|
||||
if (details == null || details.getTownForecast() == null || details.getTownForecast().length <= 0)
|
||||
this.details = null;
|
||||
else
|
||||
{
|
||||
townIndex = 0;
|
||||
currentTown = details.getTownForecast()[townIndex];
|
||||
renderer.setCurrentTown(currentTown.getTownName());
|
||||
}
|
||||
redrawRegionlost(renderer);
|
||||
}
|
||||
|
||||
private String getDay(int offset) {
|
||||
if (offset == 0)
|
||||
return "Today";
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.HOUR, offset * 24);
|
||||
return cal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.US);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawDisplay(RenderPanel renderer, Graphics2D g2d, long ticks, int iconTicks) {
|
||||
if (details == null || currentTown == null || currentTown.getDayForecast() == null || currentTown.getDayForecast().length <= 0)
|
||||
{
|
||||
DrawingUtil.drawGradientRect(g2d, RenderConstants.SIDE_OFFSET + 80, RenderConstants.TOPBAR_HEIGHT + 90, RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 160, (RenderConstants.TOPBAR_HEIGHT + 20), 10, new Color(0x220088), new Color(0x110055));
|
||||
g2d.setFont(font.deriveFont(26F));
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 60 + (RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 120) / 2 - (g2d.getFontMetrics().stringWidth("Forcast data") / 2), RenderConstants.TOPBAR_HEIGHT + 130, "Forecast data", Color.WHITE, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + 60 + (RenderConstants.W - RenderConstants.SIDE_OFFSET * 2 - 120) / 2 - (g2d.getFontMetrics().stringWidth("temporarily unavailable") / 2), RenderConstants.TOPBAR_HEIGHT + 160, "temporarily unavailable", Color.WHITE, Color.BLACK, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
drawTownForecast(g2d, currentTown, dayOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics2D gimg = lastBound.createGraphics();
|
||||
gimg.translate(-RenderConstants.SIDE_OFFSET + 1, -RenderConstants.TOPBAR_HEIGHT - 14);
|
||||
gimg.setStroke(new BasicStroke(2));
|
||||
if (dayOffset == 0)
|
||||
{
|
||||
drawTownForecast(gimg, previousTown, dayOffset + 4);
|
||||
gimg.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
||||
drawTownForecast(gimg, currentTown, dayOffset);
|
||||
gimg.translate(RenderConstants.SIDE_OFFSET - RenderConstants.W, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawTownForecast(gimg, currentTown, dayOffset - 4);
|
||||
gimg.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
||||
drawTownForecast(gimg, currentTown, dayOffset);
|
||||
gimg.translate(RenderConstants.SIDE_OFFSET - RenderConstants.W, 0);
|
||||
}
|
||||
gimg.dispose();
|
||||
|
||||
g2d.translate(-animationTicks, 0);
|
||||
g2d.drawImage(lastBound, RenderConstants.SIDE_OFFSET, RenderConstants.TOPBAR_HEIGHT + 15, renderer);
|
||||
g2d.translate(animationTicks, 0);
|
||||
}
|
||||
}
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
lastBound = renderer.getSnapshot().getSubimage(RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, 526, MAINBAR_HEIGHT - 28);
|
||||
lastBound.setAccelerationPriority(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawTownForecast(Graphics2D g2d, TownForecast townForecast, int dayOffset) {
|
||||
for (int i = 0; i < Math.min(4, townForecast.getDayForecast().length - dayOffset); i++)
|
||||
{
|
||||
|
||||
DayForecast forecast = townForecast.getDayForecast()[i + dayOffset];
|
||||
g2d.setColor(RenderConstants.BG_BLUE.brighter().brighter());
|
||||
g2d.fillRect(RenderConstants.SIDE_OFFSET + 131 * i, RenderConstants.TOPBAR_HEIGHT + 15, 127, MAINBAR_HEIGHT - 30);
|
||||
|
||||
g2d.setPaint(new GradientPaint(0, RenderConstants.TOPBAR_HEIGHT + 40, new Color(0x7777FF), 0, (RenderConstants.TOPBAR_HEIGHT + 40) + MAINBAR_HEIGHT - 60, new Color(0x0000BB)));
|
||||
g2d.fillRoundRect(RenderConstants.SIDE_OFFSET + 5 + 131 * i, RenderConstants.TOPBAR_HEIGHT + 20, 117, MAINBAR_HEIGHT - 40, 10, 10);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRoundRect(RenderConstants.SIDE_OFFSET + 5 + 131 * i, RenderConstants.TOPBAR_HEIGHT + 20, 117, MAINBAR_HEIGHT - 40, 10, 10);
|
||||
g2d.drawRect(RenderConstants.SIDE_OFFSET + 131 * i, RenderConstants.TOPBAR_HEIGHT + 15, 127, MAINBAR_HEIGHT - 30);
|
||||
|
||||
String day = getDay(i + dayOffset);
|
||||
|
||||
g2d.setFont(font.deriveFont(26F));
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + (127 / 2) - (g2d.getFontMetrics().stringWidth(day) / 2), RenderConstants.TOPBAR_HEIGHT + 50, day, Color.WHITE, Color.BLACK, 2);
|
||||
|
||||
String statLine1;
|
||||
String statLine2;
|
||||
if (ValueCheck.valueNoData(forecast.weatherLine1))
|
||||
{
|
||||
statLine1 = "MISSING";
|
||||
statLine2 = "DATA";
|
||||
}
|
||||
else
|
||||
{
|
||||
statLine1 = forecast.weatherLine1;
|
||||
statLine2 = ValueCheck.valueNoData(forecast.weatherLine2) ? "" : forecast.weatherLine2;
|
||||
}
|
||||
FontMetrics metrics = g2d.getFontMetrics();
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + (127 / 2) - (metrics.stringWidth(statLine1) / 2), RenderConstants.TOPBAR_HEIGHT + 170, statLine1, Color.WHITE, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + (127 / 2) - (metrics.stringWidth(statLine2) / 2), RenderConstants.TOPBAR_HEIGHT + 200, statLine2, Color.WHITE, Color.BLACK, 2);
|
||||
|
||||
if (!ValueCheck.valueNoData(forecast.hiTemp) && !ValueCheck.valueNoData(forecast.loTemp))
|
||||
{
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 30 - (metrics.stringWidth(String.valueOf(forecast.hiTemp)) >> 1), RenderConstants.TOPBAR_HEIGHT + 295, String.valueOf(forecast.hiTemp), Color.WHITE, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 92 - (metrics.stringWidth(String.valueOf(forecast.loTemp)) >> 1), RenderConstants.TOPBAR_HEIGHT + 295, String.valueOf(forecast.loTemp), Color.WHITE, Color.BLACK, 2);
|
||||
|
||||
g2d.setFont(smallFont.deriveFont(24F));
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 20, RenderConstants.TOPBAR_HEIGHT + 270, "Hi", Color.RED, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + 82, RenderConstants.TOPBAR_HEIGHT + 270, "Lo", Color.CYAN, Color.BLACK, 2);
|
||||
}
|
||||
|
||||
if (!ValueCheck.valueNoData(forecast.percipPercent))
|
||||
{
|
||||
String formattedPercent = String.format("%.2f%%", forecast.percipPercent);
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + (127 / 2) - (g2d.getFontMetrics().stringWidth("Precip.") / 2), RenderConstants.TOPBAR_HEIGHT + 230, "Precip.", Color.YELLOW, Color.BLACK, 2);
|
||||
DrawingUtil.drawOutlinedString(g2d, RenderConstants.SIDE_OFFSET + (131 * i) + (127 / 2) - (g2d.getFontMetrics().stringWidth(formattedPercent) / 2), RenderConstants.TOPBAR_HEIGHT + 245, formattedPercent, Color.WHITE, Color.BLACK, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBoundLimitedDisplay(RenderPanel renderer, Graphics2D g2d, Rectangle bounds, long ticks, int iconTicks) {
|
||||
if (details != null && currentTown != null && currentTown.getDayForecast() != null && currentTown.getDayForecast().length > 0)
|
||||
{
|
||||
if (animationTicks < 0)
|
||||
{
|
||||
g2d.drawImage(lastBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||
}
|
||||
else
|
||||
{
|
||||
g2d.translate(-animationTicks, 0);
|
||||
g2d.drawImage(lastBound, RenderConstants.SIDE_OFFSET - 1, RenderConstants.TOPBAR_HEIGHT + 14, renderer);
|
||||
if (dayOffset == 0)
|
||||
{
|
||||
|
||||
drawIcons(g2d, previousTown, dayOffset + 4, iconTicks);
|
||||
g2d.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawIcons(g2d, currentTown, dayOffset - 4, iconTicks);
|
||||
g2d.translate(RenderConstants.W - (RenderConstants.SIDE_OFFSET), 0);
|
||||
drawIcons(g2d, currentTown, dayOffset, iconTicks);
|
||||
}
|
||||
g2d.translate(animationTicks + (RenderConstants.SIDE_OFFSET) - RenderConstants.W, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawIcons(Graphics2D g2d, TownForecast currentTown, int dayOffset, int iconTicks) {
|
||||
|
||||
for (int i = 0; i < Math.min(4, currentTown.getDayForecast().length - dayOffset); i++)
|
||||
{
|
||||
DayForecast forecast = currentTown.getDayForecast()[i + dayOffset];
|
||||
IconProvider.drawIcon(g2d, IconProvider.INDEXED_ICONS[forecast.iconId & IconProvider.INDEXED_ICONS.length - 1], RenderConstants.SIDE_OFFSET + (131 * i) + 24, RenderConstants.TOPBAR_HEIGHT + 60, 80, iconTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redrawRegionlost(RenderPanel renderer) {
|
||||
if (animationTicks >= 0)
|
||||
renderer.addRedrawBound(0, RenderConstants.TOPBAR_HEIGHT, RenderConstants.W, RenderConstants.MAINBAR_HEIGHT);
|
||||
else renderer.addRedrawBound(RenderConstants.SIDE_OFFSET + 24, RenderConstants.TOPBAR_HEIGHT + 60, 604, 84);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyForecastProviderUpdate(RenderPanel renderer, ForecastProvider forecastProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "7-day-old";
|
||||
}
|
||||
}
|
||||
@@ -1,232 +0,0 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
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,7 +1,5 @@
|
||||
package com.flaremicro.visualforecast.forecast;
|
||||
|
||||
import com.flaremicro.visualforecast.icons.IconProvider;
|
||||
|
||||
public class DayForecast {
|
||||
public byte hiTemp;
|
||||
public byte loTemp;
|
||||
@@ -13,7 +11,7 @@ public class DayForecast {
|
||||
public DayForecast(byte hiTemp, byte loTemp, byte iconId, String weatherLine1, String weatherLine2, float percipPercent){
|
||||
this.hiTemp = hiTemp;
|
||||
this.loTemp = loTemp;
|
||||
this.iconId = (byte)(iconId % IconProvider.INDEXED_ICONS.length);
|
||||
this.iconId = (byte)(iconId & 63);
|
||||
this.weatherLine1 = weatherLine1;
|
||||
this.weatherLine2 = weatherLine2;
|
||||
this.percipPercent = percipPercent;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
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,24 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,13 @@
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
private final String townName;
|
||||
private final DayForecast[] dayForecast;
|
||||
|
||||
public DayForecast[] getDayForecast() {
|
||||
return dayForecast;
|
||||
@@ -51,12 +16,4 @@ public class TownForecast {
|
||||
public String getTownName() {
|
||||
return townName;
|
||||
}
|
||||
|
||||
public DetailedForecast[] getDetailedForecast() {
|
||||
return detailedForecast;
|
||||
}
|
||||
|
||||
public void setDetailedForecast(DetailedForecast[] detailedForecast) {
|
||||
this.detailedForecast = detailedForecast;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ public class RenderConstants {
|
||||
|
||||
|
||||
public static final Color BG_PURPLE = new Color(0x2b29b3);
|
||||
public static final Color BG_ORANGE = new Color(0xff8c00);
|
||||
public static final Color BG_OORANGE = new Color(0xff8c00);
|
||||
public static final Color BG_BLUE = new Color(0x394aa8);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class IconProvider {
|
||||
public static final Icon BUTTER_RAIN = registerIcon(new BlizzardIcon(26, CLOUD, BUTTER));
|
||||
public static final Icon RAIN_STORM = registerIcon(new LightningOverlay(27, SMALL_CLOUD, LIGHTNING_BOLT, RAIN_HEAVY));
|
||||
|
||||
public static final Icon INVALID_RAIN = registerIcon(new LightningOverlay(28, SUN, BUTTER, new BlizzardIcon(-1, LIGHTNING_BOLT, INVALID)));
|
||||
//public static final Icon INVALID_RAIN = registerIcon(new LightningOverlay(27, SUN, BUTTER, new BlizzardIcon(-1, LIGHTNING_BOLT, INVALID)));
|
||||
|
||||
private static Icon registerIcon(Icon icon)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,6 @@ public class ButterIcon extends Icon {
|
||||
};
|
||||
Color[] iceShineAnimation = new Color[] {
|
||||
new Color(0xFFFFFF),
|
||||
new Color(0xFFFFFF),
|
||||
};
|
||||
|
||||
public ButterIcon(int id) {
|
||||
|
||||
@@ -19,7 +19,6 @@ public class InvalidIcon extends Icon {
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, float scale, int animationStep) {
|
||||
g2d.getTransform();
|
||||
g2d.setFont(fnt.deriveFont(0.8F));
|
||||
g2d.translate(0.2F, 0.8F);
|
||||
DrawingUtil.drawOutlinedString(g2d, 0, 0, "X", Color.YELLOW, Color.BLACK, 1, 2/scale);
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
#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
|
||||
#Thu Mar 07 19:30:06 PST 2024
|
||||
forecast-provider-jar=CanadaDatamartProvider.jar
|
||||
|
||||
Reference in New Issue
Block a user