Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
181508e
fixed typo
SteffenHeu Feb 15, 2020
533a41f
moved chart theme application to EChartViewer
SteffenHeu Feb 16, 2020
6ce1dd5
moved TICPlot fonts and standard colors to EStandardChartTheme
SteffenHeu Feb 16, 2020
bfabc0d
Merge branch 'mzmine-master' into chartstuff
SteffenHeu Feb 24, 2020
f9ac570
moved some of the spectra plot settings to the chart theme
SteffenHeu Feb 24, 2020
fddb468
Merge branch 'mzmine-master' into chartstuff
SteffenHeu Mar 5, 2020
13f03dc
added buttons for duplicate/default
SteffenHeu Mar 7, 2020
6f18d0b
added debug messages to palette component
SteffenHeu Mar 7, 2020
1849c05
fixed equals and hash code
SteffenHeu Mar 8, 2020
3addb8a
Merge branch 'master' into chartstuff
SteffenHeu Mar 8, 2020
86dcfbe
color change reverted
SteffenHeu Mar 8, 2020
bac83aa
moved more functionality to chart theme, removed deprecated code from…
SteffenHeu Mar 8, 2020
0684832
removed unused stuff from SpectraPlot
SteffenHeu Mar 8, 2020
d322255
Merge branch 'master' into chartstuff
SteffenHeu Mar 10, 2020
d2277fa
fixed npe when launching spectra plot
SteffenHeu Mar 11, 2020
4df1bee
Merge branch 'master' into chartstuff
SteffenHeu Mar 11, 2020
44c1344
reorganised color picker dialog
SteffenHeu Mar 13, 2020
a056ea8
Default palette always in combobox, cannot be deleted or edited
SteffenHeu Mar 13, 2020
8ceaf62
added licence
SteffenHeu Mar 13, 2020
2e43bd7
Merge branch 'master' into chartstuff
SteffenHeu Mar 13, 2020
0852c8f
Implemented new color palettes, changed color picker layout
SteffenHeu Mar 16, 2020
392ea98
push to laptop - removed vision, still errors
SteffenHeu Mar 16, 2020
93e71df
added pos/neg color to palette and components
SteffenHeu Mar 16, 2020
f982189
added neutral color to palette and components
SteffenHeu Mar 16, 2020
784c72f
removed vision from graphics export, added palette parameter
SteffenHeu Mar 16, 2020
e092c5e
changed FeatureStatus and LipidDatabaseTableController
SteffenHeu Mar 16, 2020
55e553b
added awt color methods to SimpleColorPalette to remove redundant code
SteffenHeu Mar 16, 2020
55e7492
added neutral color to components
SteffenHeu Mar 17, 2020
538a78c
updated module usage from old ColorsFX & Vision to color palette
SteffenHeu Mar 17, 2020
2a2858f
updated layout, event management when color changed
SteffenHeu Mar 20, 2020
65f809a
renamed isValidPalette to SimpleColorPalette#isValid
SteffenHeu Mar 20, 2020
5adfc52
updated layout, fixed exceptions
SteffenHeu Mar 20, 2020
bbef859
added padding to picker dialog
SteffenHeu Mar 20, 2020
c60d480
renamed constants in ColorPalettePreviewField to be on par with Color…
SteffenHeu Mar 20, 2020
de06c71
fixed warning on palette not in items while loading color palette par…
SteffenHeu Mar 22, 2020
4b19c65
removed/fixed logging messages
SteffenHeu Mar 22, 2020
7f5e9be
working proper d&d - not finished
SteffenHeu Mar 22, 2020
2190df8
fixed d&d and movign colors in the palette
SteffenHeu Mar 25, 2020
3e9af5a
Merge branch 'mzmine-master' into chartstuff
SteffenHeu Mar 27, 2020
a894fde
fixed object names, fixed title formatting, made prefs use own instance
SteffenHeu Mar 27, 2020
d4114cf
fixed crash in export dialog
SteffenHeu Mar 27, 2020
e24eb78
dodgy solution for data point colors
SteffenHeu Mar 27, 2020
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
27 changes: 15 additions & 12 deletions src/main/java/io/github/mzmine/datamodel/FeatureStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package io.github.mzmine.datamodel;

import io.github.mzmine.util.color.SimpleColorPalette;
import io.github.mzmine.util.javafx.FxColorUtil;
import java.awt.Color;
import io.github.mzmine.main.MZmineCore;
import io.github.mzmine.util.color.Colors;
Expand Down Expand Up @@ -46,36 +48,37 @@ public enum FeatureStatus {
MANUAL;

public Color getColor() {
Vision vision =
MZmineCore.getConfiguration() != null ? MZmineCore.getConfiguration().getColorVision()
: Vision.DEUTERANOPIA;
SimpleColorPalette palette =
(MZmineCore.getConfiguration().getDefaultColorPalette() != null) ? MZmineCore.getConfiguration()
.getDefaultColorPalette() : SimpleColorPalette.DEFAULT.get(Vision.DEUTERANOPIA);
switch (this) {
case DETECTED:
return Colors.getPositiveColor(vision);
return palette.getPositiveColorAWT();
case ESTIMATED:
return Colors.getNeutralColor();
return palette.getNeutralColorAWT();
case MANUAL:
return Color.BLACK;
case UNKNOWN:
default:
return Colors.getNegativeColor(vision);
return palette.getNegativeColorAWT();
}
}

public javafx.scene.paint.Color getColorFX() {
Vision vision =
MZmineCore.getConfiguration() != null ? MZmineCore.getConfiguration().getColorVision()
: Vision.DEUTERANOPIA;
SimpleColorPalette palette =
(MZmineCore.getConfiguration().getDefaultColorPalette() != null) ? MZmineCore.getConfiguration()
.getDefaultColorPalette() : SimpleColorPalette.DEFAULT.get(Vision.DEUTERANOPIA);

switch (this) {
case DETECTED:
return ColorsFX.getPositiveColor(vision);
return palette.getPositiveColor();
case ESTIMATED:
return ColorsFX.getNeutralColor();
return palette.getNeutralColor();
case MANUAL:
return javafx.scene.paint.Color.BLACK;
case UNKNOWN:
default:
return ColorsFX.getNegativeColor(vision);
return palette.getNegativeColor();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
package io.github.mzmine.gui.chartbasics.chartthemes;


import java.util.List;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.title.Title;
import io.github.mzmine.parameters.Parameter;
import io.github.mzmine.parameters.dialogs.ParameterSetupDialog;
import io.github.mzmine.parameters.impl.SimpleParameterSet;
Expand Down Expand Up @@ -82,7 +79,7 @@ public class ChartThemeParameters extends SimpleParameterSet {
public static final BooleanParameter showYAxis = new BooleanParameter("Show y axis", "", true);

public ChartThemeParameters() {
super(new Parameter[] {showLegends, showTitle, changeTitle, xlabel, ylabel, color, masterFont,
super(new Parameter[]{showLegends, showTitle, changeTitle, xlabel, ylabel, color, masterFont,
titleFont, captionFont, labelFont, xGridPaint, yGridPaint, showXAxis, showYAxis});
changeTitle.setValue(false);
xlabel.setValue(false);
Expand All @@ -96,13 +93,15 @@ public ExitCode showSetupDialog(boolean valueCheckRequired) {

assert Platform.isFxApplicationThread();

if ((parameters == null) || (parameters.length == 0))
if ((parameters == null) || (parameters.length == 0)) {
return ExitCode.OK;
}
ParameterSetupDialog dialog = new ChartThemeParametersSetupDialog(valueCheckRequired, this);
dialog.showAndWait();
return dialog.getExitCode();
}

@Deprecated
public void applyToChart(JFreeChart chart) {
// // apply chart settings
// boolean showTitle = this.getParameter(ChartThemeParameters.showTitle).getValue();
Expand Down Expand Up @@ -169,29 +168,29 @@ public void applyToChartTheme(EStandardChartTheme theme) {
String ylabel =
this.getParameter(ChartThemeParameters.ylabel).getEmbeddedParameter().getValue();
FontSpecs master = this.getParameter(ChartThemeParameters.masterFont).getValue();
FontSpecs large = this.getParameter(ChartThemeParameters.titleFont).getValue();
FontSpecs medium = this.getParameter(ChartThemeParameters.captionFont).getValue();
FontSpecs small = this.getParameter(ChartThemeParameters.labelFont).getValue();
FontSpecs titleFont = this.getParameter(ChartThemeParameters.titleFont).getValue();
FontSpecs captionFont = this.getParameter(ChartThemeParameters.captionFont).getValue();
FontSpecs labelFont = this.getParameter(ChartThemeParameters.labelFont).getValue();
Color bgColor = this.getParameter(ChartThemeParameters.color).getValue();

theme.setShowTitle(showTitle);
theme.getShowSubtitles(showLegends);
theme.getShowSubtitles(showTitle);
theme.setChartBackgroundPaint(FxColorUtil.fxColorToAWT(bgColor));
theme.setPlotBackgroundPaint(FxColorUtil.fxColorToAWT(bgColor));

theme.setMasterFont(FxFontUtil.fxFontToAWT(master.getFont()));
theme.setExtraLargeFont(FxFontUtil.fxFontToAWT(large.getFont()));
theme.setLargeFont(FxFontUtil.fxFontToAWT(medium.getFont()));
theme.setRegularFont(FxFontUtil.fxFontToAWT(small.getFont()));
theme.setSmallFont(FxFontUtil.fxFontToAWT(small.getFont()));
theme.setExtraLargeFont(FxFontUtil.fxFontToAWT(titleFont.getFont()));
theme.setLargeFont(FxFontUtil.fxFontToAWT(captionFont.getFont()));
theme.setRegularFont(FxFontUtil.fxFontToAWT(labelFont.getFont()));
theme.setSmallFont(FxFontUtil.fxFontToAWT(labelFont.getFont()));

theme.setMasterFontColor(FxColorUtil.fxColorToAWT(master.getColor()));
theme.setAxisLabelPaint(FxColorUtil.fxColorToAWT(medium.getColor()));
theme.setTickLabelPaint(FxColorUtil.fxColorToAWT(small.getColor()));
theme.setTitlePaint(FxColorUtil.fxColorToAWT(large.getColor()));
theme.setItemLabelPaint(FxColorUtil.fxColorToAWT(small.getColor()));
theme.setLegendItemPaint(FxColorUtil.fxColorToAWT(medium.getColor()));
theme.setAxisLinePaint(FxColorUtil.fxColorToAWT(medium.getColor()));
theme.setAxisLabelPaint(FxColorUtil.fxColorToAWT(captionFont.getColor()));
theme.setTickLabelPaint(FxColorUtil.fxColorToAWT(labelFont.getColor()));
theme.setTitlePaint(FxColorUtil.fxColorToAWT(titleFont.getColor()));
theme.setItemLabelPaint(FxColorUtil.fxColorToAWT(labelFont.getColor()));
theme.setLegendItemPaint(FxColorUtil.fxColorToAWT(captionFont.getColor()));
theme.setAxisLinePaint(FxColorUtil.fxColorToAWT(captionFont.getColor()));

theme.setShowXAxis(showXAxis);
theme.setShowYAxis(showYAxis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@

package io.github.mzmine.gui.chartbasics.chartthemes;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Paint;
import java.awt.Stroke;
import javax.annotation.Nonnull;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.block.BlockBorder;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.chart.renderer.xy.StandardXYBarPainter;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.PaintScaleLegend;
import org.jfree.chart.title.TextTitle;
import org.jfree.chart.ui.RectangleEdge;
import io.github.mzmine.gui.chartbasics.chartthemes.ChartThemeFactory.THEME;
import io.github.mzmine.util.javafx.FxColorUtil;
import org.jfree.chart.ui.RectangleInsets;

/**
* More options for the StandardChartTheme
Expand All @@ -42,6 +47,14 @@ public class EStandardChartTheme extends StandardChartTheme {
private static final long serialVersionUID = 1L;

private static final Color DEFAULT_GRID_COLOR = Color.BLACK;
private static final Color DEFAULT_CROSS_HAIR_COLOR = Color.BLACK;

private static final boolean DEFAULT_CROSS_HAIR_VISIBLE = true;
private static final Stroke DEFAULT_CROSS_HAIR_STROKE = new BasicStroke(1.0F, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_BEVEL, 1.0f, new float[] {5.0F, 3.0F}, 0.0F);

private static final RectangleInsets DEFAULT_AXIS_OFFSET = new RectangleInsets(5.0, 5.0, 5.0, 5.0);
private static final double TITLE_TOP_MARGIN = 5.0;

public static final String XML_DESC = "ChartTheme";
// master font
Expand Down Expand Up @@ -126,9 +139,50 @@ public void setAll(boolean antiAlias, boolean showTitle, boolean noBG, Color cBG
public void apply(JFreeChart chart) {
super.apply(chart);
XYPlot p = chart.getXYPlot();

// Cross hair and axis visibility colors
applyToCrosshair(chart);
applyToAxes(chart);

// applyToTitles(chart);

// apply bg
chart.setBackgroundPaint(this.getChartBackgroundPaint());
chart.getPlot().setBackgroundPaint(this.getPlotBackgroundPaint());

//
p.setDomainGridlinesVisible(showXGrid);
p.setRangeGridlinesVisible(showYGrid);
chart.setAntiAlias(isAntiAliased());
p.setBackgroundAlpha(isNoBackground() ? 0 : 1);

applyToLegend(chart);

}


public void applyToCrosshair(@Nonnull JFreeChart chart){
XYPlot p = chart.getXYPlot();
p.setDomainCrosshairPaint(DEFAULT_CROSS_HAIR_COLOR);
p.setRangeCrosshairPaint(DEFAULT_CROSS_HAIR_COLOR);
p.setDomainCrosshairStroke(DEFAULT_CROSS_HAIR_STROKE);
p.setRangeCrosshairStroke(DEFAULT_CROSS_HAIR_STROKE);
p.setDomainCrosshairVisible(DEFAULT_CROSS_HAIR_VISIBLE);
p.setRangeCrosshairVisible(DEFAULT_CROSS_HAIR_VISIBLE);
}

public void applyToAxes(@Nonnull JFreeChart chart){
XYPlot p = chart.getXYPlot();
p.getDomainAxis().setVisible(isShowXAxis());
p.getRangeAxis().setVisible(isShowYAxis());
p.setDomainGridlinesVisible(isShowXGrid());
p.setDomainGridlinePaint(getClrXGrid());
p.setRangeGridlinesVisible(isShowYGrid());
p.setRangeGridlinePaint(getClrYGrid());

if (isUseXLabel())
p.getDomainAxis().setLabel(getXlabel());
if (isUseYLabel())
p.getRangeAxis().setLabel(getYlabel());

// all axes
for (int i = 0; i < p.getDomainAxisCount(); i++) {
NumberAxis a = (NumberAxis) p.getDomainAxis(i);
Expand All @@ -144,42 +198,35 @@ public void apply(JFreeChart chart) {
// visible?
a.setVisible(showYAxis);
}
// apply bg
chart.setBackgroundPaint(this.getChartBackgroundPaint());
chart.getPlot().setBackgroundPaint(this.getPlotBackgroundPaint());

for (int i = 0; i < chart.getSubtitleCount(); i++) {
// visible?
chart.getSubtitle(i).setVisible(subtitleVisible);
//
if (PaintScaleLegend.class.isAssignableFrom(chart.getSubtitle(i).getClass()))
((PaintScaleLegend) chart.getSubtitle(i))
.setBackgroundPaint(this.getChartBackgroundPaint());
}
if (chart.getLegend() != null)
chart.getLegend().setBackgroundPaint(this.getChartBackgroundPaint());

if (isUseXLabel())
p.getDomainAxis().setLabel(getXlabel());
if (isUseYLabel())
p.getRangeAxis().setLabel(getYlabel());

p.getDomainAxis().setVisible(isShowXAxis());
p.getRangeAxis().setVisible(isShowYAxis());
p.setAxisOffset(DEFAULT_AXIS_OFFSET);
}

p.setDomainGridlinesVisible(isShowXGrid());
p.setDomainGridlinePaint(getClrXGrid());
p.setRangeGridlinesVisible(isShowYGrid());
p.setRangeGridlinePaint(getClrYGrid());
public void applyToLegend(@Nonnull JFreeChart chart){

//
chart.setAntiAlias(isAntiAliased());
chart.getTitle().setVisible(isShowTitle());
p.setBackgroundAlpha(isNoBackground() ? 0 : 1);
if (chart.getLegend() != null)
chart.getLegend().setBackgroundPaint(this.getChartBackgroundPaint());

fixLegend(chart);
}

// public void applyToTitles(@Nonnull JFreeChart chart){
// chart.getSubtitles().forEach(s -> {
// if(s instanceof TextTitle && s != chart.getTitle()){
// ((TextTitle) s).setFont(getRegularFont());
// ((TextTitle) s).setMargin(TITLE_TOP_MARGIN, 0d, 0d, 0d);
// ((TextTitle) s).setVisible(isShowTitle());
//// ((TextTitle) s).setPaint(subtitleFontColor); // should be set by the theme itself.
//// subtitle color is set by the chart theme parameters
//
// if (PaintScaleLegend.class.isAssignableFrom(s.getClass())) {
// ((PaintScaleLegend) s)
// .setBackgroundPaint(this.getChartBackgroundPaint());
// }
// }
// });
// }

public boolean isNoBackground() {
return ((Color) this.getPlotBackgroundPaint()).getAlpha() == 0;
}
Expand All @@ -194,6 +241,8 @@ public void setNoBackground(boolean state) {
new Color(cchart.getRed(), cchart.getGreen(), cchart.getBlue(), state ? 0 : 255));
}



/**
* Fixes the legend item's colour after the colours of the datasets/series in the plot were
* changed.
Expand All @@ -211,6 +260,7 @@ public static void fixLegend(JFreeChart chart) {
newLegend.setItemFont(oldLegend.getItemFont());
chart.addLegend(newLegend);
newLegend.setVisible(oldLegend.isVisible());
newLegend.setFrame(BlockBorder.NONE);
}

// GETTERS AND SETTERS
Expand Down Expand Up @@ -349,4 +399,5 @@ public Color getClrYGrid() {
public void setClrYGrid(Color clrYGrid) {
this.clrYGrid = clrYGrid;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package io.github.mzmine.gui.chartbasics.graphicsexport;

import io.github.mzmine.util.color.SimpleColorPalette;
import io.github.mzmine.util.javafx.FxColorUtil;
import java.awt.Color;
import java.io.File;
import java.util.logging.Level;
Expand Down Expand Up @@ -60,7 +62,7 @@ public class GraphicsExportDialogFX extends ParameterSetupDialog {
protected JFreeChart chart;
protected EChartViewer chartPanel;
protected ChartThemeParameters chartParam;
protected Color[] colors;
protected SimpleColorPalette colors;

private Button btnRenewPreview;
private Button btnApply;
Expand All @@ -74,7 +76,7 @@ public GraphicsExportDialogFX(boolean valueCheckRequired, ParameterSet parameter
chartParam = (ChartThemeParameters) parameterSet
.getParameter(GraphicsExportParameters.chartParameters).getValue();

colors = Colors.getSevenColorPalette(MZmineCore.getConfiguration().getColorVision(), true);
colors = parameterSet.getParameter(GraphicsExportParameters.colorPalette).getValue();

try {
this.chart = (JFreeChart) chart.clone();
Expand Down Expand Up @@ -115,9 +117,11 @@ public GraphicsExportDialogFX(boolean valueCheckRequired, ParameterSet parameter
protected void applyTheme() {
// update param
updateParameterSetFromComponents();
chartParam = (ChartThemeParameters) parameterSet
.getParameter(GraphicsExportParameters.chartParameters).getValue();
colors = parameterSet.getParameter(GraphicsExportParameters.colorPalette).getValue();
// apply settings
chartParam.applyToChartTheme(theme);
chartParam.applyToChart(chartPanel.getChart());
setStandardColors();
theme.apply(chartPanel.getChart());
disableCrosshair();
Expand All @@ -130,7 +134,11 @@ protected void disableCrosshair() {
}

protected void setStandardColors() {
DrawingSupplier ds = new DefaultDrawingSupplier(colors, colors, colors,
Color[] clrs = new Color[colors.size()];
for(int i = 0; i < colors.size(); i++)
clrs[i] = colors.getAWT(i);

DrawingSupplier ds = new DefaultDrawingSupplier(clrs, clrs, clrs,
DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package io.github.mzmine.gui.chartbasics.graphicsexport;

import io.github.mzmine.parameters.parametertypes.colorpalette.ColorPaletteParameter;
import java.awt.Dimension;
import java.io.File;
import java.text.DecimalFormat;
Expand Down Expand Up @@ -82,9 +83,11 @@ public enum FixedSize {
public static final ParameterSetParameter chartParameters = new ParameterSetParameter(
"Chart parameters", "Manually set the chart parameters", new ChartThemeParameters());

public static final ColorPaletteParameter colorPalette = new ColorPaletteParameter("Color palette", "The color palette used for export.");

public GraphicsExportParameters() {
super(new Parameter[] {path, unit, exportFormat, fixedSize, width, height, dpi, color, alpha,
chartParameters});
chartParameters, colorPalette});
height.setValue(true);
}

Expand Down
Loading