了解/调试我继承的巨大Java Swing应用程序的线索 [英] Getting a clue at / debug a huge Java Swing App I've inherited

查看:143
本文介绍了了解/调试我继承的巨大Java Swing应用程序的线索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经被授予在Java / Swing应用程序中实现新的最终用户功能的任务。实施的任务相对简单直接。什么是繁琐的现有的应用程序被修改。

I've been given the task to implement a new end-user functionality into a Java/Swing application. The task to implement is relatively easy and straightforward. What is cumbersome is the existing app to be modified.

它包含数十个类,经常打破2000行barrer,有时达到10000行。
文档是不存在的,读取所有源代码以获得大图片是不可行的。

It comprises dozens of classes which often break the 2000 lines barrer and sometimes reach 10000 lines. Documentation is non existent and it is unfeasible to read all the source code to get the big picture of it.

应用程序本身基本上是一个GUI工具绘制图表(例如流程图)并且是开源的(如果有帮助,我可以发布链接到源代码)。

The app itself is basically a GUI tool to draw diagrams (e.g. flowcharts) and is open-source (I can post the link to the source code if it helps).

到目前为止,我已经设法导入源代码转换为Eclipse项目,并使用SwingExplorer插件来识别一些GUI组件。

So far I've managed to import the source code into an Eclipse project and use the SwingExplorer plugin to identify some of the GUI components.

应用程序中最有趣的部分是画布,其中的图形被绘制它实现为从JComponent继承的单个类(约9700行长)。
在SwingExplorer中无法选择显示图表的部分:整个画布仅被标识为上述类的单个实例。
因此,我猜这个巨大的单一类正在照顾所有的用户交互和图表的AWT绘图操作,并返回只是某种图像缓冲区来显示(但这是一个巨大的猜测)。

The most 'interesting' part of the app is the canvas onto which the diagram is drawn. It is implemented as a single class (about 9700 lines long) that inherits from JComponent. The parts of the displayed diagram can't be selected in SwingExplorer: the whole canvas is only identified as a single instance of the aforementioned class. I hence guess that this huge single class is taking care of all the user interactions and AWT drawing operations for the diagram and returning just some kind of image buffer to display (but this is a huge guess).

我的修改涉及在图表上进行计算,因为它正在画布上绘制。因此,它将成为一个新类,将在创建图表的特定元素期间接收和处理广播,然后对它们进行一些计算。

My modification involves doing computation on the diagram as it is being drawn on the canvas. Therefore it is going to be a new class which will receive and process events broadcast during the creation of specific elements of the diagram, and then do some computation on them.

我的主要的问题是:如何调试事件流?绘制图表时可以如何执行执行流程,并查看生成,处理的事件,并了解内存中绘制对象的位置?

My main problem is: how to debug the event flow? How can I follow the flow of execution when drawing a diagram and see which events are generated, processed and also get an idea of where in memory the objects being drawn reside?

我知道这个问题可能看起来太泛泛,但是我真的很无知,并且寻找一个出发点。

I know this question might seem too generic, but I'm really clueless and looking for a starting point.

提前感谢您花时间阅读;
Regards,
Marco

Thanks in advance only for taking the time to read through ;) Regards, Marco

推荐答案

在NetBeans中,我使用 File>新项目>具有现有来源的Java项目可以轻松导航。大多数IDE都有类似的功能。

In NetBeans, I use File > New Project > Java Project with Existing Sources to allow easy navigation. Most IDEs have a similar feature.


  • 使用运行>生成Javadoc ;即使没有意见,概述索引使用

  • Use Run > Generate Javadoc; even without comments, the Overview, Index, Use and Tree links may be useful.

在调试器中设置断点,并使用树 c>窗口>调试>调用堆栈来回答问题,如我如何到达这里。

Set breakpoints in the debugger and use Window > Debugging > Call Stack to answer question like, "How did I get here.

运行集成的 Profile> Profile Project 模式查看原则执行线程。

Run the code in the integrated Profile > Profile Project mode to see principle execution threads.

这篇关于了解/调试我继承的巨大Java Swing应用程序的线索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