mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Make FontPreference a public non-abstract class for backwards compatibility
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class DelegatingFontPreferences implements FontPreferences {
|
||||
public class DelegatingFontPreferences extends FontPreferences {
|
||||
private Supplier<FontPreferences> myDelegateSupplier;
|
||||
|
||||
public DelegatingFontPreferences(@NotNull Supplier<FontPreferences> delegateSupplier) {
|
||||
|
||||
+34
-18
@@ -22,36 +22,52 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public interface FontPreferences {
|
||||
@NonNls @NotNull String DEFAULT_FONT_NAME = getDefaultFontName();
|
||||
int DEFAULT_FONT_SIZE = FontSize.SMALL.getSize();
|
||||
public class FontPreferences {
|
||||
public final static @NonNls @NotNull String DEFAULT_FONT_NAME = getDefaultFontName();
|
||||
public final static int DEFAULT_FONT_SIZE = FontSize.SMALL.getSize();
|
||||
|
||||
float DEFAULT_LINE_SPACING = 1.0f;
|
||||
String FALLBACK_FONT_FAMILY = "Monospaced";
|
||||
String MAC_OS_DEFAULT_FONT_FAMILY = "Menlo";
|
||||
String LINUX_DEFAULT_FONT_FAMILY = "DejaVu Sans Mono";
|
||||
String WINDOWS_DEFAULT_FONT_FAMILY = FALLBACK_FONT_FAMILY;
|
||||
public final static float DEFAULT_LINE_SPACING = 1.0f;
|
||||
public final static String FALLBACK_FONT_FAMILY = "Monospaced";
|
||||
public final static String MAC_OS_DEFAULT_FONT_FAMILY = "Menlo";
|
||||
public final static String LINUX_DEFAULT_FONT_FAMILY = "DejaVu Sans Mono";
|
||||
public final static String WINDOWS_DEFAULT_FONT_FAMILY = FALLBACK_FONT_FAMILY;
|
||||
|
||||
@NotNull
|
||||
List<String> getEffectiveFontFamilies();
|
||||
public List<String> getEffectiveFontFamilies() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
List<String> getRealFontFamilies();
|
||||
public List<String> getRealFontFamilies() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String getFontFamily();
|
||||
public String getFontFamily() {
|
||||
return FALLBACK_FONT_FAMILY;
|
||||
}
|
||||
|
||||
int getSize(@NotNull String fontFamily);
|
||||
public int getSize(@NotNull String fontFamily) {
|
||||
return DEFAULT_FONT_SIZE;
|
||||
}
|
||||
|
||||
void copyTo(@NotNull FontPreferences preferences);
|
||||
public void copyTo(@NotNull FontPreferences preferences) {
|
||||
}
|
||||
|
||||
boolean useLigatures();
|
||||
public boolean useLigatures() {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasSize(@NotNull String fontName);
|
||||
public boolean hasSize(@NotNull String fontName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float getLineSpacing();
|
||||
public float getLineSpacing() {
|
||||
return DEFAULT_LINE_SPACING;
|
||||
}
|
||||
|
||||
/**
|
||||
* There is a possible case that particular font family is not available at particular environment (e.g. Monaco under *nix).
|
||||
@@ -67,7 +83,7 @@ public interface FontPreferences {
|
||||
* <code>null</code> if font family with the given name is registered at the current environment
|
||||
*/
|
||||
@Nullable
|
||||
static String getFallbackName(@NotNull String fontName, int fontSize, @Nullable EditorColorsScheme fallbackScheme) {
|
||||
public static String getFallbackName(@NotNull String fontName, int fontSize, @Nullable EditorColorsScheme fallbackScheme) {
|
||||
Font plainFont = new Font(fontName, Font.PLAIN, fontSize);
|
||||
if (plainFont.getFamily().equals("Dialog") && !("Dialog".equals(fontName) || fontName.startsWith("Dialog."))) {
|
||||
return fallbackScheme == null ? DEFAULT_FONT_NAME : fallbackScheme.getEditorFontName();
|
||||
@@ -75,7 +91,7 @@ public interface FontPreferences {
|
||||
return null;
|
||||
}
|
||||
|
||||
static String getDefaultFontName() {
|
||||
public static String getDefaultFontName() {
|
||||
if (SystemInfo.isWindows) return WINDOWS_DEFAULT_FONT_FAMILY;
|
||||
if (SystemInfo.isMacOSSnowLeopard) return MAC_OS_DEFAULT_FONT_FAMILY;
|
||||
if (SystemInfo.isXWindow && !GraphicsEnvironment.isHeadless()) {
|
||||
|
||||
+12
-12
@@ -19,16 +19,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ModifiableFontPreferences extends FontPreferences {
|
||||
void clear();
|
||||
void clearFonts();
|
||||
void setUseLigatures(boolean useLigatures);
|
||||
void addFontFamily(String family);
|
||||
void register(String family, int size);
|
||||
void setEffectiveFontFamilies(List<String> fontFamilies);
|
||||
void setRealFontFamilies(List<String> fontFamilies);
|
||||
void setTemplateFontSize(int size);
|
||||
void setLineSpacing(float lineSpacing);
|
||||
void resetFontSizes();
|
||||
void setFontSize(@NotNull String fontFamily, int size);
|
||||
public abstract class ModifiableFontPreferences extends FontPreferences {
|
||||
public abstract void clear();
|
||||
public abstract void clearFonts();
|
||||
public abstract void setUseLigatures(boolean useLigatures);
|
||||
public abstract void addFontFamily(String family);
|
||||
public abstract void register(String family, int size);
|
||||
public abstract void setEffectiveFontFamilies(List<String> fontFamilies);
|
||||
public abstract void setRealFontFamilies(List<String> fontFamilies);
|
||||
public abstract void setTemplateFontSize(int size);
|
||||
public abstract void setLineSpacing(float lineSpacing);
|
||||
public abstract void resetFontSizes();
|
||||
public abstract void setFontSize(@NotNull String fontFamily, int size);
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ import java.util.List;
|
||||
* @author Denis Zhdanov
|
||||
* @since 12/20/12 9:37 PM
|
||||
*/
|
||||
public class FontPreferencesImpl implements ModifiableFontPreferences {
|
||||
public class FontPreferencesImpl extends ModifiableFontPreferences {
|
||||
|
||||
@NotNull private final TObjectIntHashMap<String> myFontSizes = new TObjectIntHashMap<>();
|
||||
@NotNull private final List<String> myEffectiveFontFamilies = ContainerUtilRt.newArrayList();
|
||||
|
||||
Reference in New Issue
Block a user