Start changing tree structure

This commit is contained in:
XDrake99 2017-01-16 17:57:09 +01:00
parent e8f74c63e6
commit d799c2cf7d
30 changed files with 1906 additions and 721 deletions

View File

@ -3,29 +3,29 @@
<classpathentry excluding="org/warp/picalculator/deprecatedmath/" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="lib" path="D:/Users/Andrea/Downloads/objenesis-2.4-bin/objenesis-2.4/objenesis-2.4.jar" sourcepath="D:/Users/Andrea/Downloads/objenesis-2.4-bin/objenesis-2.4/objenesis-2.4-sources.jar">
<classpathentry kind="lib" path="libs/pi4j-1.1/pi4j-core.jar" sourcepath="libs/pi4j-1.1/pi4j-core-sources.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/D:/Users/Andrea/Downloads/objenesis-2.4-bin/objenesis-2.4/objenesis-2.4-javadoc.jar!/"/>
<attribute name="javadoc_location" value="jar:platform:/resource/PICalculator/libs/pi4j-1.1/pi4j-core-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-core.jar" sourcepath="G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-core-sources.jar">
<classpathentry kind="lib" path="libs/pi4j-1.1/pi4j-device.jar" sourcepath="libs/pi4j-1.1/pi4j-device-sources.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-core-javadoc.jar!/"/>
<attribute name="javadoc_location" value="jar:platform:/resource/PICalculator/libs/pi4j-1.1/pi4j-device-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-device.jar" sourcepath="G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-device-sources.jar">
<classpathentry kind="lib" path="libs/pi4j-1.1/pi4j-gpio-extension.jar" sourcepath="libs/pi4j-1.1/pi4j-gpio-extension-sources.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-device-javadoc.jar!/"/>
<attribute name="javadoc_location" value="jar:platform:/resource/PICalculator/libs/pi4j-1.1/pi4j-gpio-extension-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-gpio-extension.jar" sourcepath="G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-gpio-extension-sources.jar">
<classpathentry kind="lib" path="libs/pi4j-1.1/pi4j-service.jar" sourcepath="libs/pi4j-1.1/pi4j-service-sources.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-gpio-extension-javadoc.jar!/"/>
<attribute name="javadoc_location" value="jar:platform:/resource/PICalculator/libs/pi4j-1.1/pi4j-service-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-service.jar" sourcepath="G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-service-sources.jar">
<classpathentry kind="lib" path="libs/objenesis-2.4/objenesis-2.4.jar" sourcepath="libs/objenesis-2.4/objenesis-2.4-sources.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/G:/Users/Andrea/Downloads/pi4j-1.1/pi4j-1.1/lib/pi4j-service-javadoc.jar!/"/>
<attribute name="javadoc_location" value="jar:platform:/resource/PICalculator/libs/objenesis-2.4/objenesis-2.4-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>

Binary file not shown.

29
libs/lwjgl/LICENSE Normal file
View File

@ -0,0 +1,29 @@
Copyright (c) 2012-present Lightweight Java Game Library
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name Lightweight Java Game Library nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

1
libs/lwjgl/build.txt Normal file
View File

@ -0,0 +1 @@
LWJGL 3.1.1 build 16

View File

@ -0,0 +1,14 @@
Copyright (c) 2007-2015 Daniel Adler <dadler AT uni-goettingen DOT de>,
Tassilo Philipp <tphilipp AT potion-studios DOT com>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -0,0 +1,21 @@
Copyright (c) 2002-2006 Marcus Geelnard
Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would
be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.

View File

@ -0,0 +1,23 @@
Copyright (C) 2002-2014 Jason Evans <jasone@canonware.com>.
All rights reserved.
Copyright (C) 2007-2012 Mozilla Foundation. All rights reserved.
Copyright (C) 2009-2014 Facebook, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice(s),
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice(s),
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,22 @@
/*
** Copyright (c) 2013-2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/

202
libs/objenesis-2.4/LICENSE Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,9 @@
// ------------------------------------------------------------------
// NOTICE file corresponding to the section 4d of The Apache License,
// Version 2.0, in this case for Objenesis
// ------------------------------------------------------------------
Objenesis
Copyright 2006-2016 Joe Walnes, Henri Tremblay, Leonardo Mesquita

165
libs/pi4j-1.1/LICENSE.txt Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser 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
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

33
libs/pi4j-1.1/NOTICE.txt Normal file
View File

@ -0,0 +1,33 @@
=========================================================================
Pi4J :: Java library for Raspberry Pi
=========================================================================
Pi4J Library
Copyright (C) 2012-2016 Pi4J.com
This product includes software developed at:
The Pi4J Project (http://www.pi4j.com/).
This product was originally authored by: Robert Savage
This software is licensed under the GNU LGPLv3 license.
More information about licensing terms can be found at:
http://pi4j.com/license.html
Additional information about this project and its authors can be found at:
- http://www.pi4j.com/
- http://www.raspicentral.com
- http://www.savagehomeautomation.com
This software compiles against libraries from the WiringPi project.
The Wiring Pi project is provided by Gordon Henderson and is available
from
http://wiringpi.com/
The WiringPi project is licensed under the GNU LGPLv3 license
http://www.gnu.org/licenses/lgpl.html
=========================================================================
Subject to the terms of the software license, this NOTICE file must be
included in any Derivative Works that You distribute as a readable copy.
(Section 4d)

Binary file not shown.

View File

@ -2,20 +2,23 @@ package org.warp.picalculator;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.PIDisplay;
import org.warp.picalculator.screens.KeyboardDebugScreen;
import org.warp.picalculator.screens.LoadingScreen;
import com.pi4j.wiringpi.Gpio;
public class Main {
public static int[] screenPos = new int[] { 55, 0 };
public static int[] screenPos = new int[] { 0, 0 };
public static final int[] screenSize = new int[] { 480, 320 };
public static final int screenScale = 1;
public static final boolean zoomed = true;
public static Main instance;
public static boolean haxMode = true;
public Main() throws InterruptedException {
instance = this;
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
Thread.currentThread().setName("Main thread");
beforeStart();
new PIDisplay(new LoadingScreen());
Utils.debug.println("Shutdown...");
@ -33,6 +36,7 @@ public class Main {
screenPos = new int[]{0,0};
Utils.debugOn = true;
}
Utils.debugThirdScreen = Utils.debugOn & false;
PIDisplay.setBrightness(0.5f);
}

View File

@ -10,6 +10,7 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.nevec.rjm.BigDecimalMath;
@ -44,6 +45,7 @@ public class Utils {
public static DebugStream debug = new DebugStream();
public static boolean debugOn;
public static boolean debugThirdScreen;
public static Cloner cloner = new Cloner();
@ -486,4 +488,20 @@ public class Utils {
public static boolean isIntegerValue(BigDecimal bd) {
return bd.signum() == 0 || bd.scale() <= 0 || bd.stripTrailingZeros().scale() <= 0;
}
public static <T> String arrayToString(T... data) {
String sdata = "";
for (T o : data) {
sdata += ","+o.toString();
}
return sdata.substring(1);
}
public static String arrayToString(boolean... data) {
String sdata = "";
for (boolean o : data) {
sdata += (o)?1:0;
}
return sdata;
}
}

View File

@ -1,11 +1,17 @@
package org.warp.picalculator.device;
import java.awt.event.KeyEvent;
import java.util.Arrays;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.device.chip.ParallelToSerial;
import org.warp.picalculator.device.chip.SerialToParallel;
import org.warp.picalculator.device.graphicengine.Display;
import org.warp.picalculator.device.graphicengine.Screen;
import org.warp.picalculator.math.AngleMode;
import org.warp.picalculator.math.Calculator;
import org.warp.picalculator.screens.KeyboardDebugScreen;
import org.warp.picalculator.screens.MarioScreen;
import com.pi4j.wiringpi.Gpio;
@ -26,25 +32,40 @@ public class Keyboard {
private static volatile boolean[][] precedentStates = new boolean[8][8];
public static volatile boolean[][] debugKeysDown = new boolean[8][8];
public static volatile KeyEvent debugKeyEvent;
public static void startKeyboard() {
if (Utils.debugOn == false) {
Gpio.pinMode(CLK_INH_pin, Gpio.OUTPUT);
Gpio.pinMode(RCK_pin, Gpio.OUTPUT);
Gpio.pinMode(SER_pin, Gpio.OUTPUT);
Gpio.pinMode(SH_LD_pin, Gpio.OUTPUT);
Gpio.pinMode(SCK_and_CLK_pin, Gpio.OUTPUT);
Gpio.pinMode(QH_pin, Gpio.INPUT);
Gpio.digitalWrite(CLK_INH_pin, false);
Gpio.digitalWrite(RCK_pin, false);
Gpio.digitalWrite(SER_pin, false);
Gpio.digitalWrite(SH_LD_pin, false);
Gpio.digitalWrite(SCK_and_CLK_pin, false);
Gpio.digitalWrite(QH_pin, false);
Thread kt = new Thread(()->{
Thread kt = new Thread(()->{
if (Utils.debugOn) {
try {
while(true) {
if (debugKeyEvent != null) {
debugKeyPressed(debugKeyEvent);
debugKeyEvent = null;
}
Thread.sleep(50);
}
} catch (InterruptedException e) {
}
} else {
Gpio.pinMode(CLK_INH_pin, Gpio.OUTPUT);
Gpio.pinMode(RCK_pin, Gpio.OUTPUT);
Gpio.pinMode(SER_pin, Gpio.OUTPUT);
Gpio.pinMode(SH_LD_pin, Gpio.OUTPUT);
Gpio.pinMode(SCK_and_CLK_pin, Gpio.OUTPUT);
Gpio.pinMode(QH_pin, Gpio.INPUT);
Gpio.digitalWrite(CLK_INH_pin, false);
Gpio.digitalWrite(RCK_pin, false);
Gpio.digitalWrite(SER_pin, false);
Gpio.digitalWrite(SH_LD_pin, false);
Gpio.digitalWrite(SCK_and_CLK_pin, false);
Gpio.digitalWrite(QH_pin, false);
SerialToParallel chip1 = new SerialToParallel(RCK_pin, SCK_and_CLK_pin /*SCK*/, SER_pin);
ParallelToSerial chip2 = new ParallelToSerial(SH_LD_pin, CLK_INH_pin, QH_pin, SCK_and_CLK_pin/*CLK*/);
KeyboardDebugScreen.log("Started keyboard system");
while(true) {
boolean[] data;
for (int col = 0; col < 8; col++) {
@ -52,25 +73,306 @@ public class Keyboard {
data[col] = true;
chip1.write(data);
data = new boolean[8];
data = chip2.read();
KeyboardDebugScreen.ks[col] = data;
for (int row = 0; row < 8; row++) {
if (data[row] == true && precedentStates[row][col] == false) {
System.out.println("Pressed button at "+(row+1) +", "+(col+1));
KeyboardDebugScreen.log("Pressed button at "+(row+1) +", "+(col+1));
keyPressedRaw(row+1, col+1);
} else if (data[row] == false && precedentStates[row][col] == true) {
keyReleasedRaw(row+1, col+1);
KeyboardDebugScreen.log("Released button at "+(row+1) +", "+(col+1));
}
precedentStates[row][col] = data[row];
}
}
}
});
kt.setName("Keyboard thread");
kt.setPriority(Thread.MIN_PRIORITY);
kt.setDaemon(true);
kt.start();
}
});
kt.setName("Keyboard thread");
kt.setPriority(Thread.MIN_PRIORITY);
kt.setDaemon(true);
kt.start();
}
private static void debugKeyPressed(KeyEvent arg0) {
switch (arg0.getKeyCode()) {
case KeyEvent.VK_ESCAPE:
Keyboard.keyPressed(Key.POWER);
break;
case KeyEvent.VK_S:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.ARCSINE);
} else if (Keyboard.alpha) {
Keyboard.keyPressed(Key.NONE);
} else {
Keyboard.keyPressed(Key.SINE);
}
break;
case KeyEvent.VK_C:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.ARCCOSINE);
} else if (Keyboard.alpha) {
Keyboard.keyPressed(Key.NONE);
} else {
Keyboard.keyPressed(Key.COSINE);
}
break;
case KeyEvent.VK_T:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.ARCTANGENT);
} else if (Keyboard.alpha) {
Keyboard.keyPressed(Key.NONE);
} else {
Keyboard.keyPressed(Key.TANGENT);
}
break;
case KeyEvent.VK_D:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.debug_DEG);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_R:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.debug_RAD);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_G:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.debug_GRA);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_X:
if (Keyboard.alpha) {
Keyboard.keyPressed(Key.LETTER_X);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_P:
if (Keyboard.alpha) {
Keyboard.keyPressed(Key.PI);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_Y:
if (Keyboard.alpha) {
Keyboard.keyPressed(Key.LETTER_Y);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_B:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.BRIGHTNESS_CYCLE_REVERSE);
} else if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.BRIGHTNESS_CYCLE);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_ENTER:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.SIMPLIFY);
} else if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.SOLVE);
} else {
Keyboard.keyPressed(Key.NONE);
}
int row = 2;
int col = 1;
Keyboard.debugKeysDown[row-1][col-1] = true;
break;
case KeyEvent.VK_1:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM1);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_2:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM2);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_3:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM3);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_4:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM4);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_5:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM5);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_6:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM6);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_7:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM7);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_8:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM8);
} else if (Keyboard.shift) {
Keyboard.keyPressed(Key.PARENTHESIS_OPEN);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_9:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM9);
} else if (Keyboard.shift) {
Keyboard.keyPressed(Key.PARENTHESIS_CLOSE);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_0:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM0);
} else if (Keyboard.shift) {
Keyboard.keyPressed(Key.EQUAL);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_ADD:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.PLUS);
} else if (Keyboard.shift) {
Keyboard.keyPressed(Key.PLUS_MINUS);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_SUBTRACT:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.MINUS);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_MULTIPLY:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.MULTIPLY);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_DIVIDE:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.DIVIDE);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_BACK_SPACE:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.DELETE);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_DELETE:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.RESET);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_LEFT:
//LEFT
row = 2;
col = 3;
Keyboard.debugKeysDown[row-1][col-1] = true;
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.LEFT);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_RIGHT:
//RIGHT
row = 2;
col = 5;
Keyboard.debugKeysDown[row-1][col-1] = true;
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.RIGHT);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_NUMPAD4:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.HISTORY_BACK);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_NUMPAD6:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.HISTORY_FORWARD);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_PERIOD:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.DOT);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_SHIFT:
Keyboard.keyPressed(Key.SHIFT);
break;
case KeyEvent.VK_A:
Keyboard.keyPressed(Key.ALPHA);
break;
case KeyEvent.VK_NUMPAD1:
Keyboard.keyPressed(Key.SQRT);
break;
case KeyEvent.VK_NUMPAD2:
Keyboard.keyPressed(Key.ROOT);
break;
case KeyEvent.VK_NUMPAD3:
Keyboard.keyPressed(Key.POWER_OF_2);
break;
case KeyEvent.VK_NUMPAD5:
Keyboard.keyPressed(Key.POWER_OF_x);
break;
}
}
@ -83,12 +385,16 @@ public class Keyboard {
}
private static void keyReleasedRaw(int row, int col) {
KeyboardDebugScreen.keyX = row;
KeyboardDebugScreen.keyY = col;
if (row == 1 && col == 1) {
keyReleased(Key.BRIGHTNESS_CYCLE);
//keyReleased(Key.BRIGHTNESS_CYCLE);
}
}
static void keyPressedRaw(int row, int col) {
KeyboardDebugScreen.keyX = row;
KeyboardDebugScreen.keyY = col;
if (row == 1 && col == 1) {
keyPressed(Key.SHIFT);
} else if (row == 1 && col == 2) {
@ -111,7 +417,7 @@ public class Keyboard {
}
} else if (row == 2 && col == 8) {
if (shift) {
keyPressed(Key.NONE);
keyPressed(Key.PI);
} else if (alpha) {
keyPressed(Key.DRG_CYCLE);
} else {
@ -389,34 +695,6 @@ public class Keyboard {
break;
case NONE:
break;
case debug_DEG:
if (Calculator.angleMode.equals("deg") == false) {
refresh = true;
}
Calculator.angleMode = "deg";
break;
case debug_RAD:
if (Calculator.angleMode.equals("rad") == false) {
refresh = true;
}
Calculator.angleMode = "rad";
break;
case debug_GRA:
if (Calculator.angleMode.equals("gra") == false) {
refresh = true;
}
Calculator.angleMode = "gra";
break;
case DRG_CYCLE:
if (Calculator.angleMode.equals("deg") == true) {
Calculator.angleMode = "rad";
} else if (Calculator.angleMode.equals("rad") == true) {
Calculator.angleMode = "gra";
} else {
Calculator.angleMode = "deg";
}
refresh = true;
break;
case LETTER_X:
letterPressed('X');
break;
@ -498,14 +776,22 @@ public class Keyboard {
PARENTHESIS_OPEN, PARENTHESIS_CLOSE, PLUS, MINUS, PLUS_MINUS, MULTIPLY, DIVIDE, EQUAL,
DELETE, RESET, LEFT, RIGHT, UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5,
SQRT, ROOT, POWER_OF_2, POWER_OF_x,
SINE, COSINE, TANGENT, ARCSINE, ARCCOSINE, ARCTANGENT
SINE, COSINE, TANGENT, ARCSINE, ARCCOSINE, ARCTANGENT, PI
}
}
/*
-coord-
NORMAL
SHIFT
ALPHA
-------
|1,1---|1,2---|------|1,4---|------|------|1,7---|
|SHIFT |ALPHA |------| ^ |------|------|+BRIGH|
|SHIFT |ALPHA |------| |------|------|-BRIGH|
@ -540,7 +826,7 @@ public class Keyboard {
| | | | | |
|5,8---|4,8---|3,8---|2,8---|1,8-----------------|
| 0 | . | | | SOLVE |
| | | | | SIMPLIFY |
| | | |PI | SIMPLIFY |
| X | Y | Z |DRGCYCL| |
|------|------|------|------|--------------------|

View File

@ -23,6 +23,7 @@ import org.warp.picalculator.Utils;
import org.warp.picalculator.device.graphicengine.Display;
import org.warp.picalculator.device.graphicengine.RAWFont;
import org.warp.picalculator.device.graphicengine.Screen;
import org.warp.picalculator.math.AngleMode;
import org.warp.picalculator.math.Calculator;
import com.pi4j.wiringpi.Gpio;
@ -89,13 +90,13 @@ public final class PIDisplay {
public void setScreen(Screen screen) {
if (screen.initialized == false) {
if (screen.canBeInHistory) {
Calculator.currentSession = 0;
for (int i = Calculator.sessions.length - 1; i >= 1; i--) {
Calculator.sessions[i] = Calculator.sessions[i - 1];
PIDisplay.currentSession = 0;
for (int i = PIDisplay.sessions.length - 1; i >= 1; i--) {
PIDisplay.sessions[i] = PIDisplay.sessions[i - 1];
}
Calculator.sessions[0] = screen;
PIDisplay.sessions[0] = screen;
} else {
Calculator.currentSession = -1;
PIDisplay.currentSession = -1;
}
}
screen.d = this;
@ -114,11 +115,11 @@ public final class PIDisplay {
public void replaceScreen(Screen screen) {
if (screen.initialized == false) {
if (screen.canBeInHistory) {
Calculator.sessions[Calculator.currentSession] = screen;
PIDisplay.sessions[PIDisplay.currentSession] = screen;
} else {
Calculator.currentSession = -1;
for (int i = 0; i < Calculator.sessions.length - 2; i++) {
Calculator.sessions[i] = Calculator.sessions[i + 1];
PIDisplay.currentSession = -1;
for (int i = 0; i < PIDisplay.sessions.length - 2; i++) {
PIDisplay.sessions[i] = PIDisplay.sessions[i + 1];
}
}
}
@ -136,13 +137,13 @@ public final class PIDisplay {
}
public boolean canGoBack() {
if (Calculator.currentSession == -1) {
return Calculator.sessions[0] != null;
if (PIDisplay.currentSession == -1) {
return PIDisplay.sessions[0] != null;
}
if (PIDisplay.screen != Calculator.sessions[Calculator.currentSession]) {
if (PIDisplay.screen != PIDisplay.sessions[PIDisplay.currentSession]) {
} else if (Calculator.currentSession + 1 < Calculator.sessions.length) {
if (Calculator.sessions[Calculator.currentSession + 1] != null) {
} else if (PIDisplay.currentSession + 1 < PIDisplay.sessions.length) {
if (PIDisplay.sessions[PIDisplay.currentSession + 1] != null) {
} else {
return false;
@ -150,7 +151,7 @@ public final class PIDisplay {
} else {
return false;
}
if (Calculator.sessions[Calculator.currentSession] != null) {
if (PIDisplay.sessions[PIDisplay.currentSession] != null) {
return true;
}
return false;
@ -158,22 +159,22 @@ public final class PIDisplay {
public void goBack() {
if (canGoBack()) {
if (Calculator.currentSession >= 0 && PIDisplay.screen != Calculator.sessions[Calculator.currentSession]) {
if (PIDisplay.currentSession >= 0 && PIDisplay.screen != PIDisplay.sessions[PIDisplay.currentSession]) {
} else {
Calculator.currentSession += 1;
PIDisplay.currentSession += 1;
}
PIDisplay.screen = Calculator.sessions[Calculator.currentSession];
PIDisplay.screen = PIDisplay.sessions[PIDisplay.currentSession];
}
}
public boolean canGoForward() {
if (Calculator.currentSession <= 0) { // -1 e 0
if (PIDisplay.currentSession <= 0) { // -1 e 0
return false;
}
if (PIDisplay.screen != Calculator.sessions[Calculator.currentSession]) {
if (PIDisplay.screen != PIDisplay.sessions[PIDisplay.currentSession]) {
} else if (Calculator.currentSession > 0) {
if (Calculator.sessions[Calculator.currentSession - 1] != null) {
} else if (PIDisplay.currentSession > 0) {
if (PIDisplay.sessions[PIDisplay.currentSession - 1] != null) {
} else {
return false;
@ -181,7 +182,7 @@ public final class PIDisplay {
} else {
return false;
}
if (Calculator.sessions[Calculator.currentSession] != null) {
if (PIDisplay.sessions[PIDisplay.currentSession] != null) {
return true;
}
return false;
@ -189,12 +190,12 @@ public final class PIDisplay {
public void goForward() {
if (canGoForward()) {
if (PIDisplay.screen != Calculator.sessions[Calculator.currentSession]) {
if (PIDisplay.screen != PIDisplay.sessions[PIDisplay.currentSession]) {
} else {
Calculator.currentSession -= 1;
PIDisplay.currentSession -= 1;
}
PIDisplay.screen = Calculator.sessions[Calculator.currentSession];
PIDisplay.screen = PIDisplay.sessions[PIDisplay.currentSession];
}
}
@ -249,15 +250,16 @@ public final class PIDisplay {
} else {
drawSkinPart(2 + 18 * 1, 2, 16 * 1, 16 * 0, 16 + 16 * 1, 16 + 16 * 0);
}
if (Calculator.angleMode == "deg") {
/*
if (Calculator.angleMode == AngleMode.DEG) {
drawSkinPart(8 + 18 * 2, 2, 16 * 4, 16 * 0, 16 + 16 * 4, 16 + 16 * 0);
drawSkinPart(8 + 18 * 3, 2, 16 * 7, 16 * 0, 16 + 16 * 7, 16 + 16 * 0);
drawSkinPart(8 + 18 * 4, 2, 16 * 9, 16 * 0, 16 + 16 * 9, 16 + 16 * 0);
} else if (Calculator.angleMode == "rad") {
} else if (Calculator.angleMode == AngleMode.RAD) {
drawSkinPart(8 + 18 * 2, 2, 16 * 5, 16 * 0, 16 + 16 * 5, 16 + 16 * 0);
drawSkinPart(8 + 18 * 3, 2, 16 * 6, 16 * 0, 16 + 16 * 6, 16 + 16 * 0);
drawSkinPart(8 + 18 * 4, 2, 16 * 9, 16 * 0, 16 + 16 * 9, 16 + 16 * 0);
} else if (Calculator.angleMode == "gra") {
} else if (Calculator.angleMode == AngleMode.GRA) {
drawSkinPart(8 + 18 * 2, 2, 16 * 5, 16 * 0, 16 + 16 * 5, 16 + 16 * 0);
drawSkinPart(8 + 18 * 3, 2, 16 * 7, 16 * 0, 16 + 16 * 7, 16 + 16 * 0);
drawSkinPart(8 + 18 * 4, 2, 16 * 8, 16 * 0, 16 + 16 * 8, 16 + 16 * 0);
@ -265,7 +267,7 @@ public final class PIDisplay {
drawSkinPart(8 + 18 * 2, 2, 16 * 5, 16 * 0, 16 + 16 * 5, 16 + 16 * 0);
drawSkinPart(8 + 18 * 3, 2, 16 * 7, 16 * 0, 16 + 16 * 7, 16 + 16 * 0);
drawSkinPart(8 + 18 * 4, 2, 16 * 9, 16 * 0, 16 + 16 * 9, 16 + 16 * 0);
}
}*/
int padding = 2;
@ -287,7 +289,7 @@ public final class PIDisplay {
boolean canGoBack = canGoBack();
boolean canGoForward = canGoForward();
if (Calculator.haxMode) {
if (Main.haxMode) {
drawSkinPart(Main.screenSize[0] - (padding + 16), 2, 16 * 18, 16 * 0, 16 + 16 * 18, 16 + 16 * 0);
padding += 18 + 6;
}
@ -443,6 +445,8 @@ public final class PIDisplay {
}
public float[] colore = new float[] { 0.0f, 0.0f, 0.0f, 1.0f };
public static int currentSession = 0;
public static Screen[] sessions = new Screen[5];
public static void colore(float f1, float f2, float f3, float f4) {
PIDisplay.INSTANCE.colore = new float[] { f1, f2, f3, f4 };

View File

@ -9,7 +9,7 @@ import org.warp.picalculator.device.PIDisplay;
public class Display {
private static Frame INSTANCE = new Frame();
private static SwingWindow INSTANCE = new SwingWindow();
public static int[] size = new int[] { 1, 1 };
public static BufferedImage g = new BufferedImage(size[0], size[1], BufferedImage.TYPE_INT_RGB);
static int[] canvas2d = new int[1];
@ -35,7 +35,7 @@ public class Display {
}
public static void create() {
Display.setResizable(Utils.debugOn);
Display.setResizable(Utils.debugOn&!Utils.debugThirdScreen);
Display.setDisplayMode(Main.screenSize[0], Main.screenSize[1]);
INSTANCE.setVisible(true);
initialized = true;

View File

@ -1,494 +0,0 @@
package org.warp.picalculator.device.graphicengine;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.device.PIDisplay;
public class Frame extends JFrame {
private static final long serialVersionUID = 2945898937634075491L;
public CustomCanvas c;
public boolean wasResized = false;
public Frame() {
c = new CustomCanvas();
c.setDoubleBuffered(false);
this.add(c);
// this.setExtendedState(Frame.MAXIMIZED_BOTH);
Toolkit.getDefaultToolkit().setDynamicLayout(false);
// Transparent 16 x 16 pixel cursor image.
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
if (!Utils.debugOn) {
// Create a new blank cursor.
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
// Set the blank cursor to the JFrame.
getContentPane().setCursor(blankCursor);
}
this.setTitle("Raspberry PI Calculator by XDrake99 (Andrea Cavalli)");
this.setResizable(Utils.debugOn);
this.addComponentListener(new ComponentListener() {
@Override
public void componentHidden(ComponentEvent e) {
Display.destroy();
}
@Override
public void componentMoved(ComponentEvent e) {}
@Override
public void componentResized(ComponentEvent e) {
wasResized = true;
}
@Override
public void componentShown(ComponentEvent e) {}
});
this.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent arg0) {
switch (arg0.getKeyCode()) {
case KeyEvent.VK_ESCAPE:
Keyboard.keyPressed(Key.POWER);
break;
case KeyEvent.VK_S:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.ARCSINE);
} else if (Keyboard.alpha) {
Keyboard.keyPressed(Key.NONE);
} else {
Keyboard.keyPressed(Key.SINE);
}
break;
case KeyEvent.VK_C:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.ARCCOSINE);
} else if (Keyboard.alpha) {
Keyboard.keyPressed(Key.NONE);
} else {
Keyboard.keyPressed(Key.COSINE);
}
break;
case KeyEvent.VK_T:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.ARCTANGENT);
} else if (Keyboard.alpha) {
Keyboard.keyPressed(Key.NONE);
} else {
Keyboard.keyPressed(Key.TANGENT);
}
break;
case KeyEvent.VK_D:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.debug_DEG);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_R:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.debug_RAD);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_G:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.debug_GRA);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_X:
if (Keyboard.alpha) {
Keyboard.keyPressed(Key.LETTER_X);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_Y:
if (Keyboard.alpha) {
Keyboard.keyPressed(Key.LETTER_Y);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_B:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.BRIGHTNESS_CYCLE_REVERSE);
} else if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.BRIGHTNESS_CYCLE);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_ENTER:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.SIMPLIFY);
} else if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.SOLVE);
} else {
Keyboard.keyPressed(Key.NONE);
}
int row = 2;
int col = 1;
Keyboard.debugKeysDown[row-1][col-1] = true;
break;
case KeyEvent.VK_1:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM1);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_2:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM2);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_3:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM3);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_4:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM4);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_5:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM5);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_6:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM6);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_7:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM7);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_8:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM8);
} else if (Keyboard.shift) {
Keyboard.keyPressed(Key.PARENTHESIS_OPEN);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_9:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM9);
} else if (Keyboard.shift) {
Keyboard.keyPressed(Key.PARENTHESIS_CLOSE);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_0:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM0);
} else if (Keyboard.shift) {
Keyboard.keyPressed(Key.EQUAL);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_ADD:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.PLUS);
} else if (Keyboard.shift) {
Keyboard.keyPressed(Key.PLUS_MINUS);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_SUBTRACT:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.MINUS);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_MULTIPLY:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.MULTIPLY);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_DIVIDE:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.DIVIDE);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_BACK_SPACE:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.DELETE);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_DELETE:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.RESET);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_LEFT:
//LEFT
row = 2;
col = 3;
Keyboard.debugKeysDown[row-1][col-1] = true;
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.LEFT);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_RIGHT:
//RIGHT
row = 2;
col = 5;
Keyboard.debugKeysDown[row-1][col-1] = true;
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.RIGHT);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_NUMPAD4:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.HISTORY_BACK);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_NUMPAD6:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.HISTORY_FORWARD);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_PERIOD:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.DOT);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_SHIFT:
Keyboard.keyPressed(Key.SHIFT);
break;
case KeyEvent.VK_A:
Keyboard.keyPressed(Key.ALPHA);
break;
case KeyEvent.VK_NUMPAD1:
Keyboard.keyPressed(Key.SQRT);
break;
case KeyEvent.VK_NUMPAD2:
Keyboard.keyPressed(Key.ROOT);
break;
case KeyEvent.VK_NUMPAD3:
Keyboard.keyPressed(Key.POWER_OF_2);
break;
case KeyEvent.VK_NUMPAD5:
Keyboard.keyPressed(Key.POWER_OF_x);
break;
}
}
@Override
public void keyReleased(KeyEvent arg0) {
switch (arg0.getKeyCode()) {
case KeyEvent.VK_ESCAPE:
Keyboard.keyReleased(Key.POWER);
break;
case KeyEvent.VK_D:
Keyboard.keyReleased(Key.debug_DEG);
break;
case KeyEvent.VK_R:
Keyboard.keyReleased(Key.debug_RAD);
break;
case KeyEvent.VK_G:
Keyboard.keyReleased(Key.debug_GRA);
break;
case KeyEvent.VK_X:
if (Keyboard.alpha) {
Keyboard.keyReleased(Key.LETTER_X);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_B:
if (Keyboard.shift) {
Keyboard.keyReleased(Key.BRIGHTNESS_CYCLE_REVERSE);
} else if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.BRIGHTNESS_CYCLE);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_ENTER:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.SOLVE);
} else {
Keyboard.keyReleased(Key.NONE);
}
int row = 2;
int col = 1;
Keyboard.debugKeysDown[row-1][col-1] = false;
break;
case KeyEvent.VK_1:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug1);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_2:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug2);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_3:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug3);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_4:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug4);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_5:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug5);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_SHIFT:
Keyboard.keyReleased(Key.SHIFT);
break;
case KeyEvent.VK_A:
Keyboard.keyReleased(Key.ALPHA);
break;
case KeyEvent.VK_LEFT:
//LEFT
row = 2;
col = 3;
Keyboard.debugKeysDown[row-1][col-1] = false;
case KeyEvent.VK_RIGHT:
//RIGHT
row = 2;
col = 5;
Keyboard.debugKeysDown[row-1][col-1] = false;
}
}
@Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
});
}
@Override
public void setSize(int width, int height) {
c.setSize(width, height);
super.getContentPane().setPreferredSize(new Dimension(width, height));
super.pack();
}
@Override
public Dimension getSize() {
return c.getSize();
}
@Override
public int getWidth() {
return c.getWidth();
}
@Override
public int getHeight() {
return c.getHeight();
}
// private static ArrayList<Double> mediaValori = new ArrayList<Double>();
public static class CustomCanvas extends JPanel {
/**
*
*/
private static final long serialVersionUID = 605243927485370885L;
@Override
public void paintComponent(Graphics g) {
// long time1 = System.nanoTime();
PIDisplay.INSTANCE.refresh();
final int[] a = ((DataBufferInt) Display.g.getRaster().getDataBuffer()).getData();
// System.arraycopy(canvas2d, 0, a, 0, canvas2d.length);
Display.canvas2d = a;
g.clearRect(0, 0, Display.size[0], Display.size[1]);
g.drawImage(Display.g, 0, 0, null);
// long time2 = System.nanoTime();
// double timeDelta = ((double)(time2-time1))/1000000000d;
// double mediaAttuale = timeDelta;
// mediaValori.add(mediaAttuale);
// double somma = 0;
// for (Double val : mediaValori) {
// somma+=val;
// }
// System.out.println(somma/((double)mediaValori.size()));
}
}
}

View File

@ -0,0 +1,241 @@
package org.warp.picalculator.device.graphicengine;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.device.PIDisplay;
public class SwingWindow extends JFrame {
private static final long serialVersionUID = 2945898937634075491L;
public CustomCanvas c;
public boolean wasResized = false;
public SwingWindow() {
c = new CustomCanvas();
c.setDoubleBuffered(false);
this.add(c);
// this.setExtendedState(Frame.MAXIMIZED_BOTH);
Toolkit.getDefaultToolkit().setDynamicLayout(false);
// Transparent 16 x 16 pixel cursor image.
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
if (Utils.debugOn) {
if (Utils.debugThirdScreen) {
this.setLocation(2880, 900);
this.setResizable(false);
this.setAlwaysOnTop(true);
}
} else {
// Create a new blank cursor.
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
// Set the blank cursor to the JFrame.
getContentPane().setCursor(blankCursor);
this.setResizable(false);
}
this.setTitle("Raspberry PI Calculator by XDrake99 (Andrea Cavalli)");
this.addComponentListener(new ComponentListener() {
@Override
public void componentHidden(ComponentEvent e) {
Display.destroy();
}
@Override
public void componentMoved(ComponentEvent e) {}
@Override
public void componentResized(ComponentEvent e) {
wasResized = true;
}
@Override
public void componentShown(ComponentEvent e) {}
});
this.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent arg0) {
Keyboard.debugKeyEvent = arg0;
}
@Override
public void keyReleased(KeyEvent arg0) {
switch (arg0.getKeyCode()) {
case KeyEvent.VK_ESCAPE:
Keyboard.keyReleased(Key.POWER);
break;
case KeyEvent.VK_D:
Keyboard.keyReleased(Key.debug_DEG);
break;
case KeyEvent.VK_R:
Keyboard.keyReleased(Key.debug_RAD);
break;
case KeyEvent.VK_G:
Keyboard.keyReleased(Key.debug_GRA);
break;
case KeyEvent.VK_X:
if (Keyboard.alpha) {
Keyboard.keyReleased(Key.LETTER_X);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_P:
if (Keyboard.alpha) {
Keyboard.keyReleased(Key.PI);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_B:
if (Keyboard.shift) {
Keyboard.keyReleased(Key.BRIGHTNESS_CYCLE_REVERSE);
} else if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.BRIGHTNESS_CYCLE);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_ENTER:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.SOLVE);
} else {
Keyboard.keyReleased(Key.NONE);
}
int row = 2;
int col = 1;
Keyboard.debugKeysDown[row-1][col-1] = false;
break;
case KeyEvent.VK_1:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug1);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_2:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug2);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_3:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug3);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_4:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug4);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_5:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyReleased(Key.debug5);
} else {
Keyboard.keyReleased(Key.NONE);
}
break;
case KeyEvent.VK_SHIFT:
Keyboard.keyReleased(Key.SHIFT);
break;
case KeyEvent.VK_A:
Keyboard.keyReleased(Key.ALPHA);
break;
case KeyEvent.VK_LEFT:
//LEFT
row = 2;
col = 3;
Keyboard.debugKeysDown[row-1][col-1] = false;
case KeyEvent.VK_RIGHT:
//RIGHT
row = 2;
col = 5;
Keyboard.debugKeysDown[row-1][col-1] = false;
}
}
@Override
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
});
}
@Override
public void setSize(int width, int height) {
c.setSize(width, height);
super.getContentPane().setPreferredSize(new Dimension(width, height));
super.pack();
}
@Override
public Dimension getSize() {
return c.getSize();
}
@Override
public int getWidth() {
return c.getWidth();
}
@Override
public int getHeight() {
return c.getHeight();
}
// private static ArrayList<Double> mediaValori = new ArrayList<Double>();
public static class CustomCanvas extends JPanel {
/**
*
*/
private static final long serialVersionUID = 605243927485370885L;
@Override
public void paintComponent(Graphics g) {
// long time1 = System.nanoTime();
PIDisplay.INSTANCE.refresh();
final int[] a = ((DataBufferInt) Display.g.getRaster().getDataBuffer()).getData();
// System.arraycopy(canvas2d, 0, a, 0, canvas2d.length);
Display.canvas2d = a;
g.clearRect(0, 0, Display.size[0], Display.size[1]);
g.drawImage(Display.g, 0, 0, null);
// long time2 = System.nanoTime();
// double timeDelta = ((double)(time2-time1))/1000000000d;
// double mediaAttuale = timeDelta;
// mediaValori.add(mediaAttuale);
// double somma = 0;
// for (Double val : mediaValori) {
// somma+=val;
// }
// System.out.println(somma/((double)mediaValori.size()));
}
}
}

