Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BigDataViewer_Fiji_Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
BigDataViewer_Fiji_Plugin
Commits
0a4984c1
Commit
0a4984c1
authored
Jan 20, 2015
by
HongKee Moon
Browse files
Options
Downloads
Patches
Plain Diff
Add BigDataBrowserPlugin for access to BigDataServer
parent
3f8f3434
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/bdv/ij/BigDataBrowserPlugin.java
+214
-0
214 additions, 0 deletions
src/main/java/bdv/ij/BigDataBrowserPlugin.java
src/main/resources/plugins.config
+1
-0
1 addition, 0 deletions
src/main/resources/plugins.config
with
215 additions
and
0 deletions
src/main/java/bdv/ij/BigDataBrowserPlugin.java
0 → 100644
+
214
−
0
View file @
0a4984c1
package
bdv.ij
;
import
bdv.BigDataViewer
;
import
bdv.ij.util.ProgressWriterIJ
;
import
com.google.gson.stream.JsonReader
;
import
ij.IJ
;
import
ij.ImageJ
;
import
ij.plugin.PlugIn
;
import
mpicbg.spim.data.SpimDataException
;
import
org.apache.commons.lang.StringUtils
;
import
javax.imageio.ImageIO
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.awt.image.BufferedImage
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
BigDataBrowserPlugin
implements
PlugIn
{
Map
<
String
,
ImageIcon
>
imageMap
=
new
HashMap
<
String
,
ImageIcon
>();
Map
<
String
,
String
>
datasetUrlMap
=
new
HashMap
<
String
,
String
>();
@Override
public
void
run
(
final
String
arg
)
{
BufferedImage
image
=
null
;
try
{
image
=
ImageIO
.
read
(
new
URL
(
"http://fiji.sc/_images/a/ae/Fiji-icon.png"
)
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
String
serverUrl
=
"http://scicomp-pc-1-10gb:8070"
;
// Clipboard access for getting bigdataserver url
// Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
// Transferable t = c.getContents( this );
// if ( t != null )
// {
// try
// {
// serverUrl = ( String ) t.getTransferData( DataFlavor.stringFlavor );
// }
// catch ( Exception e )
// {
// e.printStackTrace();
// }
//
// if ( !serverUrl.startsWith( "http://" ) )
// {
// serverUrl = "http://" + serverUrl;
// }
// }
boolean
ret
;
do
{
Object
remoteUrl
=
JOptionPane
.
showInputDialog
(
null
,
"Enter BigDataServer Remote URL:"
,
"BigDataServer"
,
JOptionPane
.
QUESTION_MESSAGE
,
new
ImageIcon
(
image
),
null
,
serverUrl
);
if
(
remoteUrl
==
null
)
{
IJ
.
showMessage
(
"The given URL is null. Please, check it again."
);
break
;
}
ArrayList
<
String
>
nameList
=
new
ArrayList
<
String
>();
ret
=
getDatasetList
(
remoteUrl
.
toString
(),
nameList
);
if
(
!
ret
)
IJ
.
showMessage
(
"The server is not available."
);
else
createDatasetListUI
(
nameList
.
toArray
()
);
}
while
(
!
ret
);
}
private
boolean
getDatasetList
(
String
remoteUrl
,
ArrayList
<
String
>
nameList
)
{
try
{
// Get JSON string from the server
final
URL
url
=
new
URL
(
remoteUrl
+
"/json/"
);
final
InputStream
is
=
url
.
openStream
();
final
JsonReader
reader
=
new
JsonReader
(
new
InputStreamReader
(
is
,
"UTF-8"
)
);
reader
.
beginObject
();
while
(
reader
.
hasNext
()
)
{
// skipping id
reader
.
nextName
();
reader
.
beginObject
();
String
name
=
reader
.
nextName
();
String
id
=
null
,
description
=
null
,
thumbnailUrl
=
null
,
datasetUrl
=
null
;
if
(
name
.
equals
(
"id"
)
)
{
id
=
reader
.
nextString
();
nameList
.
add
(
id
);
}
name
=
reader
.
nextName
();
if
(
name
.
equals
(
"description"
)
)
{
description
=
reader
.
nextString
();
}
name
=
reader
.
nextName
();
if
(
name
.
equals
(
"thumbnailUrl"
)
)
{
thumbnailUrl
=
reader
.
nextString
();
if
(
StringUtils
.
isNotEmpty
(
thumbnailUrl
)
)
imageMap
.
put
(
id
,
new
ImageIcon
(
new
URL
(
thumbnailUrl
)
)
);
}
name
=
reader
.
nextName
();
if
(
name
.
equals
(
"datasetUrl"
)
)
{
datasetUrl
=
reader
.
nextString
();
datasetUrlMap
.
put
(
id
,
datasetUrl
);
}
reader
.
endObject
();
}
reader
.
endObject
();
}
catch
(
IOException
exception
)
{
exception
.
printStackTrace
();
return
false
;
}
return
true
;
}
private
void
createDatasetListUI
(
Object
[]
values
)
{
JList
list
=
new
JList
(
values
);
list
.
setCellRenderer
(
new
ThumbnailListRenderer
()
);
list
.
addMouseListener
(
new
MouseAdapter
()
{
public
void
mouseClicked
(
MouseEvent
evt
)
{
JList
list
=
(
JList
)
evt
.
getSource
();
if
(
evt
.
getClickCount
()
==
2
)
{
int
index
=
list
.
locationToIndex
(
evt
.
getPoint
()
);
String
key
=
String
.
valueOf
(
list
.
getModel
().
getElementAt
(
index
)
);
System
.
out
.
println
(
key
);
try
{
BigDataViewer
.
view
(
datasetUrlMap
.
get
(
key
),
new
ProgressWriterIJ
()
);
}
catch
(
SpimDataException
e
)
{
e
.
printStackTrace
();
}
}
}
}
);
JScrollPane
scroll
=
new
JScrollPane
(
list
);
scroll
.
setPreferredSize
(
new
Dimension
(
300
,
400
)
);
JFrame
frame
=
new
JFrame
();
frame
.
add
(
scroll
);
frame
.
setDefaultCloseOperation
(
JFrame
.
DISPOSE_ON_CLOSE
);
frame
.
pack
();
frame
.
setLocationRelativeTo
(
null
);
frame
.
setVisible
(
true
);
}
public
class
ThumbnailListRenderer
extends
DefaultListCellRenderer
{
Font
font
=
new
Font
(
"helvitica"
,
Font
.
BOLD
,
12
);
@Override
public
Component
getListCellRendererComponent
(
JList
list
,
Object
value
,
int
index
,
boolean
isSelected
,
boolean
cellHasFocus
)
{
JLabel
label
=
(
JLabel
)
super
.
getListCellRendererComponent
(
list
,
value
,
index
,
isSelected
,
cellHasFocus
);
label
.
setIcon
(
imageMap
.
get
(
(
String
)
value
)
);
label
.
setHorizontalTextPosition
(
JLabel
.
RIGHT
);
label
.
setFont
(
font
);
return
label
;
}
}
public
static
void
main
(
final
String
[]
args
)
{
new
ImageJ
();
new
BigDataBrowserPlugin
().
run
(
null
);
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/plugins.config
+
1
−
0
View file @
0a4984c1
...
...
@@ -10,6 +10,7 @@
# will get that as arg parameter; otherwise arg is simply the empty string.
Plugins
>
BigDataViewer
,
"Open XML/HDF5"
,
bdv
.
ij
.
BigDataViewerPlugIn
Plugins
>
BigDataViewer
,
"Open Remote BigData"
,
bdv
.
ij
.
BigDataBrowserPlugIn
Plugins
>
BigDataViewer
,
"Export Current Image as XML/HDF5"
,
bdv
.
ij
.
ExportImagePlusPlugIn
Plugins
>
BigDataViewer
,
"Export Spim Sequence as XML/HDF5"
,
bdv
.
ij
.
ExportSpimSequencePlugIn
Plugins
>
BigDataViewer
,
"Export Fused Sequence as XML/HDF5"
,
bdv
.
ij
.
ExportSpimFusionPlugIn
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment