What is the most common (and cross platform) way to deal with movie files in Java? The Java Media Framework 2.1 API says it works with AVI and a few other formats, but when it comes to things like mp4 or others, what are my options. As an additional question, is JMF still the preferred way to deal with Media in Java, or has it been replaced/outdated? Jo fucked around with this message at 00:17 on Jan 5, 2010 |
|
# ¿ Jan 4, 2010 23:10 |
|
|
# ¿ May 20, 2024 10:09 |
EDIT: Nevermind. Code was fine, just forgot to tell the drawing thread to sleep so the input events weren't being serviced quickly.
Jo fucked around with this message at 01:34 on Oct 4, 2010 |
|
# ¿ Oct 4, 2010 00:14 |
Elos posted:That method just loops trough an array asking the tiles to draw themselves. I don't have any real reason for drawing it constantly besides wanting to see how it's done and hell, I might want to make it a pseudo-realtime like Diablo or something. We're working on VERY similar projects. I had the same problem and realized that the CPU consumption was perfectly fine -- just that I wasn't telling the draw thread to wait and allow the input function to run, which made everything feel very laggy. Catch me on aim (MostlyDeadAllDay) or send me a PM. We may have a lot of overlap.
|
|
# ¿ Oct 24, 2010 18:49 |
A tangentially related note: I'm allocating hardware memory and have an alpha-transparent png loaded as below:code:
EDIT: I swear to god I spend hours on these things only to solve them moments after I ask for help. I loving hate that. Problem was in getHardwareMemoryChunk, which had a wrong value for transparency. drawImage works fine. Least it works now. Jo fucked around with this message at 20:06 on Oct 24, 2010 |
|
# ¿ Oct 24, 2010 19:12 |
Internet Janitor posted:Jo: Spiffy. Is that lighting baked into your maps, or calculated on the fly? I think your perspective is slightly off. If those walls are one square high, this shadow line should be moved down, so the shadow begins where the back of that wall would touch the ground: It's baked. In another version of this code it is all realtime with dynamic shadows and penumbras, but that's a mess and not worth diving into again.
|
|
# ¿ Oct 26, 2010 07:08 |
I'm running into a problem with input. When doing this, sometimes my player entity will simply stop moving for reasons I can't explain. It didn't seem to happen with any other style of input polling. Are there any glaring logic errors here?code:
|
|
# ¿ Nov 12, 2010 06:43 |
baquerd posted:Either max acceleration is being set to zero or the directionQueue is empty after a key release event from what you've shown here. Is this threaded? What class is directionQueue? DirectionQueue is local to the InputMan class. Yes, this is multithreaded. I do not know where acceleration could be changing. Max acceleration is constant. EDIT: Whaaa? Added some more print statements: jo@Euclid:~/source/tilegame/dist$ java -jar Tilegame.jar KEY DOWN:S KEY UP:S KEY DOWN:S KEY UP:S ... This is from HOLDING the 's' key. Why would multiple key events be generated from a single key hold?
|
|
# ¿ Nov 12, 2010 08:54 |
baquerd posted:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4504217 Oh. Thanks! EDIT: Turns out there's a better way to do this. KeyBindings is the Swing equivalent of KeyListener. Jo fucked around with this message at 01:02 on Nov 14, 2010 |
|
# ¿ Nov 12, 2010 09:12 |
As a start, I'd like to apologize for spamming requests to help to this thread without really contributing. Thank you to all those who have provided feedback to my inane problems. The most recent issue, a change from the AWT method of input to the Swing method of input, has left me daft. The following code does not work for reasons I can't explain. code:
|
|
# ¿ Nov 15, 2010 07:21 |
Paolomania posted:I may be wrong, but I think that content panes, not being input widgets, never get input focus. Ah. Okay. Thanks.
|
|
# ¿ Nov 15, 2010 16:35 |
I'd like to have my program's assets stored inside the jar itself to avoid problems when someone has a strange working directory, and to make it easier to move the program around. Simultaneously, I'd like to be able to avoid having to repack the jar every time I change a file. This compels me to leave the assets outside the jar in my assets folder. Better put, if the loader finds a file in ./assets/, use that. Otherwise, load it from the <jar root>/assets/. The solution I've heard to be universal is, `URL url = Main.class.getResource(filename);`, where filename is 'assets/mainmenu.png'. Is there a way which does not require code changes between 'outside' file references and in-jar file references? Or do I have to do something like, 'if(new File(wat).exists()) {dance} else {load url from jar}'?
|
|
# ¿ Apr 8, 2012 17:38 |
Aleksei Vasiliev posted:This is more or less what I have done. Centralized file loading method that first attempts to load from the directory, then falls back to the JAR. Many thanks. That's what I've got set up. I guess it's not _that_ ugly a solution. Ranma posted:Do you have a build script that generates the jar? You should. If so why do you care? Some of the elements might be updated after the jar is created. I can create a self-contained Jar without issue, but if our graphics person is fiddling, I don't want her to have to open the jar, extract the image, and repack it. Even a three step process can be a pain in the butt if you're making lots of little tweaks. Jo fucked around with this message at 17:55 on Apr 8, 2012 |
|
# ¿ Apr 8, 2012 17:53 |
As a general policy, if I have a constructor in Java which takes two points (for example) and produces a line, is it a good idea to use the points as a reference or should I make copies? That is...Java code:
Java code:
|
|
# ¿ Aug 22, 2012 16:13 |
Internet Janitor posted:Jo: Well, Points are mutable. It depends on what you're trying to do. In some situations it can be very useful to have composed objects update under your feet, but if you mutate the Points that are passed in it may seem like "spooky action at a distance" from the caller's perspective. At any rate, it is indeed an important issue to consider, and worth documenting. I was fiddling with a reimplementation of Ken Silverman's BUILD engine. Part of my reasoning was, if someone dicks with a vertex, I'd like to see the lines and sectors update automatically without having to iterate through each line and sector. At the same time, perhaps that's the correct way to do it on update. What if someone hoses a vertex? We'd need to update all the lines and sectors anyways to account for the loss.
|
|
# ¿ Aug 22, 2012 16:54 |
pigdog posted:Also check out Flyweight pattern if it's applicable in your context. Thank you. I think this will be beneficial.
|
|
# ¿ Aug 22, 2012 22:29 |
On the subject of maven, I've come to realize that my understanding of Java's class/jar/internals is pretty weak. I learned it as a course in my undergrad career and have continued using it, but I realize when it comes to doing things like building ant files or importing jars from external applications, I'm fuzzy. Is there a book or a collection of tutorials which don't really cover the details of learning the Java language, but highlight things like linking/gradle/maven? Is that even something wise to care about, or should I just fudge my way through it and rely on IntelliJ to build and maintain my build scripts? EDIT: Actually, going through the Oracle docs as recommended above and doing some work with Gradle has been really helpful. Jo fucked around with this message at 06:26 on May 9, 2015 |
|
# ¿ May 8, 2015 06:37 |
lamentable dustman posted:Cool site I found if anyone wants to host a hobby webapp online or gently caress around with cloud poo poo your managers keep talking about from RedHat. Pretty much the only credible site I found that hosts java projects. Don't Heroku and AWS let you host Java applications?
|
|
# ¿ May 16, 2015 06:31 |
If I have a Socket connected from a client to a server and I want to fiddle with a custom protocol, is there a more graceful way of having the server handle commands than either (1) barfing serialized 'ServerCommand' objects across the network with ObjectStream or (2) writing plain strings like, "doActionA"?
|
|
# ¿ May 27, 2015 05:02 |
Volguus posted:What do you mean by "graceful"? If you're at the socket level, you essentially have to write bytes on the wire. What those bytes mean, that's entirely up to you. There's no way around that. Now, you may come and say that you don't want to serialize objects using ObjectStream. That's fine, there are a billion other ways to serialize objects (to json, to xml, to other binary protocols like protobuf or msgpack). By graceful, I meant, something less seemingly barbaric than writing a server which reads a character from the socket and throws it into a switch statement, then reads a few more characters and reassembles objects. That feels really old-school, like something I'd do in C in 1990. If that's not actually stupid or horribly unacceptable, I think I'll just make a CommandObject and dump that over the wire. I'd figured Java might have some "community standard" or "de facto" accepted way of doing it. "Oh, actually you're supposed to subclass the CommunicationProtocolWriter," or something like that.
|
|
# ¿ May 27, 2015 06:38 |
I started playing with a new project and have been using JavaFX image, converting it to a matrix, and fiddling with it. It looks like AWT has a bunch of helpful features and has the advantage of not needing to spin up a GUI to load an image. I don't want to get stuck in 1997, but man, JavaFX images... Is it bad form to use AWT? Is there a library which has supplanted them?
|
|
# ¿ Sep 3, 2015 18:27 |
Zaphod42 posted:You could use AWT, but JavaFX should be able to do what AWT can too, and mixing both could be unnecessarily messy. There's almost assuredly a way to do what you're doing in AWT using JavaFX, and you'd probably be better off just figuring out how to do that by reading more JavaFX documentation or whatever. No, unfortunately. If you don't do launch(args) to start up the GUI component of the application, JavaFX won't allow you to use Images. That wouldn't be a problem if I were making a GUI application only, but I'm doing a dual-mode CLI/GUI app. Plus, Image doesn't have ConvolveOps like AWT and is missing a ton of features, like resizing. (You need to make an ImageView, render to an image view, then take a screenshot of the image view. Really.) Here's the stack trace when I run it as CLI: code:
Jo fucked around with this message at 19:40 on Sep 3, 2015 |
|
# ¿ Sep 3, 2015 19:33 |
Volguus posted:Just did a little test and I can load an image just fine (and read a pixel's color) : I'd rather use a consistent set of APIs and use Image everywhere. I'm confused, though, because my code almost exactly matches yours and I get an exception. I've tried two machines, both with the latest JDK, one Windows, one OSX. Same exception. Are you sure you're importing javafx.scene.image.*; and not the Swing or AWT Image? EDIT: Interesting. The following all work: code:
code:
But when I move it into a different file... code:
Jo fucked around with this message at 21:02 on Sep 3, 2015 |
|
# ¿ Sep 3, 2015 20:33 |
Zaphod42 posted:The problem is that you're extending Application in the last one, not the others. That's creating a new thread, which then invokes the start method. But you've also got a main method? I'm pretty sure that's wrong, and that's what's causing all your issues. In my defense, ALL of the JavaFX examples have main inside the main Application. This is how Oracle says to do it (http://docs.oracle.com/javase/8/javafx/get-started-tutorial/hello_world.htm). No matter the case, it still doesn't work after I remove main: code:
code:
|
|
# ¿ Sep 3, 2015 22:15 |
Zaphod42 posted:What? Didn't you say on the last page that this worked fine for you? Emphasis mine. Yes. I had to remove just the extends Application part to get a new exception. With extends Application I get a GUI (or an exception if I'm on a headless box), and it automatically spawns the GUI even if I do it outside of start(). Without extends Application I get the exception above. Unfortunately, It turns out it's not possible to use JavaFX Image without a GUI, as I found just now: https://bugs.openjdk.java.net/browse/JDK-8093075 Looks like if I want a headless and GUI application I have to use two different Image classes. EDIT: Thank you both for the input, though. Wish the outcome could have been better. EDIT EDIT: \/\/ Jo fucked around with this message at 22:59 on Sep 3, 2015 |
|
# ¿ Sep 3, 2015 22:48 |
Looking for a second opinion. I'm using jBlas for a series of rather intensive matrix operations. I don't need really fancy QR decomposition or SVD, I just need multiplication (element-wise and mat/mat) to be really fast, along with addition, subtraction, transpose, inverse, and, ideally, exp. I could say "gently caress it" and write things in OpenCL, but that might be ill advised because everyone else seems to be just using GPU accelerated matrix libraries. Thoughts?
|
|
# ¿ Oct 10, 2015 00:43 |
Update on a previous question. I have a library I'm working on (link). I'd like to make a trainer which uses OpenCL, but since trainers are pluggable, I don't want to make OpenCL a requirement to build the project. I could just say, "Yo, delete this file after you clone the repo," but that seems like a terrible solution. What are my options as far as including a library for a single class file during compile time? Anything like conditional compilation #ifdefs in C?
|
|
# ¿ Oct 14, 2015 23:21 |
I have a random generator from which I'm extracting random numbers in an anonymous function. It seems like doing this is producing strange results and more duplicates than I'd expect. Is it okay to use random in async operations and lambdas?
|
|
# ¿ Oct 27, 2015 22:14 |
Zaphod42 posted:Are you initializing a new random object each time? If so that's bad, and you're going to get strange results. If its a lambda you probably are. This is with respect to line 39 of this file: https://github.com/JosephCatrambone/Aij/blob/master/src/main/java/com/josephcatrambone/aij/trainers/RBMTrainer.java I'm initializing Random random = new Random() when the class is created. When I use it in `Arrays.parallelSetAll(sampleIndices, x -> random.nextInt(inputs.numRows()));` poo poo gets fucky. I saw the same when I was writing another function using random in a lambda. It's entirely plausible that another factor is masking this and the issue is presenting in a way that makes me want to blame random.
|
|
# ¿ Oct 27, 2015 23:05 |
baka kaba posted:What's 'more duplicates than I'd expect' though? You're picking rows at random right - how many are there, and how many are you collecting? Like with 1000 possibilities, drawing 25 at random has a 25% chance of at least one duplicate (I think) I had 400 samples from 60000 items and saw around 50% as duplicates.
|
|
# ¿ Oct 28, 2015 00:40 |
On the subject of Spring, what's the status and relation between JPA and Hibernate for persistence? The spring.io guide page is oddly devoid of Hibernate mentions. Does JPA supplant Hibernate? EDIT: http://stackoverflow.com/questions/9881611/whats-the-difference-between-jpa-and-hibernate Jo fucked around with this message at 03:14 on Jan 4, 2016 |
|
# ¿ Jan 4, 2016 02:01 |
I could use some help in designing things the new JavaFX way. I've got an application which does/will do the following:
I have, in general, three types of data, the image stream data (along with relative offsets from the earliest stream and a background pattern), the camera parameters, the recovered volume, and the recovered skeleton. In JavaFX, I have the MainWindowController which I was hoping to use to drive all the UI elements with nice, snazzy callbacks and listeners, then have the Main application do all the heavy lifting. Here's where I'm running into problems: it looks like the MainWindowController can't reference the Main Application's properties unless I pass a reference to it or make them static. Both seem like really crappy design. I'm not sure how I'd do the separation of concerns. This mock layout might help explain a bit better: I'll have the n-synchronized streams selected (and, ideally, scrubbable), a tab for the silhouette extraction, and a tab for the mesh recovery. If this were a Swing application, I imagine I'd just be adding a lot of listeners and callbacks in the main startup function, but I'd like to be slightly more graceful this time if I can be. Anyone have a recommendation for how they'd structure an application like this? === Okay, so I've got a bit of an update. Had some time to think and I'm going with this: I'll give the main model the static reference to media files and most of the main application logic. I'll let the FXML handle all the UI stuff since I'm going to be putting most of the UI in there anyway. I've done some prototyping and it looks like the code is pretty clean. Lots of observers and listeners, but on the whole it's good stuff. Jo fucked around with this message at 04:22 on Aug 31, 2016 |
|
# ¿ Aug 30, 2016 07:10 |
Not sure if this belongs in the 3D tread. What are my options for debugging and benchmarking OpenCL in Java? (I'm using JoCL.) I have an OpenCL application I'm making with JoCL and I'm having a hard time figuring out why the hotspots are what they are. The Java Mission Control application says that my program is spending most of its time in java.lang.integer.equals. That seems completely wrong. I've not been able to use any of nVidia's tools to debug the OpenCL code (since it seems to expect a C++ program). I'm out of ideas for finding out the source of the problem. The GPU is _way_ faster for most tasks, but I think the copying to and from system memory is hurting. I just wouldn't have expected it to hurt _that much_. What are my options for debugging and benchmarking OpenCL in Java? My source code is here: https://github.com/josephcatrambone/aij The GPUGraph is the subject of the inquiry.
|
|
# ¿ Oct 4, 2016 19:24 |
Jabor posted:The screenshot says that almost all of that time being spent in equals because ArrayList.indexOf is calling equals a lot. That seems completely plausible if indexOf is being called a lot on big lists - every call to indexOf effectively iterates over the entire list to try and find the right element. Zaphod42 posted:Try changing shapes from List to HashMap and see how that effects the performance. You call getShape() a lot in GPUGraph.java and that's O(N) each time. Isn't ArrayList O(1)? I get that a Linked List would be O(n), but an array list should be as fast as a direct memory seek. In either case, it's still hard for me to believe that the program is spending 50% of its time doing isEqual when the graph has only twelve nodes. Even with a non-memoized implementation that shouldn't be more than 144 calls to the method compared to 1000*1000 multiplications PER LOOP. Fake Edit: The doc says an array list access should be O(1). It's just doing an array lookup.
|
|
# ¿ Oct 4, 2016 21:17 |
Zorro KingOfEngland posted:ArrayList's .get() is O(1), but .indexOf() is O(n) because you have to get each object and test its equality until you find the one you're looking for. Aha! Well I'll have to trace down where index of is being called. If get() is actually calling it, I'd call that a bug in the docs because it means the runtime isn't as advertised. I'll just switch to a standard array and resize it as I add elements to the graph. No need to use a hashmap. Edit: OpenJDK's source indicates it's constant time. I wonder where that indexOf is getting called. Maybe I'm going down the rabbit hole with this one. Even with a fuckload of linear seeks, there's no way that finding an item in a list of length 12 takes 50% of a five-minute run. I think it's just the case that Java mission control can't effectively profile stuff that's native. It's probably not counting the two-minute matrix multiply or 30-second opencl compile. Treats it as blocked io? Jo fucked around with this message at 00:43 on Oct 5, 2016 |
|
# ¿ Oct 5, 2016 00:35 |
Zaphod42 posted:I already told you. IndexOf is called in getShape(). gently caress, I need to work on my reading comprehension. You're absolutely right. I don't actually need the check. The base-case is handled by the inputs in the case anyway. That changes the profile a good bit. Still think I need to profile the OpenCL component separately, since the performance on the GPU instance is markedly better for most tasks but incurs a high one-time overhead starting up. Thanks everyone for the help -- removing that O(n) check shaved a nice 10% off the CPU benchmarks I had. Jo fucked around with this message at 08:05 on Oct 5, 2016 |
|
# ¿ Oct 5, 2016 07:48 |
Would this be the place to talk about Kotlin? I recently stumbled upon the language and have taken a liking to it. Do we have a JVM languages thread?
|
|
# ¿ Dec 6, 2016 21:35 |
poemdexter posted:I don't know poo poo about Kotlin or Scala besides the fact that they don't do anything that Groovy doesn't already do and the syntax looks like rear end. I'm coming up for a breather from Rust and Python, so the syntax is pretty cozy for me. Of the JVM languages I've tried so far (Scala, Clojure, and Groovy), it's my favorite. Clojure is a close second, though, so take that with a grain of salt.
|
|
# ¿ Dec 7, 2016 04:18 |
AbrahamLincolnLog posted:... As far as I can tell, my professor has ripped this assignment... The rest I can kind of figure out, but I have no idea where I'm supposed to be getting this GenericMatrix stuff from, and I wanted to double check to see if I was just loving up, or if I'm right and I'm missing part of the assignment. I can see this happening and advise strongly in asking your professor if he's hosting the missing file somewhere. Email him NOW and CC a TA.
|
|
# ¿ Dec 14, 2016 08:28 |
Hughlander posted:What's the current go-to webframework for small dumb projects that should better be done with something stupid like NodeJS? I just want to have a quick website where you can drag/drop images to upload and get saved, and then add tags. Thinking a little bit Ajax, autocomplete known tags, stupid backend to show tags by count, show images matching the tag etc... I swear I did something like this awhile back in Django but no idea where the source is. Was thinking Spark, but thought there was something else that people were recommending for tiny things like this but didn't see anything in 10 minutes of googling. I'm in a similar boat. Would like to expand my horizons. Let me know if you find an answer to this.
|
|
# ¿ Dec 15, 2016 08:56 |
|
|
# ¿ May 20, 2024 10:09 |
I've got a method which operates on a parallel Java 8 stream. If I do this: code:
Something like Arrays.stream(data).map(op).toArray(data)? I see stuff like collect(Collection().toList, ...), but that seems to apply if mapping to a new array. I just want to operate in-place and using only .map() doesn't seem to do it.
|
|
# ¿ Feb 4, 2017 21:15 |