joonsrenderer 1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +53 -0
- data/.mvn/extensions.xml +8 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +6 -0
- data/LICENSE +674 -0
- data/README.md +2 -0
- data/Rakefile +43 -0
- data/docs/.gitignore +6 -0
- data/docs/_config.yml +20 -0
- data/docs/_includes/footer.html +38 -0
- data/docs/_includes/head.html +15 -0
- data/docs/_includes/header.html +27 -0
- data/docs/_includes/icon-github.html +1 -0
- data/docs/_includes/icon-github.svg +1 -0
- data/docs/_includes/icon-twitter.html +1 -0
- data/docs/_includes/icon-twitter.svg +1 -0
- data/docs/_layouts/default.html +20 -0
- data/docs/_layouts/page.html +14 -0
- data/docs/_layouts/post.html +15 -0
- data/docs/_posts/2017-01-08-animated_ray_tracing.md +72 -0
- data/docs/_posts/2017-01-08-welcome.md +78 -0
- data/docs/_sass/_base.scss +206 -0
- data/docs/_sass/_layout.scss +242 -0
- data/docs/_sass/_syntax-highlighting.scss +71 -0
- data/docs/about.md +12 -0
- data/docs/assets/Animation.ogv +0 -0
- data/docs/assets/Animation.png +0 -0
- data/docs/assets/basic.png +0 -0
- data/docs/assets/basic_traced.png +0 -0
- data/docs/css/main.scss +38 -0
- data/docs/favicon.ico +0 -0
- data/docs/feed.xml +30 -0
- data/docs/index.html +38 -0
- data/joonsrenderer.gemspec +23 -0
- data/lib/joonsrenderer.rb +12 -0
- data/lib/joonsrenderer/version.rb +3 -0
- data/pom.rb +75 -0
- data/pom.xml +163 -0
- data/src/main/java/SunflowGUI.java +1354 -0
- data/src/main/java/joons/JRFiller.java +79 -0
- data/src/main/java/joons/JRImagePanel.java +141 -0
- data/src/main/java/joons/JRRecorder.java +183 -0
- data/src/main/java/joons/JRStatics.java +199 -0
- data/src/main/java/joons/JoonsRenderer.java +837 -0
- data/src/main/java/org/sunflow/AsciiFileSunflowAPI.java +98 -0
- data/src/main/java/org/sunflow/Benchmark.java +313 -0
- data/src/main/java/org/sunflow/BinaryFileSunflowAPI.java +228 -0
- data/src/main/java/org/sunflow/FileSunflowAPI.java +354 -0
- data/src/main/java/org/sunflow/PluginRegistry.java +322 -0
- data/src/main/java/org/sunflow/RealtimeBenchmark.java +125 -0
- data/src/main/java/org/sunflow/RenderObjectMap.java +344 -0
- data/src/main/java/org/sunflow/SunflowAPI.java +762 -0
- data/src/main/java/org/sunflow/SunflowAPIInterface.java +277 -0
- data/src/main/java/org/sunflow/core/AccelerationStructure.java +20 -0
- data/src/main/java/org/sunflow/core/AccelerationStructureFactory.java +36 -0
- data/src/main/java/org/sunflow/core/BucketOrder.java +21 -0
- data/src/main/java/org/sunflow/core/Camera.java +125 -0
- data/src/main/java/org/sunflow/core/CameraLens.java +29 -0
- data/src/main/java/org/sunflow/core/CausticPhotonMapInterface.java +15 -0
- data/src/main/java/org/sunflow/core/Display.java +78 -0
- data/src/main/java/org/sunflow/core/Filter.java +27 -0
- data/src/main/java/org/sunflow/core/GIEngine.java +42 -0
- data/src/main/java/org/sunflow/core/Geometry.java +157 -0
- data/src/main/java/org/sunflow/core/GlobalPhotonMapInterface.java +21 -0
- data/src/main/java/org/sunflow/core/ImageSampler.java +26 -0
- data/src/main/java/org/sunflow/core/Instance.java +224 -0
- data/src/main/java/org/sunflow/core/InstanceList.java +83 -0
- data/src/main/java/org/sunflow/core/IntersectionState.java +120 -0
- data/src/main/java/org/sunflow/core/LightSample.java +104 -0
- data/src/main/java/org/sunflow/core/LightServer.java +382 -0
- data/src/main/java/org/sunflow/core/LightSource.java +67 -0
- data/src/main/java/org/sunflow/core/Modifier.java +16 -0
- data/src/main/java/org/sunflow/core/Options.java +20 -0
- data/src/main/java/org/sunflow/core/ParameterList.java +758 -0
- data/src/main/java/org/sunflow/core/PhotonStore.java +62 -0
- data/src/main/java/org/sunflow/core/PrimitiveList.java +70 -0
- data/src/main/java/org/sunflow/core/Ray.java +219 -0
- data/src/main/java/org/sunflow/core/RenderObject.java +25 -0
- data/src/main/java/org/sunflow/core/Scene.java +377 -0
- data/src/main/java/org/sunflow/core/SceneParser.java +58 -0
- data/src/main/java/org/sunflow/core/Shader.java +30 -0
- data/src/main/java/org/sunflow/core/ShadingCache.java +84 -0
- data/src/main/java/org/sunflow/core/ShadingState.java +939 -0
- data/src/main/java/org/sunflow/core/Statistics.java +85 -0
- data/src/main/java/org/sunflow/core/Tesselatable.java +36 -0
- data/src/main/java/org/sunflow/core/Texture.java +128 -0
- data/src/main/java/org/sunflow/core/TextureCache.java +48 -0
- data/src/main/java/org/sunflow/core/accel/BoundingIntervalHierarchy.java +652 -0
- data/src/main/java/org/sunflow/core/accel/KDTree.java +833 -0
- data/src/main/java/org/sunflow/core/accel/NullAccelerator.java +30 -0
- data/src/main/java/org/sunflow/core/accel/UniformGrid.java +329 -0
- data/src/main/java/org/sunflow/core/bucket/BucketOrderFactory.java +26 -0
- data/src/main/java/org/sunflow/core/bucket/ColumnBucketOrder.java +21 -0
- data/src/main/java/org/sunflow/core/bucket/DiagonalBucketOrder.java +28 -0
- data/src/main/java/org/sunflow/core/bucket/HilbertBucketOrder.java +65 -0
- data/src/main/java/org/sunflow/core/bucket/InvertedBucketOrder.java +28 -0
- data/src/main/java/org/sunflow/core/bucket/RandomBucketOrder.java +49 -0
- data/src/main/java/org/sunflow/core/bucket/RowBucketOrder.java +21 -0
- data/src/main/java/org/sunflow/core/bucket/SpiralBucketOrder.java +43 -0
- data/src/main/java/org/sunflow/core/camera/FisheyeLens.java +25 -0
- data/src/main/java/org/sunflow/core/camera/PinholeLens.java +43 -0
- data/src/main/java/org/sunflow/core/camera/SphericalLens.java +22 -0
- data/src/main/java/org/sunflow/core/camera/ThinLens.java +107 -0
- data/src/main/java/org/sunflow/core/display/FastDisplay.java +119 -0
- data/src/main/java/org/sunflow/core/display/FileDisplay.java +83 -0
- data/src/main/java/org/sunflow/core/display/FrameDisplay.java +97 -0
- data/src/main/java/org/sunflow/core/display/ImgPipeDisplay.java +109 -0
- data/src/main/java/org/sunflow/core/filter/BlackmanHarrisFilter.java +28 -0
- data/src/main/java/org/sunflow/core/filter/BoxFilter.java +16 -0
- data/src/main/java/org/sunflow/core/filter/CatmullRomFilter.java +29 -0
- data/src/main/java/org/sunflow/core/filter/CubicBSpline.java +32 -0
- data/src/main/java/org/sunflow/core/filter/GaussianFilter.java +24 -0
- data/src/main/java/org/sunflow/core/filter/LanczosFilter.java +30 -0
- data/src/main/java/org/sunflow/core/filter/MitchellFilter.java +28 -0
- data/src/main/java/org/sunflow/core/filter/SincFilter.java +25 -0
- data/src/main/java/org/sunflow/core/filter/TriangleFilter.java +16 -0
- data/src/main/java/org/sunflow/core/gi/AmbientOcclusionGIEngine.java +57 -0
- data/src/main/java/org/sunflow/core/gi/FakeGIEngine.java +48 -0
- data/src/main/java/org/sunflow/core/gi/InstantGI.java +194 -0
- data/src/main/java/org/sunflow/core/gi/IrradianceCacheGIEngine.java +268 -0
- data/src/main/java/org/sunflow/core/gi/PathTracingGIEngine.java +65 -0
- data/src/main/java/org/sunflow/core/light/DirectionalSpotlight.java +103 -0
- data/src/main/java/org/sunflow/core/light/ImageBasedLight.java +303 -0
- data/src/main/java/org/sunflow/core/light/PointLight.java +72 -0
- data/src/main/java/org/sunflow/core/light/SphereLight.java +166 -0
- data/src/main/java/org/sunflow/core/light/SunSkyLight.java +362 -0
- data/src/main/java/org/sunflow/core/light/TriangleMeshLight.java +296 -0
- data/src/main/java/org/sunflow/core/modifiers/BumpMappingModifier.java +37 -0
- data/src/main/java/org/sunflow/core/modifiers/NormalMapModifier.java +34 -0
- data/src/main/java/org/sunflow/core/modifiers/PerlinModifier.java +80 -0
- data/src/main/java/org/sunflow/core/parser/Keyword.java +39 -0
- data/src/main/java/org/sunflow/core/parser/RA2Parser.java +107 -0
- data/src/main/java/org/sunflow/core/parser/RA3Parser.java +68 -0
- data/src/main/java/org/sunflow/core/parser/SCAbstractParser.java +299 -0
- data/src/main/java/org/sunflow/core/parser/SCAsciiParser.java +251 -0
- data/src/main/java/org/sunflow/core/parser/SCBinaryParser.java +156 -0
- data/src/main/java/org/sunflow/core/parser/SCParser.java +1403 -0
- data/src/main/java/org/sunflow/core/parser/ShaveRibParser.java +174 -0
- data/src/main/java/org/sunflow/core/parser/TriParser.java +79 -0
- data/src/main/java/org/sunflow/core/photonmap/CausticPhotonMap.java +429 -0
- data/src/main/java/org/sunflow/core/photonmap/GlobalPhotonMap.java +530 -0
- data/src/main/java/org/sunflow/core/photonmap/GridPhotonMap.java +308 -0
- data/src/main/java/org/sunflow/core/primitive/Background.java +55 -0
- data/src/main/java/org/sunflow/core/primitive/BanchoffSurface.java +100 -0
- data/src/main/java/org/sunflow/core/primitive/Box.java +210 -0
- data/src/main/java/org/sunflow/core/primitive/CornellBox.java +476 -0
- data/src/main/java/org/sunflow/core/primitive/CubeGrid.java +318 -0
- data/src/main/java/org/sunflow/core/primitive/Cylinder.java +104 -0
- data/src/main/java/org/sunflow/core/primitive/Hair.java +275 -0
- data/src/main/java/org/sunflow/core/primitive/JuliaFractal.java +266 -0
- data/src/main/java/org/sunflow/core/primitive/ParticleSurface.java +114 -0
- data/src/main/java/org/sunflow/core/primitive/Plane.java +163 -0
- data/src/main/java/org/sunflow/core/primitive/QuadMesh.java +413 -0
- data/src/main/java/org/sunflow/core/primitive/Sphere.java +101 -0
- data/src/main/java/org/sunflow/core/primitive/SphereFlake.java +234 -0
- data/src/main/java/org/sunflow/core/primitive/Torus.java +145 -0
- data/src/main/java/org/sunflow/core/primitive/TriangleMesh.java +849 -0
- data/src/main/java/org/sunflow/core/renderer/BucketRenderer.java +491 -0
- data/src/main/java/org/sunflow/core/renderer/MultipassRenderer.java +237 -0
- data/src/main/java/org/sunflow/core/renderer/ProgressiveRenderer.java +171 -0
- data/src/main/java/org/sunflow/core/renderer/SimpleRenderer.java +106 -0
- data/src/main/java/org/sunflow/core/shader/AmbientOcclusionShader.java +53 -0
- data/src/main/java/org/sunflow/core/shader/AnisotropicWardShader.java +216 -0
- data/src/main/java/org/sunflow/core/shader/ConstantShader.java +31 -0
- data/src/main/java/org/sunflow/core/shader/DiffuseShader.java +65 -0
- data/src/main/java/org/sunflow/core/shader/GlassShader.java +147 -0
- data/src/main/java/org/sunflow/core/shader/IDShader.java +27 -0
- data/src/main/java/org/sunflow/core/shader/MirrorShader.java +68 -0
- data/src/main/java/org/sunflow/core/shader/NormalShader.java +32 -0
- data/src/main/java/org/sunflow/core/shader/PhongShader.java +89 -0
- data/src/main/java/org/sunflow/core/shader/PrimIDShader.java +30 -0
- data/src/main/java/org/sunflow/core/shader/QuickGrayShader.java +63 -0
- data/src/main/java/org/sunflow/core/shader/ShinyDiffuseShader.java +98 -0
- data/src/main/java/org/sunflow/core/shader/SimpleShader.java +24 -0
- data/src/main/java/org/sunflow/core/shader/TexturedAmbientOcclusionShader.java +31 -0
- data/src/main/java/org/sunflow/core/shader/TexturedDiffuseShader.java +31 -0
- data/src/main/java/org/sunflow/core/shader/TexturedPhongShader.java +31 -0
- data/src/main/java/org/sunflow/core/shader/TexturedShinyDiffuseShader.java +31 -0
- data/src/main/java/org/sunflow/core/shader/TexturedWardShader.java +31 -0
- data/src/main/java/org/sunflow/core/shader/UVShader.java +27 -0
- data/src/main/java/org/sunflow/core/shader/UberShader.java +149 -0
- data/src/main/java/org/sunflow/core/shader/ViewCausticsShader.java +33 -0
- data/src/main/java/org/sunflow/core/shader/ViewGlobalPhotonsShader.java +25 -0
- data/src/main/java/org/sunflow/core/shader/ViewIrradianceShader.java +25 -0
- data/src/main/java/org/sunflow/core/shader/WireframeShader.java +83 -0
- data/src/main/java/org/sunflow/core/tesselatable/BezierMesh.java +254 -0
- data/src/main/java/org/sunflow/core/tesselatable/FileMesh.java +251 -0
- data/src/main/java/org/sunflow/core/tesselatable/Gumbo.java +1147 -0
- data/src/main/java/org/sunflow/core/tesselatable/Teapot.java +237 -0
- data/src/main/java/org/sunflow/image/Bitmap.java +15 -0
- data/src/main/java/org/sunflow/image/BitmapReader.java +39 -0
- data/src/main/java/org/sunflow/image/BitmapWriter.java +79 -0
- data/src/main/java/org/sunflow/image/BlackbodySpectrum.java +16 -0
- data/src/main/java/org/sunflow/image/ChromaticitySpectrum.java +55 -0
- data/src/main/java/org/sunflow/image/Color.java +374 -0
- data/src/main/java/org/sunflow/image/ColorEncoder.java +94 -0
- data/src/main/java/org/sunflow/image/ColorFactory.java +122 -0
- data/src/main/java/org/sunflow/image/ConstantSpectralCurve.java +21 -0
- data/src/main/java/org/sunflow/image/IrregularSpectralCurve.java +57 -0
- data/src/main/java/org/sunflow/image/RGBSpace.java +207 -0
- data/src/main/java/org/sunflow/image/RegularSpectralCurve.java +30 -0
- data/src/main/java/org/sunflow/image/SpectralCurve.java +118 -0
- data/src/main/java/org/sunflow/image/XYZColor.java +50 -0
- data/src/main/java/org/sunflow/image/formats/BitmapBlack.java +27 -0
- data/src/main/java/org/sunflow/image/formats/BitmapG8.java +36 -0
- data/src/main/java/org/sunflow/image/formats/BitmapGA8.java +30 -0
- data/src/main/java/org/sunflow/image/formats/BitmapRGB8.java +40 -0
- data/src/main/java/org/sunflow/image/formats/BitmapRGBA8.java +40 -0
- data/src/main/java/org/sunflow/image/formats/BitmapRGBE.java +60 -0
- data/src/main/java/org/sunflow/image/formats/BitmapXYZ.java +38 -0
- data/src/main/java/org/sunflow/image/formats/GenericBitmap.java +73 -0
- data/src/main/java/org/sunflow/image/readers/BMPBitmapReader.java +39 -0
- data/src/main/java/org/sunflow/image/readers/HDRBitmapReader.java +155 -0
- data/src/main/java/org/sunflow/image/readers/IGIBitmapReader.java +104 -0
- data/src/main/java/org/sunflow/image/readers/JPGBitmapReader.java +39 -0
- data/src/main/java/org/sunflow/image/readers/PNGBitmapReader.java +40 -0
- data/src/main/java/org/sunflow/image/readers/TGABitmapReader.java +141 -0
- data/src/main/java/org/sunflow/image/writers/EXRBitmapWriter.java +395 -0
- data/src/main/java/org/sunflow/image/writers/HDRBitmapWriter.java +54 -0
- data/src/main/java/org/sunflow/image/writers/IGIBitmapWriter.java +75 -0
- data/src/main/java/org/sunflow/image/writers/PNGBitmapWriter.java +39 -0
- data/src/main/java/org/sunflow/image/writers/TGABitmapWriter.java +63 -0
- data/src/main/java/org/sunflow/math/BoundingBox.java +340 -0
- data/src/main/java/org/sunflow/math/MathUtils.java +159 -0
- data/src/main/java/org/sunflow/math/Matrix4.java +573 -0
- data/src/main/java/org/sunflow/math/MovingMatrix4.java +119 -0
- data/src/main/java/org/sunflow/math/OrthoNormalBasis.java +110 -0
- data/src/main/java/org/sunflow/math/PerlinScalar.java +331 -0
- data/src/main/java/org/sunflow/math/PerlinVector.java +132 -0
- data/src/main/java/org/sunflow/math/Point2.java +36 -0
- data/src/main/java/org/sunflow/math/Point3.java +133 -0
- data/src/main/java/org/sunflow/math/QMC.java +209 -0
- data/src/main/java/org/sunflow/math/Solvers.java +142 -0
- data/src/main/java/org/sunflow/math/Vector3.java +197 -0
- data/src/main/java/org/sunflow/system/BenchmarkFramework.java +73 -0
- data/src/main/java/org/sunflow/system/BenchmarkTest.java +17 -0
- data/src/main/java/org/sunflow/system/ByteUtil.java +119 -0
- data/src/main/java/org/sunflow/system/FileUtils.java +27 -0
- data/src/main/java/org/sunflow/system/ImagePanel.java +282 -0
- data/src/main/java/org/sunflow/system/Memory.java +18 -0
- data/src/main/java/org/sunflow/system/Parser.java +162 -0
- data/src/main/java/org/sunflow/system/Plugins.java +142 -0
- data/src/main/java/org/sunflow/system/RenderGlobalsPanel.java +209 -0
- data/src/main/java/org/sunflow/system/SearchPath.java +67 -0
- data/src/main/java/org/sunflow/system/Timer.java +53 -0
- data/src/main/java/org/sunflow/system/UI.java +112 -0
- data/src/main/java/org/sunflow/system/UserInterface.java +46 -0
- data/src/main/java/org/sunflow/system/ui/ConsoleInterface.java +48 -0
- data/src/main/java/org/sunflow/system/ui/SilentInterface.java +28 -0
- data/src/main/java/org/sunflow/util/FastHashMap.java +220 -0
- data/src/main/java/org/sunflow/util/FloatArray.java +77 -0
- data/src/main/java/org/sunflow/util/IntArray.java +77 -0
- data/src/test/java/a_maintest.java +129 -0
- metadata +300 -0
@@ -0,0 +1,142 @@
|
|
1
|
+
package org.sunflow.system;
|
2
|
+
|
3
|
+
import org.codehaus.janino.ClassBodyEvaluator;
|
4
|
+
import org.codehaus.commons.compiler.CompileException;
|
5
|
+
import org.sunflow.system.UI.Module;
|
6
|
+
import org.sunflow.util.FastHashMap;
|
7
|
+
|
8
|
+
/**
|
9
|
+
* This class represents a list of plugins which implement a certain interface
|
10
|
+
* or extend a certain class. Many plugins may be registered and created at a
|
11
|
+
* later time by recalling their unique name only.
|
12
|
+
*
|
13
|
+
* @param <T> Default constructible type or interface all plugins will derive
|
14
|
+
* from or implement
|
15
|
+
*/
|
16
|
+
public final class Plugins<T> {
|
17
|
+
|
18
|
+
private final FastHashMap<String, Class<? extends T>> pluginClasses;
|
19
|
+
private final Class<T> baseClass;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Create an empty plugin list. You must specify <code>T.class</code> as an
|
23
|
+
* argument.
|
24
|
+
*
|
25
|
+
* @param baseClass
|
26
|
+
*/
|
27
|
+
public Plugins(Class<T> baseClass) {
|
28
|
+
pluginClasses = new FastHashMap<>();
|
29
|
+
this.baseClass = baseClass;
|
30
|
+
}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Create an object from the specified type name. If this type name is
|
34
|
+
* unknown or invalid, <code>null</code> is returned.
|
35
|
+
*
|
36
|
+
* @param name plugin type name
|
37
|
+
* @return an instance of the specified plugin type, or <code>null</code> if
|
38
|
+
* not found or invalid
|
39
|
+
*/
|
40
|
+
public T createObject(String name) {
|
41
|
+
if (name == null || name.equals("none")) {
|
42
|
+
return null;
|
43
|
+
}
|
44
|
+
Class<? extends T> c = pluginClasses.get(name);
|
45
|
+
if (c == null) {
|
46
|
+
// don't print an error, this will be handled by the caller
|
47
|
+
return null;
|
48
|
+
}
|
49
|
+
try {
|
50
|
+
return c.newInstance();
|
51
|
+
} catch (InstantiationException | IllegalAccessException e) {
|
52
|
+
UI.printError(Module.API, "Cannot create object of type \"%s\" - %s", name, e.getLocalizedMessage());
|
53
|
+
return null;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Check this plugin list for the presence of the specified type name
|
59
|
+
*
|
60
|
+
* @param name plugin type name
|
61
|
+
* @return <code>true</code> if this name has been registered,
|
62
|
+
* <code>false</code> otherwise
|
63
|
+
*/
|
64
|
+
public boolean hasType(String name) {
|
65
|
+
return pluginClasses.get(name) != null;
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Generate a unique plugin type name which has not yet been registered.
|
70
|
+
* This is meant to be used when the actual type name is not crucial, but
|
71
|
+
* succesfully registration is.
|
72
|
+
*
|
73
|
+
* @param prefix a prefix to be used in generating the unique name
|
74
|
+
* @return a unique plugin type name not yet in use
|
75
|
+
*/
|
76
|
+
public String generateUniqueName(String prefix) {
|
77
|
+
String type;
|
78
|
+
for (int i = 1; hasType(type = String.format("%s_%d", prefix, i)); i++) {
|
79
|
+
}
|
80
|
+
return type;
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Define a new plugin type from java source code. The code string contains
|
85
|
+
* import declarations and a class body only. The implemented type is
|
86
|
+
* implicitly the one of the plugin list being registered against.If the
|
87
|
+
* plugin type name was previously associated with a different class, it
|
88
|
+
* will be overriden. This allows the behavior core classes to be modified
|
89
|
+
* at runtime.
|
90
|
+
*
|
91
|
+
* @param name plugin type name
|
92
|
+
* @param sourceCode Java source code definition for the plugin
|
93
|
+
* @return <code>true</code> if the code compiled and registered
|
94
|
+
* successfully, <code>false</code> otherwise
|
95
|
+
*/
|
96
|
+
// @SuppressWarnings("unchecked")
|
97
|
+
public boolean registerPlugin(String name, String sourceCode) {
|
98
|
+
try {
|
99
|
+
ClassBodyEvaluator cbe = new ClassBodyEvaluator();
|
100
|
+
cbe.setClassName(name);
|
101
|
+
cbe.setExtendedClass(baseClass);
|
102
|
+
cbe.cook(sourceCode);
|
103
|
+
return registerPlugin(name, cbe.getClazz());
|
104
|
+
} catch (CompileException e) {
|
105
|
+
UI.printError(Module.API, "Plugin \"%s\" could not be declared - %s", name, e.getLocalizedMessage());
|
106
|
+
return false;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Define a new plugin type from an existing class. This checks to make sure
|
112
|
+
* the provided class is default constructible (ie: has a constructor with
|
113
|
+
* no parameters). If the plugin type name was previously associated with a
|
114
|
+
* different class, it will be overriden. This allows the behavior core
|
115
|
+
* classes to be modified at runtime.
|
116
|
+
*
|
117
|
+
* @param name plugin type name
|
118
|
+
* @param pluginClass class object for the plugin class
|
119
|
+
* @return <code>true</code> if the plugin registered successfully,
|
120
|
+
* <code>false</code> otherwise
|
121
|
+
*/
|
122
|
+
public boolean registerPlugin(String name, Class<?> pluginClass) {
|
123
|
+
// check that the given class is compatible with the base class
|
124
|
+
try {
|
125
|
+
if (pluginClass.getConstructor() == null) {
|
126
|
+
UI.printError(Module.API, "Plugin \"%s\" could not be declared - default constructor was not found", name);
|
127
|
+
return false;
|
128
|
+
}
|
129
|
+
} catch (SecurityException e) {
|
130
|
+
UI.printError(Module.API, "Plugin \"%s\" could not be declared - default constructor is not visible (%s)", name, e.getLocalizedMessage());
|
131
|
+
return false;
|
132
|
+
} catch (NoSuchMethodException e) {
|
133
|
+
UI.printError(Module.API, "Plugin \"%s\" could not be declared - default constructor was not found (%s)", name, e.getLocalizedMessage());
|
134
|
+
return false;
|
135
|
+
}
|
136
|
+
if (pluginClasses.get(name) != null) {
|
137
|
+
UI.printWarning(Module.API, "Plugin \"%s\" was already defined - overwriting previous definition", name);
|
138
|
+
}
|
139
|
+
pluginClasses.put(name, (Class<? extends T>) pluginClass);
|
140
|
+
return true;
|
141
|
+
}
|
142
|
+
}
|
@@ -0,0 +1,209 @@
|
|
1
|
+
package org.sunflow.system;
|
2
|
+
|
3
|
+
import java.awt.Dimension;
|
4
|
+
import java.awt.FlowLayout;
|
5
|
+
import java.awt.GridLayout;
|
6
|
+
import java.util.logging.Level;
|
7
|
+
import java.util.logging.Logger;
|
8
|
+
|
9
|
+
import javax.swing.BorderFactory;
|
10
|
+
import javax.swing.BoxLayout;
|
11
|
+
import javax.swing.ComboBoxModel;
|
12
|
+
import javax.swing.DefaultComboBoxModel;
|
13
|
+
import javax.swing.JCheckBox;
|
14
|
+
import javax.swing.JComboBox;
|
15
|
+
import javax.swing.JFrame;
|
16
|
+
import javax.swing.JLabel;
|
17
|
+
import javax.swing.JPanel;
|
18
|
+
import javax.swing.JRadioButton;
|
19
|
+
import javax.swing.JTabbedPane;
|
20
|
+
import javax.swing.JTextField;
|
21
|
+
import javax.swing.WindowConstants;
|
22
|
+
import javax.swing.border.BevelBorder;
|
23
|
+
import javax.swing.border.TitledBorder;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
|
27
|
+
* Builder, which is free for non-commercial use. If Jigloo is being used
|
28
|
+
* commercially (ie, by a corporation, company or business for any purpose
|
29
|
+
* whatever) then you should purchase a license for each developer using Jigloo.
|
30
|
+
* Please visit www.cloudgarden.com for details. Use of Jigloo implies
|
31
|
+
* acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
|
32
|
+
* PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
|
33
|
+
* ANY CORPORATE OR COMMERCIAL PURPOSE.
|
34
|
+
*/
|
35
|
+
@SuppressWarnings("serial")
|
36
|
+
public class RenderGlobalsPanel extends JTabbedPane {
|
37
|
+
|
38
|
+
private JPanel generalPanel;
|
39
|
+
private JComboBox<String> maxSamplingComboxBox;
|
40
|
+
private JPanel samplingPanel;
|
41
|
+
private JComboBox<String> minSamplingComboBox;
|
42
|
+
private JLabel jLabel6;
|
43
|
+
private JLabel jLabel5;
|
44
|
+
private JRadioButton defaultRendererRadioButton;
|
45
|
+
private JRadioButton bucketRendererRadioButton;
|
46
|
+
private JPanel bucketRendererPanel;
|
47
|
+
private JLabel jLabel2;
|
48
|
+
private JPanel rendererPanel;
|
49
|
+
private JTextField threadTextField;
|
50
|
+
private JCheckBox threadCheckBox;
|
51
|
+
private JLabel jLabel3;
|
52
|
+
private JPanel threadsPanel;
|
53
|
+
private JLabel jLabel1;
|
54
|
+
private JPanel resolutionPanel;
|
55
|
+
private JTextField resolutionYTextField;
|
56
|
+
private JTextField resolutionXTextField;
|
57
|
+
private JCheckBox resolutionCheckBox;
|
58
|
+
|
59
|
+
/**
|
60
|
+
* This method initializes this
|
61
|
+
*/
|
62
|
+
private void initialize() {
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Auto-generated main method to display this JPanel inside a new JFrame.
|
67
|
+
*/
|
68
|
+
public static void main(String[] args) {
|
69
|
+
JFrame frame = new JFrame();
|
70
|
+
frame.getContentPane().add(new RenderGlobalsPanel());
|
71
|
+
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
72
|
+
frame.pack();
|
73
|
+
frame.setVisible(true);
|
74
|
+
}
|
75
|
+
|
76
|
+
public RenderGlobalsPanel() {
|
77
|
+
super();
|
78
|
+
initialize();
|
79
|
+
initGUI();
|
80
|
+
}
|
81
|
+
|
82
|
+
private void initGUI() {
|
83
|
+
try {
|
84
|
+
setPreferredSize(new Dimension(400, 300));
|
85
|
+
{
|
86
|
+
generalPanel = new JPanel();
|
87
|
+
FlowLayout generalPanelLayout = new FlowLayout();
|
88
|
+
generalPanelLayout.setAlignment(FlowLayout.LEFT);
|
89
|
+
generalPanel.setLayout(generalPanelLayout);
|
90
|
+
this.addTab("General", null, generalPanel, null);
|
91
|
+
{
|
92
|
+
resolutionPanel = new JPanel();
|
93
|
+
generalPanel.add(resolutionPanel);
|
94
|
+
FlowLayout resolutionPanelLayout = new FlowLayout();
|
95
|
+
resolutionPanel.setLayout(resolutionPanelLayout);
|
96
|
+
resolutionPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "Resolution", TitledBorder.LEADING, TitledBorder.TOP));
|
97
|
+
{
|
98
|
+
resolutionCheckBox = new JCheckBox();
|
99
|
+
resolutionPanel.add(resolutionCheckBox);
|
100
|
+
resolutionCheckBox.setText("Override");
|
101
|
+
}
|
102
|
+
{
|
103
|
+
jLabel1 = new JLabel();
|
104
|
+
resolutionPanel.add(jLabel1);
|
105
|
+
jLabel1.setText("Image Width:");
|
106
|
+
}
|
107
|
+
{
|
108
|
+
resolutionXTextField = new JTextField();
|
109
|
+
resolutionPanel.add(resolutionXTextField);
|
110
|
+
resolutionXTextField.setText("640");
|
111
|
+
resolutionXTextField.setPreferredSize(new java.awt.Dimension(50, 20));
|
112
|
+
}
|
113
|
+
{
|
114
|
+
jLabel2 = new JLabel();
|
115
|
+
resolutionPanel.add(jLabel2);
|
116
|
+
jLabel2.setText("Image Height:");
|
117
|
+
}
|
118
|
+
{
|
119
|
+
resolutionYTextField = new JTextField();
|
120
|
+
resolutionPanel.add(resolutionYTextField);
|
121
|
+
resolutionYTextField.setText("480");
|
122
|
+
resolutionYTextField.setPreferredSize(new java.awt.Dimension(50, 20));
|
123
|
+
}
|
124
|
+
}
|
125
|
+
{
|
126
|
+
threadsPanel = new JPanel();
|
127
|
+
generalPanel.add(threadsPanel);
|
128
|
+
threadsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "Threads", TitledBorder.LEADING, TitledBorder.TOP));
|
129
|
+
{
|
130
|
+
threadCheckBox = new JCheckBox();
|
131
|
+
threadsPanel.add(threadCheckBox);
|
132
|
+
threadCheckBox.setText("Use All Processors");
|
133
|
+
}
|
134
|
+
{
|
135
|
+
jLabel3 = new JLabel();
|
136
|
+
threadsPanel.add(jLabel3);
|
137
|
+
jLabel3.setText("Threads:");
|
138
|
+
}
|
139
|
+
{
|
140
|
+
threadTextField = new JTextField();
|
141
|
+
threadsPanel.add(threadTextField);
|
142
|
+
threadTextField.setText("1");
|
143
|
+
threadTextField.setPreferredSize(new java.awt.Dimension(50, 20));
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
{
|
148
|
+
rendererPanel = new JPanel();
|
149
|
+
FlowLayout rendererPanelLayout = new FlowLayout();
|
150
|
+
rendererPanelLayout.setAlignment(FlowLayout.LEFT);
|
151
|
+
rendererPanel.setLayout(rendererPanelLayout);
|
152
|
+
this.addTab("Renderer", null, rendererPanel, null);
|
153
|
+
{
|
154
|
+
defaultRendererRadioButton = new JRadioButton();
|
155
|
+
rendererPanel.add(defaultRendererRadioButton);
|
156
|
+
defaultRendererRadioButton.setText("Default Renderer");
|
157
|
+
}
|
158
|
+
{
|
159
|
+
bucketRendererPanel = new JPanel();
|
160
|
+
BoxLayout bucketRendererPanelLayout = new BoxLayout(bucketRendererPanel, javax.swing.BoxLayout.Y_AXIS);
|
161
|
+
bucketRendererPanel.setLayout(bucketRendererPanelLayout);
|
162
|
+
rendererPanel.add(bucketRendererPanel);
|
163
|
+
bucketRendererPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "Bucket Renderer", TitledBorder.LEADING, TitledBorder.TOP));
|
164
|
+
{
|
165
|
+
bucketRendererRadioButton = new JRadioButton();
|
166
|
+
bucketRendererPanel.add(bucketRendererRadioButton);
|
167
|
+
bucketRendererRadioButton.setText("Enable");
|
168
|
+
}
|
169
|
+
{
|
170
|
+
samplingPanel = new JPanel();
|
171
|
+
GridLayout samplingPanelLayout = new GridLayout(2, 2);
|
172
|
+
samplingPanelLayout.setColumns(2);
|
173
|
+
samplingPanelLayout.setHgap(5);
|
174
|
+
samplingPanelLayout.setVgap(5);
|
175
|
+
samplingPanelLayout.setRows(2);
|
176
|
+
samplingPanel.setLayout(samplingPanelLayout);
|
177
|
+
bucketRendererPanel.add(samplingPanel);
|
178
|
+
{
|
179
|
+
jLabel5 = new JLabel();
|
180
|
+
samplingPanel.add(jLabel5);
|
181
|
+
jLabel5.setText("Min:");
|
182
|
+
}
|
183
|
+
{
|
184
|
+
ComboBoxModel<String> minSamplingComboBoxModel = new DefaultComboBoxModel<String>(new String[]{
|
185
|
+
"Item One", "Item Two"});
|
186
|
+
minSamplingComboBox = new JComboBox<String>();
|
187
|
+
samplingPanel.add(minSamplingComboBox);
|
188
|
+
minSamplingComboBox.setModel(minSamplingComboBoxModel);
|
189
|
+
}
|
190
|
+
{
|
191
|
+
jLabel6 = new JLabel();
|
192
|
+
samplingPanel.add(jLabel6);
|
193
|
+
jLabel6.setText("Max:");
|
194
|
+
}
|
195
|
+
{
|
196
|
+
ComboBoxModel<String> maxSamplingComboxBoxModel = new DefaultComboBoxModel<String>(new String[]{
|
197
|
+
"Item One", "Item Two"});
|
198
|
+
maxSamplingComboxBox = new JComboBox<String>();
|
199
|
+
samplingPanel.add(maxSamplingComboxBox);
|
200
|
+
maxSamplingComboxBox.setModel(maxSamplingComboxBoxModel);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
} catch (Exception e) {
|
206
|
+
Logger.getLogger(RenderGlobalsPanel.class.getName()).log(Level.SEVERE, null, e);
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
package org.sunflow.system;
|
2
|
+
|
3
|
+
import java.io.File;
|
4
|
+
import java.io.IOException;
|
5
|
+
import java.util.LinkedList;
|
6
|
+
|
7
|
+
import org.sunflow.system.UI.Module;
|
8
|
+
|
9
|
+
public class SearchPath {
|
10
|
+
|
11
|
+
private final LinkedList<String> searchPath;
|
12
|
+
private final String type;
|
13
|
+
|
14
|
+
public SearchPath(String type) {
|
15
|
+
this.type = type;
|
16
|
+
searchPath = new LinkedList<>();
|
17
|
+
}
|
18
|
+
|
19
|
+
public void resetSearchPath() {
|
20
|
+
searchPath.clear();
|
21
|
+
}
|
22
|
+
|
23
|
+
public void addSearchPath(String path) {
|
24
|
+
File f = new File(path);
|
25
|
+
if (f.exists() && f.isDirectory()) {
|
26
|
+
try {
|
27
|
+
path = f.getCanonicalPath();
|
28
|
+
for (String prefix : searchPath) {
|
29
|
+
if (prefix.equals(path)) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
UI.printInfo(Module.SYS, "Adding %s search path: \"%s\"", type, path);
|
34
|
+
searchPath.add(path);
|
35
|
+
} catch (IOException e) {
|
36
|
+
UI.printError(Module.SYS, "Invalid %s search path specification: \"%s\" - %s", type, path, e.getMessage());
|
37
|
+
}
|
38
|
+
} else {
|
39
|
+
UI.printError(Module.SYS, "Invalid %s search path specification: \"%s\" - invalid directory", type, path);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
public String resolvePath(String filename) {
|
44
|
+
// account for relative naming schemes from 3rd party softwares
|
45
|
+
if (filename.startsWith("//")) {
|
46
|
+
filename = filename.substring(2);
|
47
|
+
}
|
48
|
+
UI.printDetailed(Module.SYS, "Resolving %s path \"%s\" ...", type, filename);
|
49
|
+
File f = new File(filename);
|
50
|
+
if (!f.isAbsolute()) {
|
51
|
+
for (String prefix : searchPath) {
|
52
|
+
UI.printDetailed(Module.SYS, " * searching: \"%s\" ...", prefix);
|
53
|
+
if (prefix.endsWith(File.separator) || filename.startsWith(File.separator)) {
|
54
|
+
f = new File(prefix + filename);
|
55
|
+
} else {
|
56
|
+
f = new File(prefix + File.separator + filename);
|
57
|
+
}
|
58
|
+
if (f.exists()) {
|
59
|
+
// suggested path exists - try it
|
60
|
+
return f.getAbsolutePath();
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
// file was not found in the search paths - return the filename itself
|
65
|
+
return filename;
|
66
|
+
}
|
67
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
package org.sunflow.system;
|
2
|
+
|
3
|
+
public class Timer {
|
4
|
+
|
5
|
+
private long startTime, endTime;
|
6
|
+
|
7
|
+
public Timer() {
|
8
|
+
startTime = endTime = 0;
|
9
|
+
}
|
10
|
+
|
11
|
+
public void start() {
|
12
|
+
startTime = endTime = System.nanoTime();
|
13
|
+
}
|
14
|
+
|
15
|
+
public void end() {
|
16
|
+
endTime = System.nanoTime();
|
17
|
+
}
|
18
|
+
|
19
|
+
public long nanos() {
|
20
|
+
return endTime - startTime;
|
21
|
+
}
|
22
|
+
|
23
|
+
public double seconds() {
|
24
|
+
return (endTime - startTime) * 1e-9;
|
25
|
+
}
|
26
|
+
|
27
|
+
public static String toString(long nanos) {
|
28
|
+
Timer t = new Timer();
|
29
|
+
t.endTime = nanos;
|
30
|
+
return t.toString();
|
31
|
+
}
|
32
|
+
|
33
|
+
public static String toString(double seconds) {
|
34
|
+
Timer t = new Timer();
|
35
|
+
t.endTime = (long) (seconds * 1e9);
|
36
|
+
return t.toString();
|
37
|
+
}
|
38
|
+
|
39
|
+
@Override
|
40
|
+
public String toString() {
|
41
|
+
long millis = nanos() / (1000 * 1000);
|
42
|
+
if (millis < 10000) {
|
43
|
+
return String.format("%dms", millis);
|
44
|
+
}
|
45
|
+
long hours = millis / (60 * 60 * 1000);
|
46
|
+
millis -= hours * 60 * 60 * 1000;
|
47
|
+
long minutes = millis / (60 * 1000);
|
48
|
+
millis -= minutes * 60 * 1000;
|
49
|
+
long seconds = millis / 1000;
|
50
|
+
millis -= seconds * 1000;
|
51
|
+
return String.format("%d:%02d:%02d.%1d", hours, minutes, seconds, millis / 100);
|
52
|
+
}
|
53
|
+
}
|