Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a configuration option on how to label PCR data #662

Merged
merged 3 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.chemclipse.pcr.model.comparators,
org.eclipse.chemclipse.pcr.model.core
org.eclipse.chemclipse.pcr.model.core,
org.eclipse.chemclipse.pcr.model.core.support
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Lablicate GmbH.
* Copyright (c) 2018, 2021 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 @@ -22,10 +22,12 @@ public class Position implements Comparable<Position> {
private Pattern pattern = Pattern.compile("([a-zA-Z]*)(\\d*)");

public Position() {

this("", 0);
}

public Position(String row, int column) {

this.row = row;
this.column = column;
}
Expand Down Expand Up @@ -107,7 +109,7 @@ public boolean equals(Object obj) {
@Override
public String toString() {

return "Position [row=" + row + ", column=" + column + "]";
return row + column;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Matthias Mailänder - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.pcr.model.core.support;

public enum LabelSetting {
SAMPLENAME("Sample ID"), //
COORDINATE("Coordinate"), //
COORDINATE_SAMPLENAME("Coordinate + Sample ID"); //

private String label = "";

private LabelSetting(String label) {

this.label = label;
}

public String getLabel() {

return label;
}

public static String[][] getOptions() {

LabelSetting[] labelSettings = values();
String[][] elements = new String[labelSettings.length][2];
//
int counter = 0;
for(LabelSetting labelSetting : labelSettings) {
elements[counter][0] = labelSetting.getLabel();
elements[counter][1] = labelSetting.name();
counter++;
}
//
return elements;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.eclipse.chemclipse.model.core.support.HeaderField;
import org.eclipse.chemclipse.model.traces.NamedTraceUtil;
import org.eclipse.chemclipse.msd.model.support.CalculationType;
import org.eclipse.chemclipse.pcr.model.core.support.LabelSetting;
import org.eclipse.chemclipse.swt.ui.support.Colors;
import org.eclipse.chemclipse.ux.extension.ui.support.PartSupport;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -780,6 +781,8 @@ public class PreferenceConstants extends ChartOptions {
public static final String DEF_PCR_COLOR_CODES = "";
public static final String P_PCR_SAVE_AS_FOLDER = "pcrSaveAsFolder";
public static final String DEF_PCR_SAVE_AS_FOLDER = "";
public static final String P_PCR_REFERENCE_LABEL = "pcrReferenceLabel";
public static final String DEF_PCR_REFERENCE_LABEL = LabelSetting.COORDINATE_SAMPLENAME.name();
/*
* Processor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public void initializeDefaultPreferences() {
store.setDefault(PreferenceConstants.P_PCR_DEFAULT_COLOR, PreferenceConstants.DEF_PCR_DEFAULT_COLOR);
store.setDefault(PreferenceConstants.P_PCR_COLOR_CODES, PreferenceConstants.DEF_PCR_COLOR_CODES);
store.setDefault(PreferenceConstants.P_PCR_SAVE_AS_FOLDER, PreferenceConstants.DEF_PCR_SAVE_AS_FOLDER);
store.setDefault(PreferenceConstants.P_PCR_REFERENCE_LABEL, PreferenceConstants.DEF_PCR_REFERENCE_LABEL);
/*
* Molecule(s)
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2019 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -8,12 +8,16 @@
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Matthias Mailänder - add a reference label setting
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.preferences;

import org.eclipse.chemclipse.pcr.model.core.support.LabelSetting;
import org.eclipse.chemclipse.support.ui.preferences.fieldeditors.SpacerFieldEditor;
import org.eclipse.chemclipse.ux.extension.xxd.ui.Activator;
import org.eclipse.chemclipse.ux.extension.xxd.ui.fieldeditors.ColorCodesFieldEditor;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
Expand All @@ -30,6 +34,8 @@ public PreferencePagePCR() {

public void createFieldEditors() {

addField(new ComboFieldEditor(PreferenceConstants.P_PCR_REFERENCE_LABEL, "Reference Label:", LabelSetting.getOptions(), getFieldEditorParent()));
addField(new SpacerFieldEditor(getFieldEditorParent()));
addField(new ColorFieldEditor(PreferenceConstants.P_PCR_DEFAULT_COLOR, "Default Line Color:", getFieldEditorParent()));
addField(new ColorCodesFieldEditor(PreferenceConstants.P_PCR_COLOR_CODES, "Color Codes", getFieldEditorParent()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.chemclipse.pcr.model.core.IChannel;
import org.eclipse.chemclipse.pcr.model.core.IPlate;
import org.eclipse.chemclipse.pcr.model.core.IWell;
import org.eclipse.chemclipse.pcr.model.core.support.LabelSetting;
import org.eclipse.chemclipse.rcp.ui.icons.core.ApplicationImageFactory;
import org.eclipse.chemclipse.rcp.ui.icons.core.IApplicationImage;
import org.eclipse.chemclipse.swt.ui.components.InformationUI;
Expand Down Expand Up @@ -158,8 +159,8 @@ private void createToolbarMain(Composite parent) {
buttonToolbarInfo = createButtonToggleToolbar(composite, toolbarInfo, IMAGE_INFO, TOOLTIP_INFO);
createButtonToggleChartLegend(composite, chartControl, IMAGE_LEGEND);
createResetButton(composite);
createSettingsButton(composite);
createColorCompensationButton(composite);
createSettingsButton(composite);
}

private void createSettingsButton(Composite parent) {
Expand Down Expand Up @@ -257,8 +258,9 @@ private void updateChart() {
try {
int channelNumber = comboChannels.getSelectionIndex();
IChannel channel = well.getChannels().get(channelNumber);
String label = getLabel(well);
Color color = getWellColor(well, colorCodes);
ILineSeriesData lineSeriesData = extractChannel(channel, Integer.toString(well.getPosition().getId() + 1), color);
ILineSeriesData lineSeriesData = getLineSeriesData(well, channel, label, color);
if(lineSeriesData != null) {
lineSeriesDataList.add(lineSeriesData);
}
Expand All @@ -271,6 +273,29 @@ private void updateChart() {
}
}

private String getLabel(IWell well) {

LabelSetting labelSetting = getLabelSetting();
switch(labelSetting) {
case SAMPLENAME:
return well.getSampleId();
case COORDINATE:
return well.getPosition().toString();
case COORDINATE_SAMPLENAME:
default:
return well.getPosition().toString() + ": " + well.getSampleId();
}
}

private LabelSetting getLabelSetting() {

try {
return LabelSetting.valueOf(preferenceStore.getString(PreferenceConstants.P_PCR_REFERENCE_LABEL));
} catch(Exception e) {
return LabelSetting.COORDINATE_SAMPLENAME;
}
}

private Color getWellColor(IWell well, ColorCodes colorCodes) {

String sampleSubset = well.getSampleSubset();
Expand All @@ -284,7 +309,7 @@ private Color getWellColor(IWell well, ColorCodes colorCodes) {
}
}

private ILineSeriesData extractChannel(IChannel channel, String position, Color color) {
private ILineSeriesData getLineSeriesData(IWell well, IChannel channel, String description, Color color) {

ILineSeriesData lineSeriesData = null;
if(channel != null) {
Expand All @@ -294,11 +319,13 @@ private ILineSeriesData extractChannel(IChannel channel, String position, Color
points[index] = pointList.get(index);
}
//
ISeriesData seriesData = new SeriesData(points, "Position: " + position + " | Channel: " + channel.getId());
String position = Integer.toString(well.getPosition().getId() + 1);
ISeriesData seriesData = new SeriesData(points, position);
lineSeriesData = new LineSeriesData(seriesData);
ILineSeriesSettings lineSeriesSettings = lineSeriesData.getSettings();
lineSeriesSettings.setLineColor(color);
lineSeriesSettings.setEnableArea(false);
lineSeriesSettings.setDescription(description);
}
return lineSeriesData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ private void createToolbarMain(Composite parent) {
buttonToolbarInfo = createButtonToggleToolbar(composite, toolbarInfo, IMAGE_INFO, TOOLTIP_INFO);
createButtonToggleChartLegend(composite, chartControl, IMAGE_LEGEND);
createResetButton(composite);
createSettingsButton(composite);
createColorCompensationButton(composite);
createSettingsButton(composite);
}

private void createColorCompensationButton(Composite parent) {
Expand Down Expand Up @@ -300,7 +300,7 @@ private ILineSeriesData getChannelCurve(IChannel channel, Color color) {
for(int index = 0; index < pointList.size(); index++) {
points[index] = pointList.get(index);
}
ISeriesData seriesData = new SeriesData(points, "Channel " + channel.getId());
ISeriesData seriesData = new SeriesData(points, channel.getDetectionName());
lineSeriesData = new LineSeriesData(seriesData);
ILineSeriesSettings lineSeriesSettings = lineSeriesData.getSettings();
lineSeriesSettings.setLineColor(color);
Expand Down