Skip to content
Open
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 @@ -43,23 +43,20 @@ public class FontButton extends Button
private final ComboBox<String> size = new ComboBox<>(FXCollections.observableArrayList("8", "10", "12", "14", "16", "18", "22", "24", "32"));
private final CheckBox bold = new CheckBox(Messages.FontBtnBold),
italic = new CheckBox(Messages.FontBtnItalics);
private TextField example = new TextField(Messages.FontBtnExample);
private final TextField example = new TextField(Messages.FontBtnExample);

private PopOver popover;
private final PopOver popover;

private Font font;
private Consumer<Font> on_font_selected;

public FontButton(){
}

/** @param initial_font Intiial font
* @param on_font_selected Callback for selected font
/**
* No-arg constructor needed by FXML.
* <p>
* Initial font and on_font_selected callback must be set if this constructor is used.
* </p>
*/
public FontButton(final Font initial_font, final Consumer<Font> on_font_selected)
{
this.font = initial_font;
this.on_font_selected = on_font_selected;
public FontButton(){
popover = new PopOver(createContent());
setOnAction(event ->
{
Expand All @@ -70,6 +67,16 @@ public FontButton(final Font initial_font, final Consumer<Font> on_font_selected
});
}

/** @param initial_font Initial font
* @param on_font_selected Callback for selected font
*/
public FontButton(final Font initial_font, final Consumer<Font> on_font_selected)
{
this();
this.font = initial_font;
this.on_font_selected = on_font_selected;
}

private Node createContent()
{
// Name: combo
Expand Down Expand Up @@ -171,4 +178,12 @@ private String getDescription(final Font font)
buf.append(",").append(font.getStyle());
return buf.toString();
}
}

public void setOnFontSelected(final Consumer<Font> onFontSelected) {
this.on_font_selected = onFontSelected;
}

public void setInitialFont(final Font initialFont) {
this.font = initialFont;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ public void initialize()
model.setAreaOpacity((int)Math.round(opacitySlider.getValue()));
updating = false;
});

titleFont.setOnFontSelected(font -> new ChangeFontCommand(model, undo, model.getTitleFont(), font, (m, f) -> m.setTitleFont(f)));
titleFont.setInitialFont(model.getTitleFont());

labelFont.setOnFontSelected(font -> new ChangeFontCommand(model, undo, model.getLabelFont(), font, (m, f) -> m.setLabelFont(f)));
labelFont.setInitialFont(model.getLabelFont());

scaleFont.setOnFontSelected(font -> new ChangeFontCommand(model, undo, model.getScaleFont(), font, (m, f) -> m.setScaleFont(f)));
scaleFont.setInitialFont(model.getScaleFont());

legendFont.setOnFontSelected(font -> new ChangeFontCommand(model, undo, model.getLegendFont(), font, (m, f) -> m.setLegendFont(f)));
legendFont.setInitialFont(model.getLegendFont());
}

// -----------------------------------------------------------------------
Expand Down
Loading