MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / run

Method run

ij/src/main/java/ij/plugin/LUT_Editor.java:26–78  ·  view source on GitHub ↗
(String args)

Source from the content-addressed store, hash-verified

24 int bitDepth;
25
26 public void run(String args) {
27 ImagePlus imp = WindowManager.getCurrentImage();
28 if (imp==null) {
29 IJ.showMessage("LUT Editor", "No images are open");
30 return;
31 }
32 bitDepth = imp.getBitDepth();
33 if (bitDepth==24) {
34 IJ.showMessage("LUT Editor", "RGB images do not use LUTs");
35 return;
36 }
37 if (bitDepth!=8) {
38 imp.getProcessor().resetMinAndMax();
39 imp.updateAndDraw();
40 }
41
42 colorPanel = new ColorPanel(imp);
43 if (colorPanel.getMapSize()!=256) {
44 IJ.showMessage("LUT Editor", "LUT must have 256 entries");
45 return;
46 }
47 Recorder.suspendRecording();
48 int red=0, green=0, blue=0;
49 GenericDialog gd = new GenericDialog("LUT Editor");
50 Panel buttonPanel = new Panel(new GridLayout(4, 1, 0, 5));
51 openButton = new Button("Open...");
52 openButton.addActionListener(this);
53 buttonPanel.add(openButton);
54 saveButton = new Button("Save...");
55 saveButton.addActionListener(this);
56 buttonPanel.add(saveButton);
57 resizeButton = new Button("Set...");
58 resizeButton.addActionListener(this);
59 buttonPanel.add(resizeButton);
60 invertButton = new Button("Invert...");
61 invertButton.addActionListener(this);
62 buttonPanel.add(invertButton);
63 Panel panel = new Panel();
64 panel.add(colorPanel);
65 panel.add(buttonPanel);
66 gd.addPanel(panel, GridBagConstraints.CENTER, new Insets(10, 0, 0, 0));
67 gd.showDialog();
68 Recorder.resumeRecording();
69 if (gd.wasCanceled()){
70 colorPanel.cancelLUT();
71 return;
72 } else {
73 colorPanel.applyLUT();
74 String lutName = imp.getProp(LUT.nameKey);
75 if (lutName!=null && !lutName.endsWith(" (edited)"))
76 imp.setProp(LUT.nameKey, lutName+" (edited)");
77 }
78 }
79
80 void save() {
81 try {IJ.run("LUT...");} // File>Save As>Lut...

Callers

nothing calls this directly

Calls 15

getCurrentImageMethod · 0.95
showMessageMethod · 0.95
getBitDepthMethod · 0.95
getProcessorMethod · 0.95
updateAndDrawMethod · 0.95
suspendRecordingMethod · 0.95
addPanelMethod · 0.95
showDialogMethod · 0.95
resumeRecordingMethod · 0.95
wasCanceledMethod · 0.95
getPropMethod · 0.95
setPropMethod · 0.95

Tested by

no test coverage detected