Ashley Bye

Ranch Hand
+ Follow
since Jan 30, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Ashley Bye

I've got a small graphics processing application that I'm writing in Rust. It has various graphics backends (Metal, Vulkan, D3D) depending on the underlying OS. I'd like to create a simple application in Java (probably JavaFX but I could use AWT) as a proof of concept to allow a user to make simple tweaks to the graphics. However, I'm unsure about how to approach this interop. I don't want (or think I need to use LWJGL) because the Rust library handles this. What I really want is to:

1. Create a window.
2. Assign a portion of that window to be the render context for my Rust library.
3. Assign the other parts of that window to be my editing widgets.
4. Be able to detect mouse clicks in (2) to select rendered objects and alter them with (3).

I expect there is some amount of FFI work that needs to be done, which I know I'll need to look into. Where I'm really lost is how I hook up the graphics so that the Java app displays the rendered image and is able to process input.

Any thoughts or suggestions about how to procede?
I'm writing a little game engine with LWJGL as my graphics library. For testing purposes I'd like to be able to either launch LWGJL as a separate process or call `main` directly and be able to compare past and previous screenshots (a bit like Reacts snapshots). On macOS, LWJGL requires the JVM to be started with `-XrunOnFirstThread`.

The first option is problematic because there is no easy way to capture graphical output or simulate input. The pro of this approach is that it would truly be end-to-end and exercise the system as an external user would.

The second option is problematic because I can't configure Junit5 to run each test on the first thread (I'd accept sequential tests too). The pro of this approach is that it doesn't require all kinds of external dependencies, such as xvfb, to be installed before tests can be run.

For what it's worth, I envisage something like the following test code (maybe game would be injected into system, tbd):



Has anyone any thoughts or suggestions on how I can achieve this?
Thanks Tim. I'm curious as to the rationale behind that decision. Is there any particular reason post editing is not a general feature? The only reason I can think of is users editing their post to remove or significantly change it after one or more replies, thus losing discussion context. Makes sense to limit editing in that case.
6 years ago
It's been a while since I contributed to this site, but having just done so, I noticed a mistake in my post:

Ah, I'll quickly change this. But wait, there is no edit button. Oh!

Where has the 'Edit' button gone? Was there ever an edit button? Or do I need to go and purchase a set of spectacles?
6 years ago

Aaron McCarthy wrote:Here is the actual assignment as well for additional context.
- Location (this represents a class called Location which has 2 points: longitude & latitude)



I'd suggest that you ought not to be passing the latitude and longitude as arguments, but should instead be passing a Location object.



In your move methods, you can create a new Location object, e.g:



Etc.
6 years ago
I'd be interested in working on a game project. Perhaps it could be educational too? I've been thinking for a while that making a game of Decisions & Disruptions could be a fun idea.
6 years ago
Okay, thanks. I'll take a look and see what I come up with.
7 years ago
I have put together a relatively small app which calculates some properties of a graph to help me learn JavaFX. The GUI opens a new tab for each graph created. Since some of the calculations can be quite long running (e.g. with a large number of nodes specified), I want to show the new tab and have the properties display "Calculating..." until they have been computed, at which point they should then show the result. However, what actually happens is that the app hangs until all the calculations have been completed.

Each of the calculations is computed using a Task:



When creating the view, the individual tasks are specified, e.g.:



With the result of the Task as a Worker bound to the textProperty() of the relevant TextField:



Once the View has been added to a new Tab and shown, I execute the tasks:





For what it's worth, full source code is available on GitHub.

What am I doing incorrectly that causes the app to hang until the tab has finished calculating all the values?
7 years ago
Ah, so I still need to include it on the classpath even if deployed to an App Server?
7 years ago
Although in the configuration posted I've used a database named Employee rather than SimpleWebProject, which would lead to a revised connection URL from that given in the first post.
7 years ago
In standalone.xml:

7 years ago
The following is based on Wildfly 10.1 Standalone and Derby Remote client. I assume the same will be true for other environments.

I have deployed derbyclient.jar to the deployments folder and registered a DataSource in Wildfly named 'SimpleWebProjectDS', a JNDI-Name of 'java:jboss/SimpleWebProjectDS' and associated this with the deployed Derby driver. The server URL is set to 'jdbc:derby://localhost:1527/SimpleWebProjectDB;create=true'.

With Derby running on port 1527, the following causes a ClassNotFoundException:



The following executes without throwing an exception and produces the expected functionality:



Why does the first solution cause a ClassNotFoundError?
7 years ago
According to this presentation the correct way to load resources is using Class.getResource(). As it transpires, it's right. I'm not sure what I did yesterday that caused this not to work, probably not sleeping! However, the following fixes the problem I was having:

7 years ago
I'm trying to load a stylesheet that is saved as a resource in my module, but receive the following warning when running the application under JDK9 using the module system:

When running under JDK 8, this was loaded fine with the following directory structure:



It is my understanding that for named modules in Java 9, I should be able to use either the Class or ClassLoader to load a resource and that doing so looks for the resource in module/package.name, e.g. chapter8-styling-nodes/com/jdojo/resources/css/buttonstyles.css, and I've updated the module structure to reflect this. However, if I attempt to load the stylesheet this way, I get various exceptions related to reflection. I can load the resource and read it from an InputStream:



I obviously can't add this to the scene's stylesheets as it's not a URL. If I try to load the stylesheet as a URL and convert it to a string, the below excerpt yields the following result:



Using the same method as for JDK8 results in the resource not being found. Adjusting the path for JDK9 seems to have similar effects. How should I go about adding a stylesheet to a scene in a named module in Java9?
7 years ago
The exam questions at the end of Ch5 in the OCA8 book asks what is and isn't true about interfaces.



One of the possible answers is "A class that implements HasVocalChords must override the method makeSound()". This option is considered incorrect, with the explanation that an abstract class doesn't need to implement the method.

My question, therefore, is: in the exam, should I assume that in any circumstance, unless specifically stated otherwise, the word "class" refers to both concrete and abstract classes?