-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Material Symbol icons, ability to import seed into KeyRing
- Loading branch information
Showing
7 changed files
with
142 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package convex.gui.utils; | ||
|
||
import java.awt.Color; | ||
import java.awt.Graphics2D; | ||
import java.awt.RenderingHints; | ||
import java.awt.image.BufferedImage; | ||
import java.util.WeakHashMap; | ||
|
||
import javax.swing.ImageIcon; | ||
import javax.swing.JLabel; | ||
|
||
@SuppressWarnings("serial") | ||
public class SymbolIcon extends ImageIcon { | ||
|
||
private static final Color SYMBOL_COLOUR = new Color(150,200,255); | ||
|
||
|
||
private static WeakHashMap<Long,SymbolIcon> cache= new WeakHashMap<>(); | ||
|
||
public SymbolIcon(BufferedImage image) { | ||
super(image); | ||
} | ||
|
||
private static SymbolIcon create(int codePoint, int size) { | ||
BufferedImage image =new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); | ||
|
||
char[] c=Character.toChars(codePoint); | ||
String s=new String(c); | ||
|
||
|
||
JLabel label = new JLabel(s); | ||
label.setForeground(SYMBOL_COLOUR); | ||
|
||
// set font size so we get the correct pixel size | ||
float fontSize= 72.0f * size / Toolkit.SCREEN_RES; | ||
label.setFont(Toolkit.SYMBOL_FONT.deriveFont(fontSize)); | ||
|
||
label.setHorizontalTextPosition(JLabel.CENTER); | ||
label.setVerticalTextPosition(JLabel.CENTER); | ||
|
||
label.setSize(size, size); | ||
|
||
Graphics2D g = image.createGraphics(); | ||
// have antialiasing on for better visuals | ||
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); | ||
label.print(g); | ||
|
||
return new SymbolIcon(image); | ||
} | ||
|
||
public static SymbolIcon get(int codePoint) { | ||
return get(codePoint,Toolkit.SYMBOL_SIZE); | ||
} | ||
|
||
public static SymbolIcon get(int codePoint, int size) { | ||
long id=codePoint+size*0x100000000L; | ||
SymbolIcon result=cache.get(id); | ||
|
||
if (result!=null) return result; | ||
|
||
result = create(codePoint,size); | ||
cache.put(id,result); | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
convex-gui/src/main/java/convex/gui/wallet/WalletPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package convex.gui.wallet; | ||
|
||
import javax.swing.JLabel; | ||
import javax.swing.JPanel; | ||
|
||
import convex.api.Convex; | ||
import convex.gui.components.AccountChooserPanel; | ||
import convex.gui.utils.SymbolIcon; | ||
import net.miginfocom.swing.MigLayout; | ||
|
||
@SuppressWarnings("serial") | ||
public class WalletPanel extends JPanel { | ||
|
||
public WalletPanel(Convex convex) { | ||
setLayout(new MigLayout()); | ||
|
||
add(new AccountChooserPanel(convex),"dock north"); | ||
|
||
add(new JLabel(SymbolIcon.get(0xe14a))); | ||
} | ||
} |
Binary file not shown.