MCPcopy Index your code
hub / github.com/benfry/processing4 / init

Method init

app/src/processing/app/tools/CreateFont.java:85–220  ·  view source on GitHub ↗
(Base base)

Source from the content-addressed store, hash-verified

83
84
85 public void init(Base base) {
86 this.base = base;
87
88 Container paine = getContentPane();
89 paine.setLayout(new BorderLayout()); //10, 10));
90
91 JPanel pain = new JPanel();
92 pain.setBorder(new EmptyBorder(13, 13, 13, 13));
93 paine.add(pain, BorderLayout.CENTER);
94
95 pain.setLayout(new BoxLayout(pain, BoxLayout.Y_AXIS));
96
97 String labelText = Language.text("create_font.label");
98
99 JTextArea textarea = new JTextArea(labelText);
100 textarea.setBorder(new EmptyBorder(10, 10, 20, 10));
101 textarea.setBackground(null);
102 textarea.setEditable(false);
103 textarea.setHighlighter(null);
104 textarea.setFont(new Font("Dialog", Font.PLAIN, 12));
105 pain.add(textarea);
106
107
108 // getFontList is deprecated in 1.4, so this has to be used
109 //long t = System.currentTimeMillis();
110 GraphicsEnvironment ge =
111 GraphicsEnvironment.getLocalGraphicsEnvironment();
112 Font[] fonts = ge.getAllFonts();
113 //System.out.println("font startup took " + (System.currentTimeMillis() - t) + " ms");
114
115 nameToFont = new HashMap<>();
116
117 for (Font font : fonts) {
118 try {
119 if (!skipFontFamily(font.getFamily())) {
120 // Use the PostScript name since it has a little more consistency
121 nameToFont.put(font.getPSName(), font);
122 }
123 } catch (Exception e) {
124 // Fonts can cause all kinds of weird trouble; just ignore and move on.
125 // https://github.com/processing/processing/issues/481
126 e.printStackTrace();
127 }
128 }
129
130 fontNames = nameToFont.keySet().toArray(new String[0]);
131 Arrays.sort(fontNames, String.CASE_INSENSITIVE_ORDER);
132 fontSelector = new JList<>(fontNames);
133 fontSelector.addListSelectionListener(e -> {
134 if (!e.getValueIsAdjusting()) {
135 selection = fontSelector.getSelectedIndex();
136 okButton.setEnabled(true);
137 update();
138 }
139 });
140
141 fontSelector.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
142 fontSelector.setVisibleRowCount(12);

Callers

nothing calls this directly

Calls 15

textMethod · 0.95
skipFontFamilyMethod · 0.95
updateMethod · 0.95
buildMethod · 0.95
setIconMethod · 0.95
setEditableMethod · 0.80
getFamilyMethod · 0.80
addDocumentListenerMethod · 0.80
setSelectedMethod · 0.80
setVisibleMethod · 0.65
setResizableMethod · 0.65

Tested by

no test coverage detected