├── .github ├── dependabot.yml └── workflows │ └── build.yml ├── .gitignore ├── .jitpack.yml ├── ACKNOWLEDGEMENTS.md ├── CITATION.cff ├── LICENSE.txt ├── README.md ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── sciview │ ├── fiji.gradle.kts │ ├── publish.gradle.kts │ ├── sign.gradle.kts │ └── utils.kt ├── config └── sciview-eclipse-code-formatter.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── scripts └── process_pom.sh ├── settings.gradle.kts └── src ├── main ├── java │ ├── com │ │ └── intellij │ │ │ ├── openapi │ │ │ ├── Disposable.java │ │ │ ├── diagnostic │ │ │ │ ├── ApplicationInfoProvider.java │ │ │ │ ├── ControlFlowException.java │ │ │ │ ├── DefaultLogger.java │ │ │ │ ├── Log4jBasedLogger.java │ │ │ │ └── Logger.java │ │ │ ├── ui │ │ │ │ ├── ClickListener.java │ │ │ │ ├── Divider.java │ │ │ │ ├── GraphicsConfig.java │ │ │ │ ├── NullableComponent.java │ │ │ │ ├── OnePixelDivider.java │ │ │ │ ├── Painter.java │ │ │ │ ├── RoundedLineBorder.java │ │ │ │ ├── SideBorder.java │ │ │ │ ├── Splittable.java │ │ │ │ └── Splitter.java │ │ │ ├── util │ │ │ │ ├── ActionCallback.java │ │ │ │ ├── ActiveRunnable.java │ │ │ │ ├── Comparing.java │ │ │ │ ├── Computable.java │ │ │ │ ├── Condition.java │ │ │ │ ├── Couple.java │ │ │ │ ├── Disposer.java │ │ │ │ ├── ExecutionCallback.java │ │ │ │ ├── Key.java │ │ │ │ ├── Pair.java │ │ │ │ ├── RecursionGuard.java │ │ │ │ ├── Ref.java │ │ │ │ ├── SystemInfo.java │ │ │ │ ├── SystemInfoRt.java │ │ │ │ ├── Weighted.java │ │ │ │ ├── objectTree │ │ │ │ │ ├── ObjectNode.java │ │ │ │ │ ├── ObjectTree.java │ │ │ │ │ ├── ObjectTreeAction.java │ │ │ │ │ ├── ObjectTreeListener.java │ │ │ │ │ └── ThrowableInterner.java │ │ │ │ ├── registry │ │ │ │ │ └── Registry.java │ │ │ │ └── text │ │ │ │ │ ├── StringUtil.java │ │ │ │ │ └── StringUtilRt.java │ │ │ └── wm │ │ │ │ └── IdeGlassPane.java │ │ │ ├── ui │ │ │ ├── AnchorableComponent.java │ │ │ ├── ClickListener.java │ │ │ ├── ColorUtil.java │ │ │ ├── ColoredTextContainer.java │ │ │ ├── DarculaColors.java │ │ │ ├── Gray.java │ │ │ ├── IdeBorderFactory.java │ │ │ ├── JBColor.java │ │ │ ├── JBSplitter.java │ │ │ ├── LightColors.java │ │ │ ├── OnePixelSplitter.java │ │ │ ├── RotatedIcon.java │ │ │ ├── SimpleColoredComponent.java │ │ │ ├── SimpleColoredText.java │ │ │ ├── SimpleTextAttributes.java │ │ │ ├── TextIcon.java │ │ │ ├── components │ │ │ │ ├── DefaultScrollBarUI.java │ │ │ │ ├── FixedColumnsModel.java │ │ │ │ ├── FixedRowsModel.java │ │ │ │ ├── JBCheckBox.java │ │ │ │ ├── JBCheckBoxMenuItem.java │ │ │ │ ├── JBLabel.java │ │ │ │ ├── JBLabelDecorator.java │ │ │ │ ├── JBLayeredPane.java │ │ │ │ ├── JBLoadingPanelListener.java │ │ │ │ ├── JBMenu.java │ │ │ │ ├── JBPanel.java │ │ │ │ ├── JBRadioButton.java │ │ │ │ ├── JBScrollBar.java │ │ │ │ ├── JBScrollPane.java │ │ │ │ ├── JBTabbedPane.java │ │ │ │ ├── JBViewport.java │ │ │ │ ├── MacScrollBarUI.java │ │ │ │ ├── Magnificator.java │ │ │ │ ├── MultiColumnList.java │ │ │ │ ├── MultiColumnListModel.java │ │ │ │ ├── OnOffButton.java │ │ │ │ ├── ScrollColorProducer.java │ │ │ │ ├── ScrollPainter.java │ │ │ │ ├── TwoWayAnimator.java │ │ │ │ ├── ZoomableViewport.java │ │ │ │ ├── ZoomingDelegate.java │ │ │ │ └── panels │ │ │ │ │ ├── FlowLayoutWrapper.java │ │ │ │ │ ├── HorizontalBox.java │ │ │ │ │ ├── HorizontalLayout.java │ │ │ │ │ ├── NonOpaquePanel.java │ │ │ │ │ ├── OpaquePanel.java │ │ │ │ │ ├── OpaqueWrapper.java │ │ │ │ │ ├── StatelessCardLayout.java │ │ │ │ │ ├── ValidatingComponent.java │ │ │ │ │ ├── VerticalBox.java │ │ │ │ │ ├── VerticalLayout.java │ │ │ │ │ ├── Wrapper.java │ │ │ │ │ └── package.html │ │ │ ├── mac │ │ │ │ └── foundation │ │ │ │ │ ├── Foundation.java │ │ │ │ │ ├── FoundationLibrary.java │ │ │ │ │ ├── ID.java │ │ │ │ │ ├── NSWorkspace.java │ │ │ │ │ └── Selector.java │ │ │ ├── paint │ │ │ │ ├── EffectPainter.java │ │ │ │ └── RectanglePainter.java │ │ │ └── tabs │ │ │ │ ├── JBTabs.java │ │ │ │ ├── JBTabsPosition.java │ │ │ │ ├── JBTabsPresentation.java │ │ │ │ ├── TabInfo.java │ │ │ │ ├── TabsListener.java │ │ │ │ ├── TabsUtil.java │ │ │ │ ├── UiDecorator.java │ │ │ │ └── impl │ │ │ │ ├── DarculaEditorTabsPainter.java │ │ │ │ ├── DefaultEditorTabsPainter.java │ │ │ │ ├── JBEditorTabs.java │ │ │ │ ├── JBEditorTabsPainter.java │ │ │ │ ├── JBTabsImpl.java │ │ │ │ ├── LayoutPassInfo.java │ │ │ │ ├── ShapeTransform.java │ │ │ │ ├── TabLabel.java │ │ │ │ ├── TabLayout.java │ │ │ │ ├── TabsBorder.java │ │ │ │ ├── TabsSideSplitter.java │ │ │ │ ├── singleRow │ │ │ │ ├── CompressibleSingleRowLayout.java │ │ │ │ ├── ScrollableSingleRowLayout.java │ │ │ │ ├── SingleRowLayout.java │ │ │ │ ├── SingleRowLayoutStrategy.java │ │ │ │ └── SingleRowPassInfo.java │ │ │ │ └── table │ │ │ │ ├── TableLayout.java │ │ │ │ ├── TablePassInfo.java │ │ │ │ └── TableRow.java │ │ │ └── util │ │ │ ├── Alarm.java │ │ │ ├── AppleHiDPIScaledImage.java │ │ │ ├── ArrayFactory.java │ │ │ ├── ArrayUtil.java │ │ │ ├── ArrayUtilRt.java │ │ │ ├── BitUtil.java │ │ │ ├── Consumer.java │ │ │ ├── EncodingEnvironmentUtil.java │ │ │ ├── ExceptionUtil.java │ │ │ ├── Function.java │ │ │ ├── HiDPIScaledGraphics.java │ │ │ ├── JBHiDPIScaledImage.java │ │ │ ├── NotNullFunction.java │ │ │ ├── NotNullProducer.java │ │ │ ├── NullableFunction.java │ │ │ ├── ObjectUtils.java │ │ │ ├── PairConsumer.java │ │ │ ├── Processor.java │ │ │ ├── Producer.java │ │ │ ├── ReflectionUtil.java │ │ │ ├── RetinaImage.java │ │ │ ├── SmartList.java │ │ │ ├── SystemProperties.java │ │ │ ├── concurrency │ │ │ ├── AppDelayQueue.java │ │ │ ├── AppExecutorUtil.java │ │ │ ├── AppScheduledExecutorService.java │ │ │ ├── BlockingSet.java │ │ │ ├── BoundedTaskExecutor.java │ │ │ ├── EdtExecutorService.java │ │ │ ├── FixedFuture.java │ │ │ ├── FutureResult.java │ │ │ ├── SchedulingWrapper.java │ │ │ └── Semaphore.java │ │ │ ├── containers │ │ │ ├── ContainerUtil.java │ │ │ ├── ContainerUtilRt.java │ │ │ ├── EmptyIterator.java │ │ │ ├── EmptyListIterator.java │ │ │ ├── HashMap.java │ │ │ ├── HashSet.java │ │ │ ├── ImmutableList.java │ │ │ ├── LinkedHashMap.java │ │ │ ├── LinkedHashSet.java │ │ │ ├── SingletonIteratorBase.java │ │ │ └── Stack.java │ │ │ ├── io │ │ │ └── URLUtil.java │ │ │ └── ui │ │ │ ├── Animator.java │ │ │ ├── AppleBoldDottedPainter.java │ │ │ ├── ButtonlessScrollBarUI.java │ │ │ ├── Centerizer.java │ │ │ ├── ColorUtil.java │ │ │ ├── DrawUtil.java │ │ │ ├── GraphicsUtil.java │ │ │ ├── Gray.java │ │ │ ├── IsRetina.java │ │ │ ├── JBDimension.java │ │ │ ├── JBEmptyBorder.java │ │ │ ├── JBFont.java │ │ │ ├── JBInsets.java │ │ │ ├── JBUI.java │ │ │ ├── NSScrollerHelper.java │ │ │ ├── RegionPainter.java │ │ │ ├── StatusText.java │ │ │ ├── UIUtil.java │ │ │ ├── WavePainter.java │ │ │ ├── components │ │ │ ├── BorderLayoutPanel.java │ │ │ └── JBComponent.java │ │ │ └── update │ │ │ ├── ComparableObject.java │ │ │ └── ComparableObjectCheck.java │ ├── gnu │ │ └── newtrove │ │ │ ├── CanonicalEquality.java │ │ │ ├── Equality.java │ │ │ ├── IdentityEquality.java │ │ │ ├── TObjectCanonicalHashingStrategy.java │ │ │ ├── TObjectHashingStrategy.java │ │ │ └── TObjectIdentityHashingStrategy.java │ └── sc │ │ └── iview │ │ ├── ActiveSciViewPreprocessor.java │ │ ├── DefaultSciViewService.java │ │ ├── SciViewService.java │ │ ├── Version.java │ │ ├── commands │ │ ├── demo │ │ │ ├── ResourceLoader.java │ │ │ ├── advanced │ │ │ │ └── ShowSegmentationDemo.java │ │ │ ├── animation │ │ │ │ └── SceneRiggingDemo.java │ │ │ └── basic │ │ │ │ ├── ImagePlaneDemo.java │ │ │ │ ├── Line3DDemo.java │ │ │ │ ├── LineDemo.java │ │ │ │ ├── MeshDemo.java │ │ │ │ ├── MultiMeshDemo.java │ │ │ │ ├── PointCloudDemo.java │ │ │ │ └── TextDemo.java │ │ ├── edit │ │ │ ├── DeleteObject.java │ │ │ ├── ToggleFloor.java │ │ │ └── settings │ │ │ │ └── NavigationControlsSettings.java │ │ ├── file │ │ │ ├── ExportN5.java │ │ │ ├── ExportSTL.java │ │ │ ├── ExportXYZ.java │ │ │ ├── Open.java │ │ │ └── OpenN5.kt │ │ ├── help │ │ │ ├── About.java │ │ │ └── Help.java │ │ └── process │ │ │ ├── ConvexHull.java │ │ │ ├── InteractiveConvexMesh.java │ │ │ ├── Isosurface.java │ │ │ └── MeshToImage.java │ │ ├── controls │ │ └── behaviours │ │ │ └── ControlsParameters.java │ │ ├── display │ │ ├── SciViewDisplay.java │ │ ├── SciViewDisplayViewer.java │ │ └── SciViewDisplayWindow.java │ │ ├── event │ │ ├── NodeActivatedEvent.java │ │ ├── NodeAddedEvent.java │ │ ├── NodeChangedEvent.java │ │ ├── NodeEvent.java │ │ └── NodeRemovedEvent.java │ │ ├── io │ │ ├── N5.java │ │ ├── N5IO.java │ │ ├── OBJMeshIO.java │ │ └── SMLMPointCloudIO.java │ │ └── ui │ │ ├── REPLEditor.java │ │ ├── REPLPane.java │ │ └── SwingSceneryTreeNode.java ├── kotlin │ └── sc │ │ └── iview │ │ ├── AnimatedCenteringBeforeArcBallControl.kt │ │ ├── Controls.kt │ │ ├── ImageJMain.kt │ │ ├── Main.kt │ │ ├── SciView.kt │ │ ├── SplashLabel.kt │ │ ├── Utils.kt │ │ ├── commands │ │ ├── LaunchViewer.kt │ │ ├── MenuWeights.kt │ │ ├── add │ │ │ ├── AddAtmosphere.kt │ │ │ ├── AddBox.kt │ │ │ ├── AddCamera.kt │ │ │ ├── AddCone.kt │ │ │ ├── AddCylinder.kt │ │ │ ├── AddLabelImage.kt │ │ │ ├── AddLine.kt │ │ │ ├── AddOrientationCompass.kt │ │ │ ├── AddPointLight.kt │ │ │ ├── AddProtein.kt │ │ │ ├── AddProteinFromFiles.kt │ │ │ ├── AddSlicingPlane.kt │ │ │ ├── AddSphere.kt │ │ │ └── AddVolume.kt │ │ ├── demo │ │ │ ├── advanced │ │ │ │ ├── InstancingBenchmark.kt │ │ │ │ ├── LoadCremiDatasetAndNeurons.kt │ │ │ │ └── LoadFlybrainOutOfCore.kt │ │ │ ├── animation │ │ │ │ ├── GameOfLife3D.kt │ │ │ │ ├── ParticleDemo.kt │ │ │ │ └── VolumeTimeseriesDemo.kt │ │ │ └── basic │ │ │ │ └── VolumeRenderDemo.kt │ │ ├── edit │ │ │ ├── AtmosphereProperties.kt │ │ │ ├── BasicProperties.kt │ │ │ ├── BoundingGridProperties.kt │ │ │ ├── CameraProperties.kt │ │ │ ├── InspectorInteractiveCommand.kt │ │ │ ├── LightProperties.kt │ │ │ ├── LineProperties.kt │ │ │ ├── ResetScene.kt │ │ │ ├── SlicingPlaneProperties.kt │ │ │ ├── SwingInspectorInteractiveCommandExtension.kt │ │ │ ├── SwingVolumeProperties.kt │ │ │ ├── TextBoardProperties.kt │ │ │ ├── VolumeProperties.kt │ │ │ ├── VolumeSelectorWidget.kt │ │ │ └── settings │ │ │ │ └── KeyBindings.kt │ │ └── view │ │ │ ├── CenterOnActiveNode.kt │ │ │ ├── DisplayVertices.kt │ │ │ ├── RenderToOpenVRHMD.kt │ │ │ ├── ResetCameraPosition.kt │ │ │ ├── ResetCameraRotation.kt │ │ │ ├── RotateView.kt │ │ │ ├── SaveCameraConfiguration.kt │ │ │ ├── Screenshot.kt │ │ │ ├── SetFarPlane.kt │ │ │ ├── SetLUT.kt │ │ │ ├── SetSupersamplingFactor.kt │ │ │ ├── SetTransferFunction.kt │ │ │ ├── StartRecordingVideo.kt │ │ │ ├── StopAnimation.kt │ │ │ ├── StopRecordingVideo.kt │ │ │ ├── ToggleBoundingGrid.kt │ │ │ ├── ToggleInspector.kt │ │ │ └── ToggleUnlimitedFramerate.kt │ │ ├── controls │ │ └── behaviours │ │ │ ├── ArcballResetMovementCommand.kt │ │ │ ├── CameraTranslateControl.kt │ │ │ ├── ClickAndDragWrapper.kt │ │ │ ├── NodeRotateControl.kt │ │ │ ├── NodeTranslateControl.kt │ │ │ ├── Ruler.kt │ │ │ └── SceneRollControl.kt │ │ ├── node │ │ └── Line3D.kt │ │ ├── process │ │ ├── ControlPoints.kt │ │ └── MeshConverter.kt │ │ └── ui │ │ ├── ContextPopUp.kt │ │ ├── ContextPopUpNodeChooser.kt │ │ ├── CustomPropertyUI.kt │ │ ├── MainWindow.kt │ │ ├── ProgressPie.kt │ │ ├── SwingGroupingInputHarvester.kt │ │ ├── SwingGroupingLabelListener.kt │ │ ├── SwingMainWindow.kt │ │ ├── SwingNodePropertyEditor.kt │ │ ├── SwingNodePropertyTreeCellRenderer.kt │ │ ├── Task.kt │ │ └── TaskManager.kt ├── python │ └── sciview.py └── resources │ ├── SOURCES.md │ ├── WieseRobert_simplified_Cip1.stl │ ├── blub_control_mesh.ply │ ├── cored_cube.tif │ ├── cored_cube_16bit.stl │ ├── cored_cube_16bit.tif │ ├── cored_cube_var2_8bit.tif │ └── sc │ └── iview │ ├── commands │ └── demo │ │ └── animation │ │ ├── ParticleDemo.frag │ │ └── ParticleDemo.vert │ ├── sciview-logo.png │ ├── startup.py │ ├── terminal.png │ ├── toolbox.png │ └── ui │ ├── camera.png │ ├── light.png │ ├── mesh.png │ ├── node.png │ ├── scene.png │ ├── text.png │ └── volume.png └── test ├── java └── sc │ └── iview │ ├── AllScripts.java │ ├── N5Test.java │ ├── SciViewTest.java │ └── VolumeScriptTest.java ├── kotlin └── sc │ └── iview │ └── ImageJMainTest.kt └── resources ├── outputs └── sphere_test.png └── scripts ├── sphere_test.py └── volume_test.py /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "gradle" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.jitpack.yml: -------------------------------------------------------------------------------- 1 | before_install: 2 | - sdk install java 21.0.2-zulu 3 | - sdk use java 21.0.2-zulu 4 | install: 5 | - echo "Running a custom install command" 6 | - ./gradlew clean build publishMavenPublicationToMavenLocal 7 | -------------------------------------------------------------------------------- /ACKNOWLEDGEMENTS.md: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | 3 | ## Icons 4 | 5 | Uses icons from [Gemicon](http://www.gemicon.net) for the Node Property Inspector: 6 | 7 | ``` 8 | Gemicon Icon Set (600+ free icons) 9 | A handcrafted icon set by Turqois (http://turqois.com), which there 3 different sizes (16, 32, 64). Each icon created with pixel-perfect shape layer on Photoshop. Released for Smashing Magazine and design community (http://gemicon.net). 10 | ``` 11 | 12 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | # YAML 1.2 2 | --- 3 | abstract: "ImageJ/Fiji is a widely-used tool in the biomedical community for performing everyday image analysis tasks. However, its 3D viewer component (aptly named 3D Viewer) has become dated and is no longer actively maintained. We set out to create an alternative tool that not only brings modern concepts and APIs from computer graphics to ImageJ, but is designed to be robust to long-term, open-source development. To achieve this we divided the visualization logic into two parts: the rendering framework, scenery, and the user-facing application, sciview. In this paper we describe the development process and design decisions made, putting an emphasis on sustainable development, community building, and software engineering best practises. We highlight the motivation for the Java Virtual Machine (JVM) as a target platform for visualisation applications. We conclude by discussing the remaining milestones and strategy for long-term sustainability." 4 | authors: 5 | - 6 | affiliation: "Center for Advanced Systems Understanding, Görlitz, Germany / Max Planck Institute of Molecular Cell Biology and Genetics, Dresden, Germany / Center for Systems Biology, Dresden, Germany" 7 | family-names: "Günther" 8 | given-names: Ulrik 9 | orcid: "https://orcid.org/0000-0002-1179-8228" 10 | - 11 | family-names: Harrington 12 | given-names: "Kyle I.S." 13 | orcid: "https://orcid.org/0000-0002-7237-1973" 14 | cff-version: "1.1.0" 15 | date-released: 2020-05-04 16 | doi: "10.2312/visgap.20201112" 17 | license: "BSD-2-Clause" 18 | message: "If you use this software, please cite it using these metadata." 19 | repository-code: "https://github.com/scenerygraphics/sciview" 20 | title: "Tales from the Trenches: Developing sciview, a new 3D viewer for the ImageJ community" 21 | ... -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 - 2024, sciview developers. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | gradlePluginPortal() 8 | // jcenter() // or maven(url="https://dl.bintray.com/kotlin/dokka") 9 | } 10 | 11 | dependencies { 12 | implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20") 13 | implementation("de.undercouch:gradle-download-task:5.6.0") 14 | 15 | } -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/sciview/sign.gradle.kts: -------------------------------------------------------------------------------- 1 | package sciview 2 | 3 | plugins { 4 | signing 5 | publishing 6 | } 7 | 8 | // https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials 9 | // save public and private key and passphrase into gradle.properties 10 | 11 | signing { 12 | // setRequired({ project.hasProperty("release") }) 13 | useGpgCmd() 14 | sign(publishing.publications["maven"]) 15 | sign(configurations.archives.get()) 16 | } 17 | 18 | tasks.withType().configureEach { 19 | onlyIf { project.hasProperty("release") } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-XX:MaxMetaspaceSize=2g 2 | org.gradle.caching=true 3 | jvmTarget=21 4 | #useLocalScenery=true 5 | kotlinVersion=1.9.23 6 | dokkaVersion=1.9.10 7 | scijavaParentPOMVersion=40.0.0 8 | version=0.4.1-SNAPSHOT 9 | 10 | # update site configuration 11 | fijiUpdateSite=sciview 12 | fijiUpdateSiteURL=https://sites.imagej.net/sciview 13 | # This is the class to be run as a test to determine whether the update site was correctly installed into Fiji 14 | fijiTestClass=sc.iview.commands.help.About 15 | # This is the expected stdout from the class set above. Multiple strings can be checked against, those should 16 | # then be separated by | characters. [GIT_HASH] will be replaced with the current Git hash of the project, 17 | # or by the value given in the gitHash property. [VERSION_NUMBER] will be replaced by project.version. 18 | fijiTestClassExpectedOutput=[INFO] SciView was created by Kyle Harrington|[GIT_HASH]|[VERSION_NUMBER] 19 | # Uncomment the next line if you want the fijiUpdate task to be skipped. This is useful if you plan to repeatedly run fijiPopulate without checking for remote updates every time. 20 | #fijiUpdateSkip=true 21 | # Uncomment the next line if you want the fijiUpload task to *simulate* an upload rather than actually doing it. 22 | #fijiUploadDryRun=true 23 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip 5 | networkTimeout=10000 6 | validateDistributionUrl=true 7 | zipStoreBase=GRADLE_USER_HOME 8 | zipStorePath=wrapper/dists 9 | -------------------------------------------------------------------------------- /scripts/process_pom.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sed -i '/<\/organization>/i \norg.scijava\npom-scijava\n30.0.0\n\n' ./build/publications/maven/pom-default.xml 4 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | val kotlinVersion: String by settings 3 | val dokkaVersion: String by settings 4 | 5 | plugins { 6 | kotlin("jvm") version kotlinVersion 7 | kotlin("kapt") version kotlinVersion 8 | id("org.jetbrains.dokka") version dokkaVersion 9 | 10 | id("com.github.johnrengelman.shadow") version "8.1.1" 11 | } 12 | 13 | repositories { 14 | gradlePluginPortal() 15 | maven("https://raw.githubusercontent.com/kotlin-graphics/mary/master") 16 | } 17 | } 18 | 19 | rootProject.name = "sciview" 20 | 21 | gradle.rootProject { 22 | group = "sc.iview" 23 | version = project.properties["version"]!! 24 | description = "Scenery-backed 3D visualization package for ImageJ." 25 | } 26 | 27 | val useLocalScenery: String? by extra 28 | if (System.getProperty("CI").toBoolean() != true 29 | && System.getenv("CI").toBoolean() != true 30 | && useLocalScenery?.toBoolean() == true) 31 | if(File("../scenery/build.gradle.kts").exists()) { 32 | logger.warn("Including local scenery project instead of version declared in build, set -PuseLocalScenery=false to use declared version instead.") 33 | includeBuild("../scenery") 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/Disposable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi; 17 | 18 | /** 19 | * This class marks classes, which require some work done for cleaning up. 20 | * As a general policy you shouldn't call the {@link #dispose} method directly, 21 | * but register your object to be chained with a parent disposable via {@link com.intellij.openapi.util.Disposer#register(Disposable, Disposable)}. 22 | * If you're 100% sure that you should control disposion of your object manually, 23 | * do not call the {@link #dispose} method either. Use {@link com.intellij.openapi.util.Disposer#dispose(Disposable)} instead, since 24 | * there might be any object registered in chain. 25 | */ 26 | public interface Disposable { 27 | void dispose(); 28 | 29 | interface Parent extends Disposable { 30 | void beforeTreeDispose(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/diagnostic/ApplicationInfoProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.diagnostic; 17 | 18 | public interface ApplicationInfoProvider { 19 | 20 | String getInfo(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/diagnostic/ControlFlowException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.diagnostic; 17 | 18 | /** 19 | * A marker interface for exceptions that should never be logged. 20 | */ 21 | @SuppressWarnings("NonExceptionNameEndsWithException") 22 | public interface ControlFlowException { } -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/ui/Divider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.ui; 17 | 18 | import javax.swing.*; 19 | import java.awt.*; 20 | 21 | /** 22 | * @author Konstantin Bulenkov 23 | */ 24 | public abstract class Divider extends JPanel { 25 | public Divider(LayoutManager layout) { 26 | super(layout); 27 | } 28 | 29 | public abstract void setResizeEnabled(boolean resizeEnabled); 30 | 31 | public abstract void setSwitchOrientationEnabled(boolean switchOrientationEnabled); 32 | 33 | public abstract void setOrientation(boolean vertical); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/ui/GraphicsConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.intellij.openapi.ui; 18 | 19 | import java.awt.*; 20 | import java.util.Map; 21 | 22 | public class GraphicsConfig { 23 | 24 | private final Graphics2D myG; 25 | private final Map myHints; 26 | private final Composite myComposite; 27 | 28 | public GraphicsConfig(Graphics g) { 29 | myG = (Graphics2D)g; 30 | myHints = (Map)myG.getRenderingHints().clone(); 31 | myComposite = myG.getComposite(); 32 | } 33 | 34 | public GraphicsConfig setAntialiasing(boolean on) { 35 | myG.setRenderingHint(RenderingHints.KEY_ANTIALIASING, on ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); 36 | return this; 37 | } 38 | 39 | public GraphicsConfig setAlpha(float alpha) { 40 | myG.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); 41 | return this; 42 | } 43 | 44 | public Graphics2D getG() { 45 | return myG; 46 | } 47 | 48 | public void restore() { 49 | myG.setRenderingHints(myHints); 50 | myG.setComposite(myComposite); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/ui/NullableComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.intellij.openapi.ui; 18 | 19 | import java.awt.*; 20 | 21 | public interface NullableComponent { 22 | 23 | boolean isNull(); 24 | 25 | class Check { 26 | private Check() { 27 | } 28 | 29 | public static boolean isNull(Component c) { 30 | return c == null || c instanceof NullableComponent && ((NullableComponent)c).isNull(); 31 | } 32 | 33 | public static boolean isNullOrHidden(Component c) { 34 | return c != null && !c.isShowing() || isNull(c); 35 | } 36 | 37 | public static boolean isNotNullAndVisible(Component c) { 38 | return !isNull(c) && c.isVisible(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/ui/Painter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.intellij.openapi.ui; 18 | 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | import javax.swing.*; 22 | import java.awt.*; 23 | 24 | public interface Painter { 25 | 26 | boolean needsRepaint(); 27 | void paint(Component component, final Graphics2D g); 28 | 29 | void addListener(Listener listener); 30 | void removeListener(Listener listener); 31 | 32 | interface Listener { 33 | void onNeedsRepaint(Painter painter, @Nullable JComponent dirtyComponent); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/ui/RoundedLineBorder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.ui; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | import javax.swing.border.LineBorder; 21 | import java.awt.*; 22 | 23 | /** 24 | * @author Eugene Belyaev 25 | */ 26 | public class RoundedLineBorder extends LineBorder { 27 | private int myArcSize = 1; 28 | 29 | public RoundedLineBorder(Color color) { 30 | super(color); 31 | } 32 | 33 | public RoundedLineBorder(Color color, int arcSize) { 34 | this(color, arcSize, 1); 35 | } 36 | 37 | public RoundedLineBorder(Color color, int arcSize, final int thickness) { 38 | super(color, thickness); 39 | myArcSize = arcSize; 40 | } 41 | 42 | public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { 43 | final Graphics2D g2 = (Graphics2D)g; 44 | 45 | final Object oldAntialiasing = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); 46 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 47 | final Color oldColor = g2.getColor(); 48 | g2.setColor(lineColor); 49 | 50 | for (int i = 0; i < thickness; i++) { 51 | g2.drawRoundRect(x + i, y + i, width - i - i - 1, height - i - i - 1, myArcSize, myArcSize); 52 | } 53 | 54 | g2.setColor(oldColor); 55 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasing); 56 | } 57 | 58 | public void setColor(@NotNull Color color) { 59 | lineColor = color; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/ui/Splittable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.ui; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | import java.awt.*; 21 | 22 | public interface Splittable { 23 | float getMinProportion(boolean first); 24 | 25 | void setProportion(float proportion); 26 | 27 | /** 28 | * @return true if splitter has vertical orientation, false otherwise 29 | */ 30 | boolean getOrientation(); 31 | 32 | /** 33 | * @param verticalSplit true means that splitter will have vertical split 34 | */ 35 | void setOrientation(boolean verticalSplit); 36 | 37 | @NotNull 38 | Component asComponent(); 39 | 40 | void setDragging(boolean dragging); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/ActiveRunnable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.util; 17 | 18 | import com.intellij.util.ui.update.ComparableObject; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | public abstract class ActiveRunnable extends ComparableObject.Impl { 22 | 23 | protected ActiveRunnable() { 24 | } 25 | 26 | protected ActiveRunnable(@NotNull Object object) { 27 | super(object); 28 | } 29 | 30 | protected ActiveRunnable(@NotNull Object[] objects) { 31 | super(objects); 32 | } 33 | 34 | @NotNull 35 | public abstract ActionCallback run(); 36 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/Computable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.util; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | /** 22 | * @author dsl 23 | */ 24 | public interface Computable { 25 | 26 | T compute(); 27 | 28 | class PredefinedValueComputable implements Computable { 29 | 30 | private final T myValue; 31 | 32 | public PredefinedValueComputable(@Nullable T value) { 33 | myValue = value; 34 | } 35 | 36 | @Override 37 | public T compute() { 38 | return myValue; 39 | } 40 | } 41 | 42 | abstract class NotNullCachedComputable implements Computable { 43 | private T myValue; 44 | 45 | @NotNull 46 | protected abstract T internalCompute(); 47 | 48 | @NotNull 49 | @Override 50 | public final T compute() { 51 | if (myValue == null) { 52 | myValue = internalCompute(); 53 | } 54 | return myValue; 55 | } 56 | } 57 | 58 | abstract class NullableCachedComputable implements Computable { 59 | private static final Object NULL_VALUE = new Object(); 60 | private Object myValue; 61 | 62 | @Nullable 63 | protected abstract T internalCompute(); 64 | 65 | @Nullable 66 | @Override 67 | public final T compute() { 68 | if (myValue == null) { 69 | final T value = internalCompute(); 70 | myValue = value != null ? value : NULL_VALUE; 71 | } 72 | return myValue != NULL_VALUE ? (T)myValue : null; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/Condition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.util; 17 | 18 | /** 19 | * Returns {@code true} or {@code false} for the given input object. 20 | *

21 | * See {@link Conditions} for chained conditions. 22 | * 23 | * @author dsl 24 | */ 25 | public interface Condition { 26 | boolean value(T t); 27 | 28 | Condition NOT_NULL = new Condition() { 29 | public boolean value(final Object object) { 30 | return object != null; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "Condition.NOT_NULL"; 36 | } 37 | }; 38 | 39 | /** 40 | * @see Conditions#alwaysTrue() 41 | */ 42 | Condition TRUE = new Condition() { 43 | public boolean value(final Object object) { 44 | return true; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "Condition.TRUE"; 50 | } 51 | }; 52 | /** 53 | * @see Conditions#alwaysFalse() 54 | */ 55 | Condition FALSE = new Condition() { 56 | public boolean value(final Object object) { 57 | return false; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return "Condition.FALSE"; 63 | } 64 | }; 65 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/Couple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.util; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | /** 21 | * @author Konstantin Bulenkov 22 | */ 23 | public class Couple extends Pair { 24 | private static final Couple EMPTY_COUPLE = new Couple(null, null); 25 | 26 | public Couple(T first, T second) { 27 | super(first, second); 28 | } 29 | 30 | @NotNull 31 | public static Couple of(T first, T second) { 32 | return new Couple(first, second); 33 | } 34 | 35 | @NotNull 36 | public static Couple getEmpty() { 37 | //noinspection unchecked 38 | return EMPTY_COUPLE; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/Ref.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2016 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.util; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | /** 22 | * @author ven 23 | */ 24 | public class Ref { 25 | private T myValue; 26 | 27 | public Ref() { } 28 | 29 | public Ref(@Nullable T value) { 30 | myValue = value; 31 | } 32 | 33 | public final boolean isNull() { 34 | return myValue == null; 35 | } 36 | 37 | public final T get() { 38 | return myValue; 39 | } 40 | 41 | public final void set(@Nullable T value) { 42 | myValue = value; 43 | } 44 | 45 | public final boolean setIfNull(@Nullable T value) { 46 | if (myValue == null) { 47 | myValue = value; 48 | return true; 49 | } 50 | return false; 51 | } 52 | 53 | @NotNull 54 | public static Ref create() { 55 | return new Ref(); 56 | } 57 | 58 | public static Ref create(@Nullable T value) { 59 | return new Ref(value); 60 | } 61 | 62 | @Nullable 63 | public static T deref(@Nullable Ref ref) { 64 | return ref == null ? null : ref.get(); 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return String.valueOf(myValue); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/SystemInfoRt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2016 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.util; 17 | 18 | import java.util.Locale; 19 | 20 | /** 21 | * Stripped-down version of {@code com.intellij.openapi.util.SystemInfo}. 22 | * Intended to use by external (out-of-IDE-process) runners and helpers so it should not contain any library dependencies. 23 | * 24 | * @since 12.0 25 | */ 26 | public class SystemInfoRt { 27 | public static final String OS_NAME = System.getProperty("os.name"); 28 | public static final String OS_VERSION = System.getProperty("os.version").toLowerCase(Locale.US); 29 | 30 | private static final String _OS_NAME = OS_NAME.toLowerCase(Locale.US); 31 | public static final boolean isWindows = _OS_NAME.startsWith("windows"); 32 | public static final boolean isOS2 = _OS_NAME.startsWith("os/2") || _OS_NAME.startsWith("os2"); 33 | public static final boolean isMac = _OS_NAME.startsWith("mac"); 34 | public static final boolean isLinux = _OS_NAME.startsWith("linux"); 35 | public static final boolean isFreeBSD = _OS_NAME.startsWith("freebsd"); 36 | public static final boolean isSolaris = _OS_NAME.startsWith("sunos"); 37 | public static final boolean isUnix = !isWindows && !isOS2; 38 | 39 | public static final boolean isFileSystemCaseSensitive = 40 | isUnix && !isMac || "true".equalsIgnoreCase(System.getProperty("idea.case.sensitive.fs")); 41 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/Weighted.java: -------------------------------------------------------------------------------- 1 | package com.intellij.openapi.util; 2 | 3 | public interface Weighted { 4 | double getWeight(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/objectTree/ObjectTreeAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.util.objectTree; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface ObjectTreeAction { 21 | 22 | void execute(@NotNull T each); 23 | 24 | void beforeTreeExecution(@NotNull T parent); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/objectTree/ObjectTreeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.util.objectTree; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface ObjectTreeListener { 21 | 22 | void objectRegistered(@NotNull Object node); 23 | void objectExecuted(@NotNull Object node); 24 | 25 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/objectTree/ThrowableInterner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2016 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.openapi.util.objectTree; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | /** 21 | * Please don't look, there's nothing interesting here. 22 | * 23 | * 24 | * 25 | * 26 | * If you insist, JVM stores stacktrace information in compact form in Throwable.backtrace field, but blocks reflective access to this field. 27 | * This class uses this field for comparing Throwables. 28 | * The available method Throwable.getStackTrace() unfortunately can't be used for that because it's 29 | * 1) too slow and 2) explodes Throwable retained size by polluting Throwable.stackTrace fields. 30 | */ 31 | public class ThrowableInterner { 32 | // all removed 33 | private static Object[] getBacktrace(@NotNull Throwable throwable) { 34 | return throwable.getStackTrace(); 35 | } 36 | 37 | @NotNull 38 | public static Throwable intern(@NotNull Throwable throwable) { 39 | return throwable; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/util/registry/Registry.java: -------------------------------------------------------------------------------- 1 | package com.intellij.openapi.util.registry; 2 | 3 | /** 4 | * Created by traff on 22/08/16. 5 | */ 6 | public class Registry { 7 | public static boolean is(String s) { 8 | return true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/openapi/wm/IdeGlassPane.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.intellij.openapi.wm; 18 | 19 | import com.intellij.openapi.Disposable; 20 | import com.intellij.openapi.ui.Painter; 21 | import org.jetbrains.annotations.NotNull; 22 | import org.jetbrains.annotations.Nullable; 23 | 24 | import java.awt.*; 25 | import java.awt.event.MouseEvent; 26 | import java.awt.event.MouseListener; 27 | import java.awt.event.MouseMotionListener; 28 | 29 | public interface IdeGlassPane { 30 | void addMousePreprocessor(MouseListener listener, Disposable parent); 31 | void addMouseMotionPreprocessor(MouseMotionListener listener, Disposable parent); 32 | 33 | void addPainter(final Component component, Painter painter, Disposable parent); 34 | void removePainter(final Painter painter); 35 | 36 | 37 | void removeMousePreprocessor(MouseListener listener); 38 | void removeMouseMotionPreprocessor(MouseMotionListener listener); 39 | 40 | void setCursor(@Nullable Cursor cursor, @NotNull Object requestor); 41 | 42 | interface TopComponent { 43 | boolean canBePreprocessed(MouseEvent e); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/AnchorableComponent.java: -------------------------------------------------------------------------------- 1 | package com.intellij.ui; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | import javax.swing.*; 6 | 7 | /** 8 | * @author evgeny.zakrevsky 9 | */ 10 | 11 | public interface AnchorableComponent { 12 | @Nullable 13 | JComponent getAnchor(); 14 | void setAnchor(@Nullable JComponent anchor); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/ColoredTextContainer.java: -------------------------------------------------------------------------------- 1 | package com.intellij.ui; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import javax.swing.*; 7 | 8 | public interface ColoredTextContainer { 9 | void append(@NotNull String fragment, @NotNull SimpleTextAttributes attributes); 10 | 11 | void append(@NotNull String fragment, @NotNull SimpleTextAttributes attributes, Object tag); 12 | 13 | void setIcon(@Nullable Icon icon); 14 | 15 | void setToolTipText(@Nullable String text); 16 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/DarculaColors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui; 17 | 18 | import java.awt.*; 19 | 20 | /** 21 | * @author Konstantin Bulenkov 22 | */ 23 | public interface DarculaColors { 24 | Color BLUE = new Color(0x589df6); 25 | Color RED = new Color(255, 100, 100); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/LightColors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2013 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.intellij.ui; 18 | 19 | import java.awt.*; 20 | 21 | /** 22 | * @author max 23 | */ 24 | public interface LightColors { 25 | Color YELLOW = new JBColor(new Color(0xffffcc), new Color(0x525229)); 26 | Color GREEN = new JBColor(new Color(0xccffcc), new Color(0x356936)); 27 | Color BLUE = new JBColor(new Color(0xccccff), new Color(0x589df6)); 28 | Color RED = new JBColor(new Color(0xffcccc), new Color(0x743A3A)); 29 | Color CYAN = new JBColor(new Color(0xccffff), new Color(100, 138, 138)); 30 | 31 | Color SLIGHTLY_GREEN = new JBColor(new Color(0xeeffee), new Color(0x515B51)); 32 | Color SLIGHTLY_GRAY = new JBColor(new Color(0xf5f5f5), new Color(0xc0c0c0)); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/OnePixelSplitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui; 17 | 18 | import com.intellij.openapi.ui.Divider; 19 | import com.intellij.openapi.ui.OnePixelDivider; 20 | import com.intellij.util.Producer; 21 | import org.jetbrains.annotations.NotNull; 22 | 23 | import java.awt.*; 24 | 25 | /** 26 | * @author Konstantin Bulenkov 27 | */ 28 | public class OnePixelSplitter extends JBSplitter { 29 | private Producer myBlindZone; 30 | 31 | public OnePixelSplitter() { 32 | super(); 33 | init(); 34 | } 35 | 36 | public OnePixelSplitter(boolean vertical) { 37 | super(vertical); 38 | init(); 39 | } 40 | 41 | public OnePixelSplitter(boolean vertical, @NotNull String proportionKey, float defaultProportion) { 42 | super(vertical, proportionKey, defaultProportion); 43 | init(); 44 | } 45 | 46 | public OnePixelSplitter(boolean vertical, float proportion) { 47 | super(vertical, proportion); 48 | init(); 49 | } 50 | 51 | public OnePixelSplitter(@NotNull String proportionKey, float defaultProportion) { 52 | super(proportionKey, defaultProportion); 53 | 54 | init(); 55 | } 56 | 57 | public OnePixelSplitter(float proportion) { 58 | super(proportion); 59 | init(); 60 | } 61 | 62 | public OnePixelSplitter(boolean vertical, float proportion, float minProp, float maxProp) { 63 | super(vertical, proportion, minProp, maxProp); 64 | init(); 65 | } 66 | 67 | protected void init() { 68 | setDividerWidth(1); 69 | } 70 | 71 | @Override 72 | protected Divider createDivider() { 73 | return new OnePixelDivider(isVertical(), this); 74 | } 75 | 76 | public void setBlindZone(Producer blindZone) { 77 | myDivider.setOpaque(blindZone == null); 78 | myBlindZone = blindZone; 79 | } 80 | 81 | public Producer getBlindZone() { 82 | return myBlindZone; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/FixedColumnsModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components; 17 | 18 | import javax.swing.*; 19 | 20 | /** 21 | * @author Konstantin Bulenkov 22 | */ 23 | public class FixedColumnsModel extends MultiColumnListModel { 24 | private final int myMaxColumns; 25 | 26 | public FixedColumnsModel(ListModel model, int maxColumns) { 27 | super(model); 28 | myMaxColumns = maxColumns; 29 | } 30 | 31 | @Override 32 | public int getRowCount() { 33 | final int columns = getColumnCount(); 34 | return columns == 0 ? 0 : getSize() / columns + 1; 35 | } 36 | 37 | @Override 38 | public int getColumnCount() { 39 | return Math.min(myMaxColumns, getSize()); 40 | } 41 | 42 | @Override 43 | public int toListIndex(int row, int column) { 44 | final int columns = getColumnCount(); 45 | return columns == 0 ? -1 : row * columns + column; 46 | } 47 | 48 | @Override 49 | public int getColumn(int listIndex) { 50 | return listIndex % myMaxColumns; 51 | } 52 | 53 | @Override 54 | public int getRow(int listIndex) { 55 | return listIndex / myMaxColumns; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/FixedRowsModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components; 17 | 18 | import javax.swing.*; 19 | 20 | /** 21 | * @author Konstantin Bulenkov 22 | */ 23 | class FixedRowsModel extends MultiColumnListModel { 24 | private final int myMaxRows; 25 | 26 | public FixedRowsModel(ListModel model, int rows) { 27 | super(model); 28 | myMaxRows = rows; 29 | } 30 | 31 | @Override 32 | public int getRowCount() { 33 | return Math.min(myMaxRows, getSize()); 34 | } 35 | 36 | @Override 37 | public int getColumnCount() { 38 | final int rows = getRowCount(); 39 | return rows == 0 ? 0 : getSize() / rows + 1; 40 | } 41 | 42 | @Override 43 | public int toListIndex(int row, int column) { 44 | final int rows = getRowCount(); 45 | return rows == 0 ? -1 : column * rows + row; 46 | } 47 | 48 | @Override 49 | public int getColumn(int listIndex) { 50 | return listIndex / myMaxRows; 51 | } 52 | 53 | @Override 54 | public int getRow(int listIndex) { 55 | return listIndex % myMaxRows; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/JBCheckBoxMenuItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components; 17 | 18 | import javax.accessibility.Accessible; 19 | import javax.accessibility.AccessibleContext; 20 | import javax.accessibility.AccessibleRole; 21 | import javax.swing.*; 22 | 23 | public class JBCheckBoxMenuItem extends JCheckBoxMenuItem implements Accessible { 24 | @Override 25 | public AccessibleContext getAccessibleContext() { 26 | if (accessibleContext == null) { 27 | accessibleContext = new AccessibleJBCheckBoxMenuItem(); 28 | } 29 | return accessibleContext; 30 | } 31 | 32 | protected class AccessibleJBCheckBoxMenuItem extends AccessibleJCheckBoxMenuItem { 33 | @Override 34 | public AccessibleRole getAccessibleRole() { 35 | // The base class implementation returns the CHECK_BOX role, which is incorrect 36 | // for a menu item. 37 | return AccessibleRole.MENU_ITEM; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/JBLayeredPane.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2013 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components; 17 | 18 | import javax.swing.*; 19 | import java.awt.*; 20 | 21 | /** 22 | * User: Vassiliy.Kudryashov 23 | */ 24 | public class JBLayeredPane extends JLayeredPane { 25 | 26 | @Override 27 | public Dimension getMinimumSize() { 28 | if (!isMinimumSizeSet()) 29 | return new Dimension(0, 0); 30 | return super.getMinimumSize(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/JBLoadingPanelListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2011 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components; 17 | 18 | /** 19 | * @author Konstantin Bulenkov 20 | */ 21 | public interface JBLoadingPanelListener { 22 | void onLoadingStart(); 23 | 24 | void onLoadingFinish(); 25 | 26 | 27 | abstract class Adapter implements JBLoadingPanelListener { 28 | @Override 29 | public void onLoadingStart() { 30 | } 31 | 32 | @Override 33 | public void onLoadingFinish() { 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/JBMenu.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components; 17 | 18 | import javax.accessibility.Accessible; 19 | import javax.accessibility.AccessibleContext; 20 | import javax.accessibility.AccessibleState; 21 | import javax.accessibility.AccessibleStateSet; 22 | import javax.swing.*; 23 | 24 | public class JBMenu extends JMenu implements Accessible { 25 | @Override 26 | public AccessibleContext getAccessibleContext() { 27 | if (accessibleContext == null) { 28 | accessibleContext = new AccessibleJBMenu(); 29 | } 30 | return accessibleContext; 31 | } 32 | 33 | protected class AccessibleJBMenu extends AccessibleJMenu { 34 | @Override 35 | public AccessibleStateSet getAccessibleStateSet() { 36 | AccessibleStateSet set = super.getAccessibleStateSet(); 37 | // Due to a bug in JMenu, CHECKED is added if the menu is enabled. That 38 | // is incorrect -- checked should be added only in the case of a "checkbox" 39 | // style menu. 40 | set.remove(AccessibleState.CHECKED); 41 | return set; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/JBRadioButton.java: -------------------------------------------------------------------------------- 1 | package com.intellij.ui.components; 2 | 3 | import com.intellij.ui.AnchorableComponent; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | import javax.swing.*; 7 | import java.awt.*; 8 | 9 | /** 10 | * @author evgeny.zakrevsky 11 | */ 12 | public class JBRadioButton extends JRadioButton implements AnchorableComponent { 13 | private JComponent myAnchor; 14 | 15 | public JBRadioButton() { 16 | } 17 | 18 | public JBRadioButton(Icon icon) { 19 | super(icon); 20 | } 21 | 22 | public JBRadioButton(Action a) { 23 | super(a); 24 | } 25 | 26 | public JBRadioButton(Icon icon, boolean selected) { 27 | super(icon, selected); 28 | } 29 | 30 | public JBRadioButton(String text) { 31 | super(text); 32 | } 33 | 34 | public JBRadioButton(String text, boolean selected) { 35 | super(text, selected); 36 | } 37 | 38 | public JBRadioButton(String text, Icon icon) { 39 | super(text, icon); 40 | } 41 | 42 | public JBRadioButton(String text, Icon icon, boolean selected) { 43 | super(text, icon, selected); 44 | } 45 | 46 | @Override 47 | public JComponent getAnchor() { 48 | return myAnchor; 49 | } 50 | 51 | @Override 52 | public void setAnchor(@Nullable JComponent anchor) { 53 | this.myAnchor = anchor; 54 | } 55 | 56 | @Override 57 | public Dimension getPreferredSize() { 58 | return myAnchor == null || myAnchor == this ? super.getPreferredSize() : myAnchor.getPreferredSize(); 59 | } 60 | 61 | @Override 62 | public Dimension getMinimumSize() { 63 | return myAnchor == null || myAnchor == this ? super.getMinimumSize() : myAnchor.getMinimumSize(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/Magnificator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2011 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * @author max 19 | */ 20 | package com.intellij.ui.components; 21 | 22 | import com.intellij.openapi.util.Key; 23 | 24 | import java.awt.*; 25 | 26 | public interface Magnificator { 27 | Key CLIENT_PROPERTY_KEY = Key.create("MagnifiableComponent"); 28 | Point magnify(double scale, Point at); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/MultiColumnListModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components; 17 | 18 | import org.jetbrains.annotations.Nullable; 19 | 20 | import javax.swing.*; 21 | import javax.swing.table.AbstractTableModel; 22 | import javax.swing.table.TableModel; 23 | 24 | /** 25 | * @author Konstantin Bulenkov 26 | */ 27 | public abstract class MultiColumnListModel extends AbstractTableModel implements TableModel { 28 | private final ListModel myModel; 29 | 30 | public MultiColumnListModel(ListModel model) { 31 | myModel = model; 32 | } 33 | 34 | public abstract int toListIndex(int row, int column); 35 | public abstract int getColumn(int listIndex); 36 | public abstract int getRow(int listIndex); 37 | 38 | public int getSize() { 39 | return myModel.getSize(); 40 | } 41 | 42 | @Nullable 43 | @Override 44 | public Object getValueAt(int row, int column) { 45 | final int index = toListIndex(row, column); 46 | return index == -1 || index >= myModel.getSize() ? null 47 | : myModel.getElementAt(index); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/ZoomableViewport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2011 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * @author max 19 | */ 20 | package com.intellij.ui.components; 21 | 22 | import org.jetbrains.annotations.Nullable; 23 | 24 | import java.awt.*; 25 | 26 | public interface ZoomableViewport { 27 | @Nullable 28 | Magnificator getMagnificator(); 29 | void magnificationStarted(Point at); 30 | void magnificationFinished(double magnification); 31 | void magnify(double magnification); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/panels/FlowLayoutWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components.panels; 17 | 18 | import javax.swing.*; 19 | import javax.swing.border.Border; 20 | import java.awt.*; 21 | 22 | /** 23 | * @author kir 24 | */ 25 | public class FlowLayoutWrapper extends NonOpaquePanel { 26 | public FlowLayoutWrapper(JComponent wrapped) { 27 | super(new FlowLayout(FlowLayout.LEFT, 0, 0), wrapped); 28 | } 29 | 30 | public FlowLayoutWrapper(JComponent component, Border border) { 31 | this(component); 32 | setBorder(border); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/panels/HorizontalBox.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components.panels; 17 | 18 | import javax.swing.*; 19 | import java.awt.*; 20 | 21 | public class HorizontalBox extends JPanel { 22 | 23 | private final Box myBox; 24 | 25 | public HorizontalBox() { 26 | setLayout(new BorderLayout()); 27 | myBox = new Box(BoxLayout.X_AXIS) { 28 | public Component add(Component comp) { 29 | ((JComponent) comp).setAlignmentY(0f); 30 | return super.add(comp); 31 | } 32 | }; 33 | add(myBox, BorderLayout.CENTER); 34 | setOpaque(false); 35 | } 36 | 37 | public Component add(Component aComponent) { 38 | return myBox.add(aComponent); 39 | } 40 | 41 | public void remove(Component aComponent) { 42 | myBox.remove(aComponent); 43 | } 44 | 45 | public void removeAll() { 46 | myBox.removeAll(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/panels/NonOpaquePanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2011 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components.panels; 17 | 18 | import com.intellij.util.ui.UIUtil; 19 | 20 | import javax.swing.*; 21 | import java.awt.*; 22 | 23 | public class NonOpaquePanel extends Wrapper { 24 | public NonOpaquePanel() { 25 | setOpaque(false); 26 | } 27 | 28 | public NonOpaquePanel(JComponent wrapped) { 29 | super(wrapped); 30 | setOpaque(false); 31 | } 32 | 33 | public NonOpaquePanel(LayoutManager layout, JComponent wrapped) { 34 | super(layout, wrapped); 35 | setOpaque(false); 36 | } 37 | 38 | public NonOpaquePanel(boolean isDoubleBuffered) { 39 | super(isDoubleBuffered); 40 | setOpaque(false); 41 | } 42 | 43 | public NonOpaquePanel(LayoutManager layout) { 44 | super(layout); 45 | setOpaque(false); 46 | } 47 | 48 | public NonOpaquePanel(LayoutManager layout, boolean isDoubleBuffered) { 49 | super(layout, isDoubleBuffered); 50 | setOpaque(false); 51 | } 52 | 53 | @Override 54 | public void setOpaque(boolean isOpaque) { 55 | super.setOpaque(isOpaque); 56 | setDoubleBuffered(false); 57 | 58 | if (!isOpaque && UIUtil.isUnderNimbusLookAndFeel()) { 59 | if (UIUtil.isUnderNimbusLookAndFeel()) { 60 | setBackground(UIUtil.TRANSPARENT_COLOR); 61 | } 62 | } 63 | } 64 | 65 | public static void setTransparent(JComponent c) { 66 | c.setOpaque(false); 67 | if (UIUtil.isUnderNimbusLookAndFeel()) { 68 | c.setBackground(UIUtil.TRANSPARENT_COLOR); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/panels/OpaquePanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components.panels; 17 | 18 | import javax.swing.*; 19 | import java.awt.*; 20 | 21 | /** 22 | * @author Eugene Belyaev 23 | */ 24 | public class OpaquePanel extends JPanel { 25 | private boolean myOpaqueActive = true; 26 | 27 | public OpaquePanel() { 28 | this(null, null); 29 | } 30 | 31 | public OpaquePanel(LayoutManager layout) { 32 | this(layout, null); 33 | } 34 | 35 | public OpaquePanel(Color color) { 36 | this(null, color); 37 | } 38 | 39 | public OpaquePanel(LayoutManager layoutManager, Color color) { 40 | super(layoutManager); 41 | setBackground(color); 42 | } 43 | 44 | protected void paintComponent(Graphics g) { 45 | if (isOpaqueActive()) { 46 | final Color bg = getBackground(); 47 | g.setColor(bg); 48 | final Dimension size = getSize(); 49 | g.fillRect(0, 0, size.width, size.height); 50 | } 51 | } 52 | 53 | public boolean isOpaqueActive() { 54 | return myOpaqueActive; 55 | } 56 | 57 | public void setOpaqueActive(final boolean opaqueActive) { 58 | myOpaqueActive = opaqueActive; 59 | } 60 | 61 | public static class List extends OpaquePanel { 62 | public List() { 63 | } 64 | 65 | public List(LayoutManager layout) { 66 | super(layout); 67 | } 68 | 69 | public List(Color color) { 70 | super(color); 71 | } 72 | 73 | public List(LayoutManager layoutManager, Color color) { 74 | super(layoutManager, color); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/panels/OpaqueWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components.panels; 17 | 18 | 19 | import javax.swing.*; 20 | import java.awt.*; 21 | 22 | /** 23 | * @author Eugene Belyaev 24 | */ 25 | public class OpaqueWrapper extends Wrapper { 26 | 27 | public OpaqueWrapper(JComponent wrapped, Color color) { 28 | super(wrapped); 29 | setBackground(color); 30 | } 31 | 32 | public OpaqueWrapper(LayoutManager layoutManager, JComponent wrapped, Color color) { 33 | super(layoutManager, wrapped); 34 | setBackground(color); 35 | } 36 | 37 | protected void paintComponent(Graphics g) { 38 | g.setColor(getBackground()); 39 | Dimension size = getSize(); 40 | g.fillRect(0, 0, size.width, size.height); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/panels/VerticalBox.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.components.panels; 17 | 18 | import javax.swing.*; 19 | import java.awt.*; 20 | 21 | public class VerticalBox extends Box { 22 | 23 | public VerticalBox() { 24 | super(BoxLayout.Y_AXIS); 25 | setOpaque(false); 26 | } 27 | 28 | public Component add(Component comp) { 29 | ((JComponent) comp).setAlignmentX(0f); 30 | return super.add(comp); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/components/panels/package.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | Provides a number of custom panel components. 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/mac/foundation/ID.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2013 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.mac.foundation; 17 | 18 | import com.sun.jna.NativeLong; 19 | 20 | /** 21 | * Could be an address in memory (if pointer to a class or method) or a value (like 0 or 1) 22 | * 23 | * User: spLeaner 24 | */ 25 | public class ID extends NativeLong { 26 | 27 | public ID() { 28 | } 29 | 30 | public ID(long peer) { 31 | super(peer); 32 | } 33 | 34 | public static final ID NIL = new ID(0); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/mac/foundation/NSWorkspace.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.mac.foundation; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | public class NSWorkspace { 22 | @Nullable 23 | public static String absolutePathForAppBundleWithIdentifier(@NotNull String bundleID) { 24 | Foundation.NSAutoreleasePool pool = new Foundation.NSAutoreleasePool(); 25 | try { 26 | ID workspace = Foundation.invoke(Foundation.getObjcClass("NSWorkspace"), "sharedWorkspace"); 27 | return Foundation.toStringViaUTF8(Foundation.invoke(workspace, "absolutePathForAppBundleWithIdentifier:", 28 | Foundation.nsString(bundleID))); 29 | } 30 | finally { 31 | pool.drain(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/mac/foundation/Selector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.mac.foundation; 17 | 18 | import com.sun.jna.NativeLong; 19 | 20 | /** 21 | * @author spleaner 22 | */ 23 | public class Selector extends NativeLong { 24 | 25 | private String myName; 26 | 27 | public Selector() { 28 | this("undefined selector", 0); 29 | } 30 | 31 | public Selector(String name, long value) { 32 | super(value); 33 | myName = name; 34 | } 35 | 36 | public String getName() { 37 | return myName; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return String.format("[Selector %s]", myName); 43 | } 44 | 45 | public Selector initName(final String name) { 46 | myName = name; 47 | return this; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/tabs/JBTabs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.tabs; 17 | 18 | import com.intellij.openapi.util.ActionCallback; 19 | import com.intellij.openapi.util.ActiveRunnable; 20 | import org.jetbrains.annotations.NotNull; 21 | import org.jetbrains.annotations.Nullable; 22 | 23 | import javax.swing.*; 24 | import java.awt.event.MouseEvent; 25 | import java.awt.event.MouseListener; 26 | 27 | public interface JBTabs { 28 | 29 | @NotNull 30 | TabInfo addTab(TabInfo info, int index); 31 | 32 | @NotNull 33 | TabInfo addTab(TabInfo info); 34 | 35 | @NotNull 36 | ActionCallback removeTab(@Nullable TabInfo info); 37 | 38 | void removeAllTabs(); 39 | 40 | @NotNull 41 | ActionCallback select(@NotNull TabInfo info, boolean requestFocus); 42 | 43 | @Nullable 44 | TabInfo getSelectedInfo(); 45 | 46 | @NotNull 47 | TabInfo getTabAt(int tabIndex); 48 | 49 | int getTabCount(); 50 | 51 | @NotNull 52 | JBTabsPresentation getPresentation(); 53 | 54 | @Nullable 55 | TabInfo getTargetInfo(); 56 | 57 | @NotNull 58 | JBTabs addTabMouseListener(@NotNull MouseListener listener); 59 | 60 | JBTabs addListener(@NotNull TabsListener listener); 61 | 62 | JBTabs setSelectionChangeHandler(SelectionChangeHandler handler); 63 | 64 | @NotNull 65 | JComponent getComponent(); 66 | 67 | @Nullable 68 | TabInfo findInfo(MouseEvent event); 69 | 70 | @Nullable 71 | TabInfo findInfo(Object object); 72 | 73 | int getIndexOf(@Nullable final TabInfo tabInfo); 74 | 75 | void requestFocus(); 76 | 77 | interface SelectionChangeHandler { 78 | @NotNull 79 | ActionCallback execute(final TabInfo info, final boolean requestFocus, @NotNull ActiveRunnable doChangeSelection); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/tabs/JBTabsPosition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.tabs; 17 | 18 | public enum JBTabsPosition { 19 | top, left, bottom, right 20 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/tabs/TabsListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.tabs; 17 | 18 | 19 | public interface TabsListener { 20 | 21 | void selectionChanged(TabInfo oldSelection, TabInfo newSelection); 22 | 23 | void beforeSelectionChanged(TabInfo oldSelection, TabInfo newSelection); 24 | 25 | void tabRemoved(TabInfo tabToRemove); 26 | 27 | void tabsMoved(); 28 | 29 | class Adapter implements TabsListener { 30 | @Override 31 | public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) { 32 | } 33 | 34 | @Override 35 | public void beforeSelectionChanged(TabInfo oldSelection, TabInfo newSelection) { 36 | } 37 | 38 | @Override 39 | public void tabsMoved() { 40 | } 41 | 42 | @Override 43 | public void tabRemoved(TabInfo tabToRemove) { 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/tabs/TabsUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2011 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.tabs; 17 | 18 | import javax.swing.*; 19 | 20 | /** 21 | * @author pegov 22 | */ 23 | public class TabsUtil { 24 | public static final int TAB_VERTICAL_PADDING = 2; 25 | public static final int TABS_BORDER = 1; 26 | 27 | public static final int ACTIVE_TAB_UNDERLINE_HEIGHT = 4; 28 | 29 | private TabsUtil() { 30 | } 31 | 32 | public static int getTabsHeight() { 33 | return new JLabel("XXX").getPreferredSize().height + 2 + TAB_VERTICAL_PADDING * 2 + TABS_BORDER * 2; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/tabs/UiDecorator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.tabs; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | import java.awt.*; 22 | 23 | public interface UiDecorator { 24 | @NotNull 25 | UiDecoration getDecoration(); 26 | 27 | class UiDecoration { 28 | private @Nullable 29 | final Font myLabelFont; 30 | private @Nullable 31 | final Insets myLabelInsets; 32 | 33 | public UiDecoration(final Font labelFont, final Insets labelInsets) { 34 | myLabelFont = labelFont; 35 | myLabelInsets = labelInsets; 36 | } 37 | 38 | @Nullable 39 | public Font getLabelFont() { 40 | return myLabelFont; 41 | } 42 | 43 | @Nullable 44 | public Insets getLabelInsets() { 45 | return myLabelInsets; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/tabs/impl/DarculaEditorTabsPainter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.tabs.impl; 17 | 18 | import com.intellij.ui.ColorUtil; 19 | 20 | import java.awt.*; 21 | 22 | /** 23 | * @author Konstantin Bulenkov 24 | */ 25 | @SuppressWarnings("UseJBColor") 26 | class DarculaEditorTabsPainter extends DefaultEditorTabsPainter { 27 | 28 | @Override 29 | protected Color getDefaultTabColor() { 30 | if (myDefaultTabColor != null) { 31 | return myDefaultTabColor; 32 | } 33 | return new Color(0x515658); 34 | } 35 | 36 | @Override 37 | protected Color getInactiveMaskColor() { 38 | return ColorUtil.withAlpha(new Color(0x262626), .5); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/tabs/impl/LayoutPassInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.tabs.impl; 17 | 18 | import com.intellij.ui.tabs.TabInfo; 19 | import org.jetbrains.annotations.Nullable; 20 | 21 | import java.awt.*; 22 | import java.util.List; 23 | 24 | public abstract class LayoutPassInfo { 25 | 26 | public final List myVisibleInfos; 27 | 28 | protected LayoutPassInfo(List visibleInfos) { 29 | myVisibleInfos = visibleInfos; 30 | } 31 | 32 | @Nullable 33 | public abstract TabInfo getPreviousFor(TabInfo info); 34 | 35 | @Nullable 36 | public abstract TabInfo getNextFor(TabInfo info); 37 | 38 | @Nullable 39 | public static TabInfo getPrevious(List list, int i) { 40 | return i > 0 ? list.get(i - 1) : null; 41 | } 42 | 43 | @Nullable 44 | public static TabInfo getNext(List list, int i) { 45 | return i < list.size() - 1 ? list.get(i + 1) : null; 46 | } 47 | 48 | public abstract int getRowCount(); 49 | 50 | public abstract int getColumnCount(int row); 51 | 52 | public abstract TabInfo getTabAt(int row, int column); 53 | 54 | public abstract boolean hasCurveSpaceFor(final TabInfo tabInfo); 55 | 56 | public abstract Rectangle getHeaderRectangle(); 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/tabs/impl/TabLayout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.tabs.impl; 17 | 18 | import com.intellij.openapi.util.registry.Registry; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | import java.awt.*; 22 | 23 | public abstract class TabLayout { 24 | 25 | public ShapeTransform createShapeTransform(Dimension dimension) { 26 | return createShapeTransform(new Rectangle(0, 0, dimension.width, dimension.height)); 27 | } 28 | 29 | public ShapeTransform createShapeTransform(Rectangle rectangle) { 30 | return new ShapeTransform.Top(rectangle); 31 | } 32 | 33 | public boolean isDragOut(@NotNull TabLabel tabLabel, int deltaX, int deltaY) { 34 | return Math.abs(deltaY) > tabLabel.getSize().height * getDragOutMultiplier(); 35 | } 36 | 37 | public boolean isSideComponentOnTabs() { 38 | return false; 39 | } 40 | 41 | public static double getDragOutMultiplier() { 42 | return 1.2; 43 | } 44 | 45 | public abstract int getDropIndexFor(Point point); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/ui/tabs/impl/table/TableRow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.ui.tabs.impl.table; 17 | 18 | import com.intellij.ui.tabs.TabInfo; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | class TableRow { 24 | 25 | private final TablePassInfo myData; 26 | final List myColumns = new ArrayList<>(); 27 | int width; 28 | 29 | public TableRow(final TablePassInfo data) { 30 | myData = data; 31 | } 32 | 33 | void add(TabInfo info) { 34 | myColumns.add(info); 35 | width += myData.myTabs.myInfo2Label.get(info).getPreferredSize().width; 36 | myData.myInfo2Row.put(info, this); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/AppleHiDPIScaledImage.java: -------------------------------------------------------------------------------- 1 | package com.intellij.util; 2 | 3 | import java.awt.*; 4 | import java.awt.image.BufferedImage; 5 | 6 | /** 7 | * @author Konstantin Bulenkov 8 | */ 9 | public class AppleHiDPIScaledImage { 10 | public static BufferedImage create(int width, int height, int imageType) { 11 | return new BufferedImage(width, height, imageType); 12 | } 13 | 14 | public static boolean is(Image image) { 15 | return false; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/ArrayFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * @author max 19 | */ 20 | package com.intellij.util; 21 | 22 | import org.jetbrains.annotations.NotNull; 23 | 24 | public interface ArrayFactory { 25 | @NotNull 26 | T[] create(int count); 27 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/BitUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2016 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | public class BitUtil { 19 | public static boolean isSet(byte value, byte mask) { 20 | assertOneBitMask(mask); 21 | return (value & mask) == mask; 22 | } 23 | public static boolean isSet(int value, int mask) { 24 | assertOneBitMask(mask); 25 | return (value & mask) == mask; 26 | } 27 | public static boolean isSet(long flags, long mask) { 28 | assertOneBitMask(mask); 29 | return (flags & mask) == mask; 30 | } 31 | 32 | public static byte set(byte value, byte mask, boolean setBit) { 33 | assertOneBitMask(mask); 34 | return (byte)(setBit ? value | mask : value & ~mask); 35 | } 36 | public static int set(int value, int mask, boolean setBit) { 37 | assertOneBitMask(mask); 38 | return setBit ? value | mask : value & ~mask; 39 | } 40 | public static long set(long value, long mask, boolean setBit) { 41 | assertOneBitMask(mask); 42 | return setBit ? value | mask : value & ~mask; 43 | } 44 | 45 | public static byte clear(byte value, byte mask) { 46 | return set(value, mask, false); 47 | } 48 | public static int clear(int value, int mask) { 49 | return set(value, mask, false); 50 | } 51 | public static long clear(long value, long mask) { 52 | return set(value, mask, false); 53 | } 54 | 55 | private static void assertOneBitMask(byte mask) { 56 | assertOneBitMask(mask & 0xFFL); 57 | } 58 | public static void assertOneBitMask(int mask) { 59 | assertOneBitMask(mask & 0xFFFFFFFFL); 60 | } 61 | private static void assertOneBitMask(long mask) { 62 | assert (mask & mask - 1) == 0 : "Mask must have only one bit set, but got: " + Long.toBinaryString(mask); 63 | } 64 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/Consumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | public interface Consumer { 19 | Consumer EMPTY_CONSUMER = new Consumer() { 20 | public void consume(Object t) { } 21 | }; 22 | 23 | /** 24 | * @param t consequently takes value of each element of the set this processor is passed to for processing. 25 | * t is supposed to be a not-null value. If you need to pass {@code null}s to the consumer use {@link NullableConsumer} instead 26 | */ 27 | void consume(T t); 28 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/EncodingEnvironmentUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | import com.intellij.openapi.diagnostic.Logger; 19 | import com.intellij.openapi.util.SystemInfo; 20 | import org.jetbrains.annotations.NotNull; 21 | 22 | import java.nio.charset.Charset; 23 | import java.util.Locale; 24 | import java.util.Map; 25 | 26 | public class EncodingEnvironmentUtil { 27 | private static final Logger LOG = Logger.getInstance(EncodingEnvironmentUtil.class); 28 | 29 | private static final String LC_ALL = "LC_ALL"; 30 | private static final String LC_CTYPE = "LC_CTYPE"; 31 | private static final String LANG = "LANG"; 32 | 33 | 34 | public static void setLocaleEnvironmentIfMac(@NotNull Map env, @NotNull Charset charset) { 35 | if (SystemInfo.isMac && !isLocaleDefined(env)) { 36 | setLocaleEnvironment(env, charset); 37 | } 38 | } 39 | 40 | private static void setLocaleEnvironment(@NotNull Map env, @NotNull Charset charset) { 41 | env.put(LC_CTYPE, formatLocaleValue(charset)); 42 | if (LOG.isDebugEnabled()) { 43 | LOG.debug("Fixed mac locale: " + charset.name()); 44 | } 45 | } 46 | 47 | @NotNull 48 | private static String formatLocaleValue(@NotNull Charset charset) { 49 | Locale locale = Locale.getDefault(); 50 | String language = locale.getLanguage(); 51 | String country = locale.getCountry(); 52 | return (language.isEmpty() || country.isEmpty() ? "en_US" : language + "_" + country) + "." + charset.name(); 53 | } 54 | 55 | 56 | private static boolean isLocaleDefined(@NotNull Map env) { 57 | return !env.isEmpty() && (env.containsKey(LC_CTYPE) || env.containsKey(LC_ALL) || env.containsKey(LANG)); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/Function.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | import org.jetbrains.annotations.Nullable; 19 | 20 | import java.util.Collection; 21 | 22 | /** 23 | * @author max 24 | * @author Konstantin Bulenkov 25 | * 26 | * @see Functions for some common implementations 27 | */ 28 | @SuppressWarnings({"unchecked"}) 29 | public interface Function { 30 | Result fun(Param param); 31 | 32 | Function ID = new Function.Mono() { 33 | public Object fun(Object o) { 34 | return o; 35 | } 36 | }; 37 | 38 | Function NULL = NullableFunction.NULL; 39 | 40 | Function TO_STRING = new Function() { 41 | public Object fun(Object o) { 42 | return String.valueOf(o); 43 | } 44 | }; 45 | 46 | interface Mono extends Function {} 47 | 48 | final class InstanceOf implements NullableFunction { 49 | 50 | private final Class myResultClass; 51 | 52 | public InstanceOf(Class resultClass) { 53 | myResultClass = resultClass; 54 | } 55 | 56 | @Nullable 57 | public R fun(P p) { 58 | return p.getClass().isAssignableFrom(myResultClass) ? (R)p : null; 59 | } 60 | } 61 | 62 | final class First implements Function { 63 | public R fun(P[] ps) { 64 | return (R)ps[0]; 65 | } 66 | } 67 | 68 | final class FirstInCollection implements Function, R> { 69 | public R fun(Collection

ps) { 70 | return (R)ps.iterator().next(); 71 | } 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/JBHiDPIScaledImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2013 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | import java.awt.*; 19 | import java.awt.image.BufferedImage; 20 | import java.awt.image.ImageObserver; 21 | 22 | /** 23 | * @author Konstantin Bulenkov 24 | */ 25 | public class JBHiDPIScaledImage extends BufferedImage { 26 | private final Image myImage; 27 | private int myWidth; // == myImage.width / scale 28 | private int myHeight; // == myImage.height / scale 29 | 30 | public JBHiDPIScaledImage(int width, int height, int type) { 31 | this(null, 2 * width, 2 * height, type); 32 | } 33 | 34 | public JBHiDPIScaledImage(Image image, int width, int height, int type) { 35 | // In case there's a delegate image, create a dummy wrapper image of 1x1 size 36 | super(image != null ? 1 : width, image != null ? 1 : height, type); 37 | myImage = image; 38 | myWidth = width; 39 | myHeight = height; 40 | } 41 | 42 | public Image getDelegate() { 43 | return myImage; 44 | } 45 | 46 | @Override 47 | public int getWidth() { 48 | return myImage != null ? myWidth : super.getWidth(); 49 | } 50 | 51 | @Override 52 | public int getHeight() { 53 | return myImage != null ? myHeight : super.getHeight(); 54 | } 55 | 56 | @Override 57 | public int getWidth(ImageObserver observer) { 58 | return myImage != null ? myWidth : super.getWidth(observer); 59 | } 60 | 61 | @Override 62 | public int getHeight(ImageObserver observer) { 63 | return myImage != null ? myHeight : super.getHeight(observer); 64 | } 65 | 66 | @Override 67 | public Graphics2D createGraphics() { 68 | Graphics2D g = super.createGraphics(); 69 | if (myImage == null) { 70 | return new HiDPIScaledGraphics(g, this); 71 | } 72 | return g; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/NotNullFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | /** 21 | * @author peter 22 | * @author Konstantin Bulenkov 23 | */ 24 | public interface NotNullFunction extends NullableFunction { 25 | @NotNull 26 | Result fun(final Param dom); 27 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/NotNullProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface NotNullProducer extends Producer { 21 | @Override 22 | @NotNull 23 | T produce(); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/NullableFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | import org.jetbrains.annotations.Nullable; 19 | 20 | /** 21 | * @author peter 22 | */ 23 | public interface NullableFunction extends Function { 24 | @Nullable 25 | Result fun(final Param param); 26 | 27 | /** 28 | * @see FunctionUtil#nullConstant() 29 | */ 30 | NullableFunction NULL = new NullableFunction() { 31 | public Object fun(final Object o) { 32 | return null; 33 | } 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/PairConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.intellij.util; 18 | 19 | /** 20 | * @author peter 21 | */ 22 | public interface PairConsumer { 23 | void consume(S s, T t); 24 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/Processor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2010 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | /** 19 | * @param Input value type. 20 | * @see com.intellij.util.CommonProcessors 21 | */ 22 | public interface Processor { 23 | Processor TRUE = new Processor() { 24 | @Override 25 | public boolean process(Object o) { 26 | return true; 27 | } 28 | }; 29 | Processor FALSE = new Processor() { 30 | @Override 31 | public boolean process(Object o) { 32 | return false; 33 | } 34 | }; 35 | /** 36 | * @param t consequently takes value of each element of the set this processor is passed to for processing. 37 | * @return {@code true} to continue processing or {@code false} to stop. 38 | */ 39 | boolean process(T t); 40 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/Producer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2011 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util; 17 | 18 | import org.jetbrains.annotations.Nullable; 19 | 20 | /** 21 | * @author pegov 22 | */ 23 | public interface Producer { 24 | 25 | @Nullable 26 | T produce(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/concurrency/BoundedTaskExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2016 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.concurrency; 17 | 18 | import com.intellij.util.ObjectUtils; 19 | import com.intellij.util.ReflectionUtil; 20 | 21 | import java.util.concurrent.Callable; 22 | import java.util.concurrent.FutureTask; 23 | 24 | /** 25 | * ExecutorService which limits the number of tasks running simultaneously. 26 | * The number of submitted tasks is unrestricted. 27 | */ 28 | public class BoundedTaskExecutor { 29 | 30 | // for diagnostics 31 | static Object info(Runnable info) { 32 | Object task = info; 33 | String extra = null; 34 | if (task instanceof FutureTask) { 35 | extra = ((FutureTask)task).isCancelled() ? " (future cancelled)" : ((FutureTask)task).isDone() ? " (future done)" : null; 36 | task = ObjectUtils.chooseNotNull(ReflectionUtil.getField(task.getClass(), task, Callable.class, "callable"), task); 37 | } 38 | if (task instanceof Callable && task.getClass().getName().equals("java.util.concurrent.Executors$RunnableAdapter")) { 39 | task = ObjectUtils.chooseNotNull(ReflectionUtil.getField(task.getClass(), task, Runnable.class, "task"), task); 40 | } 41 | return extra == null ? task : task == null ? extra : task.getClass() + extra; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/concurrency/FixedFuture.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2013 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.concurrency; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | import java.util.concurrent.ExecutionException; 21 | import java.util.concurrent.Future; 22 | import java.util.concurrent.TimeUnit; 23 | 24 | public class FixedFuture implements Future { 25 | private final T myValue; 26 | private final Throwable myThrowable; 27 | 28 | public FixedFuture(T value) { 29 | myValue = value; 30 | myThrowable = null; 31 | } 32 | 33 | private FixedFuture(@NotNull Throwable throwable) { 34 | myValue = null; 35 | myThrowable = throwable; 36 | } 37 | 38 | public static FixedFuture completeExceptionally(@NotNull Throwable throwable) { 39 | return new FixedFuture(throwable); 40 | } 41 | 42 | @Override 43 | public boolean cancel(boolean mayInterruptIfRunning) { 44 | return false; 45 | } 46 | 47 | @Override 48 | public boolean isCancelled() { 49 | return false; 50 | } 51 | 52 | @Override 53 | public boolean isDone() { 54 | return true; 55 | } 56 | 57 | @Override 58 | public T get() throws ExecutionException { 59 | if (myThrowable != null) { 60 | throw new ExecutionException(myThrowable); 61 | } 62 | return myValue; 63 | } 64 | 65 | @Override 66 | public T get(long timeout, @NotNull TimeUnit unit) { 67 | return myValue; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/containers/EmptyIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.containers; 17 | 18 | import java.util.Iterator; 19 | import java.util.NoSuchElementException; 20 | 21 | public class EmptyIterator implements Iterator { 22 | private static final EmptyIterator INSTANCE = new EmptyIterator(); 23 | public static EmptyIterator getInstance() { 24 | //noinspection unchecked 25 | return INSTANCE; 26 | } 27 | public boolean hasNext() { 28 | return false; 29 | } 30 | 31 | public T next() { 32 | throw new NoSuchElementException(); 33 | } 34 | 35 | public void remove() { 36 | throw new IllegalStateException(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/containers/EmptyListIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.containers; 17 | 18 | import java.util.ListIterator; 19 | import java.util.NoSuchElementException; 20 | 21 | public class EmptyListIterator extends EmptyIterator implements ListIterator { 22 | private static final EmptyListIterator INSTANCE = new EmptyListIterator(); 23 | 24 | public static EmptyListIterator getInstance() { 25 | //noinspection unchecked 26 | return (EmptyListIterator)INSTANCE; 27 | } 28 | 29 | public boolean hasPrevious() { 30 | return false; 31 | } 32 | 33 | public E previous() { 34 | throw new NoSuchElementException(); 35 | } 36 | 37 | public int nextIndex() { 38 | return 0; 39 | } 40 | 41 | public int previousIndex() { 42 | return -1; 43 | } 44 | 45 | public void set(E e) { 46 | throw new IllegalStateException(); 47 | } 48 | 49 | public void add(E e) { 50 | throw new UnsupportedOperationException(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/containers/HashMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.containers; 17 | 18 | import java.util.Map; 19 | 20 | @SuppressWarnings("ClassNameSameAsAncestorName") 21 | public class HashMap extends java.util.HashMap { 22 | public HashMap() { } 23 | 24 | public HashMap(int initialCapacity, float loadFactor) { 25 | super(initialCapacity, loadFactor); 26 | } 27 | 28 | public HashMap(int initialCapacity) { 29 | super(initialCapacity); 30 | } 31 | 32 | public HashMap(Map map) { 33 | super(map); 34 | } 35 | 36 | @Override 37 | public void clear() { 38 | if (size() == 0) return; // optimization 39 | super.clear(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/containers/HashSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.containers; 17 | 18 | import java.util.Collection; 19 | 20 | @SuppressWarnings("ClassNameSameAsAncestorName") 21 | public class HashSet extends java.util.HashSet { 22 | public HashSet() { } 23 | 24 | public HashSet(Collection collection) { 25 | super(collection); 26 | } 27 | 28 | public HashSet(int i, float v) { 29 | super(i, v); 30 | } 31 | 32 | public HashSet(int i) { 33 | super(i); 34 | } 35 | 36 | public void clear() { 37 | if (size() == 0) return; // optimization 38 | super.clear(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/containers/LinkedHashMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2012 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.containers; 17 | 18 | import java.util.Map; 19 | 20 | @SuppressWarnings("ClassNameSameAsAncestorName") 21 | class LinkedHashMap extends java.util.LinkedHashMap { 22 | public LinkedHashMap() { } 23 | 24 | public LinkedHashMap(int i, float v) { 25 | super(i, v); 26 | } 27 | 28 | public LinkedHashMap(int i) { 29 | super(i); 30 | } 31 | 32 | public LinkedHashMap(Map map) { 33 | super(map); 34 | } 35 | 36 | public void clear() { 37 | if (size() == 0) return; // optimization 38 | super.clear(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/containers/LinkedHashSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.containers; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | import java.util.Collection; 21 | 22 | @SuppressWarnings("ClassNameSameAsAncestorName") 23 | class LinkedHashSet extends java.util.LinkedHashSet { 24 | public LinkedHashSet() { } 25 | 26 | public LinkedHashSet(@NotNull Collection collection) { 27 | super(collection); 28 | } 29 | 30 | public LinkedHashSet(int i, float v) { 31 | super(i, v); 32 | } 33 | 34 | public LinkedHashSet(int i) { 35 | super(i); 36 | } 37 | 38 | @Override 39 | public void clear() { 40 | if (size() == 0) return; // optimization 41 | super.clear(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/containers/SingletonIteratorBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2014 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.containers; 17 | 18 | import java.util.Iterator; 19 | import java.util.NoSuchElementException; 20 | 21 | public abstract class SingletonIteratorBase implements Iterator { 22 | private boolean myVisited; 23 | 24 | @Override 25 | public final boolean hasNext() { 26 | return !myVisited; 27 | } 28 | 29 | @Override 30 | public final T next() { 31 | if (myVisited) { 32 | throw new NoSuchElementException(); 33 | } 34 | myVisited = true; 35 | checkCoModification(); 36 | return getElement(); 37 | } 38 | 39 | protected abstract void checkCoModification(); 40 | 41 | protected abstract T getElement(); 42 | } -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/io/URLUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2016 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.io; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | import java.util.regex.Pattern; 21 | 22 | public class URLUtil { 23 | public static final String SCHEME_SEPARATOR = "://"; 24 | public static final String FILE_PROTOCOL = "file"; 25 | public static final String HTTP_PROTOCOL = "http"; 26 | public static final String JAR_PROTOCOL = "jar"; 27 | public static final String JAR_SEPARATOR = "!/"; 28 | 29 | public static final Pattern DATA_URI_PATTERN = Pattern.compile("data:([^,;]+/[^,;]+)(;charset(?:=|:)[^,;]+)?(;base64)?,(.+)"); 30 | public static final Pattern URL_PATTERN = Pattern.compile("\\b(mailto:|(news|(ht|f)tp(s?))://|((? 1; 29 | } 30 | }; 31 | return isRetina[0]; 32 | } 33 | catch (Throwable e) { 34 | e.printStackTrace(); 35 | return false; 36 | }*/ 37 | return false; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/ui/JBDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2016 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.ui; 17 | 18 | import javax.swing.plaf.UIResource; 19 | import java.awt.*; 20 | 21 | /** 22 | * @author Konstantin Bulenkov 23 | */ 24 | public class JBDimension extends Dimension { 25 | public final float originalScale = JBUI.scale(1f); 26 | 27 | public JBDimension(int width, int height) { 28 | super(scale(width), scale(height)); 29 | } 30 | 31 | private static int scale(int size) { 32 | return size == -1 ? -1 : JBUI.scale(size); 33 | } 34 | 35 | public static JBDimension create(Dimension from) { 36 | if (from instanceof JBDimension) { 37 | return ((JBDimension)from); 38 | } 39 | return new JBDimension(from.width, from.height); 40 | } 41 | 42 | public JBDimensionUIResource asUIResource() { 43 | return new JBDimensionUIResource(this); 44 | } 45 | 46 | public static class JBDimensionUIResource extends JBDimension implements UIResource { 47 | public JBDimensionUIResource(JBDimension size) { 48 | super(0, 0); 49 | width = size.width; 50 | height = size.height; 51 | } 52 | } 53 | 54 | public JBDimension withWidth(int width) { 55 | JBDimension size = new JBDimension(0, 0); 56 | size.width = scale(width); 57 | size.height = height; 58 | return size; 59 | } 60 | 61 | public JBDimension withHeight(int height) { 62 | JBDimension size = new JBDimension(0, 0); 63 | size.width = width; 64 | size.height = scale(height); 65 | return size; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/ui/JBEmptyBorder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.ui; 17 | 18 | import javax.swing.border.EmptyBorder; 19 | import javax.swing.plaf.UIResource; 20 | import java.awt.*; 21 | 22 | /** 23 | * @author Konstantin Bulenkov 24 | */ 25 | public class JBEmptyBorder extends EmptyBorder { 26 | public JBEmptyBorder(int top, int left, int bottom, int right) { 27 | super(JBUI.insets(top, left, bottom, right)); 28 | } 29 | 30 | public JBEmptyBorder(Insets insets) { 31 | super(JBUI.insets(insets)); 32 | } 33 | 34 | public JBEmptyBorder(int offset) { 35 | this(offset, offset, offset, offset); 36 | } 37 | 38 | public JBEmptyBorderUIResource asUIResource() { 39 | return new JBEmptyBorderUIResource(this); 40 | } 41 | 42 | public static class JBEmptyBorderUIResource extends JBEmptyBorder implements UIResource { 43 | public JBEmptyBorderUIResource(JBEmptyBorder border) { 44 | super(0,0,0,0); 45 | top = border.top; 46 | left = border.left; 47 | bottom = border.bottom; 48 | right = border.right; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/ui/JBFont.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.ui; 17 | 18 | import javax.swing.plaf.UIResource; 19 | import java.awt.*; 20 | 21 | /** 22 | * @author Konstantin Bulenkov 23 | */ 24 | public class JBFont extends Font { 25 | private JBFont(Font font) { 26 | super(font); 27 | } 28 | 29 | public static JBFont create(Font font) { 30 | return create(font, true); 31 | } 32 | 33 | public static JBFont create(Font font, boolean tryToScale) { 34 | if (font instanceof JBFont) { 35 | return ((JBFont)font); 36 | } 37 | Font scaled = font; 38 | if (tryToScale) { 39 | scaled = font.deriveFont(font.getSize() * JBUI.scale(1f)); 40 | } 41 | 42 | if (font instanceof UIResource) { 43 | return new JBFontUIResource(scaled); 44 | } 45 | 46 | return new JBFont(scaled); 47 | } 48 | 49 | public JBFont asBold() { 50 | return deriveFont(BOLD, getSize()); 51 | } 52 | 53 | public JBFont asItalic() { 54 | return deriveFont(ITALIC, getSize()); 55 | } 56 | 57 | public JBFont asPlain() { 58 | return deriveFont(PLAIN, getSize()); 59 | } 60 | 61 | @Override 62 | public JBFont deriveFont(int style, float size) { 63 | return create(super.deriveFont(style, size), false); 64 | } 65 | 66 | @Override 67 | public JBFont deriveFont(float size) { 68 | return create(super.deriveFont(size), false); 69 | } 70 | 71 | public JBFont biggerOn(float size) { 72 | return deriveFont(getSize() + JBUI.scale(size)); 73 | } 74 | 75 | public JBFont lessOn(float size) { 76 | return deriveFont(getSize() - JBUI.scale(size)); 77 | } 78 | 79 | private static class JBFontUIResource extends JBFont implements UIResource { 80 | private JBFontUIResource(Font font) { 81 | super(font); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/ui/components/BorderLayoutPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.ui.components; 17 | 18 | import com.intellij.ui.components.JBPanel; 19 | import com.intellij.util.ui.JBUI; 20 | 21 | import java.awt.*; 22 | 23 | /** 24 | * @author Konstantin Bulenkov 25 | */ 26 | public class BorderLayoutPanel extends JBPanel { 27 | public BorderLayoutPanel() { 28 | this(0, 0); 29 | } 30 | 31 | public BorderLayoutPanel(int hgap, int vgap) { 32 | super(new BorderLayout(JBUI.scale(hgap), JBUI.scale(vgap))); 33 | } 34 | 35 | public BorderLayoutPanel addToCenter(Component comp) { 36 | add(comp, BorderLayout.CENTER); 37 | return this; 38 | } 39 | 40 | public BorderLayoutPanel addToRight(Component comp) { 41 | add(comp, BorderLayout.EAST); 42 | return this; 43 | } 44 | 45 | public BorderLayoutPanel addToLeft(Component comp) { 46 | add(comp, BorderLayout.WEST); 47 | return this; 48 | } 49 | 50 | public BorderLayoutPanel addToTop(Component comp) { 51 | add(comp, BorderLayout.NORTH); 52 | return this; 53 | } 54 | 55 | public BorderLayoutPanel addToBottom(Component comp) { 56 | add(comp, BorderLayout.SOUTH); 57 | return this; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/ui/components/JBComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2015 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.ui.components; 17 | 18 | import com.intellij.util.ui.JBFont; 19 | 20 | import javax.swing.border.Border; 21 | 22 | /** 23 | * @author Konstantin Bulenkov 24 | */ 25 | public interface JBComponent { 26 | T withBorder(Border border); 27 | 28 | T withFont(JBFont font); 29 | 30 | T andTransparent(); 31 | 32 | T andOpaque(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/ui/update/ComparableObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.ui.update; 17 | 18 | import org.jetbrains.annotations.NotNull; 19 | 20 | public interface ComparableObject { 21 | Object[] NONE = new Object[0]; 22 | 23 | @NotNull 24 | Object[] getEqualityObjects(); 25 | 26 | class Impl implements ComparableObject { 27 | private final Object[] myObjects; 28 | 29 | public Impl() { 30 | this(NONE); 31 | } 32 | 33 | public Impl(@NotNull Object... objects) { 34 | myObjects = objects; 35 | } 36 | 37 | @NotNull 38 | @Override 39 | public Object[] getEqualityObjects() { 40 | return myObjects; 41 | } 42 | 43 | @Override 44 | public final boolean equals(Object obj) { 45 | return ComparableObjectCheck.equals(this, obj); 46 | } 47 | 48 | @Override 49 | public final int hashCode() { 50 | return ComparableObjectCheck.hashCode(this, super.hashCode()); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/intellij/util/ui/update/ComparableObjectCheck.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2000-2009 JetBrains s.r.o. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.intellij.util.ui.update; 17 | 18 | import com.intellij.openapi.util.Comparing; 19 | import org.jetbrains.annotations.NotNull; 20 | 21 | 22 | public class ComparableObjectCheck { 23 | public static boolean equals(@NotNull ComparableObject me, Object him) { 24 | if (me == him) { 25 | return true; 26 | } 27 | 28 | else if (!(him instanceof ComparableObject)) { 29 | return false; 30 | } 31 | 32 | Object[] my = me.getEqualityObjects(); 33 | Object[] his = ((ComparableObject) him).getEqualityObjects(); 34 | 35 | if (my.length == 0 || his.length == 0 || my.length != his.length) { 36 | return false; 37 | } 38 | 39 | for (int i = 0; i < my.length; i++) { 40 | if (!Comparing.equal(my[i], his[i])) { 41 | return false; 42 | } 43 | } 44 | 45 | return true; 46 | } 47 | 48 | public static int hashCode(ComparableObject me, int superCode) { 49 | Object[] objects = me.getEqualityObjects(); 50 | if (objects.length == 0) { 51 | return superCode; 52 | } 53 | 54 | int result = 0; 55 | for (Object object : objects) { 56 | result = 29 * result + (object != null ? object.hashCode() : 239); 57 | } 58 | return result; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/gnu/newtrove/CanonicalEquality.java: -------------------------------------------------------------------------------- 1 | package gnu.newtrove; 2 | 3 | 4 | import gnu.newtrove.Equality; 5 | 6 | class CanonicalEquality implements Equality { 7 | public boolean equals(T o1, T o2) { 8 | return o1 != null ? o1.equals(o2) : o2 == null; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/gnu/newtrove/Equality.java: -------------------------------------------------------------------------------- 1 | package gnu.newtrove; 2 | 3 | import gnu.newtrove.CanonicalEquality; 4 | import gnu.newtrove.IdentityEquality; 5 | 6 | public interface Equality { 7 | Equality CANONICAL = new CanonicalEquality(); 8 | Equality IDENTITY = new IdentityEquality(); 9 | boolean equals(T o1, T o2); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/gnu/newtrove/IdentityEquality.java: -------------------------------------------------------------------------------- 1 | package gnu.newtrove; 2 | 3 | import gnu.newtrove.Equality; 4 | 5 | class IdentityEquality implements Equality { 6 | public boolean equals(T o1, T o2) { 7 | return o1 == o2; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/gnu/newtrove/TObjectCanonicalHashingStrategy.java: -------------------------------------------------------------------------------- 1 | package gnu.newtrove; 2 | 3 | /** 4 | * @author dyoma 5 | */ 6 | class TObjectCanonicalHashingStrategy implements TObjectHashingStrategy { 7 | public int computeHashCode(T value) { 8 | return value != null ? value.hashCode() : 0; 9 | } 10 | 11 | public boolean equals(T value, T value1) { 12 | return value != null ? value.equals(value1) : value1 == null; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/gnu/newtrove/TObjectHashingStrategy.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2002, Eric D. Friedman All Rights Reserved. 2 | 3 | package gnu.newtrove; 4 | 5 | import gnu.newtrove.Equality; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * Interface to support pluggable hashing strategies in maps and sets. 11 | * Implementors can use this interface to make the trove hashing 12 | * algorithms use object values, values provided by the java runtime, 13 | * or a custom strategy when computing hashcodes. 14 | * 15 | * Created: Sat Aug 17 10:52:32 2002 16 | * 17 | * @author Eric Friedman 18 | * @version $Id: TObjectHashingStrategy.java,v 1.6 2004/09/24 09:11:15 cdr Exp $ 19 | */ 20 | 21 | public interface TObjectHashingStrategy extends Serializable, Equality { 22 | 23 | /** 24 | * Computes a hash code for the specified object. Implementors 25 | * can use the object's own hashCode method, the Java 26 | * runtime's identityHashCode, or a custom scheme. 27 | * 28 | * @param object for which the hashcode is to be computed 29 | * @return the hashCode 30 | */ 31 | int computeHashCode(T object); 32 | 33 | /** 34 | * Compares o1 and o2 for equality. Strategy implementors may use 35 | * the objects' own equals() methods, compare object references, 36 | * or implement some custom scheme. 37 | * 38 | * @param o1 an Object value 39 | * @param o2 an Object value 40 | * @return true if the objects are equal according to this strategy. 41 | */ 42 | boolean equals(T o1, T o2); 43 | 44 | TObjectHashingStrategy IDENTITY = new TObjectIdentityHashingStrategy(); 45 | TObjectHashingStrategy CANONICAL = new TObjectCanonicalHashingStrategy(); 46 | } // TObjectHashingStrategy 47 | -------------------------------------------------------------------------------- /src/main/java/gnu/newtrove/TObjectIdentityHashingStrategy.java: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2002, Eric D. Friedman All Rights Reserved. 2 | 3 | package gnu.newtrove; 4 | 5 | /** 6 | * This object hashing strategy uses the System.identityHashCode 7 | * method to provide identity hash codes. These are identical to the 8 | * value produced by Object.hashCode(), even when the type of the 9 | * object being hashed overrides that method. 10 | * 11 | * Created: Sat Aug 17 11:13:15 2002 12 | * 13 | * @author Eric Friedman 14 | * @version $Id: TObjectIdentityHashingStrategy.java,v 1.8 2004/09/24 09:11:15 cdr Exp $ 15 | */ 16 | 17 | public final class TObjectIdentityHashingStrategy implements TObjectHashingStrategy { 18 | /** 19 | * Delegates hash code computation to the System.identityHashCode(Object) method. 20 | * 21 | * @param object for which the hashcode is to be computed 22 | * @return the hashCode 23 | */ 24 | public final int computeHashCode(T object) { 25 | return System.identityHashCode(object); 26 | } 27 | 28 | /** 29 | * Compares object references for equality. 30 | * 31 | * @param o1 an Object value 32 | * @param o2 an Object value 33 | * @return true if o1 == o2 34 | */ 35 | public final boolean equals(T o1, T o2) { 36 | return o1 == o2; 37 | } 38 | } // TObjectIdentityHashingStrategy 39 | -------------------------------------------------------------------------------- /src/main/java/sc/iview/SciViewService.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview; 30 | 31 | import net.imagej.ImageJService; 32 | 33 | /** 34 | * Interface for services that work with Scenery. 35 | * 36 | * @author Kyle Harrington (University of Idaho, Moscow) 37 | */ 38 | public interface SciViewService extends ImageJService { 39 | 40 | SciView getActiveSciView(); 41 | 42 | SciView getOrCreateActiveSciView() throws Exception; 43 | 44 | SciView getSciView(String name); 45 | 46 | void createSciView() throws Exception; 47 | 48 | int numSciView(); 49 | 50 | void close(SciView sciView); 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/sc/iview/event/NodeActivatedEvent.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.event; 30 | 31 | import graphics.scenery.Node; 32 | 33 | /** 34 | * An event indicating a {@link Node} was activated. 35 | * 36 | * @author Curtis Rueden 37 | */ 38 | public class NodeActivatedEvent extends NodeEvent { 39 | 40 | public NodeActivatedEvent( final Node node ) { 41 | super( node ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/sc/iview/event/NodeAddedEvent.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.event; 30 | 31 | import graphics.scenery.Node; 32 | 33 | /** 34 | * An event indicating a {@link Node} was added. 35 | * 36 | * @author Curtis Rueden 37 | */ 38 | public class NodeAddedEvent extends NodeEvent { 39 | 40 | public NodeAddedEvent( final Node node ) { 41 | super( node ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/sc/iview/event/NodeChangedEvent.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.event; 30 | 31 | import graphics.scenery.Node; 32 | 33 | /** 34 | * An event indicating a {@link Node} was changed somehow. 35 | * 36 | * @author Curtis Rueden 37 | */ 38 | public class NodeChangedEvent extends NodeEvent { 39 | 40 | public NodeChangedEvent( final Node node ) { 41 | super( node ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/sc/iview/event/NodeEvent.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.event; 30 | 31 | import org.scijava.event.SciJavaEvent; 32 | 33 | import graphics.scenery.Node; 34 | 35 | /** 36 | * An event relating to a particular {@link Node}. 37 | * 38 | * @author Curtis Rueden 39 | */ 40 | public abstract class NodeEvent extends SciJavaEvent { 41 | 42 | private final Node node; 43 | 44 | public NodeEvent( final Node node ) { 45 | this.node = node; 46 | } 47 | 48 | public Node getNode() { 49 | return node; 50 | } 51 | 52 | @Override 53 | public String toString() { 54 | return super.toString() + "\n\tnode = " + node; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/sc/iview/event/NodeRemovedEvent.java: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.event; 30 | 31 | import graphics.scenery.Node; 32 | 33 | /** 34 | * An event indicating a {@link Node} was removed. 35 | * 36 | * @author Curtis Rueden 37 | */ 38 | public class NodeRemovedEvent extends NodeEvent { 39 | 40 | public NodeRemovedEvent( final Node node ) { 41 | super( node ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/ImageJMain.kt: -------------------------------------------------------------------------------- 1 | package sc.iview 2 | 3 | import org.scijava.ui.UIService 4 | 5 | object ImageJMain { 6 | @Throws(Exception::class) 7 | @JvmStatic 8 | fun main(args: Array) { 9 | val sv = SciView.create() 10 | val context = sv.scijavaContext 11 | val uiService = context?.service(UIService::class.java) 12 | 13 | uiService?.showUI() 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/Main.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview 30 | 31 | /** 32 | * Entry point for testing SciView functionality. 33 | * 34 | * @author Kyle Harrington 35 | */ 36 | object Main { 37 | @Throws(Exception::class) 38 | @JvmStatic 39 | fun main(args: Array) { 40 | SciView.create() 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/add/AddAtmosphere.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.commands.add 2 | 3 | import graphics.scenery.primitives.Atmosphere 4 | import org.scijava.command.Command 5 | import org.scijava.plugin.Menu 6 | import org.scijava.plugin.Parameter 7 | import org.scijava.plugin.Plugin 8 | import org.scijava.widget.NumberWidget 9 | import sc.iview.SciView 10 | import sc.iview.commands.MenuWeights 11 | 12 | /** 13 | * Command to add an atmosphere background to the scene 14 | * 15 | * @author Samuel Pantze 16 | */ 17 | @Plugin( 18 | type = Command::class, 19 | menuRoot = "SciView", 20 | menu = [Menu(label = "Add", weight = MenuWeights.ADD), Menu( 21 | label = "Atmosphere...", 22 | weight = MenuWeights.EDIT_ADD_ATMOSPHERE 23 | )] 24 | ) 25 | class AddAtmosphere : Command { 26 | @Parameter 27 | private lateinit var sciView: SciView 28 | 29 | override fun run() { 30 | val atmos = Atmosphere() 31 | sciView.addNode(atmos) 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/add/AddPointLight.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.commands.add 30 | 31 | import org.scijava.command.Command 32 | import org.scijava.plugin.Menu 33 | import org.scijava.plugin.Parameter 34 | import org.scijava.plugin.Plugin 35 | import sc.iview.SciView 36 | import sc.iview.commands.MenuWeights.ADD 37 | import sc.iview.commands.MenuWeights.EDIT_ADD_POINTLIGHT 38 | 39 | /** 40 | * Command to add a point light to the scene 41 | * 42 | * @author Kyle Harrington 43 | */ 44 | @Plugin( 45 | type = Command::class, 46 | menuRoot = "SciView", 47 | menu = [Menu(label = "Add", weight = ADD), Menu( 48 | label = "Point Light", 49 | weight = EDIT_ADD_POINTLIGHT 50 | )] 51 | ) 52 | class AddPointLight : Command { 53 | @Parameter 54 | private lateinit var sciView: SciView 55 | 56 | override fun run() { 57 | sciView.addPointLight() 58 | } 59 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/edit/BoundingGridProperties.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.commands.edit 2 | 3 | import graphics.scenery.BoundingGrid 4 | import okio.withLock 5 | import org.joml.Vector3f 6 | import org.scijava.command.Command 7 | import org.scijava.plugin.Parameter 8 | import org.scijava.plugin.Plugin 9 | import org.scijava.util.ColorRGB 10 | 11 | /** 12 | * Inspector panel for inspecting a [BoundingGrid]'s properties. 13 | */ 14 | @Plugin(type = Command::class, initializer = "updateCommandFields", visible = false) 15 | class BoundingGridProperties : InspectorInteractiveCommand() { 16 | /** Parameter for the [BoundingGrid.gridColor] */ 17 | @Parameter(label = "Grid Color", callback = "updateNodeProperties", style = "group:Grid") 18 | private var gridColor: ColorRGB? = null 19 | 20 | /** Parameter for the [BoundingGrid.ticksOnly], determining whether to show a box or only ticks. */ 21 | @Parameter(label = "Ticks only", callback = "updateNodeProperties", style = "group:Grid") 22 | private var ticksOnly = false 23 | 24 | /** Updates this command fields with the node's current properties. */ 25 | override fun updateCommandFields() { 26 | val node = currentSceneNode as? BoundingGrid ?: return 27 | 28 | fieldsUpdating.withLock { 29 | gridColor = ColorRGB( 30 | node.gridColor.x().toInt() * 255, 31 | node.gridColor.y().toInt() * 255, 32 | node.gridColor.z().toInt() * 255 33 | ) 34 | ticksOnly = node.ticksOnly > 0 35 | } 36 | } 37 | 38 | /** Updates current scene node properties to match command fields. */ 39 | override fun updateNodeProperties() { 40 | val node = currentSceneNode as? BoundingGrid ?: return 41 | fieldsUpdating.withLock { 42 | 43 | val ticks = if(ticksOnly) { 44 | 1 45 | } else { 46 | 0 47 | } 48 | node.ticksOnly = ticks 49 | node.gridColor = Vector3f( 50 | gridColor!!.red / 255.0f, 51 | gridColor!!.green / 255.0f, 52 | gridColor!!.blue / 255.0f 53 | ) 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/edit/CameraProperties.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.commands.edit 2 | 3 | import graphics.scenery.Camera 4 | import okio.withLock 5 | import org.scijava.command.Command 6 | import org.scijava.plugin.Parameter 7 | import org.scijava.plugin.Plugin 8 | 9 | /** 10 | * Inspector panel for [Camera] nodes. 11 | */ 12 | @Plugin(type = Command::class, initializer = "updateCommandFields", visible = false) 13 | class CameraProperties : InspectorInteractiveCommand() { 14 | @Parameter(label = "Active", required = false, callback = "updateNodeProperties", style = "group:Camera") 15 | private var active = false 16 | 17 | /** Updates this command fields with the node's current properties. */ 18 | override fun updateCommandFields() { 19 | val node = currentSceneNode as? Camera ?: return 20 | 21 | fieldsUpdating.withLock { 22 | val scene = node.getScene() 23 | active = if(scene != null) { 24 | scene.findObserver() === node 25 | } else { 26 | false 27 | } 28 | } 29 | } 30 | 31 | /** Updates current scene node properties to match command fields. */ 32 | override fun updateNodeProperties() { 33 | val node = currentSceneNode as? Camera ?: return 34 | fieldsUpdating.withLock { 35 | 36 | val scene = node.getScene() 37 | if(active && scene != null) { 38 | scene.activeObserver = node 39 | } 40 | } 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/edit/LightProperties.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.commands.edit 2 | 3 | import graphics.scenery.PointLight 4 | import okio.withLock 5 | import org.scijava.command.Command 6 | import org.scijava.plugin.Parameter 7 | import org.scijava.plugin.Plugin 8 | import org.scijava.widget.NumberWidget 9 | 10 | /** 11 | * Inspector panel for [PointLight]s. 12 | */ 13 | @Plugin(type = Command::class, initializer = "updateCommandFields", visible = false) 14 | class LightProperties : InspectorInteractiveCommand() { 15 | @Parameter(label = "Intensity", style = NumberWidget.SPINNER_STYLE+ ",group:Lighting", stepSize = "0.1", callback = "updateNodeProperties") 16 | private var intensity = 0f 17 | 18 | /** Updates this command fields with the node's current properties. */ 19 | override fun updateCommandFields() { 20 | val node = currentSceneNode as? PointLight ?: return 21 | 22 | fieldsUpdating.withLock { 23 | intensity = node.intensity 24 | } 25 | } 26 | 27 | /** Updates current scene node properties to match command fields. */ 28 | override fun updateNodeProperties() { 29 | val node = currentSceneNode as? PointLight ?: return 30 | fieldsUpdating.withLock { 31 | node.intensity = intensity 32 | } 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/edit/LineProperties.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.commands.edit 2 | 3 | import graphics.scenery.primitives.Line 4 | import okio.withLock 5 | import org.scijava.command.Command 6 | import org.scijava.plugin.Parameter 7 | import org.scijava.plugin.Plugin 8 | 9 | /** 10 | * Inspector panel for [Line] nodes. 11 | */ 12 | @Plugin(type = Command::class, initializer = "updateCommandFields", visible = false) 13 | class LineProperties : InspectorInteractiveCommand() { 14 | /* Line properties */ 15 | 16 | @Parameter(label = "Edge width", callback = "updateNodeProperties", style = "group:Line") 17 | private var edgeWidth = 0 18 | 19 | /** Updates this command fields with the node's current properties. */ 20 | override fun updateCommandFields() { 21 | val node = currentSceneNode as? Line ?: return 22 | 23 | fieldsUpdating.withLock { 24 | edgeWidth = node.edgeWidth.toInt() 25 | } 26 | } 27 | 28 | /** Updates current scene node properties to match command fields. */ 29 | override fun updateNodeProperties() { 30 | val node = currentSceneNode as? Line ?: return 31 | fieldsUpdating.withLock { 32 | node.edgeWidth = edgeWidth.toFloat() 33 | } 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/edit/ResetScene.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.commands.edit 30 | 31 | import org.scijava.command.Command 32 | import org.scijava.log.LogService 33 | import org.scijava.plugin.Menu 34 | import org.scijava.plugin.Parameter 35 | import org.scijava.plugin.Plugin 36 | import sc.iview.SciView 37 | import sc.iview.commands.MenuWeights.EDIT 38 | import sc.iview.commands.MenuWeights.EDIT_RESET_SCENE 39 | 40 | /** 41 | * Command to reset the scene to default 42 | * 43 | * @author Kyle Harrington 44 | */ 45 | @Plugin(type = Command::class, menuRoot = "SciView", menu = [Menu(label = "Edit", weight = EDIT), Menu(label = "Reset Scene", weight = EDIT_RESET_SCENE)]) 46 | class ResetScene : Command { 47 | @Parameter 48 | private lateinit var sciView: SciView 49 | 50 | override fun run() { 51 | sciView.reset() 52 | 53 | sciView.mainWindow.rebuildSceneTree() 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/edit/SlicingPlaneProperties.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.commands.edit 2 | 3 | import graphics.scenery.volumes.SlicingPlane 4 | import graphics.scenery.volumes.VolumeManager 5 | import net.imagej.lut.LUTService 6 | import okio.withLock 7 | import org.scijava.command.Command 8 | import org.scijava.plugin.Parameter 9 | import org.scijava.plugin.Plugin 10 | import org.scijava.ui.UIService 11 | 12 | /** 13 | * Inspector panel for [SlicingPlane] nodes. 14 | */ 15 | @Plugin(type = Command::class, initializer = "updateCommandFields", visible = false) 16 | class SlicingPlaneProperties : InspectorInteractiveCommand() { 17 | /* Targets properties */ 18 | @Parameter(label = "Sliced volumes", callback = "updateNodeProperties", style = "group:Targets") 19 | private var slicedVolumes: VolumeSelectorWidget.VolumeSelection = VolumeSelectorWidget.VolumeSelection() 20 | 21 | /** Updates this command fields with the node's current properties. */ 22 | override fun updateCommandFields() { 23 | val node = currentSceneNode as? SlicingPlane ?: return 24 | 25 | fieldsUpdating.withLock { 26 | 27 | sciView.hub.get()?.let { 28 | slicedVolumes.availableVolumes = it.nodes 29 | } 30 | slicedVolumes.clear() 31 | slicedVolumes.addAll(node.slicedVolumes) 32 | } 33 | } 34 | 35 | /** Updates current scene node properties to match command fields. */ 36 | override fun updateNodeProperties() { 37 | val node = currentSceneNode as? SlicingPlane ?: return 38 | 39 | fieldsUpdating.withLock { 40 | val old = node.slicedVolumes 41 | val new = slicedVolumes 42 | val removed = old.filter { !new.contains(it) } 43 | val added = new.filter { !old.contains(it) } 44 | removed.forEach { node.removeTargetVolume(it) } 45 | added.forEach { node.addTargetVolume(it) } 46 | } 47 | } 48 | 49 | 50 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/edit/SwingInspectorInteractiveCommandExtension.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.commands.edit 2 | 3 | import graphics.scenery.Node 4 | import org.scijava.ui.swing.widget.SwingInputPanel 5 | 6 | /** 7 | * Interface for Swing-based extensions for [InspectorInteractiveCommand]. 8 | */ 9 | interface SwingInspectorInteractiveCommandExtension { 10 | 11 | /** 12 | * The create() function is called when the Swing panel is contstructed, with [inputPanel] being 13 | * the panel under construction, to which Swing objects can be attached. [sceneNode] is the 14 | * currently-selected [Node] for which the inspector is being constructed, and [uiDebug] is 15 | * a debug flag which can be used to determine whether additional debug output or visualisation 16 | * should be provided. 17 | */ 18 | fun create(inputPanel: SwingInputPanel, sceneNode: Node, uiDebug: Boolean) 19 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/edit/SwingVolumeProperties.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.commands.edit 2 | 3 | import graphics.scenery.Node 4 | import graphics.scenery.utils.lazyLogger 5 | import graphics.scenery.volumes.TransferFunctionEditor 6 | import graphics.scenery.volumes.Volume 7 | import net.miginfocom.swing.MigLayout 8 | import org.jfree.chart.ChartPanel 9 | import org.scijava.ui.swing.widget.SwingInputPanel 10 | import sc.iview.ui.SwingNodePropertyEditor.Companion.maybeActivateDebug 11 | import java.awt.Dimension 12 | import javax.swing.JPanel 13 | 14 | /** 15 | * Inspector extension that provides a [TransferFunctionEditor] for [Volume] nodes. 16 | */ 17 | class SwingVolumeProperties : SwingInspectorInteractiveCommandExtension { 18 | val logger by lazyLogger() 19 | 20 | /** 21 | * Creates a [TransferFunctionEditor] panel as child of the [inputPanel]'s Volume group. 22 | */ 23 | override fun create(inputPanel: SwingInputPanel, sceneNode: Node, uiDebug: Boolean) { 24 | if(sceneNode !is Volume) { 25 | logger.error("Wrong node type for SwingVolumeProperties") 26 | return 27 | } 28 | // This will find the group that corresponds to the expandable label. If the type of 29 | // the node is indeed Volume, this must exist. 30 | val parent = inputPanel.component.components.find { it.name == "group:Volume" } as? JPanel 31 | val tfe = TransferFunctionEditor(sceneNode) 32 | tfe.preferredSize = Dimension(300, 300) 33 | tfe.components.find { it is ChartPanel }?.minimumSize = Dimension(100, 200) 34 | 35 | tfe.layout = MigLayout("fillx,flowy,insets 0 0 0 0".maybeActivateDebug(uiDebug), "[right,fill,grow]") 36 | parent?.add(tfe, "span 2, growx") 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/view/RenderToOpenVRHMD.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.commands.view 30 | 31 | import org.scijava.command.Command 32 | import org.scijava.plugin.Menu 33 | import org.scijava.plugin.Parameter 34 | import org.scijava.plugin.Plugin 35 | import sc.iview.SciView 36 | import sc.iview.commands.MenuWeights.VIEW 37 | import sc.iview.commands.MenuWeights.VIEW_RENDER_TO_OPENVR 38 | 39 | /** 40 | * Activates rendering to an OpenVR headset 41 | * 42 | * @author Ulrik Guenther 43 | */ 44 | @Plugin(type = Command::class, menuRoot = "SciView", selectable = true, menu = [Menu(label = "View", weight = VIEW), Menu(label = "Render to OpenVR Headset", weight = VIEW_RENDER_TO_OPENVR)]) 45 | class RenderToOpenVRHMD : Command { 46 | @Parameter 47 | private lateinit var sciView: SciView 48 | 49 | override fun run() { 50 | sciView.toggleVRRendering() 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/view/SetFarPlane.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.commands.view 30 | 31 | import org.scijava.command.Command 32 | import org.scijava.plugin.Menu 33 | import org.scijava.plugin.Parameter 34 | import org.scijava.plugin.Plugin 35 | import sc.iview.SciView 36 | import sc.iview.commands.MenuWeights.VIEW 37 | import sc.iview.commands.MenuWeights.VIEW_SET_FAR_PLANE 38 | 39 | /** 40 | * Command to set the far plane for the renderer. Everything beyond this **will not** be rendered 41 | * 42 | * @author Kyle Harrington 43 | */ 44 | @Plugin(type = Command::class, menuRoot = "SciView", menu = [Menu(label = "View", weight = VIEW), Menu(label = "Set Far Plane", weight = VIEW_SET_FAR_PLANE)]) 45 | class SetFarPlane : Command { 46 | @Parameter 47 | private lateinit var sciView: SciView 48 | 49 | @Parameter 50 | private var farPlane = 1000f 51 | 52 | override fun run() { 53 | sciView.camera?.farPlaneDistance = farPlane 54 | } 55 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/view/StopAnimation.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.commands.view 30 | 31 | import org.scijava.command.Command 32 | import org.scijava.plugin.Menu 33 | import org.scijava.plugin.Parameter 34 | import org.scijava.plugin.Plugin 35 | import sc.iview.SciView 36 | import sc.iview.commands.MenuWeights.VIEW 37 | import sc.iview.commands.MenuWeights.VIEW_STOP_ANIMATION 38 | 39 | /** 40 | * Command to stop all current animations 41 | * 42 | * @author Kyle Harrington 43 | */ 44 | @Plugin(type = Command::class, menuRoot = "SciView", menu = [Menu(label = "View", weight = VIEW), Menu(label = "Stop Animation", weight = VIEW_STOP_ANIMATION)]) 45 | class StopAnimation : Command { 46 | @Parameter 47 | private lateinit var sciView: SciView 48 | 49 | override fun run() { 50 | sciView.stopAnimation() 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/view/StopRecordingVideo.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.commands.view 30 | 31 | import org.scijava.command.Command 32 | import org.scijava.plugin.Menu 33 | import org.scijava.plugin.Parameter 34 | import org.scijava.plugin.Plugin 35 | import sc.iview.SciView 36 | import sc.iview.commands.MenuWeights.VIEW 37 | import sc.iview.commands.MenuWeights.VIEW_STOP_RECORDING_VIDEO 38 | 39 | /** 40 | * Command to stop recording the current video 41 | * 42 | * @author Kyle Harrington 43 | */ 44 | @Plugin(type = Command::class, menuRoot = "SciView", menu = [Menu(label = "View", weight = VIEW), Menu(label = "Stop recording video", weight = VIEW_STOP_RECORDING_VIDEO)]) 45 | class StopRecordingVideo : Command { 46 | @Parameter 47 | private lateinit var sciView: SciView 48 | 49 | override fun run() { 50 | sciView.toggleRecordVideo() 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/view/ToggleInspector.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.commands.view 30 | 31 | import org.scijava.command.Command 32 | import org.scijava.plugin.Menu 33 | import org.scijava.plugin.Parameter 34 | import org.scijava.plugin.Plugin 35 | import sc.iview.SciView 36 | import sc.iview.commands.MenuWeights.VIEW 37 | import sc.iview.commands.MenuWeights.VIEW_TOGGLE_INSPECTOR 38 | 39 | /** 40 | * Command that displays a [SwingNodePropertyEditor] window. 41 | * 42 | * @author Curtis Rueden 43 | */ 44 | @Plugin(type = Command::class, initializer = "updateCommandFields", menuRoot = "SciView", menu = [Menu(label = "View", weight = VIEW), Menu(label = "Toggle Inspector", weight = VIEW_TOGGLE_INSPECTOR)]) 45 | class ToggleInspector : Command { 46 | @Parameter 47 | private lateinit var sciView: SciView 48 | 49 | override fun run() { 50 | sciView.toggleInspectorWindow() 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/commands/view/ToggleUnlimitedFramerate.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.commands.view 30 | 31 | import org.scijava.command.Command 32 | import org.scijava.plugin.Menu 33 | import org.scijava.plugin.Parameter 34 | import org.scijava.plugin.Plugin 35 | import sc.iview.SciView 36 | import sc.iview.commands.MenuWeights 37 | 38 | /** 39 | * Command to toggle scenery's PushMode. If this is true the scene only renders when it is changed, otherwise it is 40 | * continuously rendered 41 | * 42 | * @author Kyle Harrington 43 | */ 44 | @Plugin(type = Command::class, menuRoot = "SciView", menu = [Menu(label = "View", weight = MenuWeights.VIEW), Menu(label = "Toggle Unlimited Framerate", weight = MenuWeights.VIEW_TOGGLE_UNLIMITED_FRAMERATE)]) 45 | class ToggleUnlimitedFramerate : Command { 46 | @Parameter 47 | private lateinit var sciView: SciView 48 | 49 | override fun run() { 50 | sciView.setPushMode(!sciView.getPushMode()) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/controls/behaviours/ArcballResetMovementCommand.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.controls.behaviours 2 | import graphics.scenery.Camera 3 | import graphics.scenery.Node 4 | import graphics.scenery.controls.behaviours.MovementCommand 5 | import graphics.scenery.utils.extensions.minus 6 | import graphics.scenery.utils.extensions.plus 7 | import graphics.scenery.utils.extensions.times 8 | import org.joml.Vector3f 9 | import sc.iview.SciView 10 | 11 | class ArcballResetMovementCommand( 12 | direction: String, 13 | n: () -> Node?, 14 | speed: Float, 15 | private val sciview: SciView 16 | ) : MovementCommand(direction, n, speed) { 17 | 18 | @Synchronized override fun click(x: Int, y: Int) { 19 | // First, call the superclass method to handle the movement 20 | super.click(x, y) 21 | 22 | // Now, handle the arcball reset 23 | // Since you can't directly access the 'node', use 'n()' to get the current Node, which should be the Camera 24 | val cameraNode = sciview.camera 25 | 26 | // Assuming SciView has a method to get the camera and its position 27 | // And assuming 'targetArcball' is a feature of SciView you want to update 28 | val currentDistance = sciview.targetArcball.distance // Example to access current distance 29 | val newTargetPosition = cameraNode!!.spatial().position + cameraNode.forward.mul(currentDistance, Vector3f()) 30 | 31 | // Update the targetArcball's target to the new position 32 | // This assumes that 'targetArcball.target' is a setter method or lambda you can update 33 | sciview.targetArcball.target = { newTargetPosition } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/controls/behaviours/ClickAndDragWrapper.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.controls.behaviours 2 | 3 | import org.scijava.ui.behaviour.ClickBehaviour 4 | import org.scijava.ui.behaviour.DragBehaviour 5 | 6 | /** 7 | * Wraps one Click- and one DragBehavior into one behavior. 8 | * If the user clicks but does not drag, the click behavior is executed otherwise the drag behavior. 9 | * 10 | * @author Jan Tiemann 11 | */ 12 | class ClickAndDragWrapper(val click: ClickBehaviour, val drag: DragBehaviour): DragBehaviour { 13 | var dragged = false 14 | override fun init(x: Int, y: Int) { 15 | dragged = false 16 | } 17 | 18 | override fun drag(x: Int, y: Int) { 19 | if (!dragged) { 20 | dragged = true 21 | drag.init(x,y) 22 | } 23 | drag.drag(x,y) 24 | } 25 | 26 | override fun end(x: Int, y: Int) { 27 | if (dragged){ 28 | drag.end(x,y) 29 | } else { 30 | click.click(x,y) 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/ui/ContextPopUp.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.ui 30 | 31 | import graphics.scenery.Node 32 | import javax.swing.JMenuItem 33 | import javax.swing.JPopupMenu 34 | 35 | class ContextPopUp(n: Node) : JPopupMenu() { 36 | init { 37 | add(JMenuItem("Name: " + n.name)) 38 | add(JMenuItem("Type: ${n.javaClass.simpleName}")) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/ui/ContextPopUpNodeChooser.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.ui 30 | 31 | import sc.iview.SciView 32 | import javax.swing.JMenuItem 33 | import javax.swing.JPopupMenu 34 | 35 | class ContextPopUpNodeChooser(sv: SciView) : JPopupMenu() { 36 | init { 37 | sv.controls.objectSelectionLastResult?.matches?.forEach { match -> 38 | add( JMenuItem(match.node.name) ) 39 | .addActionListener { sv.setActiveNode(match.node) } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/ui/CustomPropertyUI.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.ui 2 | 3 | import org.scijava.module.Module 4 | import org.scijava.module.ModuleItem 5 | 6 | /** 7 | * Class for encapsulation of custom UI elements and their [Module]s. 8 | * 9 | * The constructor of the class performs a check upon initialisation to ensure that 10 | * all the [items] given actually do exist as inputs of the given [module]. 11 | * 12 | * @author Ulrik Guenther 13 | */ 14 | class CustomPropertyUI(val module: Module, val items: List) { 15 | init { 16 | val inputNames = module.inputs.map { it.key } 17 | items.forEach { 18 | if(it !in inputNames) { 19 | System.err.println("$it is not in known inputs of $module (${inputNames.joinToString(", ")})") 20 | throw IllegalStateException("Input $it not in list of known inputs for module $module.") 21 | } 22 | } 23 | } 24 | 25 | /** 26 | * Returns a list of [ModuleItem]s derived from the names given in [items]. 27 | */ 28 | fun getMutableInputs(): List> { 29 | return items.map { module.info.getInput(it) } 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/ui/SwingGroupingLabelListener.kt: -------------------------------------------------------------------------------- 1 | package sc.iview.ui 2 | 3 | import org.scijava.ui.swing.widget.SwingInputPanel 4 | import org.scijava.widget.InputPanel 5 | import java.awt.event.MouseEvent 6 | import java.awt.event.MouseListener 7 | import javax.swing.JLabel 8 | import javax.swing.JPanel 9 | 10 | /** 11 | * A [MouseListener] for opening and closing groups of the [SwingGroupingInputHarvester]. 12 | * This particular instance will be responsible for a given [groupName], attached to a [panel] 13 | * and [inputPanel]. A [label] needs to be handed over, the text of which changes depending 14 | * on the open/closed state of the group. 15 | */ 16 | open class SwingGroupingLabelListener( 17 | protected val groupName: String, 18 | protected val panel: SwingInputPanel, 19 | protected val inputPanel: InputPanel, 20 | protected val label: JLabel) : MouseListener { 21 | /** 22 | * Invoked when the mouse button has been clicked (pressed 23 | * and released) on a component. 24 | * @param e the event to be processed 25 | */ 26 | override fun mouseClicked(e: MouseEvent?) { 27 | if(e?.clickCount == 1) { 28 | panel.component.isVisible = !panel.component.isVisible 29 | 30 | if(panel.component.isVisible) { 31 | label.text = "▼ ${groupName}" 32 | } else { 33 | label.text = 34 | """ ${groupName}""" 35 | } 36 | inputPanel.component.revalidate() 37 | } 38 | } 39 | 40 | /** 41 | * Invoked when a mouse button has been pressed on a component. 42 | * @param e the event to be processed 43 | */ 44 | override fun mousePressed(e: MouseEvent?) { 45 | // noop 46 | } 47 | 48 | /** 49 | * Invoked when a mouse button has been released on a component. 50 | * @param e the event to be processed 51 | */ 52 | override fun mouseReleased(e: MouseEvent?) { 53 | // noop 54 | } 55 | 56 | /** 57 | * Invoked when the mouse enters a component. 58 | * @param e the event to be processed 59 | */ 60 | override fun mouseEntered(e: MouseEvent?) { 61 | // noop 62 | } 63 | 64 | /** 65 | * Invoked when the mouse exits a component. 66 | * @param e the event to be processed 67 | */ 68 | override fun mouseExited(e: MouseEvent?) { 69 | // noop 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /src/main/kotlin/sc/iview/ui/Task.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview.ui 30 | 31 | data class Task(val source: String, var status: String, var completion: Float = 0.0f) 32 | -------------------------------------------------------------------------------- /src/main/python/sciview.py: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # Scenery-backed 3D visualization package for ImageJ. 4 | # %% 5 | # Copyright (C) 2016 - 2024 sciview developers. 6 | # %% 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, 11 | # this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | # POSSIBILITY OF SUCH DAMAGE. 27 | # #L% 28 | ### 29 | import subprocess 30 | import os 31 | import sys 32 | 33 | # https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile 34 | def resource_path(relative_path): 35 | """ Get absolute path to resource, works for dev and for PyInstaller """ 36 | try: 37 | # PyInstaller creates a temp folder and stores path in _MEIPASS 38 | base_path = sys._MEIPASS 39 | except Exception: 40 | base_path = os.path.abspath(".") 41 | 42 | return os.path.join(base_path, relative_path) 43 | 44 | classpath = resource_path('./jars/*') 45 | classpath += ':%s' % resource_path( './jars/bio-formats/*' ) 46 | classpath += ':%s' % resource_path( './jars/linux32/*' ) 47 | classpath += ':%s' % resource_path( './jars/linux64/*' ) 48 | classpath += ':%s' % resource_path( './jars/macosx/*' ) 49 | classpath += ':%s' % resource_path( './jars/win32/*' ) 50 | classpath += ':%s' % resource_path( './jars/win64/*' ) 51 | 52 | subprocess.call(['java', '-cp', classpath, 'sc.iview.Main']) 53 | -------------------------------------------------------------------------------- /src/main/resources/SOURCES.md: -------------------------------------------------------------------------------- 1 | blub_control_mesh.ply from 2 | https://www.cs.cmu.edu/~kmcrane/Projects/ModelRepository/ 3 | Model and associated data is dedicated under CC0 1.0 Universal. 4 | 5 | -------------------------------------------------------------------------------- /src/main/resources/WieseRobert_simplified_Cip1.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/WieseRobert_simplified_Cip1.stl -------------------------------------------------------------------------------- /src/main/resources/blub_control_mesh.ply: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/blub_control_mesh.ply -------------------------------------------------------------------------------- /src/main/resources/cored_cube.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/cored_cube.tif -------------------------------------------------------------------------------- /src/main/resources/cored_cube_16bit.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/cored_cube_16bit.stl -------------------------------------------------------------------------------- /src/main/resources/cored_cube_16bit.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/cored_cube_16bit.tif -------------------------------------------------------------------------------- /src/main/resources/cored_cube_var2_8bit.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/cored_cube_var2_8bit.tif -------------------------------------------------------------------------------- /src/main/resources/sc/iview/commands/demo/animation/ParticleDemo.vert: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | #extension GL_ARB_separate_shader_objects: enable 3 | 4 | layout(location = 0) in vec3 vertexPosition; 5 | layout(location = 1) in vec3 vertexNormal; 6 | layout(location = 2) in vec2 vertexTexCoord; 7 | layout(location = 3) in mat4 iModelMatrix; 8 | layout(location = 7) in vec4 vertexColor; 9 | 10 | layout(location = 0) out VertexData { 11 | vec3 FragPosition; 12 | vec3 Normal; 13 | vec2 TexCoord; 14 | vec4 Color; 15 | } Vertex; 16 | 17 | layout(set = 2, binding = 0) uniform Matrices { 18 | mat4 ModelMatrix; 19 | mat4 NormalMatrix; 20 | int isBillboard; 21 | } ubo; 22 | 23 | struct Light { 24 | float Linear; 25 | float Quadratic; 26 | float Intensity; 27 | float Radius; 28 | vec4 Position; 29 | vec4 Color; 30 | }; 31 | 32 | layout(set = 1, binding = 0) uniform LightParameters { 33 | mat4 ViewMatrices[2]; 34 | mat4 InverseViewMatrices[2]; 35 | mat4 ProjectionMatrix; 36 | mat4 InverseProjectionMatrix; 37 | vec3 CamPosition; 38 | }; 39 | 40 | layout(set = 0, binding = 0) uniform VRParameters { 41 | mat4 projectionMatrices[2]; 42 | mat4 inverseProjectionMatrices[2]; 43 | mat4 headShift; 44 | float IPD; 45 | int stereoEnabled; 46 | } vrParameters; 47 | 48 | layout(push_constant) uniform currentEye_t { 49 | int eye; 50 | } currentEye; 51 | 52 | void main() 53 | { 54 | mat4 mv; 55 | mat4 nMVP; 56 | mat4 projectionMatrix; 57 | 58 | mv = (vrParameters.stereoEnabled ^ 1) * ViewMatrices[0] * iModelMatrix + (vrParameters.stereoEnabled * ViewMatrices[currentEye.eye] * iModelMatrix); 59 | projectionMatrix = (vrParameters.stereoEnabled ^ 1) * ProjectionMatrix + vrParameters.stereoEnabled * vrParameters.projectionMatrices[currentEye.eye]; 60 | 61 | if(ubo.isBillboard > 0) { 62 | mv[0][0] = 1.0f; 63 | mv[0][1] = .0f; 64 | mv[0][2] = .0f; 65 | 66 | mv[1][0] = .0f; 67 | mv[1][1] = 1.0f; 68 | mv[1][2] = .0f; 69 | 70 | mv[2][0] = .0f; 71 | mv[2][1] = .0f; 72 | mv[2][2] = 1.0f; 73 | } 74 | 75 | nMVP = projectionMatrix*mv; 76 | 77 | mat4 normalMatrix = transpose(inverse(iModelMatrix)); 78 | Vertex.Normal = mat3(normalMatrix) * normalize(vertexNormal); 79 | Vertex.TexCoord = vertexTexCoord; 80 | Vertex.FragPosition = vec3(iModelMatrix * vec4(vertexPosition, 1.0)); 81 | Vertex.Color = vertexColor; 82 | 83 | gl_Position = nMVP * vec4(vertexPosition, 1.0); 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/main/resources/sc/iview/sciview-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/sciview-logo.png -------------------------------------------------------------------------------- /src/main/resources/sc/iview/startup.py: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # Scenery-backed 3D visualization package for ImageJ. 4 | # %% 5 | # Copyright (C) 2016 - 2024 sciview developers. 6 | # %% 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, 11 | # this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | # POSSIBILITY OF SUCH DAMAGE. 27 | # #L% 28 | ### 29 | import sc.iview.SciView as SciView 30 | from org.joml import * 31 | from graphics.scenery import * 32 | from graphics.scenery.volumes import * 33 | from graphics.scenery.volumes import TransferFunction 34 | from graphics.scenery.volumes import Colormap 35 | from graphics.scenery.utils import * 36 | 37 | print("Welcome to SciView. Enjoy the scenery!") 38 | -------------------------------------------------------------------------------- /src/main/resources/sc/iview/terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/terminal.png -------------------------------------------------------------------------------- /src/main/resources/sc/iview/toolbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/toolbox.png -------------------------------------------------------------------------------- /src/main/resources/sc/iview/ui/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/ui/camera.png -------------------------------------------------------------------------------- /src/main/resources/sc/iview/ui/light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/ui/light.png -------------------------------------------------------------------------------- /src/main/resources/sc/iview/ui/mesh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/ui/mesh.png -------------------------------------------------------------------------------- /src/main/resources/sc/iview/ui/node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/ui/node.png -------------------------------------------------------------------------------- /src/main/resources/sc/iview/ui/scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/ui/scene.png -------------------------------------------------------------------------------- /src/main/resources/sc/iview/ui/text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/ui/text.png -------------------------------------------------------------------------------- /src/main/resources/sc/iview/ui/volume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/main/resources/sc/iview/ui/volume.png -------------------------------------------------------------------------------- /src/test/java/sc/iview/VolumeScriptTest.java: -------------------------------------------------------------------------------- 1 | package sc.iview; 2 | 3 | import org.scijava.command.CommandService; 4 | import org.scijava.script.ScriptService; 5 | 6 | import java.io.BufferedWriter; 7 | import java.io.File; 8 | import java.io.FileWriter; 9 | import java.util.HashMap; 10 | 11 | public class VolumeScriptTest { 12 | 13 | static String script = "# @SciView sv\n" + 14 | "# @UIService ui\n\n" + 15 | "import net.imglib2.img.array.ArrayImgs as ArrayImgs\n" + 16 | "w = 100\n" + 17 | "h = w\n" + 18 | "d = w\n" + 19 | "img = ArrayImgs.unsignedBytes(w, h, d)\n" + 20 | "img_ra = img.randomAccess()\n" + 21 | "for x in range(0, w):\n" + 22 | " for y in range(0, h):\n" + 23 | " for z in range(0, d):\n" + 24 | " img_ra.setPosition([x, y, z])\n" + 25 | " x0 = x - 50\n" + 26 | " y0 = y - 50\n" + 27 | " z0 = z - 50\n" + 28 | " val = 255 - (x0**2 + y0**2 + z0**2) ** 0.65\n" + 29 | " img_ra.get().setReal(val)\n" + 30 | "ui.show(img)\n" + 31 | "sv.addVolume(img)\n"; 32 | 33 | public static void main(String... args) throws Exception { 34 | SciView sv = SciView.create(); 35 | 36 | ScriptService scriptService = sv.getScijavaContext().getService(ScriptService.class); 37 | 38 | File file = File.createTempFile("sciview-script", ".py"); 39 | file.deleteOnExit(); 40 | 41 | BufferedWriter writer = new BufferedWriter(new FileWriter(file)); 42 | writer.write(script); 43 | writer.close(); 44 | 45 | scriptService.run(file, true, new HashMap()); 46 | scriptService.run(file, true, new HashMap()); 47 | 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/test/kotlin/sc/iview/ImageJMainTest.kt: -------------------------------------------------------------------------------- 1 | /*- 2 | * #%L 3 | * Scenery-backed 3D visualization package for ImageJ. 4 | * %% 5 | * Copyright (C) 2016 - 2024 sciview developers. 6 | * %% 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | * POSSIBILITY OF SUCH DAMAGE. 27 | * #L% 28 | */ 29 | package sc.iview 30 | 31 | /** 32 | * Entry point for testing SciView functionality. 33 | * 34 | * @author Kyle Harrington 35 | * @author Ulrik Guenther 36 | */ 37 | object ImageJMainTest { 38 | @JvmStatic 39 | fun main(args: Array) { 40 | ImageJMain.main(args) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/resources/outputs/sphere_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scenerygraphics/sciview/26738f7a809633c56fa2ce6489d628233bcd92b1/src/test/resources/outputs/sphere_test.png -------------------------------------------------------------------------------- /src/test/resources/scripts/sphere_test.py: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # Scenery-backed 3D visualization package for ImageJ. 4 | # %% 5 | # Copyright (C) 2016 - 2024 sciview developers. 6 | # %% 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, 11 | # this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | # POSSIBILITY OF SUCH DAMAGE. 27 | # #L% 28 | ### 29 | #@SciView sciView 30 | 31 | import cleargl 32 | 33 | # Add a sphere to the scene 34 | sphere = sciView.addSphere() 35 | 36 | # Make the sphere red 37 | sphere.getMaterial().setDiffuse(cleargl.GLVector([1,0,0])) 38 | sphere.getMaterial().setSpecular(cleargl.GLVector([1,0,0])) 39 | sphere.getMaterial().setAmbient(cleargl.GLVector([1,0,0])) 40 | 41 | # Center the camera on the sphere 42 | sciView.centerOnNode(sphere) 43 | -------------------------------------------------------------------------------- /src/test/resources/scripts/volume_test.py: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # Scenery-backed 3D visualization package for ImageJ. 4 | # %% 5 | # Copyright (C) 2016 - 2024 sciview developers. 6 | # %% 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright notice, 11 | # this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 20 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | # POSSIBILITY OF SUCH DAMAGE. 27 | # #L% 28 | ### 29 | #@SciView sciView 30 | #@Dataset img 31 | 32 | # Add a Volume to the scene 33 | vol = sciView.addVolume(img, "Test Volume", [1,1,1]) 34 | 35 | # Center the camera on the sphere 36 | sciView.centerOnNode(vol) 37 | --------------------------------------------------------------------------------