From 46344702ade7dfb4dc79a746d70e583cc5ac91ed Mon Sep 17 00:00:00 2001 From: Alexandre Gobbo Date: Tue, 26 May 2020 09:41:38 +0200 Subject: [PATCH] Configuration of plot fonts. --- Changelog.md | 2 + .../ch/psi/pshell/plot/LinePlotJFree.java | 14 +- .../ch/psi/pshell/plot/MatrixPlotJFree.java | 4 +- src/main/java/ch/psi/pshell/plot/Plot.java | 5 + .../java/ch/psi/pshell/plot/PlotBase.java | 21 +++ .../ch/psi/pshell/plot/TimePlotJFree.java | 4 +- .../java/ch/psi/pshell/swing/PlotPanel.java | 10 +- .../java/ch/psi/pshell/ui/Preferences.java | 15 +- .../ch/psi/pshell/ui/PreferencesDialog.form | 140 +++++++++++--- .../ch/psi/pshell/ui/PreferencesDialog.java | 174 ++++++++++++++---- src/main/java/ch/psi/pshell/ui/View.java | 3 + src/main/python/pshell/client.py | 2 +- 12 files changed, 317 insertions(+), 77 deletions(-) diff --git a/Changelog.md b/Changelog.md index 459b6a93..303262fd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -47,6 +47,8 @@ * Added keys(), values() and items() methods do Subsctiptable.Mapped interface (e.g: BS stream value). * Run Next command (Menu Shell->Run Next). + +* Configuration of plot fonts. ### Changed diff --git a/src/main/java/ch/psi/pshell/plot/LinePlotJFree.java b/src/main/java/ch/psi/pshell/plot/LinePlotJFree.java index 1654edef..47a2d1e0 100644 --- a/src/main/java/ch/psi/pshell/plot/LinePlotJFree.java +++ b/src/main/java/ch/psi/pshell/plot/LinePlotJFree.java @@ -92,9 +92,6 @@ public class LinePlotJFree extends LinePlotBase { boolean legendVisible; boolean showTooltips; - public static final Font TICK_LABEL_FONT = new Font(Font.SANS_SERIF, 0, 10); - public static final Font LABEL_FONT = new Font(Font.SANS_SERIF, 0, 11); - AbstractXYDataset dataY1; AbstractXYDataset dataY2; NumberAxis axisX2; @@ -589,10 +586,11 @@ public TickUnit getCeilingTickUnit(double size) { chart.getTitle().setPaint(getAxisTextColor()); } chart.getLegend().setItemPaint(getAxisTextColor()); + chart.getLegend().setItemFont(tickLabelFont); plot.getDomainAxis().setTickLabelPaint(getAxisTextColor()); plot.getDomainAxis().setLabelPaint(getAxisTextColor()); plot.getRangeAxis().setLabelPaint(getAxisTextColor()); - plot.getRangeAxis().setTickLabelPaint(getAxisTextColor()); + plot.getRangeAxis().setTickLabelPaint(getAxisTextColor()); plot.getDomainAxis().setLabelFont(labelFont); plot.getRangeAxis().setLabelFont(labelFont); plot.getDomainAxis().setTickLabelFont(tickLabelFont); @@ -602,9 +600,10 @@ public TickUnit getCeilingTickUnit(double size) { } } + @Override public void setLabelFont(Font f) { labelFont = f; - XYPlot plot = (XYPlot) chart.getPlot(); + XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLabelFont(f); plot.getRangeAxis().setLabelFont(f); if (dataY2 == null) { @@ -612,9 +611,11 @@ public void setLabelFont(Font f) { } } + @Override public void setTickLabelFont(Font f) { tickLabelFont = f; XYPlot plot = (XYPlot) chart.getPlot(); + chart.getLegend().setItemFont(f); plot.getDomainAxis().setTickLabelFont(f); plot.getRangeAxis().setTickLabelFont(f); if (dataY2 == null) { @@ -1178,7 +1179,7 @@ public void popupMenuCanceled(PopupMenuEvent e) { // http://www.jfree.org/phpBB2/viewtopic.php?t=12788&highlight=redraw+speed+performance+problem void showTooltips() { tooltips = true; - DecimalFormat dm = new DecimalFormat("0.##########"); + DecimalFormat dm = new DecimalFormat("0.##########"); getRenderer(1).setBaseToolTipGenerator(new StandardXYToolTipGenerator("x={1} y={2}", dm, dm)); if (getRenderer(2) != null) { getRenderer(2).setBaseToolTipGenerator(new StandardXYToolTipGenerator("x={1} y={2}", dm, dm)); @@ -1463,6 +1464,7 @@ public void chartMouseMoved(ChartMouseEvent event) { pointers[i].setArrowLength(5); pointers[i].setTipRadius(10); pointers[i].setLabelOffset(25); + pointers[i].setFont(tickLabelFont); chart.getXYPlot().addAnnotation(pointers[i]); } else { pointers[i].setText(text); diff --git a/src/main/java/ch/psi/pshell/plot/MatrixPlotJFree.java b/src/main/java/ch/psi/pshell/plot/MatrixPlotJFree.java index b3c593c8..e2756a8a 100644 --- a/src/main/java/ch/psi/pshell/plot/MatrixPlotJFree.java +++ b/src/main/java/ch/psi/pshell/plot/MatrixPlotJFree.java @@ -574,8 +574,8 @@ protected void createChart() { // Set axis: (plus half bin size on both sides), since we plot the bins centered. xAxis = new NumberAxis(""); yAxis = new NumberAxis(""); - xAxis.setTickLabelFont(LinePlotJFree.TICK_LABEL_FONT); - yAxis.setTickLabelFont(LinePlotJFree.TICK_LABEL_FONT); + xAxis.setTickLabelFont(TICK_LABEL_FONT); + yAxis.setTickLabelFont(TICK_LABEL_FONT); xAxis.setLabelFont(LinePlotJFree.LABEL_FONT); yAxis.setLabelFont(LinePlotJFree.LABEL_FONT); xAxis.setLabelPaint(getAxisTextColor()); diff --git a/src/main/java/ch/psi/pshell/plot/Plot.java b/src/main/java/ch/psi/pshell/plot/Plot.java index 87c069b1..63a90926 100644 --- a/src/main/java/ch/psi/pshell/plot/Plot.java +++ b/src/main/java/ch/psi/pshell/plot/Plot.java @@ -127,6 +127,11 @@ default public String getDisplayableValue(double value) { default void setPlotOutlineColor(Color c) {}; + default void setLabelFont(Font f) {} + + default void setTickLabelFont(Font f) {} + + @Hidden public static Plot newPlot(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException { diff --git a/src/main/java/ch/psi/pshell/plot/PlotBase.java b/src/main/java/ch/psi/pshell/plot/PlotBase.java index 47acc89b..835ce360 100644 --- a/src/main/java/ch/psi/pshell/plot/PlotBase.java +++ b/src/main/java/ch/psi/pshell/plot/PlotBase.java @@ -65,6 +65,10 @@ abstract public class PlotBase extends MonitoredPanel impl protected static int SNAPSHOT_WIDTH = 1200; protected static int SNAPSHOT_HEIGHT = 1000; + + protected static Font TICK_LABEL_FONT = new Font(Font.SANS_SERIF, 0, 10); + protected static Font LABEL_FONT = new Font(Font.SANS_SERIF, 0, 11); + final Class seriesType; @@ -698,6 +702,23 @@ public static Colormap getDefaultColormap() { return defaultColormap; } + + public static void setDefaultLabelFont(Font font) { + LABEL_FONT = font; + } + + public static Font getDefaultLabelFont() { + + return LABEL_FONT; + } + + public static void setDefaultTickFont(Font font) { + TICK_LABEL_FONT = font; + } + + public static Font getDefaultTickFont() { + return TICK_LABEL_FONT; + } static public int getMarkerSize() { String str = System.getProperty(PROPERTY_PLOT_MARKER_SIZE); diff --git a/src/main/java/ch/psi/pshell/plot/TimePlotJFree.java b/src/main/java/ch/psi/pshell/plot/TimePlotJFree.java index 0ffc9fde..d991ab82 100644 --- a/src/main/java/ch/psi/pshell/plot/TimePlotJFree.java +++ b/src/main/java/ch/psi/pshell/plot/TimePlotJFree.java @@ -60,7 +60,7 @@ public class TimePlotJFree extends TimePlotBase { final TimeSeriesCollection data; final ChartPanel chartPanel; final Shape marker; - Font tickLabelFont = LinePlotJFree.TICK_LABEL_FONT; + Font tickLabelFont = TICK_LABEL_FONT; Font labelFont = LinePlotJFree.LABEL_FONT; @@ -142,6 +142,7 @@ public void restoreAutoRangeBounds() { //chartPanel.setMouseZoomable(true, true); } + @Override public void setLabelFont(Font f){ labelFont = f; XYPlot plot = (XYPlot) chart.getPlot(); @@ -152,6 +153,7 @@ public void setLabelFont(Font f){ } } + @Override public void setTickLabelFont(Font f){ tickLabelFont = f; XYPlot plot = (XYPlot) chart.getPlot(); diff --git a/src/main/java/ch/psi/pshell/swing/PlotPanel.java b/src/main/java/ch/psi/pshell/swing/PlotPanel.java index e70d1d2b..76cea77c 100644 --- a/src/main/java/ch/psi/pshell/swing/PlotPanel.java +++ b/src/main/java/ch/psi/pshell/swing/PlotPanel.java @@ -74,7 +74,7 @@ public class PlotPanel extends MonitoredPanel { static public Quality DEFAULT_PLOT_QUALITY = Quality.High; static public PlotLayout DEFAULT_PLOT_LAYOUT = PlotLayout.Vertical; - public static final Font TITLE_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 13); + static Font TITLE_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 13); public static final int DEFAULT_RANGE_STEPS = 199; public static final boolean offscreen = App.isOffscreenPlotting(); @@ -93,6 +93,14 @@ public PlotPanel() { updating = new AtomicBoolean(false); prefs = new PlotPreferences(); } + + public static void setTitleFont(Font font) { + TITLE_FONT = font; + } + + public static Font getTitleFont() { + return TITLE_FONT; + } static public String getLinePlotImpl() { String impl = System.getProperty(PROPERTY_PLOT_IMPL_LINE); diff --git a/src/main/java/ch/psi/pshell/ui/Preferences.java b/src/main/java/ch/psi/pshell/ui/Preferences.java index e27a17ad..0a47b50c 100644 --- a/src/main/java/ch/psi/pshell/ui/Preferences.java +++ b/src/main/java/ch/psi/pshell/ui/Preferences.java @@ -70,6 +70,9 @@ public enum ScriptPopupDialog { public Font fontShellCommand; public Font fontOutput; public Font fontEditor; + public Font fontPlotLabel; + public Font fontPlotTick; + public Font fontPlotTitle; public int tabSize = 4; public int contentWidth; public Color editorBackground; @@ -122,6 +125,10 @@ public static Preferences load(String path) { preferences.fontEditor = fonts[1]; preferences.fontOutput = fonts[2]; preferences.fontShellCommand = fonts[3]; + preferences.fontPlotLabel = fonts[4]; + preferences.fontPlotTick = fonts[5]; + preferences.fontPlotTitle= fonts[6]; + new Font(Font.SANS_SERIF, Font.BOLD, 13); preferences.defaultPanels = getDefaultPanels(); preferences.consoleLocation = DEFAULT_CONSOLE_LOCATION; //preferences.propagateVariableEvaluation = true; @@ -181,12 +188,18 @@ public static Font[] getDefaultFonts() { ? new Font("Lucida Console", 0, 11) : new Font(Font.MONOSPACED, 0, 13); Font commandFont = new Font(Font.SANS_SERIF, 0, 13); + Font plotLabelFont = new Font(Font.SANS_SERIF, 0, 11); + Font plotTickFont = new Font(Font.SANS_SERIF, 0, 10); + Font plotTitleFont = new Font(Font.SANS_SERIF, Font.BOLD, 13); return new Font[]{ editorFont, editorFont, editorFont, - commandFont + commandFont, + plotLabelFont, + plotTickFont, + plotTitleFont }; } diff --git a/src/main/java/ch/psi/pshell/ui/PreferencesDialog.form b/src/main/java/ch/psi/pshell/ui/PreferencesDialog.form index f848667a..63a1c6e2 100644 --- a/src/main/java/ch/psi/pshell/ui/PreferencesDialog.form +++ b/src/main/java/ch/psi/pshell/ui/PreferencesDialog.form @@ -52,7 +52,7 @@ - + @@ -80,33 +80,39 @@ - + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -118,27 +124,44 @@ + - + - + - + - - + + + + + + + + + + + + + + + + + + @@ -229,6 +252,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -583,7 +663,7 @@ - + @@ -655,7 +735,7 @@ - + @@ -675,7 +755,7 @@ - + @@ -696,7 +776,7 @@ - + @@ -946,7 +1026,7 @@ - + @@ -997,7 +1077,7 @@ - + @@ -1095,7 +1175,7 @@ - + diff --git a/src/main/java/ch/psi/pshell/ui/PreferencesDialog.java b/src/main/java/ch/psi/pshell/ui/PreferencesDialog.java index f5234790..86b8d3e0 100644 --- a/src/main/java/ch/psi/pshell/ui/PreferencesDialog.java +++ b/src/main/java/ch/psi/pshell/ui/PreferencesDialog.java @@ -100,7 +100,7 @@ public boolean isReadOnly() { } Preferences preferences; - Font[] selectedFonts = new Font[4]; + Font[] selectedFonts = new Font[7]; String getFontDesc(Font f) { StringBuilder sb = new StringBuilder(); @@ -136,12 +136,22 @@ public void set(Preferences preferences) throws Exception { checkShowRowNumbers.setSelected(!preferences.hideEditorLineNumbers); checkEditorContextMenu.setSelected(!preferences.hideEditorContextMenu); panelEditorForeground.setBackground(selectedEditorForeground); - selectedFonts = new Font[]{preferences.fontShellPanel, preferences.fontEditor, preferences.fontOutput, preferences.fontShellCommand}; + selectedFonts = new Font[]{ preferences.fontShellPanel, + preferences.fontEditor, + preferences.fontOutput, + preferences.fontShellCommand, + preferences.fontPlotLabel, + preferences.fontPlotTick, + preferences.fontPlotTitle + }; comboConsoleLocation.setSelectedItem(preferences.consoleLocation); textSP.setText(getFontDesc(preferences.fontShellPanel)); textSC.setText(getFontDesc(preferences.fontShellCommand)); textOP.setText(getFontDesc(preferences.fontOutput)); textSE.setText(getFontDesc(preferences.fontEditor)); + textPTit.setText(getFontDesc(preferences.fontPlotTitle)); + textPL.setText(getFontDesc(preferences.fontPlotLabel)); + textPT.setText(getFontDesc(preferences.fontPlotTick)); ckAsyncUpdate.setSelected(preferences.asyncViewersUpdate); ckScanPlotDisabled.setSelected(preferences.scanPlotDisabled); ckScanTableDisabled.setSelected(preferences.scanTableDisabled); @@ -215,6 +225,15 @@ private void initComponents() { textSE = new javax.swing.JTextField(); buttonSE = new javax.swing.JButton(); buttonDefaultFonts = new javax.swing.JButton(); + jLabel22 = new javax.swing.JLabel(); + textPTit = new javax.swing.JTextField(); + buttonPTit = new javax.swing.JButton(); + textPL = new javax.swing.JTextField(); + jLabel23 = new javax.swing.JLabel(); + buttonPL = new javax.swing.JButton(); + buttonPT = new javax.swing.JButton(); + textPT = new javax.swing.JTextField(); + jLabel24 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); spinnerTab = new javax.swing.JSpinner(); @@ -345,40 +364,84 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); + jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel22.setText("Plot Title:"); + + textPTit.setEditable(false); + + buttonPTit.setText("Set"); + buttonPTit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonPTitActionPerformed(evt); + } + }); + + textPL.setEditable(false); + + jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel23.setText("Plot Label:"); + + buttonPL.setText("Set"); + buttonPL.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonPLActionPerformed(evt); + } + }); + + buttonPT.setText("Set"); + buttonPT.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonPTActionPerformed(evt); + } + }); + + textPT.setEditable(false); + + jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel24.setText("Plot Tick:"); + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() - .addGap(24, 24, 24) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4) - .addComponent(jLabel5)) + .addComponent(jLabel5) + .addComponent(jLabel22) + .addComponent(jLabel23) + .addComponent(jLabel24)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonDefaultFonts) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(textSP, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(textSC, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(textOP, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(textSE, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonSP) - .addComponent(buttonSC) - .addComponent(buttonOP) - .addComponent(buttonSE)))) + .addComponent(textSP, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textSC, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textOP, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textSE, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textPTit, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textPL, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textPT, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(buttonSP) + .addComponent(buttonSE) + .addComponent(buttonSC) + .addComponent(buttonOP) + .addComponent(buttonPTit) + .addComponent(buttonPL) + .addComponent(buttonPT)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(buttonDefaultFonts) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel2, jLabel3, jLabel4, jLabel5}); + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel2, jLabel22, jLabel23, jLabel24, jLabel3, jLabel4, jLabel5}); - jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textOP, textSC, textSE, textSP}); + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textOP, textPL, textPT, textPTit, textSC, textSE, textSP}); - jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonOP, buttonSC, buttonSE, buttonSP}); + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonOP, buttonPL, buttonPT, buttonPTit, buttonSC, buttonSE, buttonSP}); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -387,24 +450,38 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(textSP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(buttonSP)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonSP) + .addComponent(buttonDefaultFonts)) + .addGap(1, 1, 1) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(textSC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(buttonSC)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGap(1, 1, 1) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(textOP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(buttonOP)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGap(1, 1, 1) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(textSE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(buttonSE)) - .addGap(18, 18, 18) - .addComponent(buttonDefaultFonts) + .addGap(1, 1, 1) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel22) + .addComponent(textPTit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonPTit)) + .addGap(1, 1, 1) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel23) + .addComponent(textPL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonPL)) + .addGap(1, 1, 1) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel24) + .addComponent(textPT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonPT)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); @@ -650,7 +727,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(jLabel20) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(comboPlotsLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(314, Short.MAX_VALUE)) + .addContainerGap(321, Short.MAX_VALUE)) ); jPanel9Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel14, jLabel20}); @@ -756,7 +833,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { panelPlotsLayout.setHorizontalGroup( panelPlotsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelPlotsLayout.createSequentialGroup() - .addContainerGap() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(panelPlotsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING) @@ -774,7 +851,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(panelPlotsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(comboQuality, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(comboLayout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 116, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 84, Short.MAX_VALUE) .addGroup(panelPlotsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(panelPlotsLayout.createSequentialGroup() .addComponent(jLabel15) @@ -790,7 +867,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(jLabel18) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(spinnerMarkerSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) - .addContainerGap()) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); panelPlotsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel6, jLabel7, jLabel8, jLabel9}); @@ -858,7 +935,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(checkStatusBar) .addComponent(checkPersistRendererWindows) .addComponent(ckeckBackgroundRendering)) - .addContainerGap(329, Short.MAX_VALUE)) + .addContainerGap(374, Short.MAX_VALUE)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -922,7 +999,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(jPanel6Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 575, Short.MAX_VALUE) .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(buttonDefaultPanels) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) @@ -972,7 +1049,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(checkCachedDataPanel) - .addContainerGap(448, Short.MAX_VALUE)) + .addContainerGap(416, Short.MAX_VALUE)) .addGroup(jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(checkShowEmergencyStop) @@ -1055,7 +1132,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonOk) .addComponent(buttonCancel)) @@ -1085,6 +1162,9 @@ private void buttonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS preferences.fontEditor = selectedFonts[1]; preferences.fontOutput = selectedFonts[2]; preferences.fontShellCommand = selectedFonts[3]; + preferences.fontPlotLabel = selectedFonts[4]; + preferences.fontPlotTick = selectedFonts[5]; + preferences.fontPlotTitle = selectedFonts[6]; preferences.tabSize = (Integer) spinnerTab.getValue(); preferences.contentWidth = (Integer) spinnerContentWidth.getValue(); preferences.editorBackground = selectedEditorBackground; @@ -1179,13 +1259,16 @@ private void buttonDefaultPanelsActionPerformed(java.awt.event.ActionEvent evt) private void buttonDefaultFontsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDefaultFontsActionPerformed try { Font[] fonts = Preferences.getDefaultFonts(); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 7; i++) { selectedFonts[i] = fonts[i]; } textSP.setText(getFontDesc(fonts[0])); textSE.setText(getFontDesc(fonts[1])); textOP.setText(getFontDesc(fonts[2])); textSC.setText(getFontDesc(fonts[3])); + textPL.setText(getFontDesc(fonts[4])); + textPT.setText(getFontDesc(fonts[5])); + textPTit.setText(getFontDesc(fonts[6])); } catch (Exception ex) { SwingUtils.showException(PreferencesDialog.this, ex); } @@ -1243,6 +1326,18 @@ private void checkSyntaxHighlightActionPerformed(java.awt.event.ActionEvent evt) checkShowRowNumbers.setEnabled(checkSyntaxHighlight.isSelected()); }//GEN-LAST:event_checkSyntaxHighlightActionPerformed + private void buttonPTitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPTitActionPerformed + getFont(6, textPTit); + }//GEN-LAST:event_buttonPTitActionPerformed + + private void buttonPLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPLActionPerformed + getFont(4, textPL); + }//GEN-LAST:event_buttonPLActionPerformed + + private void buttonPTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPTActionPerformed + getFont(5, textPT); + }//GEN-LAST:event_buttonPTActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonCancel; private javax.swing.JButton buttonDefaultEditorColors; @@ -1252,6 +1347,9 @@ private void checkSyntaxHighlightActionPerformed(java.awt.event.ActionEvent evt) private javax.swing.JButton buttonInsert; private javax.swing.JButton buttonOP; private javax.swing.JButton buttonOk; + private javax.swing.JButton buttonPL; + private javax.swing.JButton buttonPT; + private javax.swing.JButton buttonPTit; private javax.swing.JButton buttonResetBackground; private javax.swing.JButton buttonSC; private javax.swing.JButton buttonSE; @@ -1297,6 +1395,9 @@ private void checkSyntaxHighlightActionPerformed(java.awt.event.ActionEvent evt) private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; + private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; @@ -1326,6 +1427,9 @@ private void checkSyntaxHighlightActionPerformed(java.awt.event.ActionEvent evt) private javax.swing.JSpinner spinnerTab; private javax.swing.JTable tablePanels; private javax.swing.JTextField textOP; + private javax.swing.JTextField textPL; + private javax.swing.JTextField textPT; + private javax.swing.JTextField textPTit; private javax.swing.JTextField textSC; private javax.swing.JTextField textSE; private javax.swing.JTextField textSP; diff --git a/src/main/java/ch/psi/pshell/ui/View.java b/src/main/java/ch/psi/pshell/ui/View.java index a68c7624..d9f5a206 100644 --- a/src/main/java/ch/psi/pshell/ui/View.java +++ b/src/main/java/ch/psi/pshell/ui/View.java @@ -1817,6 +1817,9 @@ public void applyPreferences() { PlotBase.setPlotBackground(preferences.plotBackground); PlotBase.setGridColor(preferences.gridColor); PlotBase.setOutlineColor(preferences.outlineColor); + PlotBase.setDefaultLabelFont(preferences.fontPlotLabel); + PlotBase.setDefaultTickFont(preferences.fontPlotTick); + PlotPanel.setTitleFont(preferences.fontPlotTitle); HistoryChart.setDefaultAsync(preferences.asyncViewersUpdate); if (preferences.linePlot != null) { diff --git a/src/main/python/pshell/client.py b/src/main/python/pshell/client.py index ef68bcdd..899ca346 100644 --- a/src/main/python/pshell/client.py +++ b/src/main/python/pshell/client.py @@ -339,7 +339,7 @@ def start_sse_event_loop_task(self, subscribed_events = None, event_callback = N """ Initializes server event loop task. Args: - subscribed_events: list of event names to substribe to. If None subscribes to all. + subscribed_events: list of event names to subscribe to. If None subscribes to all. event_callback: callback function. If None, self.on_event is called instead. Usage example: