├── photon.properties ├── out ├── win │ └── photon.properties ├── artifacts │ ├── photon.properties │ └── PhotonFileValidator.jar └── production │ └── PhotonFileValidator │ └── META-INF │ └── MANIFEST.MF ├── doc ├── screen1.png ├── screen2.png ├── screen4.png ├── screen5.png ├── screen6.png ├── windows.png ├── release.md └── javacode.md ├── src ├── META-INF │ └── MANIFEST.MF └── photon │ ├── file │ ├── parts │ │ ├── IPhotonProgress.java │ │ ├── PhotonRow.java │ │ ├── PhotonLine.java │ │ ├── PhotonProjectType.java │ │ ├── PhotonDot.java │ │ ├── IFileHeader.java │ │ ├── PhotonFilePrintParameters.java │ │ ├── PhotonFileMachineInfo.java │ │ ├── PhotonMatix.java │ │ ├── PhotonAaMatrix.java │ │ ├── PhotonFilePreview.java │ │ ├── PhotonOutputStream.java │ │ ├── photons │ │ │ └── PhotonsFileHeader.java │ │ └── PhotonInputStream.java │ └── ui │ │ ├── Text.java │ │ ├── ScrollPosition.java │ │ ├── PhotonAALevel.java │ │ ├── PhotonPreviewImage.java │ │ ├── PhotonEditPanel.java │ │ ├── ScrollUtil.java │ │ ├── PhotonAaPanel.java │ │ └── PhotonLayerImage.java │ └── application │ ├── render │ ├── elements │ │ ├── RenderAsSegment.java │ │ ├── RenderAsTriangle.java │ │ ├── World.java │ │ ├── BaseElement.java │ │ ├── Segment.java │ │ ├── Triangle.java │ │ └── Vertex.java │ ├── interfaces │ │ ├── IRenderer.java │ │ └── ITransformable.java │ ├── storage │ │ ├── RotationBaseMatrix.java │ │ ├── Renderer.java │ │ └── BaseMatrix.java │ ├── ResinLayer.java │ ├── PhotonBuildPlate.java │ ├── OnionMousePanel.java │ ├── PhotonBuildPlateTop.java │ ├── utils │ │ └── VectorUtil.java │ └── OnionPanel.java │ ├── base │ └── BaseFrame.java │ ├── utilities │ ├── PhotonFixWorker.java │ ├── PhotonFixAllWorker.java │ ├── PhotonRemoveAllIslandsWorker.java │ ├── PhotonCalcWorker.java │ ├── PhotonAaWorker.java │ ├── PhotonPlayWorker.java │ └── PhotonLoadWorker.java │ └── dialogs │ ├── PreviewDialog.form │ ├── PlayDialog.form │ ├── AntiAliaseDialog.form │ ├── FixDialog.form │ └── EditDialog.form ├── test └── 10mm-benchy.photon ├── install ├── img │ ├── photonster.psd │ ├── Win │ │ ├── validator16.png │ │ ├── validator20.png │ │ ├── validator32.png │ │ ├── validator40.png │ │ └── validator64.png │ ├── icons │ │ ├── validator.icns │ │ └── validator.ico │ ├── logos │ │ ├── validator.bmp │ │ ├── validator2048.png │ │ ├── validator4096.png │ │ ├── validatorlogo.png │ │ ├── validatorwhite2048.png │ │ └── validatorwhite4096.png │ └── background │ │ ├── background.jpg │ │ └── background2.jpg ├── makeapp.sh ├── makeappjre.sh ├── makewinlauncher.xml ├── makewin.iss └── makewinjre.iss ├── LICENSE └── versions.md /photon.properties: -------------------------------------------------------------------------------- 1 | margin=10 2 | peel=5.5 3 | -------------------------------------------------------------------------------- /out/win/photon.properties: -------------------------------------------------------------------------------- 1 | margin=0 2 | peel=5.5 3 | -------------------------------------------------------------------------------- /out/artifacts/photon.properties: -------------------------------------------------------------------------------- 1 | margin=0 2 | peel=5.5 3 | -------------------------------------------------------------------------------- /doc/screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/doc/screen1.png -------------------------------------------------------------------------------- /doc/screen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/doc/screen2.png -------------------------------------------------------------------------------- /doc/screen4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/doc/screen4.png -------------------------------------------------------------------------------- /doc/screen5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/doc/screen5.png -------------------------------------------------------------------------------- /doc/screen6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/doc/screen6.png -------------------------------------------------------------------------------- /doc/windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/doc/windows.png -------------------------------------------------------------------------------- /src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: photon.application.MainForm 3 | -------------------------------------------------------------------------------- /test/10mm-benchy.photon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/test/10mm-benchy.photon -------------------------------------------------------------------------------- /install/img/photonster.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/photonster.psd -------------------------------------------------------------------------------- /out/production/PhotonFileValidator/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: photon.application.MainForm 3 | -------------------------------------------------------------------------------- /install/img/Win/validator16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/Win/validator16.png -------------------------------------------------------------------------------- /install/img/Win/validator20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/Win/validator20.png -------------------------------------------------------------------------------- /install/img/Win/validator32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/Win/validator32.png -------------------------------------------------------------------------------- /install/img/Win/validator40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/Win/validator40.png -------------------------------------------------------------------------------- /install/img/Win/validator64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/Win/validator64.png -------------------------------------------------------------------------------- /install/img/icons/validator.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/icons/validator.icns -------------------------------------------------------------------------------- /install/img/icons/validator.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/icons/validator.ico -------------------------------------------------------------------------------- /install/img/logos/validator.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/logos/validator.bmp -------------------------------------------------------------------------------- /install/img/logos/validator2048.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/logos/validator2048.png -------------------------------------------------------------------------------- /install/img/logos/validator4096.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/logos/validator4096.png -------------------------------------------------------------------------------- /install/img/logos/validatorlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/logos/validatorlogo.png -------------------------------------------------------------------------------- /install/img/background/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/background/background.jpg -------------------------------------------------------------------------------- /install/img/background/background2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/background/background2.jpg -------------------------------------------------------------------------------- /out/artifacts/PhotonFileValidator.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/out/artifacts/PhotonFileValidator.jar -------------------------------------------------------------------------------- /install/img/logos/validatorwhite2048.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/logos/validatorwhite2048.png -------------------------------------------------------------------------------- /install/img/logos/validatorwhite4096.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Photonsters/PhotonFileValidator/HEAD/install/img/logos/validatorwhite4096.png -------------------------------------------------------------------------------- /install/makeapp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | jar2app ../out/artifacts/PhotonFileValidator.jar -i img/icons/validator.icns -n "Photon File Validator" -v 2.1.0 -s 2.1.0 -c "(C) Copyright by Bonosoft" -j "-Xmx5g -Xms1g" 3 | 4 | -------------------------------------------------------------------------------- /install/makeappjre.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | jar2app ../out/artifacts/PhotonFileValidator.jar -i img/icons/validator.icns -n "Photon File Validator jre" -v 2.1.0 -s 2.1.0 -c "(C) Copyright by Bonosoft" -j "-Xmx5g -Xms1g" -r /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk 3 | 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Bonosoft 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/photon/file/parts/IPhotonProgress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | /** 28 | * by bn on 05/07/2018. 29 | */ 30 | public interface IPhotonProgress { 31 | void showInfo(String str); 32 | } 33 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonRow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | import java.util.ArrayList; 28 | 29 | /** 30 | * by bn on 10/07/2018. 31 | */ 32 | public class PhotonRow { 33 | public ArrayList lines = new ArrayList<>(); 34 | } 35 | -------------------------------------------------------------------------------- /src/photon/application/render/elements/RenderAsSegment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.elements; 26 | 27 | public class RenderAsSegment extends BaseElement { 28 | 29 | public RenderAsSegment(){ 30 | super(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/photon/application/render/elements/RenderAsTriangle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.elements; 26 | 27 | public class RenderAsTriangle extends BaseElement { 28 | 29 | public RenderAsTriangle(){ 30 | super(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/photon/file/ui/Text.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.ui; 26 | 27 | public class Text { 28 | 29 | public static String formatSeconds(float time) { 30 | if (time % 1 == 0) { 31 | return String.format("%.0fs", time); 32 | } else { 33 | return String.format("%.1fs", time); 34 | } 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonLine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | import java.awt.*; 28 | 29 | /** 30 | * by bn on 10/07/2018. 31 | */ 32 | public class PhotonLine { 33 | public Color color; 34 | public int length; 35 | 36 | public PhotonLine(Color color, int length) { 37 | this.color = color; 38 | this.length = length; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /doc/release.md: -------------------------------------------------------------------------------- 1 | # Release procedure 2 | This is a checklist for creating a release 3 | 4 | ### Version Number 5 | 6 | - Update the version number (in src/photon/application/MainForm) of frame title located in the main funtion. 7 | - Update the version number in makeapp.sh 8 | - Update the version number in makeappjre.sh 9 | - Update the version number in makewin.iss 10 | - Update the version number in makewinjre.iss 11 | - Update the version number in makewinlauncher.xml 12 | 13 | ### Build 14 | 15 | - Compile and make the out/artifacts/PhotonFileValidator.jar 16 | - Push the jar file to GitHub 17 | - Pull the jar file and test it on both Mac and Windows. 18 | 19 | ### Jar Version 20 | 21 | - Zip the two files in out/artifacts/* and name the file "jar-photonfilevalidator-x.x.zip" (x.x is version number) 22 | 23 | ### macOS version (on a mac) 24 | 25 | - run makeapp.sh and pack the PhotonFileValidator.app to a DMG file, name the file "osx-photonfilevalidator-x.x.dmg" 26 | - run makeappjre.sh and pack the PhotonFileValidator.app to a DMG file, name the file "osx-jre-photonfilevalidator-x.x.dmg" 27 | 28 | ### Windows version (on a Windows) 29 | 30 | - run Launch4j, load install/makewinlauncher.xml and Build Wrapper (will be in out/win/*) 31 | - run Inno Setup Compiler, load install/makewin.iss and compile 32 | - run Inno Setup Compiler, load install/makewinjre.iss and compile 33 | 34 | ### Test 35 | 36 | - unzip and test the jar version 37 | - test the maxOS installers 38 | - test the windows installers 39 | 40 | ## Create a Release 41 | 42 | - Create a new release in GitHub 43 | - Describe the release improvements and bugfixes 44 | - Upload jar, mac and windows installers 45 | - post a picture or video on facebook with a link to the GitHub release page 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/photon/application/render/elements/World.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.elements; 26 | 27 | import photon.application.render.interfaces.ITransformable; 28 | 29 | import java.util.Vector; 30 | 31 | public class World extends BaseElement { 32 | 33 | public World() { 34 | super(); 35 | } 36 | 37 | public World(Vector iTransformables) { 38 | super(iTransformables); 39 | } 40 | 41 | public void clear() { 42 | iTransformables.clear(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonProjectType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | /** 28 | * by bn on 30/06/2018. 29 | */ 30 | public enum PhotonProjectType { 31 | cast (0), 32 | lcdMirror (1), 33 | ; 34 | 35 | int projectID; 36 | 37 | PhotonProjectType(int projectID) { 38 | this.projectID = projectID; 39 | } 40 | 41 | public static PhotonProjectType find(int typeID) { 42 | for(PhotonProjectType photonProjectType : values()) { 43 | if (photonProjectType.projectID == typeID) { 44 | return photonProjectType; 45 | } 46 | } 47 | return lcdMirror; 48 | } 49 | 50 | public int getProjectID() { 51 | return projectID; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/photon/application/render/interfaces/IRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.interfaces; 26 | 27 | import photon.application.render.elements.World; 28 | 29 | import java.awt.*; 30 | import java.awt.image.ImageObserver; 31 | 32 | public interface IRenderer { 33 | /** 34 | * This method is called to effectively render a world 35 | * @param world world object containing the set of 3d objects 36 | * @param view off screen image to render the world in 37 | * @param observer image observer object necessary to get width and height of the off screen image which can change in dimension dynamically 38 | */ 39 | 40 | void render(World world,Image view, ImageObserver observer); 41 | } 42 | -------------------------------------------------------------------------------- /src/photon/file/ui/ScrollPosition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.ui; 26 | 27 | /** 28 | * by bn on 02/07/2018. 29 | */ 30 | public enum ScrollPosition { 31 | 32 | None (0), 33 | Top (1), 34 | VerticalCenter (2), 35 | Bottom (4), 36 | Left (8), 37 | HorizontalCenter (16), 38 | Right (32); 39 | 40 | public int scrollPos; 41 | 42 | ScrollPosition(int scrollPos) { 43 | this.scrollPos = scrollPos; 44 | } 45 | 46 | 47 | public static ScrollPosition contains(int vertical) { 48 | for(ScrollPosition scrollPosition : values()) { 49 | if ((scrollPosition.scrollPos & vertical)>0) { 50 | return scrollPosition; 51 | } 52 | } 53 | return None; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonDot.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | /** 28 | * by bn on 02/07/2018. 29 | */ 30 | public class PhotonDot { 31 | public int x; 32 | public int y; 33 | 34 | public PhotonDot(int x, int y) { 35 | this.x = x; 36 | this.y = y; 37 | } 38 | 39 | @Override 40 | public boolean equals(Object o) { 41 | if (this == o) return true; 42 | if (!(o instanceof PhotonDot)) return false; 43 | 44 | PhotonDot photonDot = (PhotonDot) o; 45 | 46 | return x == photonDot.x && y == photonDot.y; 47 | 48 | } 49 | 50 | @Override 51 | public int hashCode() { 52 | int result = x; 53 | result = 31 * result + y; 54 | return result; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /install/makewinlauncher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | gui 5 | D:\Users\bn\Documents\GitHub\PhotonFileViewer\out\artifacts\PhotonFileValidator.jar 6 | D:\Users\bn\Documents\GitHub\PhotonFileViewer\out\win\photonfilevalidator.exe 7 | 8 | 9 | . 10 | normal 11 | http://java.com/download 12 | https://github.com/Photonsters/PhotonFileValidator 13 | false 14 | false 15 | 16 | D:\Users\bn\Documents\GitHub\PhotonFileViewer\install\img\icons\validator.ico 17 | 18 | jre 19 | true 20 | false 21 | 1.8.0 22 | 23 | preferJre 24 | 64/32 25 | 1024 26 | 5120 27 | 28 | 29 | D:\Users\bn\Documents\GitHub\PhotonFileViewer\install\img\logos\validator.bmp 30 | true 31 | 60 32 | true 33 | 34 | 35 | 2.1.0.0 36 | 2.1 37 | Photon File Validator 38 | (C) Copyright by Bonosoft 39 | 2.1.0.0 40 | 2.1 41 | Photon File Validator 42 | Bonosoft 43 | Photon file validator 44 | photonfilevalidator.exe 45 | 46 | ENGLISH_US 47 | 48 | -------------------------------------------------------------------------------- /versions.md: -------------------------------------------------------------------------------- 1 | # Version History and change log 2 | 3 | ### 1.5 Render in 3D (July 31, 2018) 4 | - Added a view where some layers are shown in 3D (peel the onion) 5 | - Added option to fix layer Z position round error from slicer 6 | - Added option to cancel calculation by opening a new file 7 | - Updated to the new logo and color 8 | - Added option to use "Command / Alt" and Arrows to navigate layer and render 9 | - Changed time calculation to use peel time or offtime (whichever is greatest) 10 | 11 | ### 1.4 Layer Edit (July 17, 2018) 12 | - Added option to manually edit layer data. 13 | - Fixed null pointer when saved during calculation 14 | 15 | ### 1.3 Navigation, file load and Fix dialog (July 16, 2018) 16 | - Added an option to auto fix small pixel related islands 17 | - Added the option to browse backwards for margin and problem areas 18 | - Now using native file open dialog, so users can use all attached drives 19 | - Fixed a bug where some overhangs was reported as islands 20 | - Separated file load and layer calculation workers 21 | 22 | ### 1.2 Slider and new name: Photon File Validator (July 13, 2018) 23 | - Changed java memory to min 1GB and max 5GB 24 | - Added a slider for the layers, so you can navigate quickly through all layers 25 | - Renamed the application, as validating much better describes the purpose of the application 26 | - Created new launchers for macOS and Windows, also created new installers 27 | 28 | ### 1.1 Added Zoom and Margin checks (July 11, 2018) 29 | - Changed memory handling to allow for 6000+ layer files on 4GB machines 30 | - Added Zoom from 0.5x to 2x in 5 steps where the middle is no zoom 1:1 31 | - Added margin checks, to avoid printing to close to the border 32 | 33 | ### 1.0 First release of Photon File Viewer (July 9, 2018) 34 | - Open a Photon and ChiTu sliced file 35 | - Save the file with new settings for exposure, offtime, and bottom layers 36 | - View file layers in full pixel perfect size 37 | - View small and large preview images 38 | - View information on pixels, print time calculation, and the resin use in ml 39 | - View layers with island, and quickly navigate to these -------------------------------------------------------------------------------- /install/makewin.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | #define MyAppName "Photon File Validator" 5 | #define MyAppVersion "2.1" 6 | #define MyAppPublisher "Bonosoft" 7 | #define MyAppURL "https://github.com/Photonsters/PhotonFileValidator" 8 | #define MyAppExeName "photonfilevalidator.exe" 9 | 10 | [Setup] 11 | ; NOTE: The value of AppId uniquely identifies this application. 12 | ; Do not use the same AppId value in installers for other applications. 13 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 14 | AppId={{63A4875F-C11F-4FF1-B724-539ECD089388} 15 | AppName={#MyAppName} 16 | AppVersion={#MyAppVersion} 17 | ;AppVerName={#MyAppName} {#MyAppVersion} 18 | AppPublisher={#MyAppPublisher} 19 | AppPublisherURL={#MyAppURL} 20 | AppSupportURL={#MyAppURL} 21 | AppUpdatesURL={#MyAppURL} 22 | DefaultDirName={pf}\{#MyAppName} 23 | DisableProgramGroupPage=yes 24 | OutputDir=D:\Users\bn\Documents\GitHub\PhotonFileViewer\release 25 | OutputBaseFilename=win-photonfilevalidator-{#MyAppVersion} 26 | SetupIconFile=D:\Users\bn\Documents\GitHub\PhotonFileViewer\install\img\icons\validator.ico 27 | Compression=lzma 28 | SolidCompression=yes 29 | 30 | [Languages] 31 | Name: "english"; MessagesFile: "compiler:Default.isl" 32 | 33 | [Tasks] 34 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 35 | 36 | [Files] 37 | Source: "D:\Users\bn\Documents\GitHub\PhotonFileViewer\out\win\photonfilevalidator.exe"; DestDir: "{app}"; Flags: ignoreversion 38 | Source: "D:\Users\bn\Documents\GitHub\PhotonFileViewer\out\win\photon.properties"; DestDir: "{app}"; Flags: ignoreversion 39 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 40 | 41 | [Icons] 42 | Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 43 | Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 44 | 45 | [Run] 46 | Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 47 | 48 | -------------------------------------------------------------------------------- /src/photon/file/ui/PhotonAALevel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.ui; 26 | 27 | public enum PhotonAALevel { 28 | NoAntiAliase (1,1, "No Anti Aliase"), 29 | AA2 (2, 2, "2 Layers AA"), 30 | AA4 (3, 4, "4 Layers AA"), 31 | AA8 (4, 8, "8 Layers AA"), 32 | AA16 (5, 16, "16 Layers AA"), 33 | 34 | ; 35 | 36 | public int index; 37 | public int levels; 38 | public String name; 39 | 40 | PhotonAALevel(int index, int levels, String name) { 41 | this.index = index; 42 | this.levels = levels; 43 | this.name = name; 44 | } 45 | 46 | public static PhotonAALevel find(int id) { 47 | for(PhotonAALevel photonAALevel : values()) { 48 | if (photonAALevel.index==id) { 49 | return photonAALevel; 50 | } 51 | } 52 | return NoAntiAliase; 53 | } 54 | 55 | public static PhotonAALevel findByLevel(int id) { 56 | for(PhotonAALevel photonAALevel : values()) { 57 | if (photonAALevel.levels==id) { 58 | return photonAALevel; 59 | } 60 | } 61 | return NoAntiAliase; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/photon/file/parts/IFileHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | import java.util.List; 28 | 29 | public interface IFileHeader { 30 | 31 | String getInformation(); 32 | int getNumberOfLayers(); 33 | 34 | int getResolutionY(); 35 | int getResolutionX(); 36 | 37 | float getBuildAreaX(); 38 | float getBuildAreaY(); 39 | 40 | int getBottomLayers(); 41 | void setBottomLayers(int bottomLayers); 42 | 43 | float getLayerHeight(); 44 | 45 | float getExposureTimeSeconds(); 46 | 47 | float getBottomExposureTimeSeconds(); 48 | void setExposureBottomTimeSeconds(float exposureBottomTimeSeconds); 49 | 50 | void setExposureTimeSeconds(float exposureTimeSeconds); 51 | float getNormalExposure(); 52 | 53 | float getOffTimeSeconds(); 54 | void setOffTimeSeconds(float offTimeSeconds); 55 | 56 | int getPrintTimeSeconds(); 57 | boolean isMirrored(); 58 | 59 | boolean hasAA(); 60 | int getAALevels(); 61 | void setAALevels(int levels, List layers); 62 | 63 | int getVersion(); 64 | void setFileVersion(int i); 65 | 66 | int getByteSize(); 67 | void unLink(); 68 | } 69 | -------------------------------------------------------------------------------- /src/photon/application/base/BaseFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.base; 26 | 27 | import photon.application.MainForm; 28 | 29 | import javax.swing.*; 30 | import java.awt.*; 31 | import java.awt.event.AWTEventListener; 32 | import java.awt.event.KeyEvent; 33 | 34 | /** 35 | * by bn on 31/07/2018. 36 | */ 37 | public class BaseFrame extends JFrame implements AWTEventListener { 38 | public BaseForm baseForm; 39 | 40 | public BaseFrame(String title) throws HeadlessException { 41 | super(title); 42 | this.getToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 43 | } 44 | 45 | @Override 46 | public void eventDispatched(AWTEvent event) { 47 | if(event instanceof KeyEvent){ 48 | KeyEvent key = (KeyEvent)event; 49 | if(key.getID()== KeyEvent.KEY_PRESSED){ //Handle key presses 50 | 51 | if ((key.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) == Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) { 52 | baseForm.handleKeyEvent(key); 53 | } 54 | } 55 | } 56 | } 57 | 58 | public void setMainForm(MainForm mainForm) { 59 | baseForm = mainForm; 60 | mainForm.frame = this; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/photon/file/ui/PhotonPreviewImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.ui; 26 | 27 | import photon.file.parts.PhotonFilePreview; 28 | 29 | import javax.swing.*; 30 | import java.awt.*; 31 | import java.awt.image.BufferedImage; 32 | 33 | /** 34 | * by bn on 03/07/2018. 35 | */ 36 | public class PhotonPreviewImage extends JPanel { 37 | private BufferedImage image; 38 | 39 | public PhotonPreviewImage(int width, int height) { 40 | if (width>0 && height>0) { 41 | image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 42 | setPreferredSize(new Dimension(width, height)); 43 | } 44 | } 45 | 46 | @Override 47 | protected void paintComponent(Graphics g) { 48 | if (image!=null) { 49 | g.drawImage(image, 0, 0, null); 50 | } 51 | } 52 | 53 | public void reInit(int width, int height) { 54 | if (width>0 && height>0) { 55 | image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 56 | setPreferredSize(new Dimension(width, height)); 57 | } 58 | } 59 | 60 | public void drawImage(PhotonFilePreview preview) { 61 | if (image!=null && preview.getResolutionX()>0 && preview.getResolutionY()>0) { 62 | image.getRaster().setDataElements(0, 0, preview.getResolutionX(), preview.getResolutionY(), preview.getImageData()); 63 | } 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/photon/application/render/interfaces/ITransformable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.interfaces; 26 | 27 | import photon.application.render.elements.Vertex; 28 | import photon.application.render.storage.RotationBaseMatrix; 29 | 30 | public interface ITransformable { 31 | 32 | /** 33 | * This method scales all 3 dimensions by the same quantity 34 | * @param factor scale factor 35 | */ 36 | void scale(double factor); 37 | 38 | /** 39 | * This method scales each dimension indipendently 40 | * x,y and z values of the Vertex object are used separately to scale 41 | * each dimension respectively 42 | * @param vector Vertex value 43 | */ 44 | void scale(Vertex vector); 45 | 46 | /** 47 | * This method rotates the object multiplicating with rotation matrix 48 | * wich must be created and prepared previously 49 | * @param rotationMatrix rotation matrix 50 | */ 51 | void rotate(RotationBaseMatrix rotationMatrix); 52 | 53 | /** 54 | * This method translates an object by the x,y,z values of the 55 | * vector in the x,y,z directions 56 | * @param vector translation vector 57 | */ 58 | void translate(Vertex vector); 59 | 60 | /** 61 | * Sets the color of this transformable 62 | * @param r red (0..255) 63 | * @param g green (0..255) 64 | * @param b blue (0..255) 65 | */ 66 | void setColor(int r,int g,int b); 67 | } 68 | -------------------------------------------------------------------------------- /src/photon/application/utilities/PhotonFixWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.utilities; 26 | 27 | import photon.application.MainForm; 28 | import photon.application.dialogs.FixDialog; 29 | import photon.file.PhotonFile; 30 | import photon.file.parts.IPhotonProgress; 31 | 32 | import javax.swing.*; 33 | 34 | /** 35 | * by bn on 14/07/2018. 36 | */ 37 | public class PhotonFixWorker extends SwingWorker implements IPhotonProgress { 38 | private FixDialog fixDialog; 39 | private PhotonFile photonFile; 40 | private MainForm mainForm; 41 | 42 | public PhotonFixWorker(FixDialog fixDialog, PhotonFile photonFile, MainForm mainForm) { 43 | this.fixDialog = fixDialog; 44 | this.photonFile = photonFile; 45 | this.mainForm = mainForm; 46 | } 47 | 48 | @Override 49 | protected void process(java.util.List chunks) { 50 | for (String str : chunks) { 51 | fixDialog.appendInformation(str); 52 | } 53 | } 54 | 55 | @Override 56 | protected void done() { 57 | fixDialog.enableButtons(); 58 | fixDialog.appendInformation("

Done.

"); 59 | mainForm.showFileInformation(); 60 | } 61 | 62 | @Override 63 | public void showInfo(String str) { 64 | publish(str); 65 | } 66 | 67 | @Override 68 | protected Integer doInBackground() throws Exception { 69 | try { 70 | photonFile.fixLayers(this); 71 | } catch (Exception e) { 72 | publish("

" + e.getMessage()+ "

"); 73 | return 0; 74 | } 75 | return 1; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/photon/application/utilities/PhotonFixAllWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.utilities; 26 | 27 | import photon.application.MainForm; 28 | import photon.application.dialogs.FixDialog; 29 | import photon.file.PhotonFile; 30 | import photon.file.parts.IPhotonProgress; 31 | 32 | import javax.swing.*; 33 | 34 | /** 35 | * by bn on 14/07/2018. 36 | */ 37 | public class PhotonFixAllWorker extends SwingWorker implements IPhotonProgress { 38 | private FixDialog fixDialog; 39 | private PhotonFile photonFile; 40 | private MainForm mainForm; 41 | 42 | public PhotonFixAllWorker(FixDialog fixDialog, PhotonFile photonFile, MainForm mainForm) { 43 | this.fixDialog = fixDialog; 44 | this.photonFile = photonFile; 45 | this.mainForm = mainForm; 46 | } 47 | 48 | @Override 49 | protected void process(java.util.List chunks) { 50 | for (String str : chunks) { 51 | fixDialog.appendInformation(str); 52 | } 53 | } 54 | 55 | @Override 56 | protected void done() { 57 | fixDialog.enableButtons(); 58 | fixDialog.appendInformation("

Done.

"); 59 | mainForm.showFileInformation(); 60 | } 61 | 62 | @Override 63 | public void showInfo(String str) { 64 | publish(str); 65 | } 66 | 67 | @Override 68 | protected Integer doInBackground() throws Exception { 69 | try { 70 | photonFile.fixAll(this); 71 | } catch (Exception e) { 72 | publish("

" + e.getMessage()+ "

"); 73 | return 0; 74 | } 75 | return 1; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/photon/application/utilities/PhotonRemoveAllIslandsWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.utilities; 26 | 27 | import photon.application.MainForm; 28 | import photon.application.dialogs.FixDialog; 29 | import photon.file.PhotonFile; 30 | import photon.file.parts.IPhotonProgress; 31 | 32 | import javax.swing.*; 33 | 34 | /** 35 | * by bn on 14/07/2018. 36 | */ 37 | public class PhotonRemoveAllIslandsWorker extends SwingWorker implements IPhotonProgress { 38 | private FixDialog fixDialog; 39 | private PhotonFile photonFile; 40 | private MainForm mainForm; 41 | 42 | public PhotonRemoveAllIslandsWorker(FixDialog fixDialog, PhotonFile photonFile, MainForm mainForm) { 43 | this.fixDialog = fixDialog; 44 | this.photonFile = photonFile; 45 | this.mainForm = mainForm; 46 | } 47 | 48 | @Override 49 | protected void process(java.util.List chunks) { 50 | for (String str : chunks) { 51 | fixDialog.appendInformation(str); 52 | } 53 | } 54 | 55 | @Override 56 | protected void done() { 57 | fixDialog.enableButtons(); 58 | fixDialog.appendInformation("

Done.

"); 59 | mainForm.showFileInformation(); 60 | } 61 | 62 | @Override 63 | public void showInfo(String str) { 64 | publish(str); 65 | } 66 | 67 | @Override 68 | protected Integer doInBackground() throws Exception { 69 | try { 70 | photonFile.removeAllIslands(this); 71 | } catch (Exception e) { 72 | publish("

" + e.getMessage()+ "

"); 73 | return 0; 74 | } 75 | return 1; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/photon/application/render/storage/RotationBaseMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.storage; 26 | 27 | 28 | public class RotationBaseMatrix extends BaseMatrix { 29 | /** 30 | * This constructor creates a complex 3D rotation matrix which rotates 31 | * around x,y and z by x_angle,y_angle and z_angle 32 | * by multiplying 3 elementary rotation matrices 33 | * @param x_angle x angle expressed in radians 34 | * @param y_angle y angle expressed in radians 35 | * @param z_angle z angle expressed in radians 36 | */ 37 | public RotationBaseMatrix(double x_angle, double y_angle, double z_angle){ 38 | //initializes the X rotation matrix 39 | super(1, 0, 0, 0, 40 | 0, Math.cos(x_angle), Math.sin(x_angle), 0, 41 | 0, -Math.sin(x_angle), Math.cos(x_angle), 0, 42 | 0, 0, 0, 1); 43 | 44 | //multiplies with the Y rotation matrix 45 | multiply( 46 | new BaseMatrix( 47 | Math.cos(y_angle), 0, -Math.sin(y_angle), 0, 48 | 0 , 1, 0, 0, 49 | Math.sin(y_angle), 0, Math.cos(y_angle), 0, 50 | 0 , 0, 0, 1) 51 | ); 52 | 53 | //multiplies with the Z rotation matrix 54 | multiply( 55 | new BaseMatrix( 56 | Math.cos(z_angle), Math.sin(z_angle), 0, 0, 57 | -Math.sin(z_angle), Math.cos(z_angle), 0, 0, 58 | 0, 0, 1, 0, 59 | 0, 0, 0, 1) 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/photon/application/utilities/PhotonCalcWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.utilities; 26 | 27 | import photon.application.MainForm; 28 | import photon.file.PhotonFile; 29 | import photon.file.parts.IPhotonProgress; 30 | 31 | import javax.swing.*; 32 | import java.awt.*; 33 | import java.io.File; 34 | 35 | /** 36 | * by bn on 16/07/2018. 37 | */ 38 | public class PhotonCalcWorker extends SwingWorker implements IPhotonProgress { 39 | private MainForm mainForm; 40 | private File file; 41 | 42 | public PhotonCalcWorker(MainForm mainForm) { 43 | this.mainForm = mainForm; 44 | mainForm.marginInfo.setText(""); 45 | } 46 | 47 | @Override 48 | protected void process(java.util.List chunks) { 49 | for (String str : chunks) { 50 | mainForm.layerInfo.setText(str); 51 | } 52 | } 53 | 54 | @Override 55 | protected void done() { 56 | mainForm.openBtn.setEnabled(true); 57 | if (mainForm.photonFile!=null) { 58 | mainForm.showFileInformation(); 59 | } 60 | } 61 | 62 | @Override 63 | protected Integer doInBackground() throws Exception { 64 | publish("Calculating layers..."); 65 | try { 66 | mainForm.photonFile.setMargin(mainForm.margin); 67 | mainForm.photonFile.calculate(this); 68 | publish("Calculation Complete..."); 69 | } catch (Exception e) { 70 | mainForm.marginInfo.setForeground(Color.red); 71 | mainForm.marginInfo.setText("Could not calculate the file."); 72 | return 0; 73 | } 74 | return 1; 75 | } 76 | 77 | @Override 78 | public void showInfo(String str) { 79 | publish(str); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/photon/application/render/elements/BaseElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.elements; 26 | 27 | import photon.application.render.interfaces.ITransformable; 28 | import photon.application.render.storage.RotationBaseMatrix; 29 | 30 | import java.util.Vector; 31 | 32 | 33 | public class BaseElement implements ITransformable { 34 | 35 | public Vector iTransformables; 36 | 37 | public BaseElement(){ 38 | iTransformables =new Vector<>(); 39 | } 40 | 41 | public BaseElement(Vector iTransformables){ 42 | this.iTransformables = iTransformables; 43 | } 44 | 45 | public void add(ITransformable ITransformable){ 46 | iTransformables.add(ITransformable); 47 | } 48 | 49 | public void scale(double factor) { 50 | for (Object transformable : iTransformables) { 51 | ((ITransformable) transformable).scale(factor); 52 | } 53 | } 54 | 55 | public void scale(Vertex vector) { 56 | for (ITransformable iTransformable : iTransformables) { 57 | iTransformable.scale(vector); 58 | } 59 | } 60 | 61 | public void rotate(RotationBaseMatrix rotationMatrix) { 62 | for (ITransformable iTransformable : iTransformables) { 63 | iTransformable.rotate(rotationMatrix); 64 | } 65 | } 66 | 67 | public void translate(Vertex vector) { 68 | for (ITransformable iTransformable : iTransformables) { 69 | iTransformable.translate(vector); 70 | } 71 | } 72 | 73 | public void setColor(int r,int g,int b){ 74 | for (ITransformable iTransformable : iTransformables) { 75 | iTransformable.setColor(r, g, b); 76 | } 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/photon/application/render/ResinLayer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render; 26 | 27 | import photon.application.render.elements.RenderAsSegment; 28 | import photon.application.render.elements.Segment; 29 | import photon.application.render.elements.Vertex; 30 | import photon.file.parts.PhotonFileLayer; 31 | import photon.file.parts.PhotonLayer; 32 | import photon.file.parts.PhotonLine; 33 | import photon.file.parts.PhotonRow; 34 | 35 | import java.awt.*; 36 | import java.util.ArrayList; 37 | 38 | /** 39 | * by bn on 18/07/2018. 40 | */ 41 | public class ResinLayer extends RenderAsSegment { 42 | 43 | public ResinLayer(int width, int height, PhotonFileLayer fileLayer, byte type, int offset) { 44 | double z = offset; 45 | double x1 = -1 * (width/2); 46 | double y1 = -1 * (height/2); 47 | 48 | int black = Color.black.getRGB(); 49 | int red = Color.decode("#FF0000").getRGB(); 50 | 51 | ArrayList rows = fileLayer.getRows(); 52 | if (rows != null) { 53 | int columnNumber = 0; 54 | for (PhotonRow row : rows) { 55 | int i = 0; 56 | for (PhotonLine line : row.lines) { 57 | int end = i + line.length; 58 | if (line.color.getRGB() != black) { 59 | if (type== PhotonLayer.OFF || (type==PhotonLayer.SUPPORTED && line.color.getRGB() != red) || (type==PhotonLayer.ISLAND && line.color.getRGB() == red)) { 60 | iTransformables.add(new Segment(new Vertex(x1 + columnNumber, y1 + i, z), new Vertex(x1 + columnNumber, y1 + end, z))); 61 | } 62 | } 63 | i = end; 64 | } 65 | columnNumber++; 66 | } 67 | } 68 | 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/photon/application/render/elements/Segment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.elements; 26 | 27 | import photon.application.render.storage.RotationBaseMatrix; 28 | import photon.application.render.interfaces.ITransformable; 29 | 30 | public class Segment implements ITransformable { 31 | 32 | public Vertex start; //start point 33 | public Vertex end; //end point 34 | public int r=0; //red color component 35 | public int g=255; //green color component 36 | public int b=0; //blue color component 37 | 38 | /** 39 | * Crates a new Segment with start point "start" and end point "end" 40 | * @param start start point 41 | * @param end end point 42 | */ 43 | public Segment(Vertex start,Vertex end){ 44 | this.start=start; 45 | this.end=end; 46 | } 47 | 48 | /** 49 | * @see ITransformable#scale(double) 50 | * @param factor scale factor 51 | */ 52 | public void scale(double factor) { 53 | start.scale(factor); 54 | end.scale(factor); 55 | } 56 | 57 | /** 58 | * @see ITransformable#scale(Vertex) 59 | * @param vector Vertex value 60 | */ 61 | public void scale(Vertex vector) { 62 | start.scale(vector); 63 | end.scale(vector); 64 | } 65 | 66 | /** 67 | * @see ITransformable#rotate(RotationBaseMatrix) 68 | * @param rotationMatrix rotation matrix 69 | */ 70 | public void rotate(RotationBaseMatrix rotationMatrix) { 71 | start.rotate(rotationMatrix); 72 | end.rotate(rotationMatrix); 73 | } 74 | 75 | /** 76 | * @see ITransformable#translate(Vertex) 77 | * @param vector translation vector 78 | */ 79 | public void translate(Vertex vector) { 80 | start.translate(vector); 81 | end.translate(vector); 82 | } 83 | 84 | /** 85 | * @see ITransformable#setColor(int, int, int) 86 | * @param r red (0..255) 87 | * @param g green (0..255) 88 | * @param b blue (0..255) 89 | */ 90 | public void setColor(int r, int g, int b) { 91 | this.r=r; 92 | this.g=g; 93 | this.b=b; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/photon/application/render/PhotonBuildPlate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render; 26 | 27 | import photon.application.render.elements.RenderAsTriangle; 28 | import photon.application.render.elements.Triangle; 29 | import photon.application.render.elements.Vertex; 30 | 31 | /** 32 | * by bn on 18/07/2018. 33 | */ 34 | public class PhotonBuildPlate extends RenderAsTriangle { 35 | 36 | public PhotonBuildPlate(int width, int height, int plateHeight, int offset) { 37 | 38 | double z = offset - plateHeight; 39 | double zz = offset; 40 | 41 | double x1 = -1 * (width / 2); 42 | double x2 = (width / 2); 43 | double y1 = -1 * (height / 2); 44 | double y2 = height / 2; 45 | 46 | 47 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(x1, y2, z), new Vertex(x2, y2, z))); 48 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(x2, y1, z), new Vertex(x2, y2, z))); 49 | 50 | if (plateHeight>0) { 51 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(x1, y2, z), new Vertex(x1, y2, zz))); 52 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(x1, y1, zz), new Vertex(x1, y2, zz))); 53 | 54 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(x2, y1, z), new Vertex(x2, y1, zz))); 55 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(x1, y1, zz), new Vertex(x2, y1, zz))); 56 | 57 | iTransformables.add(new Triangle(new Vertex(x2, y1, z), new Vertex(x2, y2, z), new Vertex(x2, y2, zz))); 58 | iTransformables.add(new Triangle(new Vertex(x2, y1, z), new Vertex(x2, y1, zz), new Vertex(x2, y2, zz))); 59 | 60 | iTransformables.add(new Triangle(new Vertex(x1, y2, z), new Vertex(x2, y2, z), new Vertex(x2, y2, zz))); 61 | iTransformables.add(new Triangle(new Vertex(x1, y2, z), new Vertex(x1, y2, zz), new Vertex(x2, y2, zz))); 62 | 63 | iTransformables.add(new Triangle(new Vertex(x1, y1, zz), new Vertex(x1, y2, zz), new Vertex(x2, y2, zz))); 64 | iTransformables.add(new Triangle(new Vertex(x1, y1, zz), new Vertex(x2, y1, zz), new Vertex(x2, y2, zz))); 65 | } 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/photon/application/utilities/PhotonAaWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.utilities; 26 | 27 | import photon.application.MainForm; 28 | import photon.file.parts.IPhotonProgress; 29 | import photon.file.parts.PhotonAaMatrix; 30 | 31 | import javax.swing.*; 32 | import java.awt.*; 33 | 34 | public class PhotonAaWorker extends SwingWorker implements IPhotonProgress { 35 | private MainForm mainForm; 36 | private int aaLevels; 37 | private PhotonAaMatrix photonAaMatrix; 38 | private boolean fixState; 39 | 40 | public PhotonAaWorker(MainForm mainForm, int aaLevels, PhotonAaMatrix photonAaMatrix) { 41 | this.mainForm = mainForm; 42 | this.aaLevels = aaLevels; 43 | this.photonAaMatrix = photonAaMatrix; 44 | mainForm.marginInfo.setText(""); 45 | 46 | fixState = mainForm.fixBtn.isEnabled(); 47 | mainForm.openBtn.setEnabled(false); 48 | mainForm.saveBtn.setEnabled(false); 49 | mainForm.fixBtn.setEnabled(false); 50 | mainForm.convertBtn.setEnabled(false); 51 | mainForm.playButton.setEnabled(false); 52 | 53 | } 54 | 55 | @Override 56 | protected void process(java.util.List chunks) { 57 | for (String str : chunks) { 58 | mainForm.layerInfo.setText(str); 59 | } 60 | } 61 | 62 | @Override 63 | protected void done() { 64 | mainForm.openBtn.setEnabled(true); 65 | mainForm.saveBtn.setEnabled(true); 66 | mainForm.fixBtn.setEnabled(fixState); 67 | mainForm.convertBtn.setEnabled(true); 68 | mainForm.playButton.setEnabled(true); 69 | } 70 | 71 | @Override 72 | protected Integer doInBackground() throws Exception { 73 | publish("Calculating AA layers..."); 74 | try { 75 | mainForm.photonFile.setAALevels(aaLevels); 76 | mainForm.photonFile.calculateAaLayers(this, photonAaMatrix); 77 | publish("AA Calculation Complete..."); 78 | if (mainForm.photonFile!=null) { 79 | mainForm.viewLayerInfo();; 80 | } 81 | } catch (Exception e) { 82 | mainForm.marginInfo.setForeground(Color.red); 83 | mainForm.marginInfo.setText("Could not AA calculate the file."); 84 | return 0; 85 | } 86 | return 1; 87 | } 88 | 89 | @Override 90 | public void showInfo(String str) { 91 | publish(str); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/photon/application/render/elements/Triangle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.elements; 26 | 27 | import photon.application.render.interfaces.ITransformable; 28 | import photon.application.render.storage.RotationBaseMatrix; 29 | 30 | public class Triangle implements ITransformable { 31 | 32 | public Vertex v1; //first vertex 33 | public Vertex v2; //second vertex 34 | public Vertex v3; //third vertex 35 | public int r=255; //red color component 36 | public int g=255; //green color component 37 | public int b=255; //blue color component 38 | 39 | /** 40 | * Creates a new triangle having as vertexes those given as parameter 41 | * @param v1 first vertex 42 | * @param v2 second vertex 43 | * @param v3 third vertex 44 | */ 45 | public Triangle(Vertex v1,Vertex v2,Vertex v3){ 46 | this.v1=v1; 47 | this.v2=v2; 48 | this.v3=v3; 49 | } 50 | 51 | /** 52 | * @see ITransformable#scale(double) 53 | * @param factor scale factor 54 | */ 55 | public void scale(double factor) { 56 | v1.scale(factor); 57 | v2.scale(factor); 58 | v3.scale(factor); 59 | } 60 | 61 | /** 62 | * @see ITransformable#scale(Vertex) 63 | * @param vector Vertex value 64 | */ 65 | public void scale(Vertex vector) { 66 | v1.scale(vector); 67 | v2.scale(vector); 68 | v3.scale(vector); 69 | } 70 | 71 | /** 72 | * @see ITransformable#rotate(RotationBaseMatrix) 73 | * @param rotationMatrix rotation matrix 74 | */ 75 | public void rotate(RotationBaseMatrix rotationMatrix) { 76 | v1.rotate(rotationMatrix); 77 | v2.rotate(rotationMatrix); 78 | v3.rotate(rotationMatrix); 79 | } 80 | 81 | /** 82 | * @see ITransformable#translate(Vertex) 83 | * @param vector translation vector 84 | */ 85 | public void translate(Vertex vector) { 86 | v1.translate(vector); 87 | v2.translate(vector); 88 | v3.translate(vector); 89 | } 90 | 91 | /** 92 | * @see ITransformable#setColor(int, int, int) 93 | * @param r red (0..255) 94 | * @param g green (0..255) 95 | * @param b blue (0..255) 96 | */ 97 | public void setColor(int r,int g,int b){ 98 | this.r = r; 99 | this.g = g; 100 | this.b = b; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonFilePrintParameters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | import java.io.ByteArrayInputStream; 28 | import java.util.Arrays; 29 | 30 | public class PhotonFilePrintParameters { 31 | public float bottomLiftDistance = 5.0f; 32 | public float bottomLiftSpeed = 300.0f; 33 | 34 | public float liftingDistance = 5.0f; 35 | public float liftingSpeed = 300.0f; 36 | public float retractSpeed = 300.0f; 37 | 38 | public float volumeMl = 0; 39 | public float weightG = 0; 40 | public float costDollars = 0; 41 | 42 | public float bottomLightOffDelay = 0.0f; 43 | public float lightOffDelay = 0.0f; 44 | public int bottomLayerCount; 45 | 46 | public int p1; 47 | public int p2; 48 | public int p3; 49 | public int p4; 50 | 51 | 52 | public PhotonFilePrintParameters(int bottomLayerCount) { 53 | this.bottomLayerCount = bottomLayerCount; 54 | } 55 | 56 | public PhotonFilePrintParameters(int parametersPos, byte[] file) throws Exception { 57 | byte[] data = Arrays.copyOfRange(file, parametersPos, parametersPos + getByteSize()); 58 | PhotonInputStream ds = new PhotonInputStream(new ByteArrayInputStream(data)); 59 | 60 | bottomLiftDistance = ds.readFloat(); 61 | bottomLiftSpeed = ds.readFloat(); 62 | 63 | liftingDistance = ds.readFloat(); 64 | liftingSpeed = ds.readFloat(); 65 | retractSpeed = ds.readFloat(); 66 | 67 | volumeMl = ds.readFloat(); 68 | weightG = ds.readFloat(); 69 | costDollars = ds.readFloat(); 70 | 71 | bottomLightOffDelay = ds.readFloat(); 72 | lightOffDelay = ds.readFloat(); 73 | bottomLayerCount = ds.readInt(); 74 | 75 | p1 = ds.readInt(); 76 | p2 = ds.readInt(); 77 | p3 = ds.readInt(); 78 | p4 = ds.readInt(); 79 | } 80 | 81 | public void save(PhotonOutputStream os) throws Exception { 82 | os.writeFloat(bottomLiftDistance); 83 | os.writeFloat(bottomLiftSpeed); 84 | 85 | os.writeFloat(liftingDistance); 86 | os.writeFloat(liftingSpeed); 87 | os.writeFloat(retractSpeed); 88 | 89 | os.writeFloat(volumeMl); 90 | os.writeFloat(weightG); 91 | os.writeFloat(costDollars); 92 | 93 | os.writeFloat(bottomLightOffDelay); 94 | os.writeFloat(lightOffDelay); 95 | os.writeInt(bottomLayerCount); 96 | 97 | os.writeInt(p1); 98 | os.writeInt(p2); 99 | os.writeInt(p3); 100 | os.writeInt(p4); 101 | } 102 | 103 | public int getByteSize() { 104 | return 4+4 +4+4+4 +4+4+4 +4+4+4 +4+4+4+4; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/photon/application/render/elements/Vertex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.elements; 26 | 27 | import photon.application.render.storage.RotationBaseMatrix; 28 | import photon.application.render.interfaces.ITransformable; 29 | 30 | public class Vertex implements ITransformable { 31 | public double x; 32 | public double y; 33 | public double z; 34 | public double w; 35 | 36 | /** 37 | * Creates a 0 vector 38 | */ 39 | public Vertex(){ 40 | x=0; 41 | y=0; 42 | z=0; 43 | w=1; 44 | } 45 | 46 | /** 47 | * Creates a vector with the parameter values 48 | * @param x X coordinate 49 | * @param y Y coordinate 50 | * @param z Z coordinate 51 | */ 52 | public Vertex(double x,double y,double z){ 53 | this.x=x; 54 | this.y=y; 55 | this.z=z; 56 | this.w=1; 57 | } 58 | 59 | /** 60 | * Creates a vector with the parameter values 61 | * @param x X coordinate 62 | * @param y Y coordinate 63 | * @param z Z coordinate 64 | * @param w W coordinate (not actually used as a coordinate) 65 | */ 66 | public Vertex(double x,double y,double z,double w){ 67 | this.x=x; 68 | this.y=y; 69 | this.z=z; 70 | this.w=w; 71 | } 72 | 73 | /** 74 | * @see ITransformable#scale(double) 75 | * @param factor scale factor 76 | */ 77 | public void scale(double factor) { 78 | this.x*=factor; 79 | this.y*=factor; 80 | this.z*=factor; 81 | } 82 | 83 | /** 84 | * @see ITransformable#scale(Vertex) 85 | * @param vector Vertex value 86 | */ 87 | public void scale(Vertex vector) { 88 | this.x*=vector.x; 89 | this.y*=vector.y; 90 | this.z*=vector.z; 91 | } 92 | 93 | /** 94 | * @see ITransformable#rotate(RotationBaseMatrix) 95 | * @param rotationMatrix rotation matrix 96 | */ 97 | public void rotate(RotationBaseMatrix rotationMatrix) { 98 | rotationMatrix.multiply(this); 99 | } 100 | 101 | /** 102 | * @see ITransformable#translate(Vertex) 103 | * @param vector translation vector 104 | */ 105 | public void translate(Vertex vector) { 106 | this.x+=vector.x; 107 | this.y+=vector.y; 108 | this.z+=vector.z; 109 | } 110 | 111 | /** 112 | * @see ITransformable#setColor(int, int, int) 113 | * @param r red (0..255) 114 | * @param g green (0..255) 115 | * @param b blue (0..255) 116 | */ 117 | public void setColor(int r, int g, int b) { 118 | //not implemented for the moment 119 | //will be useful when implementing phong shading 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonFileMachineInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | import java.io.ByteArrayInputStream; 28 | import java.util.Arrays; 29 | 30 | /** 31 | * by bn on 01/07/2018. 32 | */ 33 | public class PhotonFileMachineInfo { 34 | private int u1, u2, u3, u4, u5, u6, u7; 35 | 36 | private int machineNameAddress; 37 | private int machineNameSize; 38 | private byte[] machineName = {}; 39 | 40 | private int u8, u9, u10, u11, u12, u13, u14, u15, u16, u17; 41 | 42 | private int infoByteSize; 43 | 44 | public PhotonFileMachineInfo(int address, int byteSize, byte[] file) throws Exception { 45 | 46 | this.infoByteSize = byteSize; 47 | 48 | if (byteSize > 0) { 49 | byte[] data = Arrays.copyOfRange(file, address, address + byteSize); 50 | 51 | try (PhotonInputStream ds = new PhotonInputStream(new ByteArrayInputStream(data))) { 52 | u1 = ds.readInt(); 53 | u2 = ds.readInt(); 54 | u3 = ds.readInt(); 55 | u4 = ds.readInt(); 56 | u5 = ds.readInt(); 57 | u6 = ds.readInt(); 58 | u7 = ds.readInt(); 59 | 60 | machineNameAddress = ds.readInt(); 61 | machineNameSize = ds.readInt(); 62 | 63 | u8 = ds.readInt(); 64 | u9 = ds.readInt(); 65 | u10 = ds.readInt(); 66 | u11 = ds.readInt(); 67 | u12 = ds.readInt(); 68 | u13 = ds.readInt(); 69 | u14 = ds.readInt(); 70 | u15 = ds.readInt(); 71 | u16 = ds.readInt(); 72 | u17 = ds.readInt(); 73 | 74 | } 75 | 76 | machineName = Arrays.copyOfRange(file, machineNameAddress, machineNameAddress + machineNameSize); 77 | } 78 | } 79 | 80 | public void save(PhotonOutputStream os, int startAddress) throws Exception { 81 | if (infoByteSize > 0) { 82 | os.writeInt(u1); 83 | os.writeInt(u2); 84 | os.writeInt(u3); 85 | os.writeInt(u4); 86 | os.writeInt(u5); 87 | os.writeInt(u6); 88 | os.writeInt(u7); 89 | os.writeInt(startAddress + infoByteSize); 90 | os.writeInt(machineName.length); 91 | os.writeInt(u8); 92 | os.writeInt(u9); 93 | os.writeInt(u10); 94 | os.writeInt(u11); 95 | os.writeInt(u12); 96 | os.writeInt(u13); 97 | os.writeInt(u14); 98 | os.writeInt(u15); 99 | os.writeInt(u16); 100 | os.writeInt(u17); 101 | os.write(machineName); 102 | } 103 | } 104 | 105 | public int getByteSize() { 106 | return infoByteSize + machineName.length; 107 | } 108 | 109 | 110 | public void unLink() { 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonMatix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | /** 28 | * by bn on 14/07/2018. 29 | */ 30 | public class PhotonMatix { 31 | 32 | public Integer[][] calcMatrix = new Integer[5][5]; 33 | 34 | public void clear() { 35 | for (int y = 0; y < 5; y++) { 36 | for (int x = 0; x < 5; x++) { 37 | calcMatrix[y][x] = 0; 38 | } 39 | } 40 | } 41 | 42 | 43 | public int set(int x, int y, byte[][] iArray, int width, int height) { 44 | int blanks = 0; 45 | int x0 = x - 2; 46 | int y0 = y - 2; 47 | for (int yi = 0; yi < 5; yi++) { 48 | for (int xi = 0; xi < 5; xi++) { 49 | int y2 = y0 + yi; 50 | int x2 = x0 + xi; 51 | if (y2 >= 0 && y2 < height && x2 >= 0 && x2 < width) { 52 | switch (iArray[y2][x2]) { 53 | case PhotonLayer.SUPPORTED: 54 | case PhotonLayer.CONNECTED: 55 | calcMatrix[yi][xi] = 16; 56 | break; 57 | 58 | case PhotonLayer.ISLAND: 59 | calcMatrix[yi][xi] = 4; 60 | break; 61 | 62 | case PhotonLayer.OFF: 63 | if (yi > 0 && yi < 4 && xi > 0 && xi < 4) { 64 | blanks++; 65 | } 66 | break; 67 | } 68 | } 69 | } 70 | } 71 | return blanks; 72 | } 73 | 74 | 75 | public void calc() { 76 | Integer[][] temp = new Integer[3][3]; 77 | for (int yi = 0; yi < 3; yi++) { 78 | for (int xi = 0; xi < 3; xi++) { 79 | if (calcMatrix[yi+1][xi+1]==PhotonLayer.OFF) { 80 | temp[yi][xi] = calc(xi+1, yi+1); 81 | } 82 | } 83 | } 84 | for (int yi = 0; yi < 3; yi++) { 85 | for (int xi = 0; xi < 3; xi++) { 86 | if (calcMatrix[yi+1][xi+1]==PhotonLayer.OFF) { 87 | calcMatrix[yi+1][xi+1] = temp[yi][xi]; 88 | } 89 | } 90 | } 91 | } 92 | 93 | private int calc(int x, int y) { 94 | return (calcMatrix[y-1][x] / 4) + (calcMatrix[y][x-1] / 4) + (calcMatrix[y][x+1] / 4) + (calcMatrix[y+1][x] / 4); 95 | } 96 | 97 | public void level() { 98 | for (int yi = 0; yi < 5; yi++) { 99 | for (int xi = 0; xi < 5; xi++) { 100 | if (calcMatrix[yi][xi]<4) calcMatrix[yi][xi] = 0; 101 | } 102 | } 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/photon/application/dialogs/PreviewDialog.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |
73 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonAaMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | public class PhotonAaMatrix { 28 | 29 | public Integer[][] aaMatrix = new Integer[5][5]; 30 | private Boolean[] hasDivisor = new Boolean[5]; 31 | 32 | public void clear() { 33 | for (int y = 0; y < 5; y++) { 34 | for (int x = 0; x < 5; x++) { 35 | aaMatrix[y][x] = 0; 36 | } 37 | } 38 | } 39 | 40 | public void set(int x, int y, int val) { 41 | aaMatrix[y-1][x-1] = val; 42 | } 43 | 44 | public int[][] calc(int[][] source) { 45 | int[][] target = null; 46 | 47 | if (source!=null) { 48 | target = source.clone(); 49 | 50 | int divisor = 0; 51 | for (int y = 0; y < 5; y++) { 52 | int rowDivistor = 0; 53 | for (int x = 0; x < 5; x++) { 54 | rowDivistor += aaMatrix[y][x]; 55 | } 56 | hasDivisor[y] = (rowDivistor>0); 57 | divisor += rowDivistor; 58 | } 59 | 60 | if (divisor >0) { 61 | int height = source.length; 62 | if (height > 0) { 63 | int width = source[0].length; 64 | if (width > 0) { 65 | int sum;; 66 | int dy; 67 | int dx; 68 | for (int y = 0; y < height; y++) { 69 | for (int x = 0; x < width; x++) { 70 | sum = 0; 71 | for (int cy = -2; cy <= 2; cy++) { 72 | if (hasDivisor[2+cy]) 73 | for (int cx = -2; cx <= 2; cx++) { 74 | dy = y+cy; 75 | dx = x+cx; 76 | if (dy>=0 && dy< height) { 77 | if (dx>=0 && dx< width) { 78 | sum += source[dy][dx] * aaMatrix[2+cy][2+cx]; 79 | } else { 80 | sum += source[y][x] * aaMatrix[2+cy][2+cx]; 81 | } 82 | } else { 83 | sum += source[y][x] * aaMatrix[2+cy][2+cx]; 84 | } 85 | } 86 | } 87 | target[y][x] = sum / divisor; 88 | } 89 | } 90 | } 91 | } 92 | } 93 | } 94 | return target; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /install/makewinjre.iss: -------------------------------------------------------------------------------- 1 | ; Script generated by the Inno Setup Script Wizard. 2 | ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 3 | 4 | #define MyAppName "Photon File Validator" 5 | #define MyAppVersion "2.1" 6 | #define MyAppPublisher "Bonosoft" 7 | #define MyAppURL "https://github.com/Photonsters/PhotonFileValidator" 8 | #define MyAppExeName "photonfilevalidator.exe" 9 | 10 | [Setup] 11 | ; NOTE: The value of AppId uniquely identifies this application. 12 | ; Do not use the same AppId value in installers for other applications. 13 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 14 | AppId={{DF9C6F8D-CAD2-4BBB-8BD3-CB72B41FF2BC} 15 | AppName={#MyAppName} 16 | AppVersion={#MyAppVersion} 17 | ;AppVerName={#MyAppName} {#MyAppVersion} 18 | AppPublisher={#MyAppPublisher} 19 | AppPublisherURL={#MyAppURL} 20 | AppSupportURL={#MyAppURL} 21 | AppUpdatesURL={#MyAppURL} 22 | DefaultDirName={pf}\{#MyAppName} 23 | DisableProgramGroupPage=yes 24 | OutputDir=D:\Users\bn\Documents\GitHub\PhotonFileViewer\release 25 | OutputBaseFilename=win-jre-photonfilevalidator-{#MyAppVersion} 26 | SetupIconFile=D:\Users\bn\Documents\GitHub\PhotonFileViewer\install\img\icons\validator.ico 27 | Compression=lzma 28 | SolidCompression=yes 29 | 30 | [Languages] 31 | Name: "english"; MessagesFile: "compiler:Default.isl" 32 | 33 | [Tasks] 34 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 35 | 36 | [Files] 37 | Source: "D:\Users\bn\Documents\GitHub\PhotonFileViewer\out\win\photonfilevalidator.exe"; DestDir: "{app}"; Flags: ignoreversion 38 | Source: "D:\Users\bn\Documents\GitHub\PhotonFileViewer\out\win\photon.properties"; DestDir: "{app}"; Flags: ignoreversion 39 | Source: "D:\Users\bn\Documents\GitHub\jre\*"; DestDir: "{app}/jre"; Flags: ignoreversion 40 | 41 | Source: "D:\Users\bn\Documents\GitHub\jre\bin\*"; DestDir: "{app}\jre\bin"; Flags: ignoreversion 42 | Source: "D:\Users\bn\Documents\GitHub\jre\bin\dtplugin\*"; DestDir: "{app}\jre\bin\dtplugin"; Flags: ignoreversion 43 | Source: "D:\Users\bn\Documents\GitHub\jre\bin\plugin2\*"; DestDir: "{app}\jre\bin\plugin2"; Flags: ignoreversion 44 | Source: "D:\Users\bn\Documents\GitHub\jre\bin\server\*"; DestDir: "{app}\jre\bin\server"; Flags: ignoreversion 45 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\*"; DestDir: "{app}\jre\lib"; Flags: ignoreversion 46 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\amd64\*"; DestDir: "{app}\jre\lib\amd64"; Flags: ignoreversion 47 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\cmm\*"; DestDir: "{app}\jre\lib\cmm"; Flags: ignoreversion 48 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\deploy\*"; DestDir: "{app}\jre\lib\deploy"; Flags: ignoreversion 49 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\ext\*"; DestDir: "{app}\jre\lib\ext"; Flags: ignoreversion 50 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\fonts\*"; DestDir: "{app}\jre\lib\fonts"; Flags: ignoreversion 51 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\jfr\*"; DestDir: "{app}\jre\lib\jfr"; Flags: ignoreversion 52 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\management\*"; DestDir: "{app}\jre\lib\management"; Flags: ignoreversion 53 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\security\*"; DestDir: "{app}\jre\lib\security"; Flags: ignoreversion 54 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\images\cursors\*"; DestDir: "{app}\jre\lib\images\cursors"; Flags: ignoreversion 55 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\security\policy\limited\*"; DestDir: "{app}\jre\lib\security\policy\limited"; Flags: ignoreversion 56 | Source: "D:\Users\bn\Documents\GitHub\jre\lib\security\policy\unlimited\*"; DestDir: "{app}\jre\lib\security\policy\unlimited"; Flags: ignoreversion 57 | 58 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 59 | 60 | [Icons] 61 | Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" 62 | Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon 63 | 64 | [Run] 65 | Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent 66 | 67 | -------------------------------------------------------------------------------- /src/photon/application/render/OnionMousePanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render; 26 | 27 | import photon.application.render.storage.RotationBaseMatrix; 28 | 29 | import javax.swing.*; 30 | import java.awt.event.*; 31 | import java.awt.*; 32 | 33 | public class OnionMousePanel extends JPanel implements MouseMotionListener, MouseListener{ 34 | private OnionPanel onionPanel; 35 | 36 | private double totalScale = 2; 37 | 38 | private Point startPoint; //used to save the previous point when the mouse is draged 39 | private Point endPoint; //used to save the last point when the mouse is draged 40 | 41 | public OnionMousePanel(OnionPanel onionPanel) { 42 | this.onionPanel = onionPanel; 43 | onionPanel.addMouseListener(this); 44 | onionPanel.addMouseMotionListener(this); 45 | } 46 | 47 | 48 | 49 | private void rotateFromDrag(){ 50 | double angleMultiplyFactor=0.02; 51 | double angleY=angleMultiplyFactor*(endPoint.getX()-startPoint.getX()); 52 | double angleX=angleMultiplyFactor*(endPoint.getY()-startPoint.getY()); 53 | onionPanel.rotate(new RotationBaseMatrix(-angleX, angleY, 0)); 54 | } 55 | 56 | private void scaleFromDrag(){ 57 | double scaleMultiplyFactor=0.01; 58 | double scaleFactor=scaleMultiplyFactor*(endPoint.getY()-startPoint.getY()); 59 | 60 | if (scaleFactor>0) { 61 | if (totalScale*(1+scaleFactor)<2) { 62 | onionPanel.scale(1+scaleFactor); 63 | totalScale = totalScale*(1+scaleFactor); 64 | } 65 | } else { 66 | if (totalScale*(1+scaleFactor)>0.25) { 67 | onionPanel.scale(1 + scaleFactor); 68 | totalScale = totalScale*(1+scaleFactor); 69 | } 70 | } 71 | } 72 | 73 | public void mousePressed(MouseEvent event) { 74 | startPoint=event.getPoint(); 75 | } 76 | 77 | public void mouseDragged(MouseEvent event) { 78 | endPoint=event.getPoint(); 79 | 80 | if((event.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ 81 | rotateFromDrag(); 82 | }else if((event.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ 83 | scaleFromDrag(); 84 | } 85 | 86 | startPoint=endPoint; 87 | } 88 | 89 | public void mouseMoved(MouseEvent event) { 90 | //not needed 91 | } 92 | 93 | public void mouseClicked(MouseEvent event) { 94 | //not needed 95 | } 96 | 97 | public void mouseEntered(MouseEvent event) { 98 | //not needed 99 | } 100 | 101 | public void mouseExited(MouseEvent event) { 102 | //not needed 103 | } 104 | 105 | public void mouseReleased(MouseEvent event) { 106 | //not needed 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/photon/application/utilities/PhotonPlayWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.utilities; 26 | 27 | import photon.application.MainForm; 28 | import photon.file.PhotonFile; 29 | import photon.file.parts.IPhotonProgress; 30 | import photon.file.parts.PhotonFileLayer; 31 | import photon.file.ui.PhotonLayerImage; 32 | 33 | import javax.swing.*; 34 | import java.awt.*; 35 | import java.io.File; 36 | 37 | public class PhotonPlayWorker extends SwingWorker implements IPhotonProgress { 38 | private MainForm mainForm; 39 | private int layerNo = 0; 40 | private int aaNo = 0; 41 | private PhotonFileLayer photonFileLayer = null; 42 | private int miliseconds; 43 | 44 | Integer[] speeds = new Integer[] { 1000, 500, 400, 300, 200, 100, 60, 10 }; 45 | 46 | public PhotonPlayWorker(MainForm mainForm, int speedSelection) { 47 | this.mainForm = mainForm; 48 | this.miliseconds = speeds[speedSelection]; 49 | 50 | mainForm.playButton.setText("Stop"); 51 | mainForm.playing = true; 52 | 53 | } 54 | 55 | @Override 56 | protected void process(java.util.List chunks) { 57 | if (photonFileLayer != null) { 58 | mainForm.playLayerInformation(layerNo, aaNo, photonFileLayer); 59 | ((PhotonLayerImage) mainForm.layerImage).drawLayer(photonFileLayer, mainForm.margin); 60 | mainForm.layerImage.repaint(); 61 | } 62 | } 63 | 64 | @Override 65 | protected void done() { 66 | mainForm.playButton.setEnabled(true); 67 | mainForm.playButton.setText("Play"); 68 | mainForm.playing = false; 69 | if (mainForm.photonFile != null) { 70 | mainForm.viewLayerInfo();; 71 | } 72 | } 73 | 74 | @Override 75 | protected Integer doInBackground() throws Exception { 76 | try { 77 | PhotonFile photonFile = mainForm.photonFile; 78 | 79 | int totalLayers = photonFile.getLayerCount() * photonFile.getAALevels(); 80 | 81 | for (int i = 0; i < totalLayers; i++) { 82 | 83 | layerNo = i / photonFile.getAALevels(); 84 | aaNo = i % photonFile.getAALevels(); 85 | 86 | if (aaNo == 0) { 87 | photonFileLayer = photonFile.getLayer(layerNo); 88 | } else { 89 | photonFileLayer = photonFile.getLayer(layerNo).getAntiAlias(aaNo - 1); 90 | } 91 | 92 | publish("Show info"); 93 | 94 | try { 95 | Thread.sleep(miliseconds); 96 | } catch (Exception e) { 97 | // ignore... 98 | } 99 | if (!mainForm.playing) { 100 | break; 101 | } 102 | } 103 | 104 | } catch (Exception e) { 105 | return 0; 106 | } 107 | return 1; 108 | } 109 | 110 | @Override 111 | public void showInfo(String str) { 112 | publish(str); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonFilePreview.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | import java.io.ByteArrayInputStream; 28 | import java.util.Arrays; 29 | 30 | /** 31 | * by bn on 01/07/2018. 32 | */ 33 | public class PhotonFilePreview { 34 | private int resolutionX; 35 | private int resolutionY; 36 | private int imageAddress; 37 | private int dataSize; 38 | 39 | private byte[] rawImageData; 40 | 41 | private int[] imageData; 42 | 43 | private int p1; 44 | private int p2; 45 | private int p3; 46 | private int p4; 47 | 48 | public PhotonFilePreview(int previewAddress, byte[] file) throws Exception { 49 | byte[] data = Arrays.copyOfRange(file, previewAddress, previewAddress + 32); 50 | PhotonInputStream ds = new PhotonInputStream(new ByteArrayInputStream(data)); 51 | 52 | resolutionX = ds.readInt(); 53 | resolutionY = ds.readInt(); 54 | imageAddress = ds.readInt(); 55 | dataSize = ds.readInt(); 56 | p1 = ds.readInt(); 57 | p2 = ds.readInt(); 58 | p3 = ds.readInt(); 59 | p4 = ds.readInt(); 60 | 61 | rawImageData = Arrays.copyOfRange(file, imageAddress, imageAddress + dataSize); 62 | 63 | decodeImageData(); 64 | } 65 | 66 | public void save(PhotonOutputStream os, int startAddress) throws Exception { 67 | os.writeInt(resolutionX); 68 | os.writeInt(resolutionY); 69 | os.writeInt(startAddress + 4+4+4+4 + 4+4+4+4); 70 | os.writeInt(dataSize); 71 | os.writeInt(p1); 72 | os.writeInt(p2); 73 | os.writeInt(p3); 74 | os.writeInt(p4); 75 | os.write(rawImageData, 0, dataSize); 76 | } 77 | 78 | public int getByteSize() { 79 | return 4+4+4+4 + 4+4+4+4 + dataSize; 80 | } 81 | 82 | private void decodeImageData() { 83 | imageData = new int[resolutionX * resolutionY]; 84 | int d = 0; 85 | for (int i = 0; i < dataSize; i++) { 86 | int dot = rawImageData[i] & 0xFF | ((rawImageData[++i] & 0xFF) << 8); 87 | 88 | int color = ((dot & 0xF800) << 8) | ((dot & 0x07C0) << 5) | ((dot & 0x001F) << 3); 89 | 90 | // int red = ((dot >> 11) & 0x1F) << 3; 91 | // int green = ((dot >> 6) & 0x1F) << 3; 92 | // int blue = (dot & 0x1F) << 3; 93 | // color = red<<16 | green<<8 | blue; 94 | 95 | int repeat = 1; 96 | if ((dot & 0x0020) == 0x0020) { 97 | repeat += rawImageData[++i] & 0xFF | ((rawImageData[++i] & 0x0F) << 8); 98 | } 99 | 100 | while (repeat > 0) { 101 | imageData[d++] = color; 102 | repeat--; 103 | } 104 | } 105 | 106 | } 107 | 108 | public int getResolutionX() { 109 | return resolutionX; 110 | } 111 | 112 | public int getResolutionY() { 113 | return resolutionY; 114 | } 115 | 116 | public int[] getImageData() { 117 | return imageData; 118 | } 119 | 120 | public void unLink() { 121 | rawImageData = null; 122 | imageData = null; 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /src/photon/file/ui/PhotonEditPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.ui; 26 | 27 | import photon.file.parts.PhotonLayer; 28 | 29 | import javax.swing.*; 30 | import java.awt.*; 31 | import java.awt.geom.AffineTransform; 32 | import java.awt.image.BufferedImage; 33 | 34 | /** 35 | * by bn on 16/07/2018. 36 | */ 37 | public class PhotonEditPanel extends JPanel { 38 | private int width; 39 | private int height; 40 | 41 | private BufferedImage image; 42 | 43 | private boolean mirrored; 44 | 45 | public PhotonEditPanel(int width, int height) { 46 | this.width = width; 47 | this.height = height; 48 | image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 49 | setPreferredSize(new Dimension(width, height)); 50 | } 51 | 52 | public void setMirrored(boolean mirrored) { 53 | this.mirrored = mirrored; 54 | } 55 | 56 | @Override 57 | protected void paintComponent(Graphics g) { 58 | g.drawImage(image, 0, 0, null); 59 | } 60 | 61 | private Graphics2D createGraphics() { 62 | Graphics2D g = image.createGraphics(); 63 | if (mirrored) { 64 | AffineTransform transform = new AffineTransform(); 65 | transform.setToScale(1, -1); 66 | transform.translate(0, -image.getHeight()); 67 | g.setTransform(transform); 68 | } 69 | return g; 70 | } 71 | 72 | public void drawLayer(int layerX, int layerY, PhotonLayer layer) { 73 | Graphics2D g = createGraphics(); 74 | g.setBackground(Color.decode("#999999")); 75 | 76 | g.clearRect(0, 0, width, height); 77 | 78 | 79 | for (int y = 0; y < 45; y++) { 80 | for (int x = 0; x < 75; x++) { 81 | int x1 = 15 + x * 10; 82 | int y1 = 15 + y * 10; 83 | 84 | switch (layer.get(layerY + y, layerX + x)) { 85 | case PhotonLayer.SUPPORTED: 86 | g.setColor(Color.decode("#008800")); 87 | break; 88 | 89 | case PhotonLayer.CONNECTED: 90 | g.setColor(Color.decode("#FFFF00")); 91 | break; 92 | 93 | case PhotonLayer.ISLAND: 94 | g.setColor(Color.decode("#FF0000")); 95 | break; 96 | 97 | default: 98 | g.setColor(Color.black); 99 | 100 | } 101 | g.fillRect(x1, y1, 9, 9); 102 | } 103 | } 104 | 105 | g.dispose(); 106 | } 107 | 108 | public void drawDot(int layerX, int layerY, PhotonLayer layer, Color color) { 109 | Graphics2D g = createGraphics(); 110 | g.setColor(color); 111 | g.fillRect(15+layerX*10, 15+layerY*10, 9, 9); 112 | g.dispose(); 113 | } 114 | 115 | public void drawRect(Rectangle r, Color color) { 116 | Graphics2D g = createGraphics(); 117 | g.setColor(color); 118 | g.drawRect(15+r.x*10, 15+r.y*10, (r.width + 1) * 10-1, (r.height + 1) * 10-1); 119 | g.dispose(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | import java.io.DataOutput; 28 | import java.io.DataOutputStream; 29 | import java.io.IOException; 30 | import java.io.OutputStream; 31 | 32 | 33 | /** 34 | * by bn on 06/07/2018. 35 | */ 36 | public class PhotonOutputStream extends OutputStream implements DataOutput { 37 | private OutputStream outputStream; 38 | private DataOutputStream dataOutputStream; 39 | 40 | 41 | public PhotonOutputStream(OutputStream outputStream) { 42 | this.outputStream = outputStream; 43 | dataOutputStream = new DataOutputStream(outputStream); 44 | } 45 | 46 | @Override 47 | public void write(byte[] b, int off, int len) throws IOException { 48 | outputStream.write(b, off, len); 49 | } 50 | 51 | @Override 52 | public void writeBoolean(boolean v) throws IOException { 53 | dataOutputStream.writeBoolean(v); 54 | } 55 | 56 | @Override 57 | public void writeByte(int v) throws IOException { 58 | dataOutputStream.writeByte(v); 59 | } 60 | 61 | @Deprecated 62 | @Override 63 | public void writeBytes(String s) throws IOException { 64 | dataOutputStream.writeBytes(s); 65 | } 66 | 67 | @Override 68 | public void writeChar(int v) throws IOException { 69 | writeShort(v); 70 | } 71 | 72 | @Override 73 | public void writeChars(String s) throws IOException { 74 | for (int i = 0; i < s.length(); i++) { 75 | writeChar(s.charAt(i)); 76 | } 77 | } 78 | 79 | @Override 80 | public void writeDouble(double v) throws IOException { 81 | writeLong(Double.doubleToLongBits(v)); 82 | } 83 | 84 | @Override 85 | public void writeFloat(float v) throws IOException { 86 | writeInt(Float.floatToIntBits(v)); 87 | } 88 | 89 | @Override 90 | public void write(int b) throws IOException { 91 | writeInt(b); 92 | } 93 | 94 | @Override 95 | public void writeInt(int v) throws IOException { 96 | outputStream.write(0xFF & v); 97 | outputStream.write(0xFF & (v >> 8)); 98 | outputStream.write(0xFF & (v >> 16)); 99 | outputStream.write(0xFF & (v >> 24)); 100 | } 101 | 102 | @Override 103 | public void writeLong(long v) throws IOException { 104 | byte[] bytes = longToBytes(Long.reverseBytes(v)); 105 | write(bytes, 0, bytes.length); 106 | } 107 | 108 | private byte[] longToBytes(long l) { 109 | byte[] result = new byte[8]; 110 | for (int i = 7; i >= 0; i--) { 111 | result[i] = (byte)(l & 0xFF); 112 | l >>= 8; 113 | } 114 | return result; 115 | } 116 | 117 | @Override 118 | public void writeShort(int v) throws IOException { 119 | outputStream.write(0xFF & v); 120 | outputStream.write(0xFF & (v >> 8)); 121 | } 122 | 123 | @Override 124 | public void writeUTF(String str) throws IOException { 125 | dataOutputStream.writeUTF(str); 126 | } 127 | 128 | @Override 129 | public void close() throws IOException { 130 | outputStream.close(); 131 | } 132 | 133 | 134 | } 135 | -------------------------------------------------------------------------------- /src/photon/application/utilities/PhotonLoadWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.utilities; 26 | 27 | import photon.application.MainForm; 28 | import photon.file.PhotonFile; 29 | import photon.file.parts.IPhotonProgress; 30 | 31 | import javax.swing.*; 32 | import java.awt.*; 33 | import java.io.File; 34 | 35 | /** 36 | * by bn on 09/07/2018. 37 | */ 38 | public class PhotonLoadWorker extends SwingWorker implements IPhotonProgress { 39 | private MainForm mainForm; 40 | private File file; 41 | 42 | public PhotonLoadWorker(MainForm mainForm, File file) { 43 | this.mainForm = mainForm; 44 | this.file = file; 45 | 46 | mainForm.layerInfo.setForeground(Color.decode("#000099")); 47 | mainForm.marginInfo.setText(""); 48 | 49 | mainForm.openBtn.setEnabled(false); 50 | mainForm.saveBtn.setEnabled(false); 51 | mainForm.fixBtn.setEnabled(false); 52 | mainForm.islandNextBtn.setEnabled(false); 53 | mainForm.islandPrevBtn.setEnabled(false); 54 | mainForm.marginNextBtn.setEnabled(false); 55 | mainForm.marginPrevBtn.setEnabled(false); 56 | mainForm.layerSpinner.setEnabled(false); 57 | mainForm.zoomSlider.setEnabled(false); 58 | mainForm.layerSlider.setEnabled(false); 59 | mainForm.tabPreviewLarge.setEnabled(false); 60 | mainForm.tabPreviewSmall.setEnabled(false); 61 | mainForm.playButton.setEnabled(false); 62 | mainForm.convertBtn.setEnabled(false); 63 | } 64 | 65 | @Override 66 | protected void process(java.util.List chunks) { 67 | for (String str : chunks) { 68 | mainForm.layerInfo.setText(str); 69 | } 70 | } 71 | 72 | @Override 73 | protected void done() { 74 | // mainForm.openBtn.setEnabled(true); 75 | if (mainForm.photonFile!=null) { 76 | mainForm.openBtn.setEnabled(true); 77 | mainForm.saveBtn.setEnabled(true); 78 | mainForm.informationBtn.setEnabled(true); 79 | mainForm.tabPreviewLarge.setEnabled(true); 80 | mainForm.tabPreviewSmall.setEnabled(true); 81 | mainForm.showFileInformation(); 82 | mainForm.calc(); 83 | mainForm.playButton.setEnabled(true); 84 | if (mainForm.photonFile.getVersion()>1) { 85 | mainForm.convertBtn.setEnabled(true); 86 | } 87 | } 88 | } 89 | 90 | @Override 91 | protected Integer doInBackground() throws Exception { 92 | publish("Loading file..."); 93 | try { 94 | mainForm.photonFile = new PhotonFile(); 95 | mainForm.photonFile.setMargin(mainForm.margin); 96 | mainForm.photonFile.readFile(file, this); 97 | publish("Complete..."); 98 | } catch (Exception e) { 99 | mainForm.photonFile = null; 100 | mainForm.marginInfo.setForeground(Color.red); 101 | mainForm.marginInfo.setText("Could not read the file, file is corrupted or in an unsupported format."); 102 | return 0; 103 | } 104 | return 1; 105 | } 106 | 107 | @Override 108 | public void showInfo(String str) { 109 | publish(str); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/photon/application/render/PhotonBuildPlateTop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render; 26 | 27 | import photon.application.render.elements.RenderAsTriangle; 28 | import photon.application.render.elements.Triangle; 29 | import photon.application.render.elements.Vertex; 30 | 31 | /** 32 | * by bn on 18/07/2018. 33 | */ 34 | public class PhotonBuildPlateTop extends RenderAsTriangle { 35 | 36 | public PhotonBuildPlateTop() { 37 | int width = 256; 38 | int height = 144; 39 | 40 | double z = -105; 41 | double zz = -130; 42 | 43 | double x1 = -1 * (width / 2); 44 | double x2 = (width / 2); 45 | double y1 = -1 * (height / 2); 46 | double y2 = height / 2; 47 | 48 | double xx1 = x1 + ((width/5) *2); 49 | double xx2 = x2 - ((width/5) *2); 50 | double yy1 = y1 + ((height/5) *2); 51 | double yy2 = y2 - ((height/5) *2); 52 | 53 | iTransformables.add(new Triangle(new Vertex(xx1, yy1, zz), new Vertex(xx1, yy2, zz), new Vertex(xx2, yy2, zz))); 54 | iTransformables.add(new Triangle(new Vertex(xx1, yy1, zz), new Vertex(xx2, yy1, zz), new Vertex(xx2, yy2, zz))); 55 | 56 | 57 | 58 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(x1, yy1, z), new Vertex(xx1, yy1, zz))); 59 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(xx1, y1, z), new Vertex(xx1, yy1, zz))); 60 | 61 | 62 | iTransformables.add(new Triangle(new Vertex(x1, y2, z), new Vertex(xx1, y2, z), new Vertex(xx1, yy2, zz))); 63 | iTransformables.add(new Triangle(new Vertex(x1, y2, z), new Vertex(x1, yy2, z), new Vertex(xx1, yy2, zz))); 64 | 65 | iTransformables.add(new Triangle(new Vertex(x2, y1, z), new Vertex(xx2, y1, z), new Vertex(xx2, yy1, zz))); 66 | iTransformables.add(new Triangle(new Vertex(x2, y1, z), new Vertex(x2, yy1, z), new Vertex(xx2, yy1, zz))); 67 | 68 | iTransformables.add(new Triangle(new Vertex(x2, y2, z), new Vertex(x2, yy2, z), new Vertex(xx2, yy2, zz))); 69 | iTransformables.add(new Triangle(new Vertex(x2, y2, z), new Vertex(xx2, y2, z), new Vertex(xx2, yy2, zz))); 70 | 71 | 72 | iTransformables.add(new Triangle(new Vertex(x1, yy1, z), new Vertex(x1, yy2, z), new Vertex(xx1, yy2, zz))); 73 | iTransformables.add(new Triangle(new Vertex(x1, yy1, z), new Vertex(xx1, yy1, zz), new Vertex(xx1, yy2, zz))); 74 | 75 | iTransformables.add(new Triangle(new Vertex(xx1, y1, z), new Vertex(xx1, yy1, zz), new Vertex(xx2, yy1, zz))); 76 | iTransformables.add(new Triangle(new Vertex(xx1, y1, z), new Vertex(xx2, y1, z), new Vertex(xx2, yy1, zz))); 77 | 78 | iTransformables.add(new Triangle(new Vertex(xx2, yy1, zz), new Vertex(xx2, yy2, zz), new Vertex(x2, yy2, z))); 79 | iTransformables.add(new Triangle(new Vertex(xx2, yy1, zz), new Vertex(x2, yy1, z), new Vertex(x2, yy2, z))); 80 | 81 | iTransformables.add(new Triangle(new Vertex(xx1, y2, z), new Vertex(xx1, yy2, zz), new Vertex(xx2, yy2, zz))); 82 | iTransformables.add(new Triangle(new Vertex(xx1, y2, z), new Vertex(xx2, y2, z), new Vertex(xx2, yy2, zz))); 83 | 84 | 85 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(x1, y2, z), new Vertex(x2, y2, z))); 86 | iTransformables.add(new Triangle(new Vertex(x1, y1, z), new Vertex(x2, y1, z), new Vertex(x2, y2, z))); 87 | 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/photon/file/ui/ScrollUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.ui; 26 | 27 | import javax.swing.*; 28 | 29 | /** 30 | * by bn on 02/07/2018. 31 | */ 32 | public class ScrollUtil { 33 | 34 | private ScrollUtil() { 35 | } 36 | 37 | 38 | public static void scrollTo(JScrollPane c, ScrollPosition scrollPosition) { 39 | switch (scrollPosition) { 40 | case Top: 41 | c.getVerticalScrollBar().setValue(0); 42 | break; 43 | case VerticalCenter: 44 | if (c.getVerticalScrollBar()!=null) { 45 | c.getVerticalScrollBar().setValue(c.getVerticalScrollBar().getMaximum()); 46 | c.getVerticalScrollBar().setValue(c.getVerticalScrollBar().getValue() / 2); 47 | c.getVerticalScrollBar().setUnitIncrement(16); 48 | } 49 | break; 50 | case Bottom: 51 | c.getVerticalScrollBar().setValue(c.getVerticalScrollBar().getMaximum()); 52 | break; 53 | 54 | case Left: 55 | c.getHorizontalScrollBar().setValue(0); 56 | break; 57 | case HorizontalCenter: 58 | if (c.getHorizontalScrollBar()!=null) { 59 | c.getHorizontalScrollBar().setValue(c.getHorizontalScrollBar().getMaximum()); 60 | c.getHorizontalScrollBar().setValue(c.getHorizontalScrollBar().getValue() / 2); 61 | c.getHorizontalScrollBar().setUnitIncrement(16); 62 | } 63 | break; 64 | case Right: 65 | c.getHorizontalScrollBar().setValue(c.getHorizontalScrollBar().getMaximum()); 66 | break; 67 | } 68 | } 69 | 70 | public static void scroll(JScrollPane c, ScrollPosition scrollPosition) { 71 | switch (scrollPosition) { 72 | case Top: 73 | int val = c.getVerticalScrollBar().getValue(); 74 | if (val>18) { 75 | c.getVerticalScrollBar().setValue(val - 18); 76 | } else { 77 | c.getVerticalScrollBar().setValue(0); 78 | } 79 | break; 80 | case Bottom: 81 | val = c.getVerticalScrollBar().getValue(); 82 | if (val < (c.getVerticalScrollBar().getMaximum() - 18)) { 83 | c.getVerticalScrollBar().setValue(val + 18); 84 | } else { 85 | c.getVerticalScrollBar().setValue(c.getVerticalScrollBar().getMaximum()); 86 | } 87 | break; 88 | 89 | case Left: 90 | val = c.getHorizontalScrollBar().getValue(); 91 | if (val>18) { 92 | c.getHorizontalScrollBar().setValue(val - 18); 93 | } else { 94 | c.getHorizontalScrollBar().setValue(0); 95 | } 96 | break; 97 | case Right: 98 | val = c.getHorizontalScrollBar().getValue(); 99 | if (val< (c.getHorizontalScrollBar().getMaximum() - 18)) { 100 | c.getHorizontalScrollBar().setValue(val + 18); 101 | } else { 102 | c.getHorizontalScrollBar().setValue(c.getHorizontalScrollBar().getMaximum()); 103 | } 104 | break; 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/photon/application/dialogs/PlayDialog.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 |
88 | -------------------------------------------------------------------------------- /src/photon/application/render/utils/VectorUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.utils; 26 | 27 | import photon.application.render.elements.Vertex; 28 | import photon.application.render.elements.Triangle; 29 | 30 | public class VectorUtil { 31 | 32 | /** 33 | * Calculates the normal vector of the triangle tri 34 | * 35 | * @param tri triangle 36 | * @return triangle normal vector 37 | */ 38 | public static Vertex calculateNormal(Triangle tri) { 39 | 40 | //obtain first vector 41 | Vertex v1 = new Vertex(); 42 | v1.x = tri.v2.x - tri.v1.x; 43 | v1.y = tri.v2.y - tri.v1.y; 44 | v1.z = tri.v2.z - tri.v1.z; 45 | 46 | //obtain second vector 47 | Vertex v2 = new Vertex(); 48 | v2.x = tri.v3.x - tri.v1.x; 49 | v2.y = tri.v3.y - tri.v1.y; 50 | v2.z = tri.v3.z - tri.v1.z; 51 | 52 | //calculate the cross product between the two vectors to obtain 53 | //a vector orthogonal to the others 54 | 55 | return calculateCrossProduct(v1, v2); 56 | } 57 | 58 | /** 59 | * Calculates the length(modulus) of a vector 60 | * 61 | * @param vector vector to be calculated 62 | * @return vector length 63 | */ 64 | public static double calculateLength(Vertex vector) { 65 | return Math.sqrt(vector.x * vector.x + vector.y * vector.y + vector.z * vector.z); 66 | } 67 | 68 | /** 69 | * Calculate unit vector 70 | * 71 | * @param vector vector from which to calculate the unit vector 72 | * @return unit vector 73 | */ 74 | public static Vertex calculateUnitVector(Vertex vector) { 75 | Vertex unit = new Vertex(); 76 | double length = calculateLength(vector); 77 | unit.x = vector.x / length; 78 | unit.y = vector.y / length; 79 | unit.z = vector.z / length; 80 | return unit; 81 | } 82 | 83 | /** 84 | * Calculates the cosin value of the angle between the two vectors 85 | * 86 | * @param v1 first vector 87 | * @param v2 second vector 88 | * @return cosin value 89 | */ 90 | public static double calculateAngleCosBetweenVectors(Vertex v1, Vertex v2) { 91 | Vertex u1 = calculateUnitVector(v1); 92 | Vertex u2 = calculateUnitVector(v2); 93 | return calculateDotProduct(u1, u2); 94 | } 95 | 96 | /** 97 | * Calculates the dot product between two vectors 98 | * 99 | * @param v1 first vector 100 | * @param v2 second vector 101 | * @return dot product value 102 | */ 103 | public static double calculateDotProduct(Vertex v1, Vertex v2) { 104 | return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; 105 | } 106 | 107 | /** 108 | * Calculates the cross product between two vectors 109 | * 110 | * @param v1 first vector 111 | * @param v2 second vector 112 | * @return cross product vector 113 | */ 114 | public static Vertex calculateCrossProduct(Vertex v1, Vertex v2) { 115 | return new Vertex(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x); 116 | } 117 | 118 | public static double calculateDist(Vertex v1, Vertex v2) { 119 | double x = v1.x - v2.x; 120 | double y = v1.y - v2.y; 121 | double z = v1.z - v2.z; 122 | return Math.sqrt(x * x + y * y + z * z); 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /src/photon/file/ui/PhotonAaPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.ui; 26 | 27 | import photon.file.parts.PhotonFileLayer; 28 | import photon.file.parts.PhotonLayer; 29 | 30 | import javax.swing.*; 31 | import java.awt.*; 32 | import java.awt.geom.AffineTransform; 33 | import java.awt.image.BufferedImage; 34 | import java.util.ArrayList; 35 | 36 | public class PhotonAaPanel extends JPanel { 37 | private int width; 38 | private int height; 39 | 40 | private BufferedImage image; 41 | 42 | private boolean mirrored; 43 | 44 | public PhotonAaPanel(int width, int height) { 45 | this.width = width; 46 | this.height = height; 47 | image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 48 | setPreferredSize(new Dimension(width, height)); 49 | } 50 | 51 | public void setMirrored(boolean mirrored) { 52 | this.mirrored = mirrored; 53 | } 54 | 55 | @Override 56 | protected void paintComponent(Graphics g) { 57 | g.drawImage(image, 0, 0, null); 58 | } 59 | 60 | private Graphics2D createGraphics() { 61 | Graphics2D g = image.createGraphics(); 62 | if (mirrored) { 63 | AffineTransform transform = new AffineTransform(); 64 | transform.setToScale(1, -1); 65 | transform.translate(0, -image.getHeight()); 66 | g.setTransform(transform); 67 | } 68 | return g; 69 | } 70 | 71 | public void drawLayer(int layerX, int layerY, PhotonFileLayer layer, int aaLevel) { 72 | 73 | ArrayList photonLayers = new ArrayList<>(); 74 | 75 | if (aaLevel<1) { 76 | photonLayers.add(layer.getLayer()); 77 | for(PhotonFileLayer photonFileLayer: layer.getAntiAlias()) { 78 | photonLayers.add(photonFileLayer.getLayer()); 79 | } 80 | } else if (aaLevel==1) { 81 | photonLayers.add(layer.getLayer()); 82 | } else { 83 | photonLayers.add(layer.getAntiAlias(aaLevel-2).getLayer()); 84 | } 85 | 86 | Graphics2D g = createGraphics(); 87 | 88 | g.setBackground(Color.decode("#999999")); 89 | g.clearRect(0, 0, width, height); 90 | 91 | for (int y = 0; y < 45; y++) { 92 | for (int x = 0; x < 75; x++) { 93 | int x1 = 15 + x * 10; 94 | int y1 = 15 + y * 10; 95 | 96 | if (aaLevel == 0) { 97 | int colorDiv = 170 / photonLayers.size(); 98 | int color = 0; 99 | 100 | for(PhotonLayer photonLayer : photonLayers) { 101 | switch (photonLayer.get(layerY + y, layerX + x)) { 102 | case PhotonLayer.ISLAND: 103 | case PhotonLayer.CONNECTED: 104 | case PhotonLayer.SUPPORTED: 105 | color += colorDiv; 106 | break; 107 | } 108 | } 109 | 110 | if (color>0) color += 75; 111 | if (color>=235) color = 255; 112 | 113 | g.setColor(new Color( color, color, color)); 114 | 115 | } else { 116 | 117 | switch (photonLayers.get(0).get(layerY + y, layerX + x)) { 118 | case PhotonLayer.ISLAND: 119 | case PhotonLayer.CONNECTED: 120 | case PhotonLayer.SUPPORTED: 121 | g.setColor(Color.decode("#FFFFFF")); 122 | break; 123 | 124 | default: 125 | g.setColor(Color.black); 126 | 127 | } 128 | } 129 | g.fillRect(x1, y1, 9, 9); 130 | 131 | } 132 | } 133 | 134 | g.dispose(); 135 | } 136 | 137 | public void drawDot(int layerX, int layerY, PhotonLayer layer, Color color) { 138 | Graphics2D g = createGraphics(); 139 | g.setColor(color); 140 | g.fillRect(15 + layerX * 10, 15 + layerY * 10, 9, 9); 141 | g.dispose(); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /doc/javacode.md: -------------------------------------------------------------------------------- 1 | # Java Style Guide 2 | 3 | ## Introduction 4 | This document serves as the complete definition of our coding standards for source code in the Java™ Programming Language. A Java source file is allowed only if it adheres to the rules herein. 5 | 6 | Like other programming style guides, the issues covered span not only aesthetic issues of formatting, but other types of conventions or coding standards as well. 7 | 8 | ## File names 9 | The source file name consists of the case-sensitive name of the top-level class it contains (of which there is exactly one), plus the .java extension. 10 | 11 | ## File encoding 12 | Source files are encoded in UTF-8. 13 | 14 | ## Characters 15 | Aside from the line terminator sequence, the ASCII horizontal space character (0x20) is the only whitespace character that appears anywhere in a source file. This implies that: 16 | 17 | All other whitespace characters in string and character literals are escaped. 18 | Tab characters are not used for indentation. 19 | 20 | For any character that has a special escape sequence (\b, \t, \n, \f, \r, \", \' and \\), that sequence is used rather than the corresponding octal (e.g. \012) or Unicode (e.g. \u000a) escape. 21 | 22 | # Source File structure 23 | A source file consists of, in order: 24 | 25 | - License or copyright information, if present 26 | - Package statement, The package statement is not line-wrapped 27 | - Import statements, Import statements are not line-wrapped. 28 | - Exactly one top-level class 29 | 30 | Exactly one blank line separates each section that is present. 31 | 32 | # Class definition 33 | 34 | Exactly one top-level class declaration 35 | Each top-level class resides in a source file of its own. 36 | 37 | ## Ordering of class contents 38 | The order you choose for the members and initializers of your class can have a great effect on learnability. However, there's no single correct recipe for how to do it; different classes may order their contents in different ways. 39 | 40 | What is important is that each class uses some logical order, which its maintainer could explain if asked. For example, new methods are not just habitually added to the end of the class, as that would yield "chronological by date added" ordering, which is not a logical ordering. 41 | 42 | ## Overloads: never split 43 | When a class has multiple constructors, or multiple methods with the same name, these appear sequentially, with no other code in between (not even private members). 44 | 45 | 46 | # Formatting 47 | 48 | ## Braces 49 | 50 | ### Braces are used where optional 51 | Braces are used with if, else, for, do and while statements, even when the body is empty or contains only a single statement. 52 | 53 | ### Nonempty blocks: K & R style 54 | Braces follow the Kernighan and Ritchie style ("Egyptian brackets") for nonempty blocks and block-like constructs: 55 | 56 | - No line break before the opening brace. 57 | - Line break after the opening brace. 58 | - Line break before the closing brace. 59 | - Line break after the closing brace, only if that brace terminates a statement or terminates the body of a method, constructor, or named class. For example, there is no line break after the brace if it is followed by else or a comma. 60 | 61 | 62 | ### Block indentation: +4 spaces 63 | Each time a new block or block-like construct is opened, the indent increases by two spaces. When the block ends, the indent returns to the previous indent level. The indent level applies to both code and comments throughout the block. 64 | 65 | ### One statement per line 66 | Each statement is followed by a line break. 67 | 68 | ### Indent continuation lines at least +8 spaces 69 | When line-wrapping, each line after the first (each continuation line) is indented at least +8 from the original line. 70 | 71 | When there are multiple continuation lines, indentation may be varied beyond +8 as desired. In general, two continuation lines use the same indentation level if and only if they begin with syntactically parallel elements. 72 | 73 | 74 | # Naming 75 | ## Rules common to all identifiers 76 | Identifiers use only ASCII letters and digits (underscores not allowed) 77 | 78 | ## Package names 79 | Package names are all lowercase, with consecutive words simply concatenated together (no underscores). 80 | 81 | ## Class names 82 | Class names are written in UpperCamelCase. 83 | 84 | Class names are typically nouns or noun phrases. For example, Character or ImmutableList. Interface names may also be nouns or noun phrases (for example, List), but may sometimes be adjectives or adjective phrases instead (for example, Readable). 85 | 86 | ## Method names 87 | Method names are written in lowerCamelCase. 88 | 89 | Method names are typically verbs or verb phrases. For example, sendMessage or stop. 90 | 91 | ## Constant names 92 | Constant names use CONSTANT_CASE: all uppercase letters, with each word separated from the next by a single underscore. 93 | 94 | ## Non-constant field names 95 | Non-constant field names (static or otherwise) are written in lowerCamelCase. These names are typically nouns or noun phrases. 96 | 97 | ## Parameter names 98 | Parameter names are written in lowerCamelCase. One-character parameter names in public methods should be avoided. 99 | 100 | ## Local variable names 101 | Local variable names are written in lowerCamelCase. Even when final and immutable, local variables are not considered to be constants, and should not be styled as constants. 102 | 103 | -------------------------------------------------------------------------------- /src/photon/file/parts/photons/PhotonsFileHeader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts.photons; 26 | 27 | import photon.file.parts.IFileHeader; 28 | import photon.file.parts.PhotonFileLayer; 29 | import photon.file.parts.PhotonInputStream; 30 | 31 | import java.io.ByteArrayInputStream; 32 | import java.io.DataInputStream; 33 | import java.util.List; 34 | 35 | public class PhotonsFileHeader implements IFileHeader { 36 | 37 | private int fileVersion; 38 | 39 | private int fileMark0; 40 | private int fileMark1; 41 | private int fileMark2; 42 | private int fileMark3; 43 | private int fileMark4; 44 | 45 | 46 | private int areaNum; 47 | 48 | private int headerAddress; 49 | private int backup0; 50 | private int previewAddress; 51 | private int backup1; 52 | private int layersDefAddress; 53 | private int backup2; 54 | private int layersImageAddress; 55 | 56 | 57 | public PhotonsFileHeader(byte[] file) throws Exception { 58 | DataInputStream ds = new DataInputStream(new ByteArrayInputStream(file)); 59 | 60 | fileVersion = ds.readInt(); 61 | 62 | fileMark0 = ds.readInt(); 63 | fileMark1 = ds.readInt(); 64 | fileMark2 = ds.readInt(); 65 | fileMark3 = ds.readInt(); 66 | fileMark4 = ds.readInt(); 67 | 68 | 69 | areaNum = ds.readInt(); 70 | 71 | headerAddress = ds.readInt(); 72 | backup0 = ds.readInt(); 73 | previewAddress = ds.readInt(); 74 | backup1 = ds.readInt(); 75 | layersDefAddress = ds.readInt(); 76 | backup2 = ds.readInt(); 77 | layersImageAddress = ds.readInt(); 78 | 79 | } 80 | 81 | 82 | 83 | @Override 84 | public String getInformation() { 85 | return null; 86 | } 87 | 88 | @Override 89 | public int getNumberOfLayers() { 90 | return 0; 91 | } 92 | 93 | @Override 94 | public int getResolutionY() { 95 | return 0; 96 | } 97 | 98 | @Override 99 | public int getResolutionX() { 100 | return 0; 101 | } 102 | 103 | @Override 104 | public float getBuildAreaX() { 105 | return 0; 106 | } 107 | 108 | @Override 109 | public float getBuildAreaY() { 110 | return 0; 111 | } 112 | 113 | @Override 114 | public int getBottomLayers() { 115 | return 0; 116 | } 117 | 118 | @Override 119 | public void setBottomLayers(int bottomLayers) { 120 | 121 | } 122 | 123 | @Override 124 | public float getLayerHeight() { 125 | return 0; 126 | } 127 | 128 | @Override 129 | public float getExposureTimeSeconds() { 130 | return 0; 131 | } 132 | 133 | @Override 134 | public float getBottomExposureTimeSeconds() { 135 | return 0; 136 | } 137 | 138 | @Override 139 | public void setExposureBottomTimeSeconds(float exposureBottomTimeSeconds) { 140 | 141 | } 142 | 143 | @Override 144 | public void setExposureTimeSeconds(float exposureTimeSeconds) { 145 | 146 | } 147 | 148 | @Override 149 | public float getNormalExposure() { 150 | return 0; 151 | } 152 | 153 | @Override 154 | public float getOffTimeSeconds() { 155 | return 0; 156 | } 157 | 158 | @Override 159 | public void setOffTimeSeconds(float offTimeSeconds) { 160 | 161 | } 162 | 163 | @Override 164 | public int getPrintTimeSeconds() { 165 | return 0; 166 | } 167 | 168 | @Override 169 | public boolean isMirrored() { return false; } 170 | 171 | @Override 172 | public boolean hasAA() { 173 | return false; 174 | } 175 | 176 | @Override 177 | public int getAALevels() { 178 | return 0; 179 | } 180 | 181 | @Override 182 | public void setAALevels(int levels, List layers) { 183 | 184 | } 185 | 186 | @Override 187 | public int getVersion() { 188 | return 0; 189 | } 190 | 191 | @Override 192 | public void setFileVersion(int i) { 193 | 194 | } 195 | 196 | @Override 197 | public int getByteSize() { 198 | return 0; 199 | } 200 | 201 | @Override 202 | public void unLink() { 203 | 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /src/photon/file/parts/PhotonInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.parts; 26 | 27 | /** 28 | * by bn on 01/07/2018. 29 | */ 30 | 31 | import java.io.DataInput; 32 | import java.io.DataInputStream; 33 | import java.io.IOException; 34 | import java.io.InputStream; 35 | 36 | public class PhotonInputStream extends InputStream implements DataInput { 37 | private DataInputStream dataInputStream; 38 | private InputStream inputStream; 39 | private byte byteBuffer[]; 40 | 41 | public PhotonInputStream(InputStream inputStream) { 42 | this.inputStream = inputStream; 43 | dataInputStream = new DataInputStream(inputStream); 44 | byteBuffer = new byte[8]; // Largest data type is 64-bits (8 bytes) 45 | } 46 | 47 | @Override 48 | public int read() throws IOException { 49 | return inputStream.read(); 50 | } 51 | 52 | @Override 53 | public final int read(byte[] bytes, int offset, int readLen) throws IOException { 54 | return inputStream.read(bytes, offset, readLen); 55 | } 56 | 57 | @Override 58 | public final void readFully(byte[] bytes) throws IOException { 59 | dataInputStream.readFully(bytes, 0, bytes.length); 60 | } 61 | 62 | @Override 63 | public final void readFully(byte[] bytes, int offset, int readLen) throws IOException { 64 | dataInputStream.readFully(bytes, offset, readLen); 65 | } 66 | 67 | @Override 68 | public final int skipBytes(int n) throws IOException { 69 | return dataInputStream.skipBytes(n); 70 | } 71 | 72 | @Override 73 | public final boolean readBoolean() throws IOException { 74 | return dataInputStream.readBoolean(); 75 | } 76 | 77 | @Override 78 | public final byte readByte() throws IOException { 79 | return dataInputStream.readByte(); 80 | } 81 | 82 | @Override 83 | public final int readUnsignedByte() throws IOException { 84 | return dataInputStream.readUnsignedByte(); 85 | } 86 | 87 | @Override 88 | public final short readShort() throws IOException { 89 | dataInputStream.readFully(byteBuffer, 0, 2); 90 | return (short)((byteBuffer[1] & 0xff) << 8 | (byteBuffer[0] & 0xff)); 91 | } 92 | 93 | @Override 94 | public final int readUnsignedShort() throws IOException { 95 | dataInputStream.readFully(byteBuffer, 0, 2); 96 | return ((byteBuffer[1] & 0xff) << 8 | (byteBuffer[0] & 0xff)); 97 | } 98 | 99 | @Override 100 | public final char readChar() throws IOException { 101 | dataInputStream.readFully(byteBuffer, 0, 2); 102 | return (char)((byteBuffer[1] & 0xff) << 8 | (byteBuffer[0] & 0xff)); 103 | } 104 | 105 | @Override 106 | public final int readInt() throws IOException { 107 | dataInputStream.readFully(byteBuffer, 0, 4); 108 | return (byteBuffer[3]) << 24 | (byteBuffer[2] & 0xff) << 16 | 109 | (byteBuffer[1] & 0xff) << 8 | (byteBuffer[0] & 0xff); 110 | } 111 | 112 | @Override 113 | public final long readLong() throws IOException { 114 | dataInputStream.readFully(byteBuffer, 0, 8); 115 | return (long)(byteBuffer[7]) << 56 | (long)(byteBuffer[6]&0xff) << 48 | 116 | (long)(byteBuffer[5] & 0xff) << 40 | (long)(byteBuffer[4] & 0xff) << 32 | 117 | (long)(byteBuffer[3] & 0xff) << 24 | (long)(byteBuffer[2] & 0xff) << 16 | 118 | (long)(byteBuffer[1] & 0xff) << 8 | (long)(byteBuffer[0] & 0xff); 119 | } 120 | 121 | @Override 122 | public final float readFloat() throws IOException { 123 | return Float.intBitsToFloat(readInt()); 124 | } 125 | 126 | @Override 127 | public final double readDouble() throws IOException { 128 | return Double.longBitsToDouble(readLong()); 129 | } 130 | 131 | @Deprecated 132 | @Override 133 | public final String readLine() throws IOException { 134 | return dataInputStream.readLine(); 135 | } 136 | 137 | @Override 138 | public final String readUTF() throws IOException { 139 | return dataInputStream.readUTF(); 140 | } 141 | 142 | @Override 143 | public int available() throws IOException { 144 | return dataInputStream.available(); 145 | } 146 | 147 | @Override 148 | public final void close() throws IOException { 149 | dataInputStream.close(); 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/photon/application/dialogs/AntiAliaseDialog.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 |
115 | -------------------------------------------------------------------------------- /src/photon/application/dialogs/FixDialog.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 |
121 | -------------------------------------------------------------------------------- /src/photon/application/render/OnionPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render; 26 | 27 | import photon.application.render.interfaces.IRenderer; 28 | import photon.application.render.storage.Renderer; 29 | import photon.application.render.storage.RotationBaseMatrix; 30 | import photon.application.render.elements.BaseElement; 31 | import photon.application.render.elements.World; 32 | import photon.file.PhotonFile; 33 | import photon.file.parts.PhotonFileLayer; 34 | import photon.file.parts.PhotonLayer; 35 | 36 | import javax.swing.*; 37 | import java.awt.*; 38 | 39 | public class OnionPanel extends JPanel { 40 | 41 | private World world; //world object to put 3d objects here before rendering 42 | private IRenderer renderer; //the renderer 43 | 44 | public OnionPanel() { 45 | super(); 46 | 47 | BaseElement baseElement; 48 | 49 | renderer = new Renderer(); //create a new Z-buffer renderer 50 | world = new World(); //create a new world object 51 | 52 | 53 | baseElement = new PhotonBuildPlateTop(); 54 | baseElement.setColor(0, 255, 255); 55 | world.add(baseElement); 56 | 57 | baseElement = new PhotonBuildPlate(2560, 1440, 50, -1000); 58 | baseElement.setColor(0, 255, 255); 59 | baseElement.scale(0.1); 60 | world.add(baseElement); 61 | 62 | world.rotate(new RotationBaseMatrix(45, 0, 0)); 63 | } 64 | 65 | @Override 66 | public void paint(Graphics gr) { 67 | Image view = this.createImage(this.getWidth(), this.getHeight()); 68 | Graphics g = view.getGraphics(); 69 | g.setColor(Color.black); 70 | g.fillRect(this.getX(), this.getY(), this.getWidth(), this.getHeight()); 71 | renderer.render(world, view, this); 72 | 73 | gr.drawImage(view, 0, 0, this); 74 | } 75 | 76 | 77 | private static final int MAX_SHOW = 500; 78 | 79 | public void drawLayer(int layerNo, PhotonFileLayer fileLayer, PhotonFile photonFile, int screenHeight) { 80 | double scaleFactor = screenHeight * 1f / (photonFile.getHeight() * 2.6f); 81 | 82 | world.clear(); 83 | 84 | int showMax = photonFile.getLayerCount(); 85 | // showMax = Integer.min(showMax, MAX_SHOW); 86 | 87 | 88 | int layerOffset = 0; // showMax / 2; 89 | 90 | BaseElement baseElement; 91 | 92 | int offset = layerOffset - 1; 93 | 94 | if (layerNo > 1) { 95 | int showLayers = layerNo - 1; 96 | if (showLayers > showMax) showLayers = showMax; 97 | 98 | 99 | int b = (showLayers / 40); 100 | double a = b / (showLayers - 10d); 101 | 102 | // boolean colorUp = true; 103 | // int colorIndex = 0; 104 | 105 | long pixels = 0; 106 | 107 | for (int i = showLayers; i > 0; i--) { 108 | int prevNo = layerNo - showLayers + i; 109 | PhotonFileLayer photonFileLayer = photonFile.getLayer(prevNo); 110 | 111 | pixels += photonFileLayer.getPixels(); 112 | if (pixels>30000000L) { 113 | showMax = 0; 114 | break; 115 | } 116 | 117 | baseElement = new ResinLayer(2560, 1440, photonFileLayer, PhotonLayer.OFF, offset); 118 | baseElement.scale(scaleFactor); 119 | if (prevNo < photonFile.getPhotonFileHeader().getBottomLayers()) { 120 | baseElement.setColor(0, 95, 63); 121 | } else { 122 | // if (colorUp) { 123 | // colorIndex+=5; 124 | // colorUp = colorIndex<=30; 125 | // } else { 126 | // colorIndex-=5; 127 | // colorUp = colorIndex<=0; 128 | // } 129 | // baseElement.setColor(63, 110 + colorIndex, 63); 130 | int col; 131 | if (i < (showLayers - 20)) { 132 | col = 64 + (i * 100 / showLayers); 133 | } else { 134 | col = 204 - (showLayers-i)*2; 135 | } 136 | baseElement.setColor(0, col, col / 2); 137 | ///baseElement.setColor(0, 64 + (i * 100 / showLayers), 0); 138 | } 139 | world.add(baseElement); 140 | 141 | if (i < (showLayers - 20)) { 142 | int skipLayers = ((Double) (-1 * a * i + b)).intValue(); 143 | i -= skipLayers; 144 | offset -= (1 + skipLayers); 145 | } else { 146 | offset -= 1; 147 | } 148 | } 149 | } 150 | 151 | 152 | if (layerNo < showMax) { 153 | baseElement = new PhotonBuildPlate(2560, 1440, 0, offset); 154 | baseElement.setColor(0, 255, 255); 155 | baseElement.scale(scaleFactor); 156 | world.add(baseElement); 157 | } 158 | 159 | baseElement = new ResinLayer(2560, 1440, fileLayer, PhotonLayer.SUPPORTED, layerOffset); 160 | baseElement.scale(scaleFactor); 161 | baseElement.setColor(0, 255, 0); 162 | world.add(baseElement); 163 | 164 | if (fileLayer.getIsLandsCount() > 0) { 165 | baseElement = new ResinLayer(2560, 1440, fileLayer, PhotonLayer.ISLAND, layerOffset); 166 | baseElement.scale(scaleFactor); 167 | baseElement.setColor(255, 0, 0); 168 | world.add(baseElement); 169 | } 170 | 171 | 172 | world.rotate(new RotationBaseMatrix(-1.8, 0, 0)); 173 | 174 | repaint(); 175 | } 176 | 177 | public void scale(double factor) { 178 | world.scale(factor); 179 | repaint(); 180 | } 181 | 182 | public void rotate(RotationBaseMatrix rotationMatrix) { 183 | world.rotate(rotationMatrix); 184 | repaint(); 185 | } 186 | 187 | } 188 | -------------------------------------------------------------------------------- /src/photon/file/ui/PhotonLayerImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.file.ui; 26 | 27 | import photon.file.parts.PhotonFileLayer; 28 | import photon.file.parts.PhotonLine; 29 | import photon.file.parts.PhotonRow; 30 | 31 | import javax.swing.*; 32 | import java.awt.*; 33 | import java.awt.geom.AffineTransform; 34 | import java.awt.image.BufferedImage; 35 | import java.util.ArrayList; 36 | import java.util.BitSet; 37 | 38 | /** 39 | * by bn on 02/07/2018. 40 | */ 41 | public class PhotonLayerImage extends JPanel { 42 | private int width; 43 | private int height; 44 | private float scale = 1f; 45 | private BufferedImage image; 46 | private boolean mirrored; 47 | 48 | public PhotonLayerImage(int width, int height) { 49 | this.width = width; 50 | this.height = height; 51 | image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 52 | setPreferredSize(new Dimension(width, height)); 53 | } 54 | 55 | public void setMirrored(boolean mirrored) { 56 | this.mirrored = mirrored; 57 | } 58 | 59 | @Override 60 | protected void paintComponent(Graphics g) { 61 | g.drawImage(image, 0, 0, null); 62 | } 63 | 64 | public void reScale(int width, int height) { 65 | reScale(scale, width, height); 66 | } 67 | 68 | public void reScale(float scale, int width, int height) { 69 | this.scale = scale; 70 | this.width = width; 71 | this.height = height; 72 | 73 | image = new BufferedImage((int) (width * scale), (int) (height * scale), BufferedImage.TYPE_INT_RGB); 74 | setPreferredSize(new Dimension((int) (width * scale), (int) (height * scale))); 75 | } 76 | 77 | public void drawLayer(PhotonFileLayer layer, int margin) { 78 | if (layer != null) { 79 | Graphics2D g = image.createGraphics(); 80 | 81 | if (mirrored) { 82 | AffineTransform transform = new AffineTransform(); 83 | transform.setToScale(1, -1); 84 | transform.translate(0, -image.getHeight()); 85 | g.setTransform(transform); 86 | } 87 | 88 | g.scale(scale, scale); 89 | 90 | g.clearRect(0, 0, width, height); 91 | 92 | if (margin > 0) { 93 | int x2 = (width - 1) - margin; 94 | int y2 = (height - 1) - margin; 95 | g.setColor(Color.decode("#009999")); 96 | g.drawLine(margin, margin, x2, margin); 97 | g.drawLine(margin, margin, margin, y2); 98 | g.drawLine(margin, y2, x2, y2); 99 | g.drawLine(x2, margin, x2, y2); 100 | } 101 | 102 | if (layer.isCalculated) { 103 | if (layer.getIsLandsCount() < 100) { 104 | int columnNumber = 0; 105 | g.setColor(Color.decode("#550000")); 106 | for (BitSet column : layer.getIslandRows()) { 107 | drawCross(g, columnNumber, column); 108 | columnNumber++; 109 | } 110 | 111 | } 112 | 113 | ArrayList rows = layer.getRows(); 114 | if (rows != null) { 115 | int columnNumber = 0; 116 | for (PhotonRow row : rows) { 117 | int i = 0; 118 | for (PhotonLine line : row.lines) { 119 | int end = i + line.length; 120 | if (line.color != Color.black) { 121 | g.setColor(line.color); 122 | g.drawLine(columnNumber, i, columnNumber, end); 123 | } 124 | i = end; 125 | } 126 | columnNumber++; 127 | } 128 | } 129 | 130 | } else { 131 | g.setColor(Color.decode("#008888")); 132 | int columnNumber = 0; 133 | for (BitSet column : layer.getUnknownRows()) { 134 | drawDot(g, columnNumber, column); 135 | columnNumber++; 136 | } 137 | } 138 | 139 | /* 140 | if (rootLayer) { 141 | g.setColor(Color.decode("#008800")); 142 | int columnNumber = 0; 143 | for (BitSet column : layer.getSupportedRows()) { 144 | drawDot(g, columnNumber, column); 145 | columnNumber++; 146 | } 147 | } else { 148 | int columnNumber = 0; 149 | g.setColor(Color.decode("#008800")); 150 | for (BitSet column : layer.getSupportedRows()) { 151 | drawDot(g, columnNumber, column); 152 | columnNumber++; 153 | } 154 | 155 | columnNumber = 0; 156 | g.setColor(Color.decode("#FFFF00")); 157 | for (BitSet column : layer.getUnSupportedRows()) { 158 | drawDot(g, columnNumber, column); 159 | columnNumber++; 160 | } 161 | 162 | columnNumber = 0; 163 | g.setColor(Color.decode("#FF0000")); 164 | for (BitSet column : layer.getIslandRows()) { 165 | drawDot(g, columnNumber, column); 166 | columnNumber++; 167 | } 168 | } 169 | */ 170 | g.dispose(); 171 | } 172 | } 173 | 174 | private void drawDot(Graphics2D g, int columnNumber, BitSet column) { 175 | if (!column.isEmpty()) { 176 | for (int i = column.nextSetBit(0); i >= 0; i = column.nextSetBit(i + 1)) { 177 | g.drawLine(columnNumber, i, columnNumber, i); 178 | } 179 | } 180 | } 181 | 182 | private void drawCross(Graphics2D g, int columnNumber, BitSet column) { 183 | if (!column.isEmpty()) { 184 | for (int i = column.nextSetBit(0); i >= 0; i = column.nextSetBit(i + 1)) { 185 | g.drawLine(columnNumber, 0, columnNumber, height - 1); 186 | g.drawLine(0, i, width - 1, i); 187 | } 188 | } 189 | } 190 | 191 | } 192 | -------------------------------------------------------------------------------- /src/photon/application/dialogs/EditDialog.form: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /src/photon/application/render/storage/Renderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.storage; 26 | 27 | import photon.application.render.elements.BaseElement; 28 | import photon.application.render.elements.Segment; 29 | import photon.application.render.elements.Triangle; 30 | import photon.application.render.elements.Vertex; 31 | import photon.application.render.interfaces.IRenderer; 32 | import photon.application.render.utils.VectorUtil; 33 | import photon.application.render.elements.RenderAsSegment; 34 | import photon.application.render.elements.World; 35 | import photon.application.render.utils.ZBufferUtil; 36 | 37 | import java.awt.*; 38 | import java.awt.image.ImageObserver; 39 | 40 | public class Renderer implements IRenderer { 41 | 42 | //perspective division constant 43 | private static final double D = 400; 44 | 45 | /** 46 | * Renders segment based objects 47 | * 48 | * @param baseElement object to be rendered 49 | * @param view off screen image 50 | * @param observer image observer object 51 | * @param zbuffer z depth buffer 52 | */ 53 | private void renderSegmentBased(BaseElement baseElement, Image view, ImageObserver observer, int[][] zbuffer) { 54 | 55 | Graphics gr = view.getGraphics(); //obtain graphic object from off screen image 56 | 57 | int w = view.getWidth(observer); //obtain image width 58 | int h = view.getHeight(observer); //obtain image height 59 | 60 | for (int i = 0; baseElement != null && i < baseElement.iTransformables.size(); i++) { 61 | Segment segment = (Segment) baseElement.iTransformables.get(i); 62 | 63 | //sets the color of the graphic object used to draw 64 | gr.setColor(new Color(segment.r, segment.g, segment.b)); 65 | 66 | //calculate perspective transformation for all vertexes 67 | //and for x,y and z coordinates 68 | int x1, x2; 69 | x1 = (int) (segment.start.x / (1 + segment.start.z / D)) + w / 2; 70 | x2 = (int) (segment.end.x / (1 + segment.end.z / D)) + w / 2; 71 | 72 | int y1, y2; 73 | y1 = (int) (segment.start.y / (1 + segment.start.z / D)) + h / 2; 74 | y2 = (int) (segment.end.y / (1 + segment.end.z / D)) + h / 2; 75 | 76 | int z1, z2; 77 | z1 = (int) segment.start.z; 78 | z2 = (int) segment.end.z; 79 | 80 | //draw line 81 | ZBufferUtil.drawLine(gr, x1, y1, z1, x2, y2, z2, zbuffer); 82 | 83 | } 84 | 85 | 86 | } 87 | 88 | /** 89 | * Renders triangle based objects 90 | * 91 | * @param baseElement object to be rendered 92 | * @param view off screen image 93 | * @param observer image observer object 94 | * @param zbuffer z depth buffer 95 | */ 96 | private void renderTriangleBased(BaseElement baseElement, Image view, ImageObserver observer, int[][] zbuffer) { 97 | 98 | Graphics gr = view.getGraphics(); //obtain graphic object from offscreen image 99 | 100 | int w = view.getWidth(observer); //obtain image width 101 | int h = view.getHeight(observer); //obtain image height 102 | 103 | for (int i = 0; i < baseElement.iTransformables.size(); i++) { 104 | Triangle tri = (Triangle) baseElement.iTransformables.get(i); 105 | 106 | //calculate perspective transformation for all vertexes 107 | //and for x,y and z coordinates 108 | int[] x = new int[3]; 109 | x[0] = (int) (tri.v1.x / (1 + tri.v1.z / D)) + w / 2; 110 | x[1] = (int) (tri.v2.x / (1 + tri.v2.z / D)) + w / 2; 111 | x[2] = (int) (tri.v3.x / (1 + tri.v3.z / D)) + w / 2; 112 | 113 | int[] y = new int[3]; 114 | y[0] = (int) (tri.v1.y / (1 + tri.v1.z / D)) + h / 2; 115 | y[1] = (int) (tri.v2.y / (1 + tri.v2.z / D)) + h / 2; 116 | y[2] = (int) (tri.v3.y / (1 + tri.v3.z / D)) + h / 2; 117 | 118 | int[] z = new int[3]; 119 | z[0] = (int) tri.v1.z; 120 | z[1] = (int) tri.v2.z; 121 | z[2] = (int) tri.v3.z; 122 | 123 | //obtains the normal vector of the triangle 124 | Vertex normale = VectorUtil.calculateNormal(tri); 125 | 126 | /* 127 | calculates cos between triangle normal and light direction vector 128 | and calculate color intensity in function of cos value 129 | */ 130 | double cos = VectorUtil.calculateAngleCosBetweenVectors(normale, new Vertex(Math.cos(Math.PI / 2), Math.cos(Math.PI / 2) / 2, Math.cos(Math.PI / 2))); 131 | int r, g, b; 132 | cos = Math.abs(cos); 133 | r = (int) (cos * tri.r); 134 | g = (int) (cos * tri.g); 135 | b = (int) (cos * tri.b); 136 | 137 | //set graphic color 138 | gr.setColor(new Color(r, g, b)); 139 | 140 | //if filled flag is true render filled triangles 141 | ZBufferUtil.fillTriangle(gr, x, y, z, zbuffer); 142 | 143 | } 144 | } 145 | 146 | /** 147 | * @param world world object containing the set of 3d objects 148 | * @param view offscreen image to render the world in 149 | * @param observer image observer object necessary to get width and height of the 150 | */ 151 | public void render(World world, Image view, ImageObserver observer) { 152 | 153 | int w = view.getWidth(observer); //obtain image width 154 | int h = view.getHeight(observer); //obtain image height 155 | 156 | int[][] zbuffer = new int[w][h]; 157 | 158 | //initialize zbuffer with the max depth value 159 | for (int k = 0; k < w; k++) { 160 | for (int n = 0; n < h; n++) { 161 | zbuffer[k][n] = 0xFFFE; 162 | } 163 | } 164 | 165 | for (int i = 0; i < world.iTransformables.size(); i++) { 166 | BaseElement baseElement = (BaseElement) world.iTransformables.get(i); 167 | 168 | //render the object appropriately according to their type 169 | if (baseElement instanceof RenderAsSegment) { 170 | renderSegmentBased(baseElement, view, observer, zbuffer); 171 | } else { 172 | renderTriangleBased(baseElement, view, observer, zbuffer); 173 | } 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/photon/application/render/storage/BaseMatrix.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Bonosoft 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package photon.application.render.storage; 26 | 27 | import photon.application.render.elements.Vertex; 28 | 29 | public class BaseMatrix { 30 | 31 | // for performance issues (being a key feature in 3D graphics) 32 | // fields are made pulbic for direct and faster access 33 | private double e11; 34 | private double e12; 35 | private double e13; 36 | private double e14; 37 | private double e21; 38 | private double e22; 39 | private double e23; 40 | private double e24; 41 | private double e31; 42 | private double e32; 43 | private double e33; 44 | private double e34; 45 | private double e41; 46 | private double e42; 47 | private double e43; 48 | private double e44; 49 | 50 | 51 | /** 52 | * Initializes a matrix with the given parameter values 53 | * 54 | * @param e11 row 1 column 1 value 55 | * @param e12 row 1 column 2 value 56 | * @param e13 row 1 column 3 value 57 | * @param e14 row 1 column 4 value 58 | * @param e21 row 2 column 1 value 59 | * @param e22 row 2 column 2 value 60 | * @param e23 row 2 column 3 value 61 | * @param e24 row 2 column 4 value 62 | * @param e31 row 3 column 1 value 63 | * @param e32 row 3 column 2 value 64 | * @param e33 row 3 column 3 value 65 | * @param e34 row 3 column 4 value 66 | * @param e41 row 4 column 1 value 67 | * @param e42 row 4 column 2 value 68 | * @param e43 row 4 column 3 value 69 | * @param e44 row 4 column 4 value 70 | */ 71 | public BaseMatrix(double e11, double e12, double e13, double e14, 72 | double e21, double e22, double e23, double e24, 73 | double e31, double e32, double e33, double e34, 74 | double e41, double e42, double e43, double e44) { 75 | this.e11 = e11; 76 | this.e12 = e12; 77 | this.e13 = e13; 78 | this.e14 = e14; 79 | this.e21 = e21; 80 | this.e22 = e22; 81 | this.e23 = e23; 82 | this.e24 = e24; 83 | this.e31 = e31; 84 | this.e32 = e32; 85 | this.e33 = e33; 86 | this.e34 = e34; 87 | this.e41 = e41; 88 | this.e42 = e42; 89 | this.e43 = e43; 90 | this.e44 = e44; 91 | } 92 | 93 | /** 94 | * Creates a copy of the matrix given as parameter 95 | * 96 | * @param parentMatrix matrix to be copied 97 | */ 98 | public BaseMatrix(BaseMatrix parentMatrix) { 99 | this.e11 = parentMatrix.e11; 100 | this.e12 = parentMatrix.e12; 101 | this.e13 = parentMatrix.e13; 102 | this.e14 = parentMatrix.e14; 103 | this.e21 = parentMatrix.e21; 104 | this.e22 = parentMatrix.e22; 105 | this.e23 = parentMatrix.e23; 106 | this.e24 = parentMatrix.e24; 107 | this.e31 = parentMatrix.e31; 108 | this.e32 = parentMatrix.e32; 109 | this.e33 = parentMatrix.e33; 110 | this.e34 = parentMatrix.e34; 111 | this.e41 = parentMatrix.e41; 112 | this.e42 = parentMatrix.e42; 113 | this.e43 = parentMatrix.e43; 114 | this.e44 = parentMatrix.e44; 115 | } 116 | 117 | /** 118 | * Multiplies itself with another matrix 119 | * 120 | * @param matrix the matrix to be multiplied with 121 | */ 122 | public void multiply(BaseMatrix matrix) { 123 | //creates a copy of itself to use for the calulations 124 | BaseMatrix a = new BaseMatrix(this); 125 | 126 | /* 127 | matrix multiplication is made directly and not using for cycle which 128 | would take less code but become slower 129 | */ 130 | this.e11 = a.e11 * matrix.e11 + a.e12 * matrix.e21 + a.e13 * matrix.e31 + a.e14 * matrix.e41; 131 | this.e21 = a.e21 * matrix.e11 + a.e22 * matrix.e21 + a.e23 * matrix.e31 + a.e24 * matrix.e41; 132 | this.e31 = a.e31 * matrix.e11 + a.e32 * matrix.e21 + a.e33 * matrix.e31 + a.e34 * matrix.e41; 133 | this.e41 = a.e41 * matrix.e11 + a.e42 * matrix.e21 + a.e43 * matrix.e31 + a.e44 * matrix.e41; 134 | 135 | this.e12 = a.e11 * matrix.e12 + a.e12 * matrix.e22 + a.e13 * matrix.e32 + a.e14 * matrix.e42; 136 | this.e22 = a.e21 * matrix.e12 + a.e22 * matrix.e22 + a.e23 * matrix.e32 + a.e24 * matrix.e42; 137 | this.e32 = a.e31 * matrix.e12 + a.e32 * matrix.e22 + a.e33 * matrix.e32 + a.e34 * matrix.e42; 138 | this.e42 = a.e41 * matrix.e12 + a.e42 * matrix.e22 + a.e43 * matrix.e32 + a.e44 * matrix.e42; 139 | 140 | this.e13 = a.e11 * matrix.e13 + a.e12 * matrix.e23 + a.e13 * matrix.e33 + a.e14 * matrix.e43; 141 | this.e23 = a.e21 * matrix.e13 + a.e22 * matrix.e23 + a.e23 * matrix.e33 + a.e24 * matrix.e43; 142 | this.e33 = a.e31 * matrix.e13 + a.e32 * matrix.e23 + a.e33 * matrix.e33 + a.e34 * matrix.e43; 143 | this.e43 = a.e41 * matrix.e13 + a.e42 * matrix.e23 + a.e43 * matrix.e33 + a.e44 * matrix.e43; 144 | 145 | this.e14 = a.e11 * matrix.e14 + a.e12 * matrix.e24 + a.e13 * matrix.e34 + a.e14 * matrix.e44; 146 | this.e24 = a.e21 * matrix.e14 + a.e22 * matrix.e24 + a.e23 * matrix.e34 + a.e24 * matrix.e44; 147 | this.e34 = a.e31 * matrix.e14 + a.e32 * matrix.e24 + a.e33 * matrix.e34 + a.e34 * matrix.e44; 148 | this.e44 = a.e41 * matrix.e14 + a.e42 * matrix.e24 + a.e43 * matrix.e34 + a.e44 * matrix.e44; 149 | } 150 | 151 | /** 152 | * Multiplies itself with a vertex, the most used operation 153 | * applied to all object vertexes during transformations 154 | * 155 | * @param vertex the vertex to be transformed 156 | */ 157 | public void multiply(Vertex vertex) { 158 | //creates a copy of the old values necessary for the calculations 159 | double x = vertex.x; 160 | double y = vertex.y; 161 | double z = vertex.z; 162 | double w = vertex.w; 163 | 164 | //calculates the values updating directly the vertex given as parameter 165 | //and not by creating a new object, for memory and performance issues 166 | vertex.x = this.e11 * x + this.e12 * y + this.e13 * z + this.e14 * w; 167 | vertex.y = this.e21 * x + this.e22 * y + this.e23 * z + this.e24 * w; 168 | vertex.z = this.e31 * x + this.e32 * y + this.e33 * z + this.e34 * w; 169 | vertex.w = this.e41 * x + this.e42 * y + this.e43 * z + this.e44 * w; 170 | } 171 | 172 | } 173 | --------------------------------------------------------------------------------