23 package com.realtime.crossfire.jxclient.gui.misc;
29 import java.awt.Color;
30 import java.awt.Component;
31 import java.awt.Container;
32 import java.awt.Dimension;
33 import java.awt.Graphics;
34 import java.awt.Point;
35 import java.awt.event.MouseEvent;
36 import java.awt.event.MouseWheelEvent;
37 import java.io.IOException;
38 import java.io.Writer;
39 import java.time.LocalDateTime;
40 import java.time.format.DateTimeFormatter;
41 import java.util.Locale;
42 import java.util.regex.Pattern;
43 import javax.swing.JRootPane;
44 import org.jetbrains.annotations.NotNull;
45 import org.jetbrains.annotations.Nullable;
90 private static final DateTimeFormatter
FORMATTER = DateTimeFormatter.ofPattern(
"yyyy-MM-dd HH:mm:ss,SSS ", Locale.ENGLISH);
146 @SuppressWarnings(
"UnusedParameters")
150 final double distance =
clickPosition.distanceSq(e.getLocationOnScreen());
152 debugMouseWrite(
"mouseDragged: distance "+distance+
" is too far for a click event; click point="+
clickPosition+
", current point="+e.getLocationOnScreen());
207 if (tmpIsClicked && element !=
null) {
211 element.mouseClicked(e);
263 if (element !=
null) {
264 element.mouseEntered(e);
277 if (element ==
null) {
281 final int wheelRotation = e.getWheelRotation();
283 element.mouseWheelMoved(wheelRotation);
292 if (component !=
null) {
295 final String text1 =
formatName(component)+
" "+component.getWidth()+
"x"+component.getHeight()+
"+"+x1+
"+"+y1;
297 final Container parent = component.getParent();
300 final String text2 = parent ==
null ?
"" :
formatName(parent)+
" "+parent.getWidth()+
"x"+parent.getHeight()+
"+"+x2+
"+"+y2;
305 g.setColor(Color.BLACK);
306 g.fillRect(0, 2, Math.max(dimension1.width, dimension2.width)+4, dimension1.height+dimension2.height+16);
308 g.setColor(Color.RED);
309 g.drawString(text1, 2, dimension1.height+8-6);
310 g.drawRect(x1, y1, component.getWidth()-1, component.getHeight()-1);
312 if (parent !=
null) {
313 g.setColor(Color.ORANGE);
314 g.drawString(text2, 2, dimension1.height+dimension2.height+16-6);
315 g.drawRect(x2, y2, parent.getWidth()-1, parent.getHeight()-1);
326 private static String
formatName(@NotNull
final Component component) {
327 return PATTERN_PACKAGE_NAME.matcher(component.getClass().getName()).replaceAll(
"")+
"/"+component.getName();
344 }
catch (
final IOException ex) {
345 System.err.println(
"Cannot write mouse debug: "+ex.getMessage());
347 throw new AssertionError(ex);
361 if (this.activeComponent !=
null) {
362 this.activeComponent.setChanged();
366 final JRootPane rootPane = tmp.getRootPane();
367 if (rootPane !=
null) {
374 if (this.activeComponent !=
null) {
378 final JRootPane rootPane = tmp.getRootPane();
379 if (rootPane !=
null) {