MCPcopy Create free account
hub / github.com/akeranen/the-one / addEvent

Method addEvent

gui/EventLogPanel.java:158–192  ·  view source on GitHub ↗

Adds a new event to the event log panel @param description Textual description of the event @param host1 Host that caused the event or null if there was not any @param host2 Another host that was involved in the event (or null) @param message Message that was involved in the event (or null) @param h

(String description, DTNHost host1,
			DTNHost host2, Message message, boolean highlight)

Source from the content-addressed store, hash-verified

156 * @param highlight If true, the log entry is highlighted
157 */
158 private void addEvent(String description, DTNHost host1,
159 DTNHost host2, Message message, boolean highlight) {
160 JPanel eventPane = new JPanel();
161 eventPane.setLayout(new BoxLayout(eventPane,BoxLayout.LINE_AXIS));
162
163 String text = String.format(ENTRY_FORMAT,
164 SimClock.getTime(),description);
165 JLabel label = new JLabel(text);
166 label.setFont(font);
167 eventPane.add(label);
168
169 if (host1 != null) {
170 addInfoButton(eventPane,host1,HOST_PROP);
171 }
172 if (host2 != null) {
173 JLabel betweenLabel = new JLabel(HOST_DELIM);
174 betweenLabel.setFont(font);
175 eventPane.add(betweenLabel);
176 addInfoButton(eventPane,host2,HOST_PROP);
177 }
178 if (message != null) {
179 addInfoButton(eventPane, message, MSG_PROP);
180 }
181
182 if (highlight) {
183 eventPane.setBackground(HIGHLIGHT_BG_COLOR);
184 }
185
186 eventPanes.add(eventPane);
187
188 // if the log is full, remove oldest entries first
189 if (this.eventPanes.size() > maxNrofEvents) {
190 eventPanes.remove(0);
191 }
192 }
193
194 /**
195 * Updates the log view

Callers 1

processEventMethod · 0.95

Calls 4

getTimeMethod · 0.95
addInfoButtonMethod · 0.95
formatMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected