Skip to content

Commit

Permalink
Split ruler chart.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Jan 27, 2025
1 parent fab4f0e commit 20a7416
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 173 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2023 Lablicate GmbH.
* Copyright (c) 2021, 2025 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -9,10 +9,12 @@
* Contributors:
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.charts;
package org.eclipse.chemclipse.ux.extension.msd.ui.views;

import org.eclipse.chemclipse.ux.extension.msd.ui.swt.MassSpectrumChartProfile;
import org.eclipse.chemclipse.ux.extension.xxd.ui.support.BaselineSelectionPaintListener;
import org.eclipse.chemclipse.ux.extension.ui.model.IRulerUpdateNotifier;
import org.eclipse.chemclipse.ux.extension.ui.support.BaselineSelectionPaintListener;
import org.eclipse.chemclipse.ux.extension.ui.support.RulerEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Point;
Expand All @@ -29,7 +31,7 @@ public class MassSpectrumRulerChart extends MassSpectrumChartProfile {
private Cursor defaultCursor;
private BaselineSelectionPaintListener baselineSelectionPaintListener;
private IRulerUpdateNotifier rulerUpdateNotifier = null;
//

private int xStart;
private int yStart;
private int xStop;
Expand Down Expand Up @@ -97,7 +99,7 @@ private void calculateDimension() {
Point rectangle = baseChart.getPlotArea().getSize();
int width = rectangle.x;
int height = rectangle.y;
//

if(rulerUpdateNotifier != null) {
if(width != 0) {
/*
Expand All @@ -106,7 +108,7 @@ private void calculateDimension() {
double factorWidth = 100.0d / width;
double percentageStartWidth = (factorWidth * xStart) / 100.0d;
double percentageStopWidth = (factorWidth * xStop) / 100.0d;
//

IAxis retentionTime = axisSet.getXAxis(BaseChart.ID_PRIMARY_X_AXIS);
Range millisecondsRange = retentionTime.getRange();
double millisecondsWidth = millisecondsRange.upper - millisecondsRange.lower;
Expand All @@ -124,7 +126,7 @@ private void calculateDimension() {
double factorHeight = 100.0d / height;
double percentageStartHeight = (100.0d - (factorHeight * yStart)) / 100.0d;
double percentageStopHeight = (100.0d - (factorHeight * yStop)) / 100.0d;
//

startY = (float)(intensityRange.lower + abundanceHeight * percentageStartHeight);
stopY = (float)(intensityRange.lower + abundanceHeight * percentageStopHeight);
}
Expand Down Expand Up @@ -156,12 +158,12 @@ private void trackBaselineSelection(int x, int y) {

xStop = x;
yStop = y;
//

baselineSelectionPaintListener.setX1(xStart);
baselineSelectionPaintListener.setY1(yStart);
baselineSelectionPaintListener.setX2(xStop);
baselineSelectionPaintListener.setY2(yStop);
//

redrawChart();
}

Expand All @@ -174,12 +176,12 @@ private void stopBaselineSelection(int x, int y) {
private void resetSelectedRange() {

baselineSelectionPaintListener.reset();
//

xStart = 0;
yStart = 0;
xStop = 0;
yStop = 0;
//

redrawChart();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 Lablicate GmbH.
* Copyright (c) 2021, 2025 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -9,7 +9,9 @@
* Contributors:
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.charts;
package org.eclipse.chemclipse.ux.extension.ui.model;

import org.eclipse.chemclipse.ux.extension.ui.support.RulerEvent;

public interface IRulerUpdateNotifier {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2023 Lablicate GmbH.
* Copyright (c) 2011, 2025 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -9,7 +9,7 @@
* Contributors:
* Dr. Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.support;
package org.eclipse.chemclipse.ux.extension.ui.support;

import org.eclipse.chemclipse.support.ui.workbench.DisplayUtils;
import org.eclipse.swt.SWT;
Expand All @@ -20,12 +20,11 @@
public class BaselineSelectionPaintListener implements ICustomPaintListener {

private static final int VERTICAL_MARKER_SIZE = 10;
//

private int x1;
private int y1;
private int x2;
private int y2;
//

@Override
public void paintControl(PaintEvent e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 Lablicate GmbH.
* Copyright (c) 2021, 2025 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -9,7 +9,7 @@
* Contributors:
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.charts;
package org.eclipse.chemclipse.ux.extension.ui.support;

/**
* The values of the primary chart axes are returned.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021, 2023 Lablicate GmbH.
* Copyright (c) 2021, 2025 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -11,7 +11,9 @@
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.charts;

import org.eclipse.chemclipse.ux.extension.xxd.ui.support.BaselineSelectionPaintListener;
import org.eclipse.chemclipse.ux.extension.ui.model.IRulerUpdateNotifier;
import org.eclipse.chemclipse.ux.extension.ui.support.BaselineSelectionPaintListener;
import org.eclipse.chemclipse.ux.extension.ui.support.RulerEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Point;
Expand All @@ -28,7 +30,7 @@ public class ChromatogramRulerChart extends ChromatogramChart {
private Cursor defaultCursor;
private BaselineSelectionPaintListener baselineSelectionPaintListener;
private IRulerUpdateNotifier rulerUpdateNotifier = null;
//

private int xStart;
private int yStart;
private int xStop;
Expand Down Expand Up @@ -97,7 +99,7 @@ private void calculateDimension(Event event) {
Point rectangle = baseChart.getPlotArea().getSize();
int width = rectangle.x;
int height = rectangle.y;
//

if(rulerUpdateNotifier != null) {
if(width != 0) {
/*
Expand All @@ -106,7 +108,7 @@ private void calculateDimension(Event event) {
double factorWidth = 100.0d / width;
double percentageStartWidth = (factorWidth * xStart) / 100.0d;
double percentageStopWidth = (factorWidth * xStop) / 100.0d;
//

IAxis retentionTime = axisSet.getXAxis(BaseChart.ID_PRIMARY_X_AXIS);
Range millisecondsRange = retentionTime.getRange();
double millisecondsWidth = millisecondsRange.upper - millisecondsRange.lower;
Expand All @@ -124,7 +126,7 @@ private void calculateDimension(Event event) {
double factorHeight = 100.0d / height;
double percentageStartHeight = (100.0d - (factorHeight * yStart)) / 100.0d;
double percentageStopHeight = (100.0d - (factorHeight * yStop)) / 100.0d;
//

startY = (float)(intensityRange.lower + abundanceHeight * percentageStartHeight);
stopY = (float)(intensityRange.lower + abundanceHeight * percentageStopHeight);
}
Expand Down Expand Up @@ -156,12 +158,12 @@ private void trackBaselineSelection(int x, int y) {

xStop = x;
yStop = y;
//

baselineSelectionPaintListener.setX1(xStart);
baselineSelectionPaintListener.setY1(yStart);
baselineSelectionPaintListener.setX2(xStop);
baselineSelectionPaintListener.setY2(yStop);
//

redrawChart();
}

Expand All @@ -174,12 +176,12 @@ private void stopBaselineSelection(int x, int y) {
private void resetSelectedRange() {

baselineSelectionPaintListener.reset();
//

xStart = 0;
yStart = 0;
xStop = 0;
yStop = 0;
//

redrawChart();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2022 Lablicate GmbH.
* Copyright (c) 2020, 2025 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -13,9 +13,9 @@

import org.eclipse.chemclipse.model.core.IChromatogram;
import org.eclipse.chemclipse.model.core.IPeak;
import org.eclipse.chemclipse.ux.extension.ui.support.BaselineSelectionPaintListener;
import org.eclipse.chemclipse.ux.extension.xxd.ui.ranges.TimeRangesChart;
import org.eclipse.chemclipse.ux.extension.xxd.ui.ranges.TimeRangesChromatogramUI;
import org.eclipse.chemclipse.ux.extension.xxd.ui.support.BaselineSelectionPaintListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
Expand All @@ -32,16 +32,16 @@
public class ManualSelectionChart extends TimeRangesChromatogramUI {

private Cursor defaultCursor;
//

private int xStart;
private int yStart;
private int xStop;
private int yStop;
//

private IChromatogram<? extends IPeak> chromatogram;
private BaselineSelectionPaintListener baselineSelectionPaintListener;
private ISelectionListener selectionListener = null;
//

private boolean manualDetectionEnabled = false;

public ManualSelectionChart(Composite parent, int style) {
Expand Down Expand Up @@ -80,7 +80,7 @@ private void init() {
TimeRangesChart peakChart = getChromatogramChartControl().get();
BaseChart baseChart = peakChart.getBaseChart();
defaultCursor = baseChart.getCursor();
//

peakChart.addMouseListener(new MouseAdapter() {

@Override
Expand All @@ -107,7 +107,7 @@ public void mouseDown(MouseEvent event) {
}
}
});
//

peakChart.addMouseMoveListener(new MouseMoveListener() {

@Override
Expand Down Expand Up @@ -150,12 +150,12 @@ private void trackBaselineSelection(int x, int y) {

xStop = x;
yStop = y;
//

baselineSelectionPaintListener.setX1(xStart);
baselineSelectionPaintListener.setY1(yStart);
baselineSelectionPaintListener.setX2(xStop);
baselineSelectionPaintListener.setY2(yStop);
//

redrawChart();
}

Expand All @@ -168,12 +168,12 @@ private void stopBaselineSelection(int x, int y) {
private void resetSelectedRange() {

baselineSelectionPaintListener.reset();
//

xStart = 0;
yStart = 0;
xStop = 0;
yStop = 0;
//

redrawChart();
}

Expand Down Expand Up @@ -255,7 +255,7 @@ private SelectionCoordinates extractSelectionCoordinates(int xStart, int yStart,
}
}
}
//

return selectionCoordinates;
}
}
Loading

0 comments on commit 20a7416

Please sign in to comment.