Skip to content

Commit

Permalink
Minor improvements incl. scan exclusion button not showing any border…
Browse files Browse the repository at this point in the history
… unless selected
  • Loading branch information
nathanielsherry committed Jun 16, 2024
1 parent f5717bb commit e685444
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class SpectrumCoordsAxisPainter extends AbstractKeyCoordAxisPainter
{
private int spectrumSteps;
private List<Palette> colourRules;
private List<Palette> colourRules;
private boolean negativeValues;
private List<Pair<Float, String>> markings;
private int decimalPoints;
Expand Down Expand Up @@ -102,11 +102,12 @@ protected void drawKey(final PainterData p)
if (drawCoords) offsetY += 0.3f*keyHeight;

float spectrumPosition = position;
for (int i = (negativeValues ? -steps : 0); i < steps; i++)
{

float maxY = p.dr.maxYIntensity;
float scale = maxY / steps;
for (int i = (negativeValues ? -steps : 0); i < steps; i++) {
p.context.rectAt(spectrumPosition, offsetY, increment + 1.0f, keyHeight);
p.context.setSource(getColourFromRules(((float)i/(float)steps)*p.dr.maxYIntensity, p.dr.maxYIntensity, p.dr.viewTransform));
var source = getColourFromRules(i * scale, maxY, p.dr.viewTransform);
p.context.setSource(source);
p.context.fill();
spectrumPosition += increment;

Expand Down Expand Up @@ -173,8 +174,7 @@ protected void drawKey(final PainterData p)
}


public PaletteColour getColourFromRules(float intensity, float maximum, ViewTransform transform)
{
public PaletteColour getColourFromRules(float intensity, float maximum, ViewTransform transform) {

PaletteColour c;

Expand All @@ -183,8 +183,7 @@ public PaletteColour getColourFromRules(float intensity, float maximum, ViewTran
maximum = (float)Math.log1p(maximum);
}

for (Palette r : colourRules)
{
for (Palette r : colourRules) {
c = r.getFillColour(intensity, maximum);
if (c != null) return c;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ public interface Discards {
boolean isDiscarded(int scanNo);
void discard(int scanNo);
void undiscard(int scanNo);
default void setDiscarded(int scanNo, boolean discarded) {
if (discarded) {
discard(scanNo);
} else {
undiscard(scanNo);
}
}
List<Integer> list();
void clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.peakaboo.framework.stratus.api.Spacing;
import org.peakaboo.framework.stratus.api.icons.StockIcon;
import org.peakaboo.framework.stratus.components.panels.ClearPanel;
import org.peakaboo.framework.stratus.components.ui.fluentcontrols.button.FluentButtonConfig.BorderStyle;
import org.peakaboo.framework.stratus.components.ui.fluentcontrols.button.FluentToggleButton;

public class PlotScanNumber extends ClearPanel {
Expand All @@ -33,12 +34,10 @@ public PlotScanNumber(PlotController controller) {
scanLabel.setBorder(Spacing.bSmall());
scanBlock = new FluentToggleButton(StockIcon.CHOOSE_CANCEL)
.withTooltip("Flag this scan to exclude it and extrapolate it from neighbouring points in maps")
.withBordered(BorderStyle.ACTIVE)
.withAction(selected -> {
if (selected) {
controller.data().getDiscards().discard(controller.view().getScanNumber());
} else {
controller.data().getDiscards().undiscard(controller.view().getScanNumber());
}
int scanNumber = controller.view().getScanNumber();
controller.data().getDiscards().setDiscarded(scanNumber, selected);
});

this.add(scanLabel);
Expand Down

0 comments on commit e685444

Please sign in to comment.