JavaFX library - trying to add attributes not on offer - java

I am using a JavaFX library, TilesFX. I am new to using libraries such as this. The library uses a builder class.
The builder allows properties to be added, for example a text property. I want to add a text field however, so when the user clicks on the text they can edit the contents.
The only way I can think to achieve this is by manually editing the library code to add in the text field class details.
This doesn't seem right to me, is there a better way of achieving this? Is it common for people to manipulate libraries?

Altering library code in your project is usually not a good idea.
This particular library releases a new version every few days. If you alter the code, you'll have a hard time upgrading to a new version, that might contain bug fixes or features you need.
If the library cannot be configured to the way you'd like to work, you can either try to find something else that does what you want, or try to contribute code to the library you're working with (or just do it yourself).
The way to go about it, is to fork the library, add the feature you want, and submit a pull-request to the library maintainers.

Related

Is there a way to use external libraries in IntelliJ without downloading their .jars?

I am trying to write a standalone Java application in IntelliJ using edu.stanford.nlp.trees.GrammaticalStructure. Therefore, I have imported the module:
import edu.stanford.nlp.trees.GrammaticalStructure;
Currently, Intellij doesn't recognize this and many others of the imported external libraries (cannot resolve the symbols) and is also not able to automatically download/import them.
Is there a way to use the GrammaticalStructure class without having to download the entire Stanford CoreNLP .jar and adding it to the project as a library? This question applies to other dependencies as well, since I want to use other external libraries but avoid including their .jar files as much as possible (to minimize the size of the final application, given that it will be standalone). Unfortunately, all the solutions I have found proposed exactly that.
Apologies if I have overlooked some basic setting or setup steps, it has been a while since I have worked with Java.
Any help is greatly appreciated.
If you want to use it means you want to execute the code in them. How is the runtime supposed to execute code that is does not have? How is the compiler supposed to know how the code is defined (e.g. what the classes look like)? This is simply impossible. If you want to use the code you have to provide it to the compiler as well as the runtime.
If you just dont want to include all of that code into your application, you need either access to the sources and just pick the class you need or you need some kind of JAR minimizer as #CrazyCoder suggested.

Is there a way to leave notes in library code in eclipse?

due to reasons I am working with undocumented java library code that I cannot alter in any way or write into. Im using eclipse 2020-06 and I would like to leaves some notes for myself to make things easier. Is there a way to do that? or maybe an eclipse extension?
You can use bookmarks. They work somewhat similarly to breakpoints, without pausing execution when you're debugging.
You can add them via the context menu.
If I recall, you're a bit limited by the amount of information you can add. It's basically just a single text box.
See the help section on bookmarks
Maybe there's some plugins which extend the functionality (e.g. this one for adding keyboard shortcuts)

How do I use MUpdf in an existing java project

Mupdf documentation shows me how to use the library as an application and deploy it. However, I want to suck it into an existing java project and build my application on top of it. Can this be done? If so, how do I bring just the pieces needed, into my project?
Take a look at jMuPdf. I never used it, but it seems to be active.
Otherwise you will need to create Java Native Bindings (JNA or JNI).

Accessing information about Java libraries programmatically

I would like to write toy IDE for Java, so I ask a question about one particular thing that as I hope can help me get started.
I have editor implemented on top of swing and i have some text in there. There is for example:
import java.util.List;
Now I need a way to send "java.util.List" string to a method that returns me all the information I may need including JavaDoc document.
So is there any tool that can set up classpath with libraries, that would parse every string I send and try to find if there is any Class/Interface with documentation to return?
So is there any tool that can set up classpath with libraries, that would parse every string I send and try to find if there is any Class/Interface with documentation to return?
AFAIK, no. There is no such free-standing tool or library. You will need to implement it yourself. (Don't expect that writing a Java IDE is simple ... even a "toy" one.)
Libraries will have class files, which will not have javadocs.. So it is not clear what you want to do.
There are many byte code engineering tools to analyse and extract information from class files. For example asm or bcel. Javassist allows to process both source and byte code, so may be close to what you need.
You could use html parser to get the javadoc and other info from the web using the full path to the class (including package names to construct the correct URL per class). This will of course depend on the version of java you are using.
You can also use the javadoc tool from within java to generate the desired documentation from java source files (which can be downloaded from the web). The source code of the tool could also help you out. See http://java.sun.com/j2se/javadoc/faq/#developingwithjavadoc
Lastly, if you need information based on runtime types in your program, you might want to check reflection capabilities.
First you need to know How to print imported java libraries?. Then download java API documentation here. Once you find out imported libraries, open an inputStream in order to read appropriate HTML file.
Beware! This technic will only work when importing from jdk.

Automated way to find number of usages?

Are there any open source tools that automate the functionality of finding the number of usages of a Java API? I can figure out this information for one class at a time in my IDE. I want to use this information to create a rudimentary report on the speed of adoption of a particular library. I would create a daily report on the number of usages of dozens of classes, and I would report on several code bases.
I'd go with one of those tools for analyzing dependencies in Java code. Let it work on your source tree, a package or a single class and see if you can export the results to XML or something like that. I've used Dependency Finder in a project about two years ago and I think it should do what you want. Not sure about the export to XML, though.
In Eclipse you can right click on a method name or class and go to the References menu and from there you can choose the scope of where you want to search for classes that reference that item.
Is that what you need?
I'm going to try Macker. Its style is to report references to configured classes as errors, but that's fine. It can be run from an automated build. Thanks Robert.

Categories