Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Cubiks
Aug 31, 2005
I wish I had something witty to put here...
Okay, I have a question similar to the MultiMap one last page. I have a grid of devices laid out, with each device taking up (possibly) several grid cells, and in addition devices can be layered so that there are several on a single cell. I want to be able to go from a cell to the devices on said cell, and from a device to all cells covered by that device. Is there anything better than just using two HashMaps/MultiMaps for this, one for each direction?

Adbot
ADBOT LOVES YOU

Cubiks
Aug 31, 2005
I wish I had something witty to put here...

shodanjr_gr posted:

Im coming back to this. I read the link on Sun's dev pages about SWING and threads.

So i decide to spin my MouseInputListener into a separate thread. This gives me a notable improvement in fluidity, but still, it's not as good as i want to be...i still find that my mouse goes over my component and events dont register, or are late to register, etc.

Ive tried increasing the priority of the thread, but it doesnt seem to help.

Is there a way i can make this better?

edit:

Another issue i seem to have is that the MouseInputListener seems to ignore MouseClicked and MousePressed/Released events that happen inside the JScrollPane...They dont get handled at all...Any ideas?

I don't understand what you mean by "spin my MouseInputListener into a separate thread". Listeners of all sorts run pretty much exclusively on the EDT, are you doing some trickery to then do the actual work in a separate thread or something?

When you attach a MouseListener or other listener to a java swing component, all the work done by that listener is called from the EDT, no matter what thread the listener was created on, attached on, whatever. The only way I can think of to spin the work onto a separate thread would be to use some type of inter-thread communication when your listener registers an event, which would be kinda awkward, but feasible.

Without seeing any of your code, I can't tell if that is what you are doing or not. If not, then you may still be running the listener events on the EDT. If you are doing a lot of painting as well, that could clog the EDT so that mouse events bunch up. I've run into this problem a few times, doing custom painting but refreshing it too quickly.

I guess the take-away message is that all GUI work occurs on the EDT, so if you're experiencing slowdown then some part of your GUI displaying/updating is taking too long, or being called too often. I'm sorry I can't really give you more direction than that, I hope it's helpful.

Cubiks
Aug 31, 2005
I wish I had something witty to put here...
So I have a library question for anyone up to the challenge. I'm looking to deserialize a stream of JSON objects coming in over a network connection. I'd like to find a JSON library capable of deserializing these objects, but in a non-blocking fashion: i.e. I feed the library bits of data, and it gives me back complete objects when they're done.

The API I kinda imagine would be similar to this:

code:
String jsonText1 = "{ \"key1\":\"value1\", \"key2-";
String jsonText2 = "broken\":\"value2\" }";

Parser p = new Parser(...);
boolean done = p.parse(jsonText1); // done == false

done = p.parse(jsonText2); // done == true

Object o = p.getResult(); // { "key1":"value1", "key2-broken":"value2" }
Now, the closest I've found is something called async-json-library, but that fails if a token is split between parts, like "key2-broken" in my example.

At this point I'm pretty much resigned to just making something myself, but if there is something that can do this that'd be awesome.

Cubiks
Aug 31, 2005
I wish I had something witty to put here...

Jabor posted:

Is there a reason you need to do this drip-feeding instead of, say,

code:
Future<Object> f = p.parseAsync(networkStream);
//do some other stuff
Object o = f.get();
//alternatively hand it off to another thread to do

My end goal is to have a single server, many client setup, where creating a thread on the server for each client just wouldn't scale. I'm basically building baby's first networked game, figured I'd use JSON as a transport mechanism because it's fairly easy to understand and I don't care much about the overhead (not much being transmitted anyway).

Cubiks
Aug 31, 2005
I wish I had something witty to put here...

Hidden Under a Hat posted:

I feel like this should be something simple but I haven't been able to find a solution after quite a bit of googling... is there a way to add a subscript or superscript to a string and have it be treated as a string so it can be printed in TextFields, etc. I word it like that because I know about AttributedString, but it doesn't seem like that can be used interchangeably with regular text strings.

Unicode has a few pre-defined superscripts and subscripts, but not support for arbitrary strings in super/subscripts. See wikipedia for details.

That said, some form of markup (or AttributedString) may be preferable. I've never done rich text display, so I'm not sure what the go-to solution is, or even what Swing elements display formatted text.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply