diff --git a/Framework/Cyclops/Cyclops/src/main/java/org/peakaboo/framework/cyclops/visualization/palette/Gradient.java b/Framework/Cyclops/Cyclops/src/main/java/org/peakaboo/framework/cyclops/visualization/palette/Gradient.java index d93aae8de..ef3da4ae8 100644 --- a/Framework/Cyclops/Cyclops/src/main/java/org/peakaboo/framework/cyclops/visualization/palette/Gradient.java +++ b/Framework/Cyclops/Cyclops/src/main/java/org/peakaboo/framework/cyclops/visualization/palette/Gradient.java @@ -21,13 +21,16 @@ public Stop(int argb, float position) { }; private List stops; + private String name; - public Gradient(List stops) { + public Gradient(String name, List stops) { this.stops = stops; + this.name = name; } - public Gradient(Stop... stops) { + public Gradient(String name, Stop... stops) { this.stops = List.of(stops); + this.name = name; } public List toList(int steps) { @@ -118,6 +121,10 @@ public static List extrapolateStops(float totalSteps, List return spectrum; } + + public String getName() { + return name; + } } diff --git a/Framework/Cyclops/Cyclops/src/main/java/org/peakaboo/framework/cyclops/visualization/palette/Gradients.java b/Framework/Cyclops/Cyclops/src/main/java/org/peakaboo/framework/cyclops/visualization/palette/Gradients.java index 9de5b7920..77aa4eda2 100644 --- a/Framework/Cyclops/Cyclops/src/main/java/org/peakaboo/framework/cyclops/visualization/palette/Gradients.java +++ b/Framework/Cyclops/Cyclops/src/main/java/org/peakaboo/framework/cyclops/visualization/palette/Gradients.java @@ -1,5 +1,8 @@ package org.peakaboo.framework.cyclops.visualization.palette; +import java.util.List; +import java.util.Optional; + import org.peakaboo.framework.cyclops.visualization.palette.Gradient.Stop; public class Gradients { @@ -7,18 +10,18 @@ public class Gradients { private Gradients() {}; - public static final Gradient MONOCHROME = new Gradient( + public static final Gradient MONOCHROME = new Gradient("Monochrome", new Stop(0xff000000, 0f), new Stop(0xffffffff, 1f) ); - public static final Gradient INV_MONOCHROME = new Gradient( + public static final Gradient INV_MONOCHROME = new Gradient("Inverted Monochrome", new Stop(0xffffffff, 0f), new Stop(0xff000000, 1f) ); - public static final Gradient THERMAL = new Gradient( + public static final Gradient SPECTRUM = new Gradient("Spectrum", new Stop(0xff10154D, 0f), new Stop(0xff0D47A1, 0.235f), new Stop(0xff388E3C, 0.392f), @@ -28,7 +31,62 @@ public class Gradients { ); - public static final Gradient GEORGIA = new Gradient( + public static final Gradient NAVIA = new Gradient("Navia", + new Stop(0xff0b1627, 0f), + new Stop(0xff1a2b3f, 0.11f), + new Stop(0xff19598c, 0.22f), + new Stop(0xff29728e, 0.33f), + new Stop(0xff3a8285, 0.44f), + new Stop(0xff4b9379, 0.55f), + new Stop(0xff66aa6a, 0.66f), + new Stop(0xff98ca6e, 0.77f), + new Stop(0xffd9e5a6, 0.88f), + new Stop(0xfffcf5d9, 1f) + ); + + + public static final Gradient LAJOLLA = new Gradient("Lajolla", + new Stop(0xff1f1e0f, 0f), + new Stop(0xff332312, 0.11f), + new Stop(0xff5b2f22, 0.22f), + new Stop(0xff91403c, 0.33f), + new Stop(0xffc94e4a, 0.44f), + new Stop(0xffe1714d, 0.55f), + new Stop(0xffe9924f, 0.66f), + new Stop(0xffefb553, 0.77f), + new Stop(0xfff8de7a, 0.88f), + new Stop(0xfffcf9cb, 1f) + ); + + public static final Gradient OSLO = new Gradient("Oslo", + new Stop(0xff080706, 0f), + new Stop(0xff101928, 0.11f), + new Stop(0xff143250, 0.22f), + new Stop(0xff1f4c7b, 0.33f), + new Stop(0xff3968a7, 0.44f), + new Stop(0xff688ac4, 0.55f), + new Stop(0xff8a9fc8, 0.66f), + new Stop(0xffabb6c9, 0.77f), + new Stop(0xffd4d6da, 0.88f), + new Stop(0xfffefefe, 1f) + ); + + public static final Gradient IRON = new Gradient("Iron", + new Stop(0xff020f15, 0f), + new Stop(0xff26036c, 0.1f), + new Stop(0xff66059f, 0.2f), + new Stop(0xffa60b9c, 0.3f), + new Stop(0xffcd2972, 0.4f), + new Stop(0xffee4e3d, 0.5f), + new Stop(0xfffa7c0f, 0.6f), + new Stop(0xfff6aa00, 0.7f), + new Stop(0xfffdcc06, 0.8f), + new Stop(0xfffeee5c, 0.9f), + new Stop(0xfff0fff0, 1f) + ); + + + public static final Gradient GEORGIA = new Gradient("Georgia", new Stop(0xffFFFFFF, 0f), new Stop(0xffE6B350, 0.2f), new Stop(0xffF27C55, 0.4f), @@ -38,98 +96,30 @@ public class Gradients { ); - public static final Gradient RATIO_THERMAL = new Gradient( + public static final Gradient RATIO_THERMAL = new Gradient("Ratio Thermal", new Stop(0xff1485CC, 0f), new Stop(0xff000000, 0.5f), new Stop(0xffff0000, 1f) ); - public static final Gradient RATIO_MONOCHROME = new Gradient( + public static final Gradient RATIO_MONOCHROME = new Gradient("Ratio Monochrome", new Stop(0xff000000, 0f), new Stop(0xffffffff, 1f) ); - - // nice - public static final Gradient THOUGHTFUL = new Gradient( - new Stop(0xffecd078, 0f), - new Stop(0xffd95b43, 0.333f), - new Stop(0xffc02942, 0.666f), - new Stop(0xff542437, 1f) - ); - - - // nice - public static final Gradient TERRA = new Gradient( - new Stop(0xff031634, 0f), - new Stop(0xff033649, 0.25f), - new Stop(0xff036564, 0.50f), - new Stop(0xffcdb380, 0.75f), - new Stop(0xffe8ddcb, 1f) - ); - - - //good on unsubtracted, okay on subtracted - public static final Gradient OLIVE = new Gradient( - new Stop(0xff300018, 0f), - new Stop(0xff5a3d31, 0.25f), - new Stop(0xff837b47, 0.50f), - new Stop(0xffadb85f, 0.57f), - new Stop(0xffe5edb8, 1f) - ); - - - public static final Gradient VINTAGE = new Gradient( - new Stop(0xff8c2318, 0f), - new Stop(0xff5e8c6a, 0.25f), - new Stop(0xff88a65e, 0.50f), - new Stop(0xffbfb35a, 0.75f), - new Stop(0xfff2c45a, 1f) - ); - - - public static final Gradient GOLDFISH = new Gradient( - new Stop(0xff69d2e7, 0f), - new Stop(0xffa7dbd8, 0.304f), - new Stop(0xffe0e4cc, 0.548f), - new Stop(0xffd9d6b8, 0.639f), - new Stop(0xfff39449, 0.700f), - new Stop(0xfffa6900, 0.882f), - new Stop(0xffff4000, 1f) - ); - - - // based off of "sugar is three" - public static final Gradient SUGAR = new Gradient( - new Stop(0xff2c8b9a, 0f), - new Stop(0xff6ac3ae, 0.25f), - new Stop(0xffd9c8a7, 0.44f), - new Stop(0xfff9cdad, 0.63f), - new Stop(0xfffc9d9a, 0.82f), - new Stop(0xfffe4365, 0.94f), - new Stop(0xfffe264d, 1f) - ); - - - - public static final Gradient BROWNSUGAR = new Gradient( - new Stop(0xff490a3d, 0f), - new Stop(0xffbd1550, 0.25f), - new Stop(0xffe97f02, 0.50f), - new Stop(0xfff8ca00, 0.74f), - new Stop(0xff8a9b0f, 1f) - ); - - - public static final Gradient BLACKBODY = new Gradient( - new Stop(0xfff82600, 0f), - new Stop(0xffffb12f, 0.25f), - new Stop(0xffffe7bf, 0.50f), - new Stop(0xffdfe6ff, 0.75f), - new Stop(0xffa6baff, 1f) - ); + public static final Gradient DEFAULT = SPECTRUM; + + public static Optional forName(String colourPalette) { + var gs = List.of(MONOCHROME, INV_MONOCHROME, SPECTRUM, NAVIA, LAJOLLA, OSLO, IRON, GEORGIA); + for (var g : gs) { + if (g.getName().equalsIgnoreCase(colourPalette)) { + return Optional.of(g); + } + } + return Optional.empty(); + } } diff --git a/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/MappingController.java b/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/MappingController.java index 203a207b2..bf8c2eb3d 100644 --- a/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/MappingController.java +++ b/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/MappingController.java @@ -141,7 +141,7 @@ public MapRenderSettings getRenderSettings() { settings.mapTitle = this.getFitting().mapLongTitle(); settings.scalemode = this.getFitting().getMapScaleMode(); - settings.monochrome = this.getSettings().getMonochrome(); + settings.gradient = this.getSettings().getColourGradient(); settings.darkmode = this.getParentPlotController().view().getDarkMode(); settings.contours = this.getSettings().getContours(); settings.contourSteps = this.getSettings().getSpectrumSteps(); diff --git a/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/settings/MapSettingsController.java b/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/settings/MapSettingsController.java index ac152adf0..f461e45ae 100644 --- a/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/settings/MapSettingsController.java +++ b/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/settings/MapSettingsController.java @@ -6,6 +6,8 @@ import org.peakaboo.controller.mapper.MappingController; import org.peakaboo.framework.cyclops.Bounds; import org.peakaboo.framework.cyclops.Coord; +import org.peakaboo.framework.cyclops.visualization.palette.Gradient; +import org.peakaboo.framework.cyclops.visualization.palette.Gradients; import org.peakaboo.framework.eventful.EventfulType; /** @@ -30,7 +32,7 @@ public class MapSettingsController extends EventfulType private int spectrumSteps = 15; private boolean contour = false; - private boolean monochrome = false; + private Gradient colourGradient = Gradients.DEFAULT; private float zoom = 1f; @@ -93,20 +95,19 @@ public int getSpectrumSteps() return this.spectrumSteps; } - - public void setMonochrome(boolean mono) + + public void setColourGradient(Gradient gradient) { - this.monochrome = mono; + this.colourGradient = gradient; updateListeners(MapUpdateType.UI_OPTIONS); } - public boolean getMonochrome() + public Gradient getColourGradient() { - return this.monochrome; + return this.colourGradient; } - public void setShowSpectrum(boolean show) { diff --git a/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/settings/SavedMapSettingsController.java b/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/settings/SavedMapSettingsController.java index b28d44a91..22de40690 100644 --- a/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/settings/SavedMapSettingsController.java +++ b/LibPeakaboo/src/main/java/org/peakaboo/controller/mapper/settings/SavedMapSettingsController.java @@ -1,5 +1,7 @@ package org.peakaboo.controller.mapper.settings; +import org.peakaboo.framework.cyclops.visualization.palette.Gradients; + public class SavedMapSettingsController { public boolean drawCoordinates = true; @@ -10,7 +12,7 @@ public class SavedMapSettingsController { public int spectrumSteps = 15; public boolean contour = false; - public boolean monochrome = false; + public String colourPalette = ""; public void loadInto(MapSettingsController controller) { controller.setShowCoords(drawCoordinates); @@ -20,7 +22,8 @@ public void loadInto(MapSettingsController controller) { controller.setShowDatasetTitle(drawDataSetTitle); controller.setSpectrumSteps(spectrumSteps); controller.setContours(contour); - controller.setMonochrome(monochrome); + controller.setColourGradient(Gradients.forName(colourPalette).orElse(Gradients.DEFAULT)); + } public SavedMapSettingsController storeFrom(MapSettingsController controller) { @@ -32,7 +35,7 @@ public SavedMapSettingsController storeFrom(MapSettingsController controller) { drawDataSetTitle = controller.getShowDatasetTitle(); spectrumSteps = controller.getSpectrumSteps(); contour = controller.getContours(); - monochrome = controller.getMonochrome(); + colourPalette = controller.getColourGradient().getName(); return this; } diff --git a/LibPeakaboo/src/main/java/org/peakaboo/display/map/MapRenderSettings.java b/LibPeakaboo/src/main/java/org/peakaboo/display/map/MapRenderSettings.java index 15a909039..3d9c7dc62 100644 --- a/LibPeakaboo/src/main/java/org/peakaboo/display/map/MapRenderSettings.java +++ b/LibPeakaboo/src/main/java/org/peakaboo/display/map/MapRenderSettings.java @@ -5,6 +5,8 @@ import org.peakaboo.display.map.modes.MapModeRegistry; import org.peakaboo.framework.cyclops.Coord; import org.peakaboo.framework.cyclops.SISize; +import org.peakaboo.framework.cyclops.visualization.palette.Gradient; +import org.peakaboo.framework.cyclops.visualization.palette.Gradients; import org.peakaboo.framework.cyclops.visualization.palette.PaletteColour; import it.unimi.dsi.fastutil.ints.IntArrayList; @@ -22,7 +24,7 @@ public class MapRenderSettings { public String mapTitle = ""; public MapScaleMode scalemode = MapScaleMode.ABSOLUTE; - public boolean monochrome = false; + public Gradient gradient = Gradients.DEFAULT; public boolean darkmode = false; public boolean contours = false; public int contourSteps = 15; diff --git a/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/composite/CompositeMapMode.java b/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/composite/CompositeMapMode.java index 0eeb22c71..32b81294c 100644 --- a/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/composite/CompositeMapMode.java +++ b/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/composite/CompositeMapMode.java @@ -39,7 +39,7 @@ public void draw(Coord size, MapRenderData data, MapRenderSettings sett backend.setSource(settings.getBg()); backend.fill(); - Palette palette = new ColourStopPalette(settings.monochrome ? Gradients.MONOCHROME : Gradients.THERMAL); + Palette palette = new ColourStopPalette(settings.gradient); List paletteList = new ArrayList<>(); diff --git a/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/correlation/CorrelationMapMode.java b/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/correlation/CorrelationMapMode.java index 6ee81c8d9..b33a59762 100644 --- a/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/correlation/CorrelationMapMode.java +++ b/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/correlation/CorrelationMapMode.java @@ -63,7 +63,7 @@ public void draw(Coord size, MapRenderData data, MapRenderSettings sett map.setDrawingRequest(dr); List paletteList = new ArrayList<>(); - paletteList.add(new ColourStopPalette(settings.monochrome ? Gradients.INV_MONOCHROME : Gradients.GEORGIA)); + paletteList.add(new ColourStopPalette(settings.gradient)); List axisPainters = new ArrayList<>(); super.setupTitleAxisPainters(settings, axisPainters); diff --git a/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/ratio/RatioMapMode.java b/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/ratio/RatioMapMode.java index b58a131ab..decd24f0b 100644 --- a/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/ratio/RatioMapMode.java +++ b/LibPeakaboo/src/main/java/org/peakaboo/display/map/modes/ratio/RatioMapMode.java @@ -65,7 +65,7 @@ public void draw(Coord size, MapRenderData data, MapRenderSettings sett //if this is a valid ratio, make a real colour palette -- otherwise, just a black palette if (validRatio) { - paletteList.add(new RatioPalette(settings.monochrome ? Gradients.RATIO_MONOCHROME : Gradients.RATIO_THERMAL)); + paletteList.add(new RatioPalette(settings.gradient)); } diff --git a/SwingUI/src/main/java/org/peakaboo/ui/swing/app/PeakabooIcons.java b/SwingUI/src/main/java/org/peakaboo/ui/swing/app/PeakabooIcons.java index 1566751f6..3ad063875 100644 --- a/SwingUI/src/main/java/org/peakaboo/ui/swing/app/PeakabooIcons.java +++ b/SwingUI/src/main/java/org/peakaboo/ui/swing/app/PeakabooIcons.java @@ -26,7 +26,8 @@ public enum PeakabooIcons implements IconSet { MENU_VIEW, MENU_ENERGY, - MENU_SETTINGS + MENU_SETTINGS, + MENU_PALETTE, ; diff --git a/SwingUI/src/main/java/org/peakaboo/ui/swing/mapping/components/MapMenuView.java b/SwingUI/src/main/java/org/peakaboo/ui/swing/mapping/components/MapMenuView.java index 1a371cb7c..ddd186ead 100644 --- a/SwingUI/src/main/java/org/peakaboo/ui/swing/mapping/components/MapMenuView.java +++ b/SwingUI/src/main/java/org/peakaboo/ui/swing/mapping/components/MapMenuView.java @@ -1,58 +1,151 @@ package org.peakaboo.ui.swing.mapping.components; -import javax.swing.JCheckBoxMenuItem; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.TexturePaint; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RoundRectangle2D; +import java.awt.image.BufferedImage; +import java.awt.image.WritableRaster; + +import javax.swing.ButtonGroup; +import javax.swing.ImageIcon; +import javax.swing.JLabel; import javax.swing.JPopupMenu; +import javax.swing.SwingConstants; +import javax.swing.border.EmptyBorder; import org.peakaboo.controller.mapper.MappingController; import org.peakaboo.controller.mapper.settings.MapSettingsController; -import org.peakaboo.framework.stratus.components.ui.fluentcontrols.menu.FluentCheckMenuItem; +import org.peakaboo.framework.cyclops.visualization.palette.ColourStopPalette; +import org.peakaboo.framework.cyclops.visualization.palette.Gradient; +import org.peakaboo.framework.cyclops.visualization.palette.Gradients; +import org.peakaboo.framework.cyclops.visualization.palette.PaletteColour; +import org.peakaboo.framework.stratus.api.Spacing; +import org.peakaboo.framework.stratus.api.Stratus; +import org.peakaboo.framework.stratus.components.panels.ClearPanel; +import org.peakaboo.framework.stratus.components.ui.options.OptionBlock; +import org.peakaboo.framework.stratus.components.ui.options.OptionBlocksPanel; +import org.peakaboo.framework.stratus.components.ui.options.OptionCheckBox; +import org.peakaboo.framework.stratus.components.ui.options.OptionRadioButton; +import org.peakaboo.framework.stratus.components.ui.options.OptionSize; public class MapMenuView extends JPopupMenu { - private FluentCheckMenuItem title, spectrum, coords, dstitle, scalebar, monochrome; + private MappingController controller; public MapMenuView(MappingController controller) { + this.controller = controller; MapSettingsController settings = controller.getSettings(); - title = new FluentCheckMenuItem("Show Elements List") - .withSelected(settings.getShowTitle()) - .withAction(settings::setShowTitle); + ClearPanel panel = new ClearPanel(new BorderLayout()); + panel.setBorder(Spacing.bHuge()); - dstitle = new FluentCheckMenuItem("Show Dataset Title") - .withSelected(settings.getShowDatasetTitle()) - .withAction(settings::setShowDatasetTitle); + ButtonGroup paletteGroup = new ButtonGroup(); + OptionBlock paletteBlock = new OptionBlock(); - spectrum = new FluentCheckMenuItem("Show Spectrum") - .withSelected(settings.getShowSpectrum()) - .withAction(settings::setShowSpectrum); + paletteBlock.add(makeOpt(Gradients.SPECTRUM, paletteBlock, paletteGroup)); + paletteBlock.add(makeOpt(Gradients.GEORGIA, paletteBlock, paletteGroup)); + paletteBlock.add(makeOpt(Gradients.IRON, paletteBlock, paletteGroup)); + paletteBlock.add(makeOpt(Gradients.NAVIA, paletteBlock, paletteGroup)); + paletteBlock.add(makeOpt(Gradients.LAJOLLA, paletteBlock, paletteGroup)); + paletteBlock.add(makeOpt(Gradients.OSLO, paletteBlock, paletteGroup)); + paletteBlock.add(makeOpt(Gradients.MONOCHROME, paletteBlock, paletteGroup)); + paletteBlock.add(makeOpt(Gradients.INV_MONOCHROME, paletteBlock, paletteGroup)); - coords = new FluentCheckMenuItem("Show Coordinates") - .withSelected(settings.getShowCoords()) - .withAction(settings::setShowCoords); + OptionBlocksPanel blockPanel = new OptionBlocksPanel(OptionSize.SMALL, paletteBlock); + panel.add(blockPanel, BorderLayout.WEST); + + + OptionBlock viewBlock = new OptionBlock().withDividers(false).withBorder(false); + + OptionCheckBox opt; + opt = new OptionCheckBox(viewBlock) + .withTitle("Show Elements List") + .withSelection(settings.getShowTitle()) + .withListener(settings::setShowTitle); + viewBlock.add(opt); + + opt = new OptionCheckBox(viewBlock) + .withTitle("Show Dataset Title") + .withSelection(settings.getShowDatasetTitle()) + .withListener(settings::setShowDatasetTitle); + viewBlock.add(opt); + + opt = new OptionCheckBox(viewBlock) + .withTitle("Show Spectrum") + .withSelection(settings.getShowSpectrum()) + .withListener(settings::setShowSpectrum); + viewBlock.add(opt); + + opt = new OptionCheckBox(viewBlock) + .withTitle("Show Coordinates") + .withSelection(settings.getShowCoords()) + .withListener(settings::setShowCoords); + viewBlock.add(opt); + + opt = new OptionCheckBox(viewBlock) + .withTitle("Show Scale Bar") + .withSelection(settings.getShowScaleBar()) + .withListener(settings::setShowScaleBar); + viewBlock.add(opt); + + blockPanel = new OptionBlocksPanel(OptionSize.SMALL, viewBlock); + blockPanel.setBorder(new EmptyBorder(Spacing.none, Spacing.huge, Spacing.none, Spacing.none)); + panel.add(blockPanel, BorderLayout.EAST); - scalebar = new FluentCheckMenuItem("Show Scale Bar") - .withSelected(settings.getShowScaleBar()) - .withAction(settings::setShowScaleBar); - monochrome = new FluentCheckMenuItem("Monochrome") - .withSelected(settings.getMonochrome()) - .withAction(settings::setMonochrome); + JLabel energyTitle = new JLabel("Map Display Options"); + energyTitle.setHorizontalAlignment(SwingConstants.CENTER); + energyTitle.setFont(energyTitle.getFont().deriveFont(Font.BOLD)); + energyTitle.setBorder(new EmptyBorder(Spacing.none, Spacing.huge, Spacing.huge, Spacing.huge)); + panel.add(energyTitle, BorderLayout.NORTH); + + this.add(panel); + } + + private OptionRadioButton makeOpt(Gradient g, OptionBlock block, ButtonGroup group) { + var opt = new OptionRadioButton<>(block, group, g) + .withListener(this::set) + .withTitle(g.getName()); + opt.getButton().setIcon(gradientToIcon(g)); + return opt; + } + + private void set(Gradient g) { + this.controller.getSettings().setColourGradient(g); + } + + private ImageIcon gradientToIcon(Gradient g) { + int width = 64; + int height = 16; + + // Generate the raw gradient + ColourStopPalette palette = new ColourStopPalette(g); + BufferedImage i = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + WritableRaster raster = i.getRaster(); + for (int x = 0; x < width; x++) { + PaletteColour col = palette.getFillColour(x, width); + int[] argb = new int[] {col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha()}; + for (int y = 0; y < height; y++) { + raster.setPixel(x, y, argb);; + } + } + + // Paint the gradient image onto another image within a rounded rectangle shape + BufferedImage c = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = Stratus.g2d(c.createGraphics()); + var clip = new RoundRectangle2D.Float(0, 0, width, height, 10, 10); + var bounds = new Rectangle2D.Float(0, 0, width, height); + var texture = new TexturePaint(i, bounds); + g2d.setPaint(texture); + g2d.fill(clip); - this.add(title); - this.add(dstitle); - this.add(spectrum); - this.add(coords); - this.add(scalebar); - this.addSeparator(); - this.add(monochrome); - - controller.addListener(t -> { - monochrome.setSelected(controller.getSettings().getMonochrome()); - spectrum.setSelected(controller.getSettings().getShowSpectrum()); - coords.setSelected(controller.getSettings().getShowCoords()); - }); + return new ImageIcon(c); } diff --git a/SwingUI/src/main/java/org/peakaboo/ui/swing/mapping/components/MapperToolbar.java b/SwingUI/src/main/java/org/peakaboo/ui/swing/mapping/components/MapperToolbar.java index efe293769..de3fe3a0e 100644 --- a/SwingUI/src/main/java/org/peakaboo/ui/swing/mapping/components/MapperToolbar.java +++ b/SwingUI/src/main/java/org/peakaboo/ui/swing/mapping/components/MapperToolbar.java @@ -76,7 +76,6 @@ public MapperToolbar(MapperPanel panel, MappingController controller) { - controller.addListener(t -> { examineSubset.setEnabled(controller.getSelection().isReplottable()); @@ -98,7 +97,7 @@ public static FluentToolbarButton createOptionsButton(MappingController controll FluentToolbarButton opts = new FluentToolbarButton() .withIcon(PeakabooIcons.MENU_VIEW, Stratus.getTheme().getControlText()) - .withTooltip("Map Settings Menu"); + .withTooltip("Map Display Options"); opts.withAction(() -> { int x = (int)(opts.getWidth() - menu.getPreferredSize().getWidth()); @@ -108,6 +107,7 @@ public static FluentToolbarButton createOptionsButton(MappingController controll return opts; } + private FluentToolbarButton createExportMenuButton(MapperPanel panel) {