Skip to content

Commit

Permalink
Release 1.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Morph21 committed Dec 20, 2024
1 parent 4a907dd commit 586109a
Show file tree
Hide file tree
Showing 42 changed files with 139 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mercury.platform.core;

public class MercuryConstants {
public static final String APP_VERSION = "1.3.7";
public static final String APP_VERSION = "1.3.8";
public static final String SERVER_HOST = "exslims.ddns.net";
public static final int PORT = 5555;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ public class ApplicationDescriptor implements Serializable {
private boolean checkOutUpdate;
private boolean hideTaskbarUntilHover;
private boolean poe2;
private Languages languages;
private Languages languages = Languages.en;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) {
default: {
if (!this.block) {
if (!lastPressed.contains(nativeKeyEvent.getKeyCode())) {
System.out.println("pressed " + nativeKeyEvent.getKeyChar());
MercuryStoreCore.hotKeySubject.onNext(this.getDescriptor(nativeKeyEvent));
lastPressed.add(nativeKeyEvent.getKeyCode());
}
Expand All @@ -51,7 +50,6 @@ public void nativeKeyPressed(NativeKeyEvent nativeKeyEvent) {
@Override
public void nativeKeyReleased(NativeKeyEvent nativeKeyEvent) {
if (!this.block) {
System.out.println("released " + nativeKeyEvent.getKeyChar());
MercuryStoreCore.hotKeyReleaseSubject.onNext(this.getDescriptor(nativeKeyEvent));
lastPressed.remove(nativeKeyEvent.getKeyCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void subscribe() {
this.frames.add(this.frameProviderFactory.getProviderFor(descriptor).getFrame(true));

AdrCaptureOutComponentFrame outFrame = new AdrCaptureOutComponentFrame((AdrCaptureDescriptor) descriptor);
outFrame.setPanel(new AdrCaptureOutPanel((AdrCaptureDescriptor) descriptor, new ComponentsFactory()));
outFrame.setPanel(new AdrCaptureOutPanel((AdrCaptureDescriptor) descriptor, ComponentsFactory.INSTANCE));
outFrame.init();
outFrame.showComponent();
outFrame.enableSettings();
Expand Down Expand Up @@ -284,7 +284,7 @@ private void initComponents(boolean showSettings) {
if (component instanceof AdrCaptureDescriptor) {
this.frames.add(this.frameProviderFactory.getProviderFor(component).getFrame(showSettings));
AdrCaptureOutComponentFrame outFrame = new AdrCaptureOutComponentFrame((AdrCaptureDescriptor) component);
outFrame.setPanel(new AdrCaptureOutPanel((AdrCaptureDescriptor) component, new ComponentsFactory()));
outFrame.setPanel(new AdrCaptureOutPanel((AdrCaptureDescriptor) component, ComponentsFactory.INSTANCE));
outFrame.init();
if (showSettings) {
outFrame.showComponent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public boolean isSuitable(AdrComponentDescriptor descriptor) {

@Override
public AdrComponentPanel getPanel() {
return new AdrCapturePanel((AdrCaptureDescriptor) this.descriptor, new ComponentsFactory());
return new AdrCapturePanel((AdrCaptureDescriptor) this.descriptor, ComponentsFactory.INSTANCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public AbstractAdrFrame getFrame(boolean showSettings) {

@Override
public AdrComponentPanel getPanel() {
return new AdrDurationCellPanel((AdrDurationComponentDescriptor) this.descriptor, new ComponentsFactory());
return new AdrDurationCellPanel((AdrDurationComponentDescriptor) this.descriptor, ComponentsFactory.INSTANCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public AbstractAdrFrame getFrame(boolean showSettings) {

@Override
public AdrComponentPanel getPanel() {
return new AdrTrackerGroupPanel((AdrTrackerGroupDescriptor) this.descriptor, new ComponentsFactory());
return new AdrTrackerGroupPanel((AdrTrackerGroupDescriptor) this.descriptor, ComponentsFactory.INSTANCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class AdrPagePanel<T> extends JPanel {
@Setter
protected boolean fromGroup;
protected T payload;
protected ComponentsFactory componentsFactory = new ComponentsFactory();
protected ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;
protected boolean advancedExpanded;
protected AdrComponentsFactory adrComponentsFactory = new AdrComponentsFactory(this.componentsFactory);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public abstract class AdrNodePanel<D extends AdrComponentDescriptor> extends JPanel implements ViewInit {
@Getter
protected D descriptor;
protected ComponentsFactory componentsFactory = new ComponentsFactory();
protected ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;
protected AdrComponentsFactory adrComponentsFactory = new AdrComponentsFactory(this.componentsFactory);
protected AdrMouseOverListener mouseListener;
protected AdrTreeNode<AdrComponentDescriptor> treeNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AdrTreePanel extends JPanel {
@Getter
@Setter
private AdrTreeNodeRenderer renderer;
private ComponentsFactory componentsFactory = new ComponentsFactory();
private ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;
@Getter
private List<AdrComponentDescriptor> descriptors;
private JPanel container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void onViewInit() {
tracker.setPreferredSize(new Dimension(48, 48));
tracker.setShowCase(true);
tracker.setValue(new Random().nextInt((int) (this.descriptor.getDuration() * 1000)));
tracker.setFont(new ComponentsFactory().getFont(FontStyle.BOLD, 20));
tracker.setFont(ComponentsFactory.INSTANCE.getFont(FontStyle.BOLD, 20));
tracker.setBackground(AppThemeColor.ADR_TEXT_ARE_BG);

JLabel titleLabel = this.componentsFactory.getTextLabel(this.descriptor.getTitle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


public class AdrDialogTreeNodeRenderer implements AdrTreeNodeRenderer {
private ComponentsFactory componentsFactory = new ComponentsFactory();
private ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;

@Override
public JPanel getViewOf(AdrTreeNode<AdrComponentDescriptor> node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void onViewInit() {
this.tracker.setPreferredSize(new Dimension(48, 48));
this.tracker.setShowCase(true);
this.tracker.setValue(new Random().nextInt((int) (this.descriptor.getDuration() * 1000)));
this.tracker.setFont(new ComponentsFactory().getFont(FontStyle.BOLD, 20));
this.tracker.setFont(ComponentsFactory.INSTANCE.getFont(FontStyle.BOLD, 20));
this.tracker.setBackground(AppThemeColor.ADR_TEXT_ARE_BG);

this.titleLabel = this.componentsFactory.getTextLabel(this.descriptor.getTitle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


public class AdrMainTreeNodeRenderer implements AdrTreeNodeRenderer {
private ComponentsFactory componentsFactory = new ComponentsFactory();
private ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;

@Override
public JPanel getViewOf(AdrTreeNode<AdrComponentDescriptor> treeNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void onViewInit() {
root.setBackground(AppThemeColor.SLIDE_BG);
this.tracker = new MercuryTracker(descriptor);
this.tracker.setValue((int) ((descriptor.getDuration() / 2) * 1000));
this.tracker.setFont(new ComponentsFactory().getFont(FontStyle.BOLD, 20));
this.tracker.setFont(ComponentsFactory.INSTANCE.getFont(FontStyle.BOLD, 20));
this.tracker.setPreferredSize(new Dimension(150, 36));
this.tracker.setShowCase(true);
this.tracker.setBackground(AppThemeColor.ADR_TEXT_ARE_BG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


public class IconsListCellRenderer implements ListCellRenderer<String> {
private ComponentsFactory componentsFactory = new ComponentsFactory();
private ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;
private IconBundleConfigurationService config = Configuration.get().iconBundleConfiguration();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class MercuryTracker extends JComponent {
public MercuryTracker(AdrDurationComponentDescriptor descriptor) {
this.descriptor = descriptor;
this.setMaximum((int) (this.descriptor.getDuration() * 1000));
this.setFont(new ComponentsFactory().getFont(FontStyle.BOLD, this.descriptor.getFontSize()));
this.setFont(ComponentsFactory.INSTANCE.getFont(FontStyle.BOLD, this.descriptor.getFontSize()));
this.setForeground(AppThemeColor.TEXT_DEFAULT);
this.setBackground(AppThemeColor.TRANSPARENT);
this.initUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.awt.*;

public abstract class AdrDialog<T> extends JDialog {
protected ComponentsFactory componentsFactory = new ComponentsFactory();
protected ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;
@Getter
protected T payload;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.mercury.platform.ui.components;

import com.mercury.platform.core.misc.SoundType;
import com.mercury.platform.shared.MainWindowHWNDFetch;
import com.mercury.platform.shared.entity.message.NotificationDescriptor;
import com.mercury.platform.shared.store.MercuryStoreCore;
import com.mercury.platform.ui.components.fields.font.FontStyle;
import com.mercury.platform.ui.components.fields.font.TextAlignment;
Expand Down Expand Up @@ -30,21 +32,36 @@
import java.io.IOException;
import java.net.URL;
import java.text.NumberFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
* Factory for each element which uses in application
*/
public class ComponentsFactory {
private final static Logger log = LogManager.getLogger(ComponentsFactory.class);

public static ComponentsFactory INSTANCE = ComponentsFactory.ComponentsFactoryHolder.HOLDER_INSTANCE;

private static class ComponentsFactoryHolder {
static final ComponentsFactory HOLDER_INSTANCE = new ComponentsFactory();
}

private Font BOLD_FONT;
private Font REGULAR_FONT;
private Font DEFAULT_FONT;
private Font CJK_FONT;
private Font KR_FONT;
private float scale;
private ExecutorService executor = Executors.newFixedThreadPool(3);
private List<Future<Font>> futures = new ArrayList<>();

private final static Map<TextAttribute, Float> boldAttr = new HashMap<TextAttribute, Float>() {{
put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
Expand All @@ -56,8 +73,7 @@ public class ComponentsFactory {
put(TextAttribute.WIDTH, TextAttribute.WIDTH_SEMI_CONDENSED);
}};


public ComponentsFactory() {
private ComponentsFactory() {
this.scale = 1.0f;
loadFonts();

Expand All @@ -71,13 +87,24 @@ public ComponentsFactory() {
*/
private void loadFonts() {
try {
Font base = Font.createFont(Font.TRUETYPE_FONT,
getClass().getClassLoader()
.getResourceAsStream("font/NotoSans-VariableFont.ttf"));
CJK_FONT = Font.createFont(Font.TRUETYPE_FONT,
getClass().getClassLoader().getResourceAsStream("font/GoNotoCJKCore.ttf"));
KR_FONT = Font.createFont(Font.TRUETYPE_FONT,
getClass().getClassLoader().getResourceAsStream("font/HayashiSerif.ttf"));

Instant start = Instant.now();
Callable<Font> baseCallable = () -> Font.createFont(Font.TRUETYPE_FONT, getClass().getClassLoader().getResourceAsStream("font/NotoSans-VariableFont.ttf"));
Callable<Font> cjkCallable = () -> Font.createFont(Font.TRUETYPE_FONT, getClass().getClassLoader().getResourceAsStream("font/GoNotoCJKCore.ttf"));
Callable<Font> krCallable = () -> Font.createFont(Font.TRUETYPE_FONT, getClass().getClassLoader().getResourceAsStream("font/HayashiSerif.ttf"));
futures.add(executor.submit(cjkCallable));
futures.add(executor.submit(krCallable));
futures.add(executor.submit(baseCallable));

Font base = futures.get(0).get();
CJK_FONT = futures.get(1).get();
KR_FONT = futures.get(2).get();


// Font base = Font.createFont(Font.TRUETYPE_FONT, getClass().getClassLoader().getResourceAsStream("font/NotoSans-VariableFont.ttf"));
// CJK_FONT = Font.createFont(Font.TRUETYPE_FONT, getClass().getClassLoader().getResourceAsStream("font/GoNotoCJKCore.ttf"));
// KR_FONT = Font.createFont(Font.TRUETYPE_FONT, getClass().getClassLoader().getResourceAsStream("font/HayashiSerif.ttf"));
Instant load = Instant.now();

DEFAULT_FONT = base.deriveFont(regularAttr);
BOLD_FONT = base.deriveFont(boldAttr);
Expand All @@ -95,6 +122,10 @@ private void loadFonts() {
genv.registerFont(REGULAR_FONT);
genv.registerFont(CJK_FONT);
genv.registerFont(KR_FONT);
Instant end = Instant.now();
System.out.println("loading fonts from file: " + (load.toEpochMilli() - start.toEpochMilli()) + " ms");
System.out.println("processing fonts took: " + (end.toEpochMilli() - load.toEpochMilli()) + " ms");
executor = null;

} catch (Exception e) {
log.error(e);
Expand Down Expand Up @@ -257,7 +288,7 @@ protected void paintBorder(Graphics g) {
@Override
public JToolTip createToolTip() {
JToolTip tip = ComponentsFactory.this.createTooltip(tooltip);
tip.setDoubleBuffered(true);
//tip.setDoubleBuffered(true);
return tip;
}

Expand All @@ -269,8 +300,8 @@ public JToolTip createToolTip() {
button.setBackground(button.getBackground());
}
});
if (tooltip.length() > 0) {
button.setToolTipText(tooltip);
if (!tooltip.isEmpty()) {
button.setToolTipText(wrapTextWithPadding(tooltip));
}

button.setFocusPainted(false);
Expand Down Expand Up @@ -334,6 +365,16 @@ public JToolTip createTooltip(String text) {
return toolTip;
}

private String wrapTextWithPadding(String text) {
StringBuilder b = new StringBuilder();
b.append("<html>");
b.append("<div style=\"padding: 2px 4px 2px 4px;\">");
b.append(text);
b.append("</div>");
b.append("</html>");
return b.toString();
}

public JButton getIconifiedTransparentButton(String iconPath, String tooltip) {
JButton iconButton = getIconButton(iconPath, 10, AppThemeColor.FRAME_RGB, tooltip);
iconButton.setIcon(getImage(iconPath));
Expand Down Expand Up @@ -493,7 +534,7 @@ public JToolTip createToolTip() {
return ComponentsFactory.this.createTooltip(tooltip);
}
};
iconLabel.setToolTipText(tooltip);
iconLabel.setToolTipText(wrapTextWithPadding(tooltip));
try {
iconLabel.setIcon(getIcon(iconPath, (int) (scale * size)));
} catch (Exception e) {
Expand Down Expand Up @@ -582,7 +623,7 @@ public JToolTip createToolTip() {
return ComponentsFactory.this.createTooltip(tooltip);
}
};
checkBox.setToolTipText(tooltip);
checkBox.setToolTipText(wrapTextWithPadding(tooltip));
checkBox.setFocusPainted(false);
checkBox.setBackground(AppThemeColor.TRANSPARENT);
// checkBox.setUI(new WindowsButtonUI());
Expand All @@ -609,7 +650,7 @@ public Font getFontByLang(String text, FontStyle style) {
}

public JPanel getSliderSettingsPanel(JLabel titleLabel, JLabel countLabel, JSlider slider) {
Dimension elementsSize = convertSize(new Dimension((int)scale*250, 30));
Dimension elementsSize = convertSize(new Dimension((int) scale * 250, 30));
Dimension countSize = convertSize(new Dimension(40, 30));
titleLabel.setPreferredSize(elementsSize);
slider.setPreferredSize(elementsSize);
Expand Down Expand Up @@ -950,4 +991,18 @@ public static boolean isKorean(String s) {
}
return s.codePoints().anyMatch(x -> Character.UnicodeScript.of(x).equals(Character.UnicodeScript.HANGUL));
}

public String getTooltipMessageForChatHistory(NotificationDescriptor source) {
StringBuilder b = new StringBuilder();

source.getRelatedMessages().stream().forEach(d -> {
b.append("<p>");
b.append(d.isIncoming() ? "> " : "");
b.append(d.getMessage());
b.append("<br/>");
b.append("</p>");
});
return b.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.stream.Collectors;

public class MDataTable<T> extends JPanel implements ViewInit, ViewDestroy, AfterViewInit {
private ComponentsFactory componentsFactory = new ComponentsFactory();
private ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;
private MColumn[] columns;
private MDataService<T> dataService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.swing.*;

public class NotificationTypeRenderer implements MCellRenderer<String> {
private ComponentsFactory componentsFactory = new ComponentsFactory();
private ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;

@Override
public JComponent getComponent(String data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.swing.*;

public class PlainDoubleRenderer implements MCellRenderer<Double> {
private ComponentsFactory componentsFactory = new ComponentsFactory();
private ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;

@Override
public JComponent getComponent(Double data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.awt.event.MouseEvent;

public class PlainIconRenderer implements MCellRenderer<String> {
private ComponentsFactory componentsFactory = new ComponentsFactory();
private ComponentsFactory componentsFactory = ComponentsFactory.INSTANCE;

@Override
public JComponent getComponent(String data) {
Expand Down
Loading

0 comments on commit 586109a

Please sign in to comment.