View File

@ -0,0 +1,7 @@
package org.warp.picalculator.math;
public enum AngleMode {
DEG,
RAD,
GRA
}

View File

@ -11,10 +11,10 @@ import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.PIDisplay;
import org.warp.picalculator.device.graphicengine.Screen;
import org.warp.picalculator.math.functions.Expression;
import org.warp.picalculator.math.functions.Function;
import org.warp.picalculator.math.functions.Number;
import org.warp.picalculator.math.functions.Variable;
import org.warp.picalculator.math.functions.equations.Equation;
import org.warp.picalculator.math.functions.equations.EquationsSystem;
import org.warp.picalculator.screens.MathInputScreen;
@ -22,12 +22,13 @@ import org.warp.picalculator.screens.SolveEquationScreen;
public class Calculator {
public static String angleMode = "deg";
public static Screen[] sessions = new Screen[5];
public static int currentSession = 0;
public static boolean haxMode = true;
public static boolean exactMode = false;
public static Function parseString(String string) throws Error {
public AngleMode angleMode = AngleMode.DEG;
public boolean exactMode = false;
public Calculator() {
}
public Function parseString(String string) throws Error {
if (string.contains("{")) {
if (!string.startsWith("{")) {
throw new Error(Errors.SYNTAX_ERROR);
@ -45,7 +46,7 @@ public class Calculator {
}
}
public static Function parseEquationString(String string) throws Error {
public Function parseEquationString(String string) throws Error {
String[] parts = string.split("=");
if (parts.length == 1) {
Equation e = new Equation(null, null, null);
@ -62,7 +63,7 @@ public class Calculator {
}
}
public static ArrayList<Function> solveExpression(ArrayList<Function> input) throws Error {
public ArrayList<Function> solveExpression(ArrayList<Function> input) throws Error {
ArrayList<Function> results = new ArrayList<>();
ArrayList<Function> partialResults = new ArrayList<>();
for (Function f : input) {
@ -92,33 +93,7 @@ public class Calculator {
return results;
}
public static void solve(MathInputScreen es) throws Error {
for (Function f : es.f) {
if (f instanceof Equation) {
PIDisplay.INSTANCE.setScreen(new SolveEquationScreen(es));
return;
}
}
ArrayList<Function> results = solveExpression(es.f);
if (results.size() == 0) {
es.resultsCount = 0;
} else {
es.resultsCount = results.size();
Collections.reverse(results);
// add elements to al, including duplicates
Set<Function> hs = new LinkedHashSet<>();
hs.addAll(results);
results.clear();
results.addAll(hs);
es.f2 = results;
for (Function rf : es.f2) {
rf.generateGraphics();
}
}
}
/*public static void solve(EquationScreen equationScreen, char letter) throws Error {
/*public void solve(EquationScreen equationScreen, char letter) throws Error {
if (Calculator.currentSession == 0 && Calculator.sessions[0] instanceof EquationScreen) {
EquationScreen es = (EquationScreen) Calculator.sessions[0];
ArrayList<Function> f = es.f;
@ -138,41 +113,4 @@ public class Calculator {
}
}*/
public static void simplify(MathInputScreen es) throws Error {
ArrayList<Function> results = new ArrayList<>();
ArrayList<Function> partialResults = new ArrayList<>();
for (Function f : es.f2) {
if (f instanceof Equation) {
PIDisplay.INSTANCE.setScreen(new SolveEquationScreen(es));
} else {
results.add(f);
for (Function itm : results) {
if (itm.isSolved() == false) {
List<Function> dt = itm.solveOneStep();
partialResults.addAll(dt);
} else {
partialResults.add(itm);
}
}
results = new ArrayList<Function>(partialResults);
partialResults.clear();
}
}
if (results.size() == 0) {
es.resultsCount = 0;
} else {
es.resultsCount = results.size();
Collections.reverse(results);
// add elements to al, including duplicates
Set<Function> hs = new LinkedHashSet<>();
hs.addAll(results);
results.clear();
results.addAll(hs);
es.f2 = results;
for (Function rf : es.f2) {
rf.generateGraphics();
}
}
}
}

View File

@ -24,6 +24,7 @@ public class MathematicalSymbols {
public static final String ARC_SINE = "";
public static final String ARC_COSINE = "";
public static final String ARC_TANGENT = "";
public static final String PI = "π";
public static final String[] functions() {
return concat(functionsNSN(), functionsSN());
@ -50,7 +51,7 @@ public class MathematicalSymbols {
}
public static String[] variables() {
return new String[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "", "", "Z"};
return new String[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "", "", "Z", PI};
}
public static String[] genericSyntax() {

View File

@ -27,7 +27,7 @@ public class Number implements Function {
protected int line;
protected boolean small;
public Number(Function parent, BigInteger val) {
public Number(Calculator calc, Function parent, BigInteger val) {
this.parent = parent;
term = new BigDecimal(val).setScale(Utils.scale, Utils.scaleMode2);
}

View File

@ -95,6 +95,16 @@ public class Variable implements Function {
private int calcLine() {
return Utils.getFontHeight(small) / 2;
}
public static class VariableValue {
public final Variable v;
public final Number n;
public VariableValue(Variable v, Number n) {
this.v = v;
this.n = n;
}
}
@Override
public Variable clone() {

View File

@ -1,11 +1,19 @@
package org.warp.picalculator.math.functions.trigonometry;
import java.math.BigInteger;
import java.util.ArrayList;
import org.nevec.rjm.BigDecimalMath;
import org.nevec.rjm.BigIntegerMath;
import org.warp.picalculator.Error;
import org.warp.picalculator.Utils;
import org.warp.picalculator.math.AngleMode;
import org.warp.picalculator.math.Calculator;
import org.warp.picalculator.math.MathematicalSymbols;
import org.warp.picalculator.math.functions.AnteriorFunction;
import org.warp.picalculator.math.functions.Function;
import org.warp.picalculator.math.functions.Multiplication;
import org.warp.picalculator.math.functions.Number;
public class Sine extends AnteriorFunction {
@ -24,15 +32,27 @@ public class Sine extends AnteriorFunction {
}
@Override
public ArrayList<Function> solve() throws Error {
// TODO Auto-generated method stub
return null;
protected boolean isSolvable() {
if (variable instanceof Number) {
if (Calculator.exactMode == false) {
return true;
}
}
if (Calculator.angleMode == AngleMode.DEG) {
Function[] solvableValues = new Function[]{new Number(null, 0), new Number(null, 30), new Number(null, 90), };
}
return false;
}
@Override
protected boolean isSolvable() {
// TODO Auto-generated method stub
return false;
public ArrayList<Function> solve() throws Error {
ArrayList<Function> results = new ArrayList<>();
if (variable instanceof Number) {
if (Calculator.exactMode == false) {
results.add(new Number(parent, BigDecimalMath.sin(((Number) variable).getTerm())));
}
}
return results;
}
@Override

View File

@ -0,0 +1,96 @@
package org.warp.picalculator.math.rules.methods;
import java.util.ArrayList;
import org.warp.picalculator.Error;
import org.warp.picalculator.math.functions.Function;
import org.warp.picalculator.math.functions.Multiplication;
import org.warp.picalculator.math.functions.Division;
import org.warp.picalculator.math.functions.Number;
/**
* Division method<br>
* <b>Example: (XY)/(YZ) = X/Z</b>
* @author Andrea Cavalli
*
*/
public class DivisionRule1 {
public static boolean compare(Function f) {
return ((Division)f).getVariable1().isSolved() && ((Division)f).getVariable2().isSolved() && !(((Division)f).getVariable1() instanceof Number && ((Division)f).getVariable2() instanceof Number) && getFirstWorkingDivisionCouple(getDivisionElements(f)) != null;
}
public static ArrayList<Function> execute(Function f) throws Error {
Function result;
ArrayList<Function> elements = getDivisionElements(f);
int[] workingElementCouple = getFirstWorkingDivisionCouple(elements);
Function elem1 = elements.get(workingElementCouple[0]);
Function elem2 = elements.get(workingElementCouple[1]);
final int size = elements.size();
Function prec = new Multiplication(null, elem1, elem2);
elem1.setParent(prec);
elem2.setParent(prec);
for (int i = size-1; i >= 0; i--) {
if (i != workingElementCouple[0] & i != workingElementCouple[1]) {
Function a = prec;
Function b = elements.get(i);
prec = new Multiplication(null, a, b);
a.setParent(prec);
b.setParent(prec);
}
}
prec.setParent(f.getParent());
result = prec;
ArrayList<Function> results = new ArrayList<>();
results.add(result);
return results;
}
private static ArrayList<Function> getDivisionElements(Division division) {
ArrayList<Function> elementsNumerator = new ArrayList<>();
Function numMult = division.getVariable1();
while (numMult instanceof Multiplication) {
elementsNumerator.add(((Multiplication) numMult).getVariable1());
numMult = ((Multiplication) numMult).getVariable2();
}
elementsNumerator.add(numMult);
ArrayList<Function> elementsDenominator = new ArrayList<>();
Function denomMult = division.getVariable1();
while (denomMult instanceof Multiplication) {
elementsDenominator.add(((Multiplication) denomMult).getVariable1());
denomMult = ((Multiplication) denomMult).getVariable2();
}
elementsDenominator.add(denomMult);
return elements;
}
private static int[] getFirstWorkingDivisionCouple(ArrayList<Function> elements) {
final int size = elements.size();
Function a;
Function b;
if (elements.size() == 2) {
return null;
}
for (int i = 0; i < size; i++) {
a = elements.get(i);
for (int j = 0; j < size; j++) {
b = elements.get(j);
if (i != j) {
Function testFunc;
testFunc = new Multiplication(null, a, b);
if (!testFunc.isSolved()) {
return new int[]{i, j};
}
}
}
}
return null;
}
}

View File

@ -0,0 +1,85 @@
package org.warp.picalculator.screens;
import static org.warp.picalculator.device.graphicengine.Display.Render.glColor3i;
import static org.warp.picalculator.device.graphicengine.Display.Render.glColor4i;
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringCenter;
import org.warp.picalculator.Error;
import org.warp.picalculator.Main;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.device.PIDisplay;
import org.warp.picalculator.device.graphicengine.Screen;
import org.warp.picalculator.math.Calculator;
import org.warp.picalculator.math.functions.Function;
import org.warp.picalculator.math.functions.Variable;
import org.warp.picalculator.math.functions.Variable.VariableValue;
public class ChooseVariableValueScreen extends Screen {
@SuppressWarnings("unused")
private MathInputScreen es;
public Function resultNumberValue;
public ChooseVariableValueScreen(MathInputScreen es, VariableValue variableValue) {
super();
canBeInHistory = false;
this.es = es;
}
@Override
public void created() throws InterruptedException {
}
@Override
public void init() throws InterruptedException {}
@Override
public void render() {
glColor4i(0, 0, 0, 64);
glDrawStringCenter(Main.screenSize[0]/2+1, Main.screenSize[1]/4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
glDrawStringCenter(Main.screenSize[0]/2, Main.screenSize[1]/4+1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
glDrawStringCenter(Main.screenSize[0]/2+1, Main.screenSize[1]/4+1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
glColor3i(255, 0, 0);
glDrawStringCenter(Main.screenSize[0]/2, Main.screenSize[1]/4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
}
@Override
public void beforeRender(float dt) {
}
@Override
public boolean mustBeRefreshed() {
return true;
}
@Override
public boolean keyPressed(Key k) {
switch (k) {
case LETTER_X:
// PIDisplay.INSTANCE.goBack();
// try {
// Calculator.solveExpression('X');
// } catch (Error e) {
// Screen scr = PIDisplay.INSTANCE.getScreen();
// if (scr instanceof MathInputScreen) {
// MathInputScreen escr = (MathInputScreen) scr;
// escr.errorLevel = 1;
// escr.err2 = e;
// } else {
// e.printStackTrace();
// }
// }
return true;
default:
return false;
}
}
@Override
public boolean keyReleased(Key k) {
return false;
}
}

View File

@ -0,0 +1,229 @@
package org.warp.picalculator.screens;
import static org.warp.picalculator.device.PIDisplay.colore;
import static org.warp.picalculator.device.PIDisplay.fonts;
import static org.warp.picalculator.device.graphicengine.Display.Render.*;
import org.warp.picalculator.Main;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.device.graphicengine.Screen;
public class KeyboardDebugScreen extends Screen {
public String key;
public String keyevent;
public static int keyX;
public static int keyY;
public static String[] log = new String[]{"POWER ON","LOADING","LOADED","DONE","---"};
public long beforetime;
public KeyboardDebugScreen() {
super();
canBeInHistory = false;
}
@Override
public void created() throws InterruptedException {
}
@Override
public void init() throws InterruptedException {
}
@Override
public void render() {
glSetFont(fonts[2]);
colore(0.75f, 0.0f, 0.0f, 1.0f);
glDrawStringRight(Main.screenSize[0] - 10, 30, "-" + keyevent.toUpperCase() + "-");
if (keyevent != "NONE") {
glSetFont(fonts[2]);
colore(0.0f, 0.0f, 0.0f, 1.0f);
glDrawStringLeft(10, 30, "Key position");
glDrawStringLeft(10, 45, "X: " + keyX + ", Y:" + keyY);
glDrawStringLeft(10, 65, "Key value");
glDrawStringLeft(10, 80, key);
}
glSetFont(fonts[3]);
colore(0.0f, 0.0f, 0.0f, 1.0f);
for (int i = 0; i < 5; i++) {
if (log[i] != null) {
glDrawStringLeft(10, 230 + 15*(i+1), log[i].toUpperCase());
}
}
//FROM SERIAL
colore(0.0f, 0.0f, 0.0f, 1.0f);
glFillRect(-80+100+200, 90, 5, 5);
glFillRect(-80+100, 100, 200, 70);
glSetFont(fonts[2]);
colore(1.0f, 1.0f, 1.0f, 1.0f);
glDrawStringCenter(-80+100+200/2, 100+70/2-(currentFont.charH/2), "FROM SERIAL");
glSetFont(fonts[3]);
colore(0.0f, 0.0f, 1.0f, 1.0f);
for (int i = 0; i < 8; i++) {
if (pinsA[i] == 1) {
colore(0.0f, 1.0f, 0.0f, 1.0f);
} else if (pinsA[i] == 2) {
colore(0.5f, 0.5f, 1.0f, 1.0f);
} else if (pinsA[i] == -1) {
colore(0.7f, 0.7f, 0.7f, 1.0f);
} else if (pinsA[i] == 0) {
colore(1.0f, 0.0f, 0.0f, 1.0f);
}
glFillRect(-80+103+25*(7-i), 80, 20, 20);
colore(0.0f, 0.0f, 0.0f, 1.0f);
glDrawStringCenter(-80+113+25*(7-i), 90-(currentFont.charH/2), ""+(i+1));
}
for (int i = 15; i >= 8; i--) {
if (pinsA[i] == 1) {
colore(0.0f, 1.0f, 0.0f, 1.0f);
} else if (pinsA[i] == 2) {
colore(0.5f, 0.5f, 1.0f, 1.0f);
} else if (pinsA[i] == -1) {
colore(0.7f, 0.7f, 0.7f, 1.0f);
} else if (pinsA[i] == 0) {
colore(1.0f, 0.0f, 0.0f, 1.0f);
}
glFillRect(-80+103+25*(i-8), 170, 20, 20);
colore(0.0f, 0.0f, 0.0f, 1.0f);
glDrawStringCenter(-80+113+25*(i-8), 180-(currentFont.charH/2), ""+(i+1));
}
for (int i = 0; i < 8; i++) {
if (dataA[i]) {
colore(0.0f, 1.0f, 0.0f, 1.0f);
} else {
colore(1.0f, 0.0f, 0.0f, 1.0f);
}
glFillRect(-80+160+10*(i), 150, 8, 8);
}
//TO SERIAL
colore(0.0f, 0.0f, 0.0f, 1.0f);
glFillRect(150+90, 200, 5, 5);
glFillRect(150+100, 100, 200, 70);
glSetFont(fonts[2]);
colore(1.0f, 1.0f, 1.0f, 1.0f);
glDrawStringCenter(150+100+200/2, 100+70/2-(currentFont.charH/2), "TO SERIAL");
glSetFont(fonts[3]);
colore(0.0f, 0.0f, 1.0f, 1.0f);
for (int i = 15; i >= 8; i--) {
if (pinsB[i] == 1) {
colore(0.0f, 1.0f, 0.0f, 1.0f);
} else if (pinsB[i] == 2) {
colore(0.5f, 0.5f, 1.0f, 1.0f);
} else if (pinsB[i] == -1) {
colore(0.7f, 0.7f, 0.7f, 1.0f);
} else if (pinsB[i] == 0) {
colore(1.0f, 0.0f, 0.0f, 1.0f);
}
glFillRect(150+103+25*(15-i), 80, 20, 20);
colore(0.0f, 0.0f, 0.0f, 1.0f);
glDrawStringCenter(150+113+25*(15-i), 90-(currentFont.charH/2), ""+(i+1));
}
for (int i = 7; i >= 0; i--) {
if (pinsB[i] == 1) {
colore(0.0f, 1.0f, 0.0f, 1.0f);
} else if (pinsB[i] == 2) {
colore(0.5f, 0.5f, 1.0f, 1.0f);
} else if (pinsB[i] == -1) {
colore(0.7f, 0.7f, 0.7f, 1.0f);
} else if (pinsB[i] == 0) {
colore(1.0f, 0.0f, 0.0f, 1.0f);
}
glFillRect(150+103+25*(i), 170, 20, 20);
colore(0.0f, 0.0f, 0.0f, 1.0f);
glDrawStringCenter(150+113+25*(i), 180-(currentFont.charH/2), ""+(i+1));
}
for (int i = 0; i < 8; i++) {
if (dataB[i]) {
colore(0.0f, 1.0f, 0.0f, 1.0f);
} else {
colore(1.0f, 0.0f, 0.0f, 1.0f);
}
glFillRect(150+160+10*(i), 150, 8, 8);
}
//GPIO
for (int i = 0; i < 40; i++) {
if (gpio[i] == true) {
colore(0.0f, 1.0f, 0.0f, 1.0f);
} else {
colore(1.0f, 0.0f, 0.0f, 1.0f);
}
if (i % 2 == 0) {
glFillRect(53+15*((i)/2), 50, 5, 5);
colore(0.0f, 0.0f, 0.0f, 1.0f);
glDrawStringCenter(55+15*((i)/2), 60, ""+(i+1));
} else {
glFillRect(53+15*((i-1)/2), 40, 5, 5);
colore(0.0f, 0.0f, 0.0f, 1.0f);
glDrawStringCenter(55+15*((i-1)/2), 35-currentFont.charH, ""+(i+1));
}
}
//KEYS
for (int c = 0; c < 8; c++) {
for (int r = 0; r < 8; r++) {
if (ks[c][r]) {
colore(0.0f, 1.0f, 0.0f, 1.0f);
} else {
colore(1.0f, 0.0f, 0.0f, 1.0f);
}
glFillRect(250+6*c, 250+6*r, 5, 5);
}
}
}
@Override
public void beforeRender(float dt) {
if (System.currentTimeMillis()-beforetime >= 1000) {
keyevent = "NONE";
keyX = 0;
keyY = 0;
key = "";
}
}
@Override
public boolean mustBeRefreshed() {
return true;
}
@Override
public boolean keyPressed(Key k) {
beforetime = System.currentTimeMillis();
keyevent = "PRESSED";
keyX = 0;
keyY = 0;
key = k.toString();
return false;
}
@Override
public boolean keyReleased(Key k) {
beforetime = System.currentTimeMillis();
keyevent = "RELEASED";
keyX = 0;
keyY = 0;
key = k.toString();
return false;
}
public static int[] pinsA = new int[]{2, 2, 2, 2, 2, 2, 2, 1, -1, -1, 0, 0, 0, 0, 2, -1};
public static int[] pinsB = new int[]{0, 0, 2, 2, 2, 2, -1, 1, 0, -1, 2, 2, 2, 2, 0, -1};
public static boolean[] dataA = new boolean[8];
public static boolean[] dataB = new boolean[8];
public static boolean[][] ks = new boolean[8][8];
public static boolean[] gpio = new boolean[40];
public static void log(String str) {
String[] newlog = log;
for (int i = 1; i < 5; i++) {
newlog[i-1] = newlog[i];
}
newlog[4] = "[" + System.currentTimeMillis() + "]" + str;
log = newlog;
}
}

View File

@ -12,7 +12,11 @@ import static org.warp.picalculator.device.graphicengine.Display.Render.glSetFon
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
@ -24,9 +28,17 @@ import org.warp.picalculator.device.PIDisplay;
import org.warp.picalculator.device.graphicengine.Display;
import org.warp.picalculator.device.graphicengine.RAWFont;
import org.warp.picalculator.device.graphicengine.Screen;
import org.warp.picalculator.math.AngleMode;
import org.warp.picalculator.math.Calculator;
import org.warp.picalculator.math.MathematicalSymbols;
import org.warp.picalculator.math.functions.AnteriorFunction;
import org.warp.picalculator.math.functions.Function;
import org.warp.picalculator.math.functions.FunctionMultipleValues;
import org.warp.picalculator.math.functions.FunctionTwoValues;
import org.warp.picalculator.math.functions.Variable;
import org.warp.picalculator.math.functions.Variable.VariableValue;
import org.warp.picalculator.math.functions.equations.Equation;
import org.warp.picalculator.math.functions.Number;
public class MathInputScreen extends Screen {
@ -37,16 +49,20 @@ public class MathInputScreen extends Screen {
public volatile float showCaretDelta = 0f;
public ArrayList<Function> f;
public ArrayList<Function> f2;
public ArrayList<VariableValue> variablesValues;
public int resultsCount;
public boolean autoscroll;
public int scrollX = 0;
public int errorLevel = 0; // 0 = nessuno, 1 = risultato, 2 = tutto
boolean mustRefresh = true;
boolean afterDoNextStep = false;
public final Calculator calc;
public MathInputScreen() {
super();
canBeInHistory = true;
calc = new Calculator();
}
@Override
@ -89,6 +105,7 @@ public class MathInputScreen extends Screen {
if (f == null & f2 == null) {
f = new ArrayList<Function>();
f2 = new ArrayList<Function>();
variablesValues = new ArrayList<>();
resultsCount = 0;
}
// interpreta("{(5X*(15X/3X))+(25X/(5X*(15X/3X)))=15{X=5"); //TODO RIMUOVERE
@ -124,7 +141,7 @@ public class MathInputScreen extends Screen {
ArrayList<Function> fncs = new ArrayList<Function>();
if (eqn.length() > 0) {
try {
fncs.add(Calculator.parseString(eqn.replace("sqrt", "").replace("^", "")));
fncs.add(calc.parseString(eqn.replace("sqrt", "").replace("^", "")));
} catch (Exception ex) {
}
@ -249,29 +266,34 @@ public class MathInputScreen extends Screen {
switch (k) {
case SIMPLIFY:
if (nuovaEquazione.length() > 0) {
try {
if (!afterDoNextStep) {
try {
if (!afterDoNextStep) {
interpreta(false);
f2 = f;
afterDoNextStep = true;
Calculator.simplify(this);
try {
interpreta(true);
showVariablesDialog(new Runnable(){
@Override
public void run() {
equazioneCorrente = nuovaEquazione;
f2 = f;
afterDoNextStep = true;
simplify(MathInputScreen.this);
}
});
} catch (Exception ex) {
if (Utils.debugOn)
ex.printStackTrace();
throw new Error(Errors.SYNTAX_ERROR);
}
Calculator.simplify(this);
} catch (Exception ex) {
if (Utils.debugOn) {
ex.printStackTrace();
}
throw new Error(Errors.SYNTAX_ERROR);
} catch (Error e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
PIDisplay.error = e.id.toString();
System.err.println(e.id);
}
} catch (Error e) {
glClearColor(0xFFDC3C32);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
PIDisplay.error = e.id.toString();
System.err.println(e.id);
} else {
simplify(this);
}
}
return true;
@ -288,12 +310,17 @@ public class MathInputScreen extends Screen {
try {
try {
if (afterDoNextStep) {
Calculator.simplify(this);
simplify(this);
} else {
if (nuovaEquazione != equazioneCorrente && nuovaEquazione.length() > 0) {
changeEquationScreen();
interpreta(false);
Calculator.solve(this);
interpreta(true);
showVariablesDialog(new Runnable(){
@Override
public void run() {
equazioneCorrente = nuovaEquazione;
solve();
}});
}
}
} catch (Exception ex) {
@ -381,6 +408,9 @@ public class MathInputScreen extends Screen {
case POWER_OF_x:
typeChar(MathematicalSymbols.POWER);
return true;
case PI:
typeChar(MathematicalSymbols.PI);
return true;
case LETTER_X:
typeChar(MathematicalSymbols.variables()[23]);
return true;
@ -452,27 +482,12 @@ public class MathInputScreen extends Screen {
return true;
}
case SURD_MODE:
Calculator.exactMode = !Calculator.exactMode;
try {
try {
if (Calculator.exactMode == false) {
f2 = Calculator.solveExpression(f2);
} else {
equazioneCorrente = "";
Keyboard.keyPressed(Key.SOLVE);
}
} catch (Exception ex) {
if (Utils.debugOn)
ex.printStackTrace();
throw new Error(Errors.SYNTAX_ERROR);
}
} catch (Error e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
PIDisplay.error = e.id.toString();
System.err.println(e.id);
calc.exactMode = !calc.exactMode;
if (calc.exactMode == false) {
f2 = solveExpression(f2);
} else {
equazioneCorrente = "";
Keyboard.keyPressed(Key.SOLVE);
}
return true;
case debug1:
@ -480,7 +495,7 @@ public class MathInputScreen extends Screen {
return true;
case HISTORY_BACK:
if (PIDisplay.INSTANCE.canGoBack()) {
if (equazioneCorrente != null && equazioneCorrente.length() > 0 & Calculator.sessions[Calculator.currentSession+1] instanceof MathInputScreen) {
if (equazioneCorrente != null && equazioneCorrente.length() > 0 & PIDisplay.sessions[PIDisplay.currentSession+1] instanceof MathInputScreen) {
nuovaEquazione = equazioneCorrente;
try {
interpreta(true);
@ -491,7 +506,7 @@ public class MathInputScreen extends Screen {
return false;
case HISTORY_FORWARD:
if (PIDisplay.INSTANCE.canGoForward()) {
if (equazioneCorrente != null && equazioneCorrente.length() > 0 & Calculator.sessions[Calculator.currentSession-1] instanceof MathInputScreen) {
if (equazioneCorrente != null && equazioneCorrente.length() > 0 & PIDisplay.sessions[PIDisplay.currentSession-1] instanceof MathInputScreen) {
nuovaEquazione = equazioneCorrente;
try {
interpreta(true);
@ -500,11 +515,156 @@ public class MathInputScreen extends Screen {
}
}
return false;
case debug_DEG:
if (calc.angleMode.equals(AngleMode.DEG) == false) {
calc.angleMode = AngleMode.DEG;
return true;
}
return false;
case debug_RAD:
if (calc.angleMode.equals(AngleMode.RAD) == false) {
calc.angleMode = AngleMode.RAD;
return true;
}
return false;
case debug_GRA:
if (calc.angleMode.equals(AngleMode.GRA) == false) {
calc.angleMode = AngleMode.GRA;
return true;
}
return false;
case DRG_CYCLE:
if (calc.angleMode.equals(AngleMode.DEG) == true) {
calc.angleMode = AngleMode.RAD;
} else if (calc.angleMode.equals(AngleMode.RAD) == true) {
calc.angleMode = AngleMode.GRA;
} else {
calc.angleMode = AngleMode.DEG;
}
return true;
default:
return false;
}
}
private ArrayList<Function> solveExpression(ArrayList<Function> f22) {
try {
try {
return calc.solveExpression(f22);
} catch (Exception ex) {
if (Utils.debugOn) {
ex.printStackTrace();
}
throw new Error(Errors.SYNTAX_ERROR);
}
} catch (Error e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
PIDisplay.error = e.id.toString();
System.err.println(e.id);
}
return null;
}
protected void simplify(MathInputScreen mathInputScreen) {
try {
try {
showVariablesDialog();
ArrayList<Function> results = new ArrayList<>();
ArrayList<Function> partialResults = new ArrayList<>();
for (Function f : f2) {
if (f instanceof Equation) {
PIDisplay.INSTANCE.setScreen(new SolveEquationScreen(this));
} else {
results.add(f);
for (Function itm : results) {
if (itm.isSolved() == false) {
List<Function> dt = itm.solveOneStep();
partialResults.addAll(dt);
} else {
partialResults.add(itm);
}
}
results = new ArrayList<Function>(partialResults);
partialResults.clear();
}
}
if (results.size() == 0) {
resultsCount = 0;
} else {
resultsCount = results.size();
Collections.reverse(results);
// add elements to al, including duplicates
Set<Function> hs = new LinkedHashSet<>();
hs.addAll(results);
results.clear();
results.addAll(hs);
f2 = results;
for (Function rf : f2) {
rf.generateGraphics();
}
}
} catch (Exception ex) {
if (Utils.debugOn) {
ex.printStackTrace();
}
throw new Error(Errors.SYNTAX_ERROR);
}
} catch (Error e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
PIDisplay.error = e.id.toString();
System.err.println(e.id);
}
}
protected void solve() {
try {
try {
for (Function f : f) {
if (f instanceof Equation) {
PIDisplay.INSTANCE.setScreen(new SolveEquationScreen(this));
return;
}
}
ArrayList<Function> results = solveExpression(f);
if (results.size() == 0) {
resultsCount = 0;
} else {
resultsCount = results.size();
Collections.reverse(results);
// add elements to al, including duplicates
Set<Function> hs = new LinkedHashSet<>();
hs.addAll(results);
results.clear();
results.addAll(hs);
f2 = results;
for (Function rf : f2) {
rf.generateGraphics();
}
}
} catch (Exception ex) {
if (Utils.debugOn) {
ex.printStackTrace();
}
throw new Error(Errors.SYNTAX_ERROR);
}
} catch (Error e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
PIDisplay.error = e.id.toString();
System.err.println(e.id);
}
}
private void changeEquationScreen() {
if (equazioneCorrente != null && equazioneCorrente.length() > 0) {
MathInputScreen cloned = clone();
@ -536,10 +696,70 @@ public class MathInputScreen extends Screen {
@Override
public boolean keyReleased(Key k) {
return false;
}
public void showVariablesDialog(final Runnable runnable) {
Thread ct = new Thread(()->{
ArrayList<Function> variablesInFunctions = getVariables(f.toArray(new Function[f.size()]));
for (VariableValue f : variablesValues) {
if (variablesInFunctions.contains(f.v)) {
variablesInFunctions.remove(f.v);
}
}
boolean cancelled = false;
for (Function f : variablesInFunctions) {
ChooseVariableValueScreen cvs = new ChooseVariableValueScreen(this, new VariableValue((Variable) f, new Number(null, 0)));
PIDisplay.INSTANCE.setScreen(cvs);
try {
while (PIDisplay.screen == cvs) {
Utils.debug.println(Thread.currentThread().getName());
Thread.sleep(200);
}
} catch (InterruptedException e) {}
if (cvs.resultNumberValue == null) {
cancelled = true;
break;
} else {
final int is = variablesValues.size();
for (int i = 0; i < is; i++) {
if (variablesValues.get(i).v == f) {
variablesValues.remove(i);
}
}
variablesValues.add(new VariableValue((Variable) f, (Number) cvs.resultNumberValue));
}
}
if (!cancelled) {
runnable.run();
Utils.debug.println(f.toString());
}
});
ct.setName("Variables user-input queue thread");
ct.setPriority(Thread.MIN_PRIORITY);
ct.setDaemon(true);
ct.start();
}
private ArrayList<Function> getVariables(Function[] fncs) {
ArrayList<Function> res = new ArrayList<>();
for (Function f : fncs) {
if (f instanceof FunctionTwoValues) {
res.addAll(getVariables(new Function[]{((FunctionTwoValues)f).getVariable1(), ((FunctionTwoValues)f).getVariable2()}));
} else if (f instanceof FunctionMultipleValues) {
res.addAll(getVariables(((FunctionMultipleValues)f).getVariables()));
} else if (f instanceof AnteriorFunction) {
res.addAll(getVariables(new Function[]{((AnteriorFunction)f).getVariable()}));
} else if (f instanceof Variable) {
if (!res.contains(f)) {
res.add(f);
}
}
}
return res;
}
@Override
public MathInputScreen clone() {
MathInputScreen es = this;
@ -557,6 +777,7 @@ public class MathInputScreen extends Screen {
es2.errorLevel = es.errorLevel;
es2.mustRefresh = es.mustRefresh;
es2.afterDoNextStep = es.afterDoNextStep;
es2.variablesValues = Utils.cloner.deepClone(es.variablesValues);
return es2;
}