Skip to content

Commit

Permalink
added support for adding colomaps and the RdBu maps. Also removed bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerHeintzmann committed Nov 26, 2024
1 parent eb6cbb2 commit b2a2626
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 91 deletions.
8 changes: 4 additions & 4 deletions javacAll
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ cp "$myjar" "/mnt/c/NoBackup/DeconvCompileTest/DIPlib_3_2017/share/DIPimage/pri
cp "$myjar" "/mnt/c/NoBackup/DeconvCompileTest/DIPlib_3_2019/share/DIPimage/private/View5D.jar"
cp "$myjar" "../View5D.jar"
cp "$myjar" "/mnt/c/Users/pi96doc/.julia/artifacts/View5D.jar"
cp "$myjar" "C:\Program Files\DIPimage 2.9\common\dipimage\private\View5D.jar"
cp "$myjar" "C:\Program Files\DIPlib_3_2019\share\DIPimage\private\View5D.jar"
cp "$myjar" "C:\NoBackup\DeconvCompileTest\DIPlib_3_2019\share\DIPimage\private\View5D.jar"
cp "$myjar" "C:\NoBackup\DeconvCompileTest\DIPlib_3_2017\share\DIPimage\private\View5D.jar"
cp "$myjar" "/mnt/c/Program Files/DIPimage 2.9/common/dipimage/private/View5D.jar"
cp "$myjar" "/mnt/c/Program Files/DIPlib_3_2019/share/DIPimage/private/View5D.jar"
cp "$myjar" "/mnt/c/NoBackup/DeconvCompileTest/DIPlib_3_2019/share/DIPimage/private/View5D.jar"
cp "$myjar" "/mnt/c/NoBackup/DeconvCompileTest/DIPlib_3_2017/share/DIPimage/private/View5D.jar"
cp "$myjar" "/mnt/c/Users/pi96doc/Desktop/UserPrograms/fiji-win64/Fiji.app/plugins/"
tar -czf "${myjar%.jar}.tar.gz" "$myjar"
# cp /*.class /usr/local/ImageJ/plugins/View5D/
Expand Down
27 changes: 16 additions & 11 deletions src/main/java/view5d/AlternateViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,22 @@ public AlternateViewer(Container myapplet, int width, int height) {
}

public void Assign3DData(Container myapplet, ImgPanel ownerPanel, My3DData cloneddata) {
cloned = cloneddata; // new My3DData(datatoclone);
ImgPanel np=new ImgPanel(myapplet,cloneddata);
if (!(applet instanceof View5D))
((View5D_) applet).panels.addElement(np); // enter this view into the list
else
((View5D) applet).panels.addElement(np); // enter this view into the list
np.OwnerPanel(ownerPanel);
mycomponent=np;
np.CheckScrollBar();
add("Center", np);
setVisible(true);
cloned = cloneddata; // new My3DData(datatoclone);

ImgPanel np=new ImgPanel(myapplet,cloneddata);

if (!(applet instanceof View5D)) {
((View5D_) applet).panels.addElement(np); // enter this view into the list
}
else {
((View5D) applet).panels.addElement(np); // enter this view into the list
((View5D) applet).mypan = np; // ensure that the viewer main class accepts this as the main panel
}
np.OwnerPanel(ownerPanel);
mycomponent=np;
np.CheckScrollBar();
add("Center", np);
setVisible(true);
}

public void AssignPixelDisplay(PixelDisplay pd) {
Expand Down
81 changes: 57 additions & 24 deletions src/main/java/view5d/Bundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public class Bundle extends Object implements Cloneable { // this class bundles
private double mincs=0.0,maxcs=1.0;
private double ProjMincs[]={0.0,0.0},ProjMaxcs[]={1.0,1.0}; // For the different projection modes (Max, Avg)
public int ElementModelNr=0; // just a number for the current model
final static int ElementModels=13; // Nr of element models
final static String ElementModelName[]={"GrayScale","Red","Green","Blue","Purple","Glow Red","Glow Green-Blue","Glow Green-Yellow","Glow Blue","Glow Purple","Rainbow","Random","Cyclic"}; // Nr of element models
final static int ElementModels=15; // Nr of element models
final static String ElementModelName[]={"GrayScale","Red","Green","Blue","Purple","Glow Red","Glow Green-Blue","Glow Green-Yellow","Glow Blue","Glow Purple","Rainbow","Random","Cyclic","RdBu", "RdBu_r"}; // Nr of element models
byte cmapRed[],cmapGreen[],cmapBlue[];
static Vector<Integer> MapSizes = new Vector<Integer>();
static Vector<byte[]> RedMaps = new Vector<byte[]>(),GreenMaps = new Vector<byte[]>(),BlueMaps = new Vector<byte[]>(); // For user-supplied colormaps
Expand Down Expand Up @@ -188,8 +188,8 @@ public static Color ColFromHue(float tmp)

public void CompCMap() { // computes the color map of this element
double tmp;
double LogGain = (double) MaxCTable;
double LogCalib = java.lang.Math.log(LogGain+1.0);
double LogGain = (double) MaxCTable;
double LogCalib = java.lang.Math.log(LogGain+1.0);
Random myrnd= new Random(0);

for (int i=0;i<MaxCTable;i++)
Expand Down Expand Up @@ -251,12 +251,12 @@ public void CompCMap() { // computes the color map of this element
cmapGreen[i]=0;
cmapBlue[i]=(byte) (tmp * 255);
break;
case 5: // Nonlin glow Red
case 5: // Nonlin GlowRed
cmapRed[i]=(byte) (255*CClip(tmp*3.0));
cmapGreen[i]=(byte) (255*CClip(tmp*3.0-1.0));
cmapBlue[i]=(byte) (255*CClip(tmp*3.0-2.0));
break;
case 6: // Nonlin glow Green
case 6: // Nonlin GlowGreen
cmapRed[i]=(byte) (255.0*CClip(tmp*3.0-2.0));
cmapGreen[i]=(byte) (255.0*CClip(tmp*3.0));
cmapBlue[i]=(byte) (255.0*CClip(tmp*3.0-1.0));
Expand Down Expand Up @@ -287,7 +287,7 @@ public void CompCMap() { // computes the color map of this element
cmapBlue[i]=(byte) (0);
}
break;
case 11: // Random Colors
case 11: // Cyclic Colors
if (i==0)
{
cmapRed[i]=(byte) (0);
Expand All @@ -303,38 +303,71 @@ public void CompCMap() { // computes the color map of this element
break;
case 12: // Random Colors
if (tmp < 1/3.0)
{
{
cmapRed[i]=(byte) (255*MClip(1-tmp*3));
cmapGreen[i]=(byte) (255*MClip(tmp*3));
cmapBlue[i]=(byte) 0;
}
}
if (tmp>= 1/3.0 && tmp < 2/3.0)
{
{
cmapRed[i]=(byte) 0;
cmapGreen[i]=(byte) (255*MClip(1-(tmp-1/3.0)*3));
cmapBlue[i]=(byte) (255*MClip((tmp-1/3.0)*3));
}
}
if (tmp>= 2/3.0)
{
{
cmapRed[i]=(byte) (255*MClip((tmp-2/3.0)*3));
cmapGreen[i]=(byte) 0;
cmapBlue[i]=(byte) (255*MClip(1-(tmp-2/3.0)*3));
}
}
if (i==0)
{
cmapRed[i]=(byte) (0);
cmapGreen[i]=(byte) (0);
cmapBlue[i]=(byte) (0);
cmapRed[i]=(byte) (0);
cmapGreen[i]=(byte) (0);
cmapBlue[i]=(byte) (0);
}
break;
default: // a user supplied colormap
int elem=ElementModelNr-ElementModels;
int MapSize=MapSizes.elementAt(elem).intValue();
//int MapSize=((byte []) RedMaps.elementAt(elem)).length;
int index=(int) ((MapSize-1)*tmp);
cmapRed[i]=RedMaps.elementAt(elem)[index];
cmapGreen[i]=GreenMaps.elementAt(elem)[index];
cmapBlue[i]=BlueMaps.elementAt(elem)[index];
case 13: // RdBu
if (tmp < 1/2.0)
{ // high reference (103, 0, 5)
double lb = MClip(1-tmp*2);
cmapRed[i]=(byte) (255-152*lb);
cmapGreen[i]=(byte) (255-255*lb);
// cmapBlue[i]=(byte) (255-224*lb);
cmapBlue[i]=(byte) (255-250*lb);
}
else
{ // low reference (5, 48, 97)
double rb = MClip(tmp*2-1);
cmapRed[i]=(byte) (255-250*rb);
cmapGreen[i]=(byte) (255-207*rb);
cmapBlue[i]=(byte) (255-158*rb);
}
break;
case 14: // RdBu_r
if (tmp < 1/2.0)
{ // low reference (5, 48, 97)
double lb = MClip(1-tmp*2);
cmapRed[i]=(byte) (255-250*lb);
cmapGreen[i]=(byte) (255-207*lb);
cmapBlue[i]=(byte) (255-158*lb);
}
else
{ // high reference (103, 0, 5)
double rb = MClip(tmp*2-1);
cmapRed[i]=(byte) (255-152*rb);
cmapGreen[i]=(byte) (255-255*rb);
cmapBlue[i]=(byte) (255-250*rb);
}
break;
default: // a user supplied colormap
int elem=ElementModelNr-ElementModels;
int MapSize=MapSizes.elementAt(elem).intValue();
//int MapSize=((byte []) RedMaps.elementAt(elem)).length;
int index=(int) ((MapSize-1)*tmp);
cmapRed[i]=RedMaps.elementAt(elem)[index];
cmapGreen[i]=GreenMaps.elementAt(elem)[index];
cmapBlue[i]=BlueMaps.elementAt(elem)[index];
}
if (cmapIsInverse)
{
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/view5d/ImageCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -2180,9 +2180,9 @@ else if ((my3ddata.Times > 1))
case 'l':
if (!(applet instanceof View5D))
((View5D_) applet).LoadImg(0);
else {
my3ddata.Load(my3ddata.PrevType, my3ddata.PrevBytes, my3ddata.PrevBits, ((View5D) applet).getDocumentBase() + ((View5D) applet).filename); // ((View5D) applet) commented out for now, since the document base is unknown for non-applets
UpdateAllPanels();
else { // do nothing
// my3ddata.Load(my3ddata.PrevType, my3ddata.PrevBytes, my3ddata.PrevBits, ((View5D) applet).getDocumentBase() + ((View5D) applet).filename); // ((View5D) applet) commented out for now, since the document base is unknown for non-applets
// UpdateAllPanels();
}
UpdateAll(); // To display mask
return;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/view5d/ImgPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ public ImgPanel(Container app,My3DData mydata) {
tmp = new MenuItem("Force new histogram window [H]");
tmp.addActionListener(new MyMenuProcessor(c1,'H')); SubMenu.add(tmp);

label = new PositionLabel("View5D initialization.",c1,c2,c3,data3d);
grid.add(label);
label = new PositionLabel("View5D initialization.",c1,c2,c3,data3d);
grid.add(label);

c1.ConnectLabel(label);
c2.ConnectLabel(label);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/view5d/My3DData.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class My3DData extends Object {

public Vector<Vector<AnElement>> MyTimes;
public Vector<Vector<ASlice>[]> MyTimeProj; // this stores all the different multi element projection data as a vector of vectors
public int Times=0,ActiveTime=0;
public int Times=0, ActiveTime=0;
public Vector<ASlice[]> MyTimeColorProj; // a vector of an array of ASlice
// public Vector TimeValues; // keeps track of the exact time points

Expand Down
74 changes: 37 additions & 37 deletions src/main/java/view5d/PixelDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

import java.awt.image.*;
import java.awt.event.*;
import java.awt.Graphics;
import java.awt.*;
import java.util.*;
import java.text.*;
Expand All @@ -74,74 +73,75 @@ public class PixelDisplay extends Panel implements MouseListener,MouseWheelListe
PopupMenu MyPopupMenu;
Menu ColorMenu;

void AddColorMenu(String Name,int i)
void AddColorMenu(String Name, int i)
{
MenuItem tmp;
tmp = new MenuItem(Name);
tmp.addActionListener(new MyMenuProcessor(this,c1,false,i)); ColorMenu.add(tmp);
tmp.addActionListener(new MyMenuProcessor(this, c1,false,i));
ColorMenu.add(tmp);
tmp = new MenuItem(Name+" (inverted)");
tmp.addActionListener(new MyMenuProcessor(this,c1,true,i)); ColorMenu.add(tmp);
tmp.addActionListener(new MyMenuProcessor(this, c1,true,i));
ColorMenu.add(tmp);
}

PixelDisplay(My3DData data, ImageCanvas C1,ImageCanvas C2, ImageCanvas C3)
{
c1 = C1;
c2 = C2;
c3 = C3;
data3d = data;
// Rectangle r=getBounds();
// System.out.println("Rectangle "+r);
setBounds(0,0,200,50);
// r=getBounds();
// System.out.println("Rectangle "+r);
// initialize();
if (data.Elements > 5)
PlotMode = 1; // Spectrum Plot

addMouseListener(this); // register this class for handling the events in it
addMouseWheelListener(this); // register this class for handling the events in it
addKeyListener(this); // register this class for handling the events in it
c1 = C1;
c2 = C2;
c3 = C3;
data3d = data;
// Rectangle r=getBounds();
// System.out.println("Rectangle "+r);
setBounds(0,0,200,50);
// r=getBounds();
// System.out.println("Rectangle "+r);
// initialize();
if (data.Elements > 5)
PlotMode = 1; // Spectrum Plot

addMouseListener(this); // register this class for handling the events in it
addMouseWheelListener(this); // register this class for handling the events in it
addKeyListener(this); // register this class for handling the events in it

MyPopupMenu =new PopupMenu("Element Menu"); // tear off menu
add(MyPopupMenu);
add(MyPopupMenu);

Menu SubMenu = new Menu("General",false); // can eventually be dragged to the side
MyPopupMenu.add(SubMenu);

MenuItem tmp;
tmp = new MenuItem("initialise scaling [i]");
tmp.addActionListener(new MyMenuProcessor(this,'i')); SubMenu.add(tmp);
tmp = new MenuItem("Set Value Units and Scalings [N]");
tmp.addActionListener(new MyMenuProcessor(this,'N')); SubMenu.add(tmp);
tmp = new MenuItem("eXport to ImageJ (ImageJ only) [X]");
tmp.addActionListener(new MyMenuProcessor(this,'X')); SubMenu.add(tmp);
tmp = new MenuItem("initialise scaling [i]");
tmp.addActionListener(new MyMenuProcessor(this,'i')); SubMenu.add(tmp);
tmp = new MenuItem("Set Value Units and Scalings [N]");
tmp.addActionListener(new MyMenuProcessor(this,'N')); SubMenu.add(tmp);
tmp = new MenuItem("eXport to ImageJ (ImageJ only) [X]");
tmp.addActionListener(new MyMenuProcessor(this,'X')); SubMenu.add(tmp);

SubMenu = new Menu("Markers",false); // can eventually be dragged to the side
MyPopupMenu.add(SubMenu);
tmp = new MenuItem("Marker Menu [M]");
tmp.addActionListener(new MyMenuProcessor(this,'M')); SubMenu.add(tmp);
tmp = new MenuItem("print/save marker list [m]");
tmp.addActionListener(new MyMenuProcessor(this,'m')); SubMenu.add(tmp);
tmp = new MenuItem("Marker Menu [M]");
tmp.addActionListener(new MyMenuProcessor(this,'M')); SubMenu.add(tmp);
tmp = new MenuItem("print/save marker list [m]");
tmp.addActionListener(new MyMenuProcessor(this,'m')); SubMenu.add(tmp);

SubMenu = new Menu("Plotting",false); // can eventually be dragged to the side
MyPopupMenu.add(SubMenu);
tmp = new MenuItem("spawn plot display [s]");
tmp.addActionListener(new MyMenuProcessor(this,'s')); SubMenu.add(tmp);
tmp.addActionListener(new MyMenuProcessor(this,'s')); SubMenu.add(tmp);
tmp = new MenuItem("toggle plot display [q]");
tmp.addActionListener(new MyMenuProcessor(this,'q')); SubMenu.add(tmp);
tmp.addActionListener(new MyMenuProcessor(this,'q')); SubMenu.add(tmp);
tmp = new MenuItem("normalize plot display [n]");
tmp.addActionListener(new MyMenuProcessor(this,'n')); SubMenu.add(tmp);
tmp.addActionListener(new MyMenuProcessor(this,'n')); SubMenu.add(tmp);
tmp = new MenuItem("logarithmic mode [O]");
tmp.addActionListener(new MyMenuProcessor(this,'O')); SubMenu.add(tmp);
tmp.addActionListener(new MyMenuProcessor(this,'O')); SubMenu.add(tmp);
SubMenu = new Menu("ColorMaps",false); // can eventually be dragged to the side
MyPopupMenu.add(SubMenu);
ColorMenu=SubMenu; // is used in AddColorMenu

for (int i=0;i<Bundle.ElementModels;i++)
{
AddColorMenu(Bundle.ElementModelName[i],i);
AddColorMenu(Bundle.ElementModelName[i], i);
}

}

@Override
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/view5d/PositionLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public PositionLabel(String text, ImageCanvas C1, ImageCanvas C2, ImageCanvas C3
MyText.setFont(new Font(data3d.FontType, Font.PLAIN, data3d.FontSize));
MyText.setEditable(false);
PixDisplay = new PixelDisplay(data, c1, c2, c3);

nf = java.text.NumberFormat.getNumberInstance(Locale.US);
nf.setMaximumFractionDigits(6);
// nf.setMinimumIntegerDigits(7);
Expand Down Expand Up @@ -185,7 +186,12 @@ void TextDisplayDialog() { // allows the user to define the units and scales

void Help() {
// javax.swing.JOptionPane.showMessageDialog(applet,
String newtext = "Java 5D image viewer, Version V" + View5D_.VersionString + // serialVersionUID + "." + View5D_.serialSubVersionUID + "." + View5D_.serialSubSubVersionUID + "" +
String Version;
if ((data3d.applet instanceof View5D))
Version = ((View5D) data3d.applet).getVersion();
else
Version = ((View5D_) data3d.applet).getVersion();
String newtext = "Java 5D image viewer, Version V" + Version + // serialVersionUID + "." + View5D_.serialSubVersionUID + "." + View5D_.serialSubSubVersionUID + "" +
" by Rainer Heintzmann\nLeibniz-IPHT and Friedrich Schiller University of Jena, Germany ([email protected])\n\n" +
"NAVIGATION: Right-click for menu and context menus (individual for panels, colopmap list and text panel)\nUse mouse click for changing slices or cursor keys (arrows) and next/previous page keys.\n" +
"Zoom in and out via the mouse wheel. Press `shift` and use the mouse wheel to change the LUT gamma value. `shift middle mouse click resets gamma to one`\n +" +
Expand Down
Loading

0 comments on commit b2a2626

Please sign in to comment.