Skip to content

Commit

Permalink
Add a configuration option on how to label PCR data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Jun 28, 2021
1 parent 42a8d80 commit 941b9d8
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 7 deletions.
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 @@ -778,6 +779,8 @@ public class PreferenceConstants extends ChartOptions {
public static final String DEF_PCR_DEFAULT_COLOR = "192,192,192";
public static final String P_PCR_COLOR_CODES = "pcrColorCodes";
public static final String DEF_PCR_COLOR_CODES = "";
public static final String P_PCR_REFERENCE_LABEL = "pcrReferenceLabel";
public static final String DEF_PCR_REFERENCE_LABEL = LabelSetting.COORDINATE_SAMPLENAME.getLabel();
/*
* Processor
*/
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 @@ -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(channel, label, color);
if(lineSeriesData != null) {
lineSeriesDataList.add(lineSeriesData);
}
Expand All @@ -271,6 +273,18 @@ private void updateChart() {
}
}

private String getLabel(IWell well) {

LabelSetting referenceLabel = LabelSetting.valueOf(preferenceStore.getString(PreferenceConstants.P_PCR_REFERENCE_LABEL));
if(referenceLabel.equals(LabelSetting.SAMPLENAME))
return well.getSampleId();
if(referenceLabel.equals(LabelSetting.COORDINATE))
return well.getPosition().toString();
if(referenceLabel.equals(LabelSetting.COORDINATE_SAMPLENAME))
return well.getPosition().toString() + ": " + well.getSampleId();
return "";
}

private Color getWellColor(IWell well, ColorCodes colorCodes) {

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

private ILineSeriesData extractChannel(IChannel channel, String position, Color color) {
private ILineSeriesData getLineSeriesData(IChannel channel, String label, Color color) {

ILineSeriesData lineSeriesData = null;
if(channel != null) {
Expand All @@ -294,7 +308,7 @@ private ILineSeriesData extractChannel(IChannel channel, String position, Color
points[index] = pointList.get(index);
}
//
ISeriesData seriesData = new SeriesData(points, "Position: " + position + " | Channel: " + channel.getId());
ISeriesData seriesData = new SeriesData(points, label);
lineSeriesData = new LineSeriesData(seriesData);
ILineSeriesSettings lineSeriesSettings = lineSeriesData.getSettings();
lineSeriesSettings.setLineColor(color);
Expand Down

0 comments on commit 941b9d8

Please sign in to comment.