Skip to content
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 @@ -37,6 +37,8 @@
AddPV_PeriodTT,
AppendSearchResults,
AppendSearchResultsTT,
AreaOpacity,

Check warning on line 40 in app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static AreaOpacity" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7V564FD6QiI-cq2uLr&open=AZ7V564FD6QiI-cq2uLr&pullRequest=3838

Check warning on line 40 in app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "AreaOpacity" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7V564FD6QiI-cq2uLt&open=AZ7V564FD6QiI-cq2uLt&pullRequest=3838

Check warning on line 40 in app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make AreaOpacity a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7V564FD6QiI-cq2uLp&open=AZ7V564FD6QiI-cq2uLp&pullRequest=3838
AreaOpacityTT,

Check warning on line 41 in app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make AreaOpacityTT a static final constant or non-public and provide accessors if needed.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7V564FD6QiI-cq2uLq&open=AZ7V564FD6QiI-cq2uLq&pullRequest=3838

Check warning on line 41 in app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this "public static AreaOpacityTT" field final

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7V564FD6QiI-cq2uLs&open=AZ7V564FD6QiI-cq2uLs&pullRequest=3838

Check warning on line 41 in app/databrowser/src/main/java/org/csstudio/trends/databrowser3/Messages.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "AreaOpacityTT" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AZ7V564FD6QiI-cq2uLu&open=AZ7V564FD6QiI-cq2uLu&pullRequest=3838
ArchiveFetchDetailFmt,
ArchiveFetchJobFmt,
ArchiveFetchProgressFmt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ public class Model
/** Background color */
private volatile Color background = Color.WHITE;

/**
* Area opacity, common for all plots.
*/
private volatile int areaOpacity = Preferences.opacity;

/** Title font */
private volatile Font title_font = Font.font("Liberation Sans", FontWeight.BOLD, 20);

Expand Down Expand Up @@ -426,7 +431,7 @@ else if (j < i) {
item.fireItemLookChanged(); // Prevents the "Axis" UI-setting (under the "Traces" tab) from sometimes not displaying in the UI when moving axes.
}
}
};
}

/** @return How should plot rescale after archived data arrived? */
public ArchiveRescale getArchiveRescale()
Expand Down Expand Up @@ -1009,4 +1014,16 @@ public ModelItem getItemByUniqueId(String uniqueId){
}
return items.stream().filter(item -> uniqueId.equals(item.getUniqueId())).findAny().orElse(null);
}

public int getAreaOpacity(){
return areaOpacity;
}

public void setAreaOpacity(int areaOpacity){
this.areaOpacity = areaOpacity;
getItems().forEach(item -> {
for (ModelListener listener : listeners)
listener.changedItemLook(item);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ abstract public class ModelItem
*/
private volatile Color color = null;

/** RGB for item's area color
*/
private volatile Color areaColor = null;

/** How to display the trace */
private volatile TraceType trace_type = Preferences.trace_type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class ModelBasedPlot
public ModelBasedPlot(final boolean active)
{
plot = new RTTimePlot(active);
plot.setOpacity(Preferences.opacity);
plot.setAreaOpacity(Preferences.opacity);
plot.showLegend(false);

final Button time_config_button =
Expand Down Expand Up @@ -368,6 +368,7 @@ public void updateTrace(final ModelItem item)
// These happen to not cause an immediate redraw, so
// set even if no change
trace.setColor(item.getPaintColor());
plot.setAreaOpacity(item.getModel().get().getAreaOpacity());
trace.setType(item.getTraceType());
trace.setWidth(item.getLineWidth());
trace.setLineStyle(item.getLineStyle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ public class FontButton extends Button
italic = new CheckBox(Messages.FontBtnItalics);
private TextField example = new TextField(Messages.FontBtnExample);

private final PopOver popover;
private PopOver popover;

private Font font;
private final Consumer<Font> on_font_selected;
private Consumer<Font> on_font_selected;

public FontButton(){
}

/** @param initial_font Intiial font
* @param on_font_selected Callback for selected font
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,213 +7,47 @@
******************************************************************************/
package org.csstudio.trends.databrowser3.ui.properties;

import java.time.Duration;
import java.io.IOException;
import java.util.ResourceBundle;

import javafx.fxml.FXMLLoader;
import org.csstudio.trends.databrowser3.Messages;
import org.csstudio.trends.databrowser3.model.Model;
import org.csstudio.trends.databrowser3.model.ModelListener;
import org.phoebus.framework.nls.NLS;
import org.phoebus.ui.undo.UndoableActionManager;

import javafx.geometry.Insets;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.GridPane;

/** Property tab for misc. items
* @author Kay Kasemir
*/
@SuppressWarnings("nls")
public class MiscTab extends Tab
{
private final Model model;

/** Flag to prevent recursion when this tab updates the model and thus triggers the model_listener */
private boolean updating = false;

private final TextField title = new TextField(), update_period = new TextField(), scroll_step = new TextField();
private CheckBox save_changes = new CheckBox(), show_legend = new CheckBox();
private ColorPicker foreground = new ColorPicker(), background = new ColorPicker();
private FontButton title_font, label_font, scale_font, legend_font;

/** Update Tab when model changes (undo, ...) */
private ModelListener model_listener = new ModelListener()
{
@Override
public void changedSaveChangesBehavior(boolean do_save_changes)
{
if (updating)
return;
save_changes.setSelected(do_save_changes);
}

@Override
public void changedLayout()
{
if (updating)
return;
show_legend.setSelected(model.isLegendVisible());
}

@Override
public void changedTitle()
{
if (updating)
return;
title.setText(model.getTitle().orElse(""));
}

@Override
public void changedColorsOrFonts()
{
if (updating)
return;
foreground.setValue(model.getPlotForeground());
background.setValue(model.getPlotBackground());
title_font.selectFont(model.getTitleFont());
label_font.selectFont(model.getLabelFont());
scale_font.selectFont(model.getScaleFont());
legend_font.selectFont(model.getLegendFont());
}

@Override
public void changedTiming()
{
if (updating)
return;
update_period.setText(Double.toString(model.getUpdatePeriod()));
scroll_step.setText(Double.toString(model.getScrollStep().toMillis() / 1000.0));
}
};


MiscTab(final Model model, final UndoableActionManager undo)
{
super(Messages.Miscellaneous);
this.model = model;

final GridPane layout = new GridPane();
layout.setHgap(5);
layout.setVgap(5);
layout.setPadding(new Insets(5));
// layout.setGridLinesVisible(true); // Debug layout


layout.add(new Label(Messages.TitleLbl), 0, 0);
title.setTooltip(new Tooltip(Messages.TitleTT));
title.setOnAction(event ->
{
updating = true;
new ChangeTitleCommand(model, undo, title.getText());
updating = false;
});
layout.add(title, 1, 0);

layout.add(new Label(Messages.UpdatePeriodLbl), 0, 1);
layout.add(update_period, 1, 1);
update_period.setOnAction(event ->
{
updating = true;
final double period = Double.parseDouble(update_period.getText().trim());
new ChangeUpdatePeriodCommand(model, undo, period);
updating = false;
});

layout.add(new Label(Messages.ScrollStepLbl), 0, 2);
layout.add(scroll_step, 1, 2);
scroll_step.setOnAction(event ->
{
updating = true;
try
{
final Duration step = Duration.ofMillis(
Math.round( Double.parseDouble(scroll_step.getText().trim()) * 1000.0 ) );
new ChangeScrollStepCommand(model, undo, step);
}
catch (Exception ex)
{
scroll_step.setText(Double.toString(model.getScrollStep().toMillis() / 1000.0));
super(Messages.Miscellaneous);
ResourceBundle resourceBundle = NLS.getMessages(Messages.class);
FXMLLoader loader = new FXMLLoader();
loader.setResources(resourceBundle);
loader.setLocation(this.getClass().getResource("MiscTab.fxml"));

loader.setControllerFactory(clazz -> {
if(clazz.isAssignableFrom(MiscTabController.class)){
try {
return clazz.getConstructor(Model.class, UndoableActionManager.class).newInstance(model, undo);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
updating = false;
});

layout.add(new Label(Messages.ForegroundColorLbl), 0, 3);
foreground.setStyle("-fx-color-label-visible: false ;");
layout.add(foreground, 1, 3);
foreground.setValue(model.getPlotForeground());
foreground.setOnAction(event ->
{
updating = true;
new ChangePlotForegroundCommand(model, undo, foreground.getValue());
updating = false;
});

layout.add(new Label(Messages.BackgroundColorLbl), 0, 4);
background.setStyle("-fx-color-label-visible: false ;");
layout.add(background, 1, 4);
background.setValue(model.getPlotBackground());
background.setOnAction(event ->
{
updating = true;
new ChangePlotBackgroundCommand(model, undo, background.getValue());
updating = false;
});

layout.add(new Label(Messages.SaveChangesLbl), 0, 5);
save_changes.setTooltip(new Tooltip(Messages.SaveChangesTT));
save_changes.setOnAction(event ->
{
updating = true;
new ChangeSaveChangesCommand(model, undo, save_changes.isSelected());
updating = false;
return null;
});
layout.add(save_changes, 1, 5);

layout.add(new Label(Messages.TitleFontLbl), 2, 0);
title_font = new FontButton(model.getTitleFont(),
font -> new ChangeFontCommand(model, undo, model.getTitleFont(), font, (m, f) -> m.setTitleFont(f)));
title_font.setMaxWidth(Double.MAX_VALUE);
layout.add(title_font, 3, 0);

layout.add(new Label(Messages.LabelFontLbl), 2, 1);
label_font = new FontButton(model.getLabelFont(),
font -> new ChangeFontCommand(model, undo, model.getLabelFont(), font, (m, f) -> m.setLabelFont(f)));
label_font.setMaxWidth(Double.MAX_VALUE);
layout.add(label_font, 3, 1);

layout.add(new Label(Messages.ScaleFontLbl), 2, 2);
scale_font = new FontButton(model.getScaleFont(),
font -> new ChangeFontCommand(model, undo, model.getScaleFont(), font, (m, f) -> m.setScaleFont(f)));
scale_font.setMaxWidth(Double.MAX_VALUE);
layout.add(scale_font, 3, 2);

layout.add(new Label(Messages.LegendFontLbl), 2, 3);
legend_font = new FontButton(model.getLegendFont(),
font -> new ChangeFontCommand(model, undo, model.getLegendFont(), font, (m, f) -> m.setLegendFont(f)));
legend_font.setMaxWidth(Double.MAX_VALUE);
layout.add(legend_font, 3, 3);

layout.add(new Label(Messages.LegendLbl), 2, 4);
show_legend.setOnAction(event ->
{
updating = true;
new ChangeShowLegendCommand(model, undo, show_legend.isSelected());
updating = false;
});
layout.add(show_legend, 3, 4);

setContent(layout);

model.addListener(model_listener);

// Initial values
model_listener.changedTitle();
model_listener.changedColorsOrFonts();
model_listener.changedSaveChangesBehavior(model.shouldSaveChanges());
model_listener.changedTiming();
model_listener.changedLayout();
try {
setContent(loader.load());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Loading
Loading