Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* MIT License
*
* Copyright (c) 2020 Jannis Weis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf;
import com.github.weisj.darklaf.components.border.DarkBorders;
import com.github.weisj.darklaf.platform.Decorations;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.util.SystemInfo;
import sun.awt.AppContext;
import javax.swing.*;
import javax.swing.plaf.basic.BasicLookAndFeel;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.font.TextAttribute;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Method;
import java.text.AttributedCharacterIterator;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author Jannis Weis
*/
public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener {
private static final Logger LOGGER = Logger.getLogger(DarkLaf.class.getName());
private static final String NAME = "Darklaf";
private final BasicLookAndFeel base;
/**
* Create Custom Darcula LaF.
*/
public DarkLaf() {
LafManager.getTheme().beforeInstall();
base = getBase();
}
private BasicLookAndFeel getBase() {
BasicLookAndFeel baseLaf;
if (SystemInfo.isWindows || SystemInfo.isLinux) {
baseLaf = new MetalLookAndFeel();
} else {
final String systemLafClassName = UIManager.getSystemLookAndFeelClassName();
final LookAndFeel currentLaf = UIManager.getLookAndFeel();
if (currentLaf != null && systemLafClassName.equals(currentLaf.getClass().getName())) {
baseLaf = currentOrFallback(currentLaf);
} else {
try {
UIManager.setLookAndFeel(systemLafClassName);
baseLaf = currentOrFallback(UIManager.getLookAndFeel());
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e.getStackTrace());
throw new IllegalStateException("Could not load base LaF class." + e.getMessage());
}
}
}
return baseLaf;
}
private BasicLookAndFeel currentOrFallback(final LookAndFeel currentLaf) {
if (currentLaf instanceof BasicLookAndFeel) {
return (BasicLookAndFeel) currentLaf;
} else {
return new MetalLookAndFeel();
}
}
@Override
public UIDefaults getDefaults() {
try {
final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
superMethod.setAccessible(true);
final UIDefaults metalDefaults = (UIDefaults) superMethod.invoke(new MetalLookAndFeel());
final UIDefaults defaults = (UIDefaults) superMethod.invoke(base);
initInputMapDefaults(defaults);
loadThemeDefaults(defaults);
initIdeaDefaults(defaults);
patchComboBox(metalDefaults, defaults);
if (SystemInfo.isMac) {
patchMacOSFonts(defaults);
}
setupDecorations();
return defaults;
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.toString(), e.getStackTrace());
}
return super.getDefaults();
}
private void patchMacOSFonts(final UIDefaults defaults) {
for (Map.Entry