diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/FontAction.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/FontAction.java index c8ca56398..f8ca8a843 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/FontAction.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/actions/FontAction.java @@ -72,10 +72,7 @@ public void run() { // Set default font on first selected object FontData fontData = FontFactory.getDefaultUserViewFontData(); - String rgbValue = null; - - rgbValue = model.getFontColor(); - String fontValue = model.getFont(); + String fontValue = FontFactory.getPlatformDependentFontString(model.getFont()); if(fontValue != null) { try { fontData = new FontData(fontValue); @@ -89,7 +86,7 @@ public void run() { dialog.setText(Messages.FontAction_1); dialog.setEffectsVisible(false); // Don't allow underline/strikeout on Windows. See https://github.com/archimatetool/archi/issues/851 dialog.setFontList(new FontData[] { fontData } ); - dialog.setRGB(ColorFactory.convertStringToRGB(rgbValue)); + dialog.setRGB(ColorFactory.convertStringToRGB(model.getFontColor())); FontData selectedFontData = dialog.open(); if(selectedFontData != null) { diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/AbstractBaseEditPart.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/AbstractBaseEditPart.java index 0c9881cfa..fdb4d2ab2 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/AbstractBaseEditPart.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/AbstractBaseEditPart.java @@ -76,10 +76,11 @@ public IDiagramModelObjectFigure getFigure() { */ @Override protected void applicationPreferencesChanged(PropertyChangeEvent event) { - // Default font or colour preferences changed + // Default font or colour preferences changed, or font scaling changed if(IPreferenceConstants.DEFAULT_VIEW_FONT.equals(event.getProperty()) || event.getProperty().startsWith(IPreferenceConstants.DEFAULT_FILL_COLOR_PREFIX) || - event.getProperty().equals(IPreferenceConstants.DEFAULT_ELEMENT_LINE_COLOR)) { + event.getProperty().equals(IPreferenceConstants.DEFAULT_ELEMENT_LINE_COLOR) || + event.getProperty().equals(IPreferenceConstants.PLATFORM_FONT_SCALING)) { refreshFigure(); } diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/DiagramConnectionEditPart.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/DiagramConnectionEditPart.java index 558b3cb4b..39280b642 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/DiagramConnectionEditPart.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/editparts/DiagramConnectionEditPart.java @@ -191,6 +191,9 @@ else if(IPreferenceConstants.CONNECTION_LABEL_STRATEGY.equals(property)) { else if(IPreferenceConstants.VIEWPOINTS_GHOST_DIAGRAM_ELEMENTS.equals(property)) { getFigure().refreshVisuals(); } + else if(IPreferenceConstants.PLATFORM_FONT_SCALING.equals(property)) { + getFigure().refreshVisuals(); + } } @Override diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java index 4141aec78..d179a9b63 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java @@ -153,7 +153,7 @@ protected void setDisabledState(Graphics graphics) { * Set the font to that in the model, or failing that, as per user's default */ protected void setFont() { - String fontName = fDiagramModelObject.getFont(); + String fontName = FontFactory.getPlatformDependentFontString(fDiagramModelObject.getFont()); setFont(FontFactory.get(fontName)); // Need to do this after font change diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/connections/AbstractDiagramConnectionFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/connections/AbstractDiagramConnectionFigure.java index 723321b4f..a760bca80 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/connections/AbstractDiagramConnectionFigure.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/connections/AbstractDiagramConnectionFigure.java @@ -178,7 +178,7 @@ protected void setConnectionText() { * Set the font in the label to that in the model, or failing that, as per user's default */ protected void setLabelFont() { - String fontName = getModelConnection().getFont(); + String fontName = FontFactory.getPlatformDependentFontString(getModelConnection().getFont()); Font font = FontFactory.get(fontName); // Possible font scaling for non 96 DPI on Windows or if property set diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/GeneralPreferencePage.java b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/GeneralPreferencePage.java index 9df50dd58..7359d26e1 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/GeneralPreferencePage.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/GeneralPreferencePage.java @@ -44,9 +44,9 @@ public class GeneralPreferencePage private Button fWarnOnDeleteButton; private Button fShowSpecializationsModelTreeButton; - private Button fScaleImagesButton; - private Button fAddDocumentationNoteButton; + private Button fScaleImagesButton; + private Button fScaleFontsButton; private Button fUseEdgeBrowserButton; @@ -146,6 +146,11 @@ protected Control createContents(Composite parent) { fScaleImagesButton.setLayoutData(createHorizontalGridData(2)); fScaleImagesButton.setToolTipText(Messages.GeneralPreferencePage_14); + fScaleFontsButton = new Button(otherGroup, SWT.CHECK); + fScaleFontsButton.setText(Messages.GeneralPreferencePage_25); + fScaleFontsButton.setLayoutData(createHorizontalGridData(2)); + fScaleFontsButton.setToolTipText(Messages.GeneralPreferencePage_26); + // Internal Browser Group browserGroup = new Group(client, SWT.NULL); browserGroup.setText(Messages.GeneralPreferencePage_19); @@ -222,6 +227,8 @@ private void setValues() { fAddDocumentationNoteButton.setSelection(getPreferenceStore().getBoolean(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE)); + fScaleFontsButton.setSelection(getPreferenceStore().getBoolean(PLATFORM_FONT_SCALING)); + if(fUseEdgeBrowserButton != null) { fUseEdgeBrowserButton.setSelection(getPreferenceStore().getBoolean(EDGE_BROWSER)); } @@ -254,6 +261,8 @@ public boolean performOk() { getPreferenceStore().setValue(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE, fAddDocumentationNoteButton.getSelection()); + getPreferenceStore().setValue(PLATFORM_FONT_SCALING, fScaleFontsButton.getSelection()); + if(fUseEdgeBrowserButton != null) { getPreferenceStore().setValue(EDGE_BROWSER, fUseEdgeBrowserButton.getSelection()); } @@ -288,6 +297,8 @@ protected void performDefaults() { fAddDocumentationNoteButton.setSelection(getPreferenceStore().getDefaultBoolean(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE)); + fScaleFontsButton.setSelection(getPreferenceStore().getDefaultBoolean(PLATFORM_FONT_SCALING)); + if(fUseEdgeBrowserButton != null) { fUseEdgeBrowserButton.setSelection(getPreferenceStore().getDefaultBoolean(EDGE_BROWSER)); } diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/IPreferenceConstants.java b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/IPreferenceConstants.java index 48e81f6a7..a153fcbf6 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/IPreferenceConstants.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/IPreferenceConstants.java @@ -103,9 +103,6 @@ public interface IPreferenceConstants { // Whether to use a line offset in all cases for figures drawn on hi-res screens String USE_FIGURE_LINE_OFFSET = "figureLineOffset"; - // Whether to add a note to the documentation field of relationships that have been changed to Association when setting a new concept type - String ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE = "addDocumentationNoteOnRelationChange"; - // Appearance String DEFAULT_ARCHIMATE_FIGURE_WIDTH = "defaultArchiMateFigureWidth"; @@ -135,7 +132,10 @@ public interface IPreferenceConstants { String USE_LABEL_EXPRESSIONS_IN_ANALYSIS_TABLE = "useLabelExpressionInAnalysisTable"; + // Whether to add a note to the documentation field of relationships that have been changed to Association when setting a new concept type + String ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE = "addDocumentationNoteOnRelationChange"; String SCALE_IMAGE_EXPORT = "scaleImageExport"; + String PLATFORM_FONT_SCALING = "platformFontScaling"; // Animation String ANIMATE_VIEW = "animateView"; diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/Messages.java b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/Messages.java index f63a71ea0..84f518156 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/Messages.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/Messages.java @@ -287,6 +287,10 @@ public class Messages extends NLS { public static String GeneralPreferencePage_24; + public static String GeneralPreferencePage_25; + + public static String GeneralPreferencePage_26; + public static String GeneralPreferencePage_3; public static String GeneralPreferencePage_4; diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/PreferenceInitializer.java b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/PreferenceInitializer.java index f3cd7f924..d41f9831c 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/PreferenceInitializer.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/PreferenceInitializer.java @@ -104,8 +104,6 @@ public void initializeDefaultPreferences() { // Windows at hi-res needs this set to true store.setDefault(USE_FIGURE_LINE_OFFSET, PlatformUtils.isWindows() && ImageFactory.getDeviceZoom() > 100); - store.setDefault(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE, false); - // Appearance store.setDefault(DEFAULT_ARCHIMATE_FIGURE_WIDTH, 120); @@ -131,8 +129,10 @@ public void initializeDefaultPreferences() { store.setDefault(USE_LABEL_EXPRESSIONS_IN_ANALYSIS_TABLE, true); + store.setDefault(ADD_DOCUMENTATION_NOTE_ON_RELATION_CHANGE, false); // Windows hi-res and Mac Retina use 200 zoom, Linux is 100 store.setDefault(SCALE_IMAGE_EXPORT, (!PlatformUtils.isLinux() && ImageFactory.getDeviceZoom() > 100) ? true : false); + store.setDefault(PLATFORM_FONT_SCALING, true); // Animation store.setDefault(ANIMATE_VIEW, false); diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/messages.properties b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/messages.properties index 6a138d750..8dc2acb35 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/preferences/messages.properties +++ b/com.archimatetool.editor/src/com/archimatetool/editor/preferences/messages.properties @@ -144,6 +144,8 @@ GeneralPreferencePage_21=Enable JavaScript in Hints GeneralPreferencePage_22=Allow External Hosts in Hints GeneralPreferencePage_23=If a connected relation type is changed as a result of changing an Element's type,\na note will be added to the Relation's documentation field. GeneralPreferencePage_24=Show Specializations in "New" menu +GeneralPreferencePage_25=Adjust font height for each platform +GeneralPreferencePage_26=Adjust font height when a font height has been set on another operating system platform GeneralPreferencePage_3=Animation GeneralPreferencePage_4=Animate Views GeneralPreferencePage_5=Automatically create a backup file (*.bak) when saving diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FontSection.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FontSection.java index 1db332a2a..6a8522249 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FontSection.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/FontSection.java @@ -131,14 +131,12 @@ else if(event.getProperty() == ColorChooser.PROP_COLORDEFAULT) { }; /** - * Listen to default font change in Prefs + * Listen to default font change and font scaling in Prefs */ - private IPropertyChangeListener prefsListener = new IPropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().startsWith(IPreferenceConstants.DEFAULT_VIEW_FONT)) { - update(); - } + private IPropertyChangeListener prefsListener = event -> { + if(event.getProperty().startsWith(IPreferenceConstants.DEFAULT_VIEW_FONT) + || IPreferenceConstants.PLATFORM_FONT_SCALING.equals(event.getProperty())) { + update(); } }; diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/ui/FontFactory.java b/com.archimatetool.editor/src/com/archimatetool/editor/ui/FontFactory.java index 31a1f9b28..a39ed36a1 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/ui/FontFactory.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/ui/FontFactory.java @@ -153,7 +153,7 @@ public static Font getScaledFont96DPI(Font font) { FontData[] fd = font.getFontData(); float factor = (float)96 / DPI; - int newHeight = (int)(fd[0].getHeight() * factor); + int newHeight = Math.round(fd[0].getHeight() * factor); fd[0].setHeight(newHeight); String fontName = fd[0].toString(); @@ -168,6 +168,40 @@ public static Font getScaledFont96DPI(Font font) { return font; } + /** + * Return a FontData string with adjusted font height if the FontData string is not for the current platform. + * @param fontDataString The FontData string + * @return The Font Data String for the current platform or the same string if there is no change. + */ + public static String getPlatformDependentFontString(String fontDataString) { + if(StringUtils.isSet(fontDataString) && ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.PLATFORM_FONT_SCALING)) { + float factor = 0; + + // On Mac but fontdata contains Windows or Linux + if(PlatformUtils.isMac() && (fontDataString.contains("|WINDOWS|") || fontDataString.contains("|GTK|"))) { + factor = (float)96 / 72; + } + // On Windows or Linux but font came from Mac + else if(!PlatformUtils.isMac() && fontDataString.contains("|COCOA|")) { + factor = (float)72 / 96; + } + + if(factor != 0) { + try { + FontData fd = new FontData(fontDataString); + int newHeight = Math.round(fd.getHeight() * factor); + fd.setHeight(newHeight); + fontDataString = fd.toString(); + } + catch(Exception ex) { + //ex.printStackTrace(); + } + } + } + + return fontDataString; + } + /** * @param font * @return The italic variant of the given font diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/ui/components/FontChooser.java b/com.archimatetool.editor/src/com/archimatetool/editor/ui/components/FontChooser.java index 374fb5f9f..752a2adb8 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/ui/components/FontChooser.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/ui/components/FontChooser.java @@ -240,7 +240,7 @@ public void chooseFont() { protected void updateFont() { fFontData = FontFactory.getDefaultUserViewFontData(); - String fontValue = fFontObject.getFont(); + String fontValue = FontFactory.getPlatformDependentFontString(fFontObject.getFont()); if(fontValue != null) { try { fFontData = new FontData(fontValue); @@ -275,24 +275,16 @@ protected void updateButtonText() { } /** - * Adds a property change listener to this ColorSelector. - * Events are fired when the color in the control changes via the user - * clicking an selecting a new one in the color dialog. No event is fired in - * the case where setColorValue(RGB) is invoked. - * - * @param listener - * a property change listener + * Adds a property change listener to listen for font change events. + * @param listener a property change listener */ public void addListener(IPropertyChangeListener listener) { addListenerObject(listener); } /** - * Removes the given listener from this ColorSelector. Has - * no effect if the listener is not registered. - * - * @param listener - * a property change listener + * Removes the given listener. Has no effect if the listener is not registered. + * @param listener a property change listener */ public void removeListener(IPropertyChangeListener listener) { removeListenerObject(listener); @@ -300,9 +292,6 @@ public void removeListener(IPropertyChangeListener listener) { /** * Fire the given event to listeners - * @param propertyName - * @param oldValue - * @param newValue */ private void fireActionListenerEvent(String propertyName, Object oldValue, Object newValue) { final Object[] finalListeners = getListeners(); diff --git a/com.archimatetool.help/help/Text/prefs_general.html b/com.archimatetool.help/help/Text/prefs_general.html index 158d93a42..e71383617 100644 --- a/com.archimatetool.help/help/Text/prefs_general.html +++ b/com.archimatetool.help/help/Text/prefs_general.html @@ -56,7 +56,10 @@

Other

When this is selected, images are exported and copied to the clipboard at twice their normal size. This is set on by default for Windows operating systems where display scaling is greater than 100%, and on Mac Retina devices. This is so that the exported image quality is not compromised since it is not possible to set a higher DPI in the image. This setting is usually not needed on Linux displays.

If the resulting image needs to be at its logical size you could edit it in an image editor and set the DPI to double its value. For example, on Mac change the DPI from to 72 to 144.

+
+

Adjust font height for each platform
+ When this is selected, fonts are adjusted to match the DPI (dots per inch) setting for the current platform. For example, you might work on an Archi model on Windows and set the font height for an object to 10. However, when opening the model on Mac the font will appear too small because Mac uses 72 DPI while Windows uses 96 DPI. Conversely, you might set the font height on Mac but it appears too big on Windows. This setting adjusts for this difference so that font heights are the same on all platforms.


Internal Web Browser

diff --git a/org.opengroup.archimate.xmlexchange/src/org/opengroup/archimate/xmlexchange/XMLModelExporter.java b/org.opengroup.archimate.xmlexchange/src/org/opengroup/archimate/xmlexchange/XMLModelExporter.java index ef8f97e8b..d1407c19c 100644 --- a/org.opengroup.archimate.xmlexchange/src/org/opengroup/archimate/xmlexchange/XMLModelExporter.java +++ b/org.opengroup.archimate.xmlexchange/src/org/opengroup/archimate/xmlexchange/XMLModelExporter.java @@ -1033,7 +1033,7 @@ Element writeFont(IFontAttribute fontObject, Element styleElement) { try { FontData fontData = null; - String fontString = fontObject.getFont(); + String fontString = FontFactory.getPlatformDependentFontString(fontObject.getFont()); if(fontString != null) { fontData = new FontData(fontString); }