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
rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

csammis posted:

Java 1.5:

I'm trying to figure out how to load a text file contained inside my program's JAR (into a FileReader if that matters). java.util.ResourceBundle was the first place I looked, but it seems to want to split the file into key/value pairs and that's not what I'm going for.

The JAR layout:
code:
src
  main
   +java
   |  various
   |    folders
   |      seriously
   |        ridiculously
   |          deep
   |            OhHereItIs.java
   +resources
      myfile.txt
How can I address this file? I know next to nothing about Java IO :smith:

Class.getResource() and friends will get you a file if it's on your classpath. So, in your example:

code:
URL myErl = Class.getResource("myfile.txt");
should work ok. You won't be able to write to it, IIRC.

Adbot
ADBOT LOVES YOU

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Alan Greenspan posted:

OK, I'm pretty sure this is what happens.

1. I write my stuff in my BufferedImage
2. I drawImage my BufferedImage to the Graphics context from the argument
3. The zoom kicks in and uses a method like Graphics2D::scale on the context
4. My drawn image pixelates because the scale method only sees the image and not the operations that created the image

:smithicide:

right. You have to draw a fresh image every time you zoom. One thing you can try is rendering the maximally zoomed-in image at start-up and rendering scaled-down versions of it as events warrant. There's really no free lunch when it comes to rendering high-quality zoomed-in text, you just shuffle the work around.

rotor fucked around with this message at 21:44 on Mar 4, 2008

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

roadhead posted:

I'd like to Parse an HTML-formatted String (so I can get tables at a certain width, columns either justified or centered, other simple stuff).

Once this data is "rendered" I need to pop it back into a plain String (still formatted using absolute spaces and cr/lf) to feed it to a receipt printer.

Am I crazy?

I have to make a bunch of these receipts, and they have to dynamically adjust their width based on the printer model. The end result would be exactly like what you get if you rendered the HTML in a browser, then copied and pasted it into a non-HTML aware application.


So, is this going to be possible with the Java standard library? I'm using javax.swing.text.html.HTMLDocument right this second.

Any other ideas ?

If I understand you correctly (never a safe bet) it seems that html has nothing do do with this. You have some string data you want formatted nicely on fixed-width font printers, and you're trying to abuse an html layout engine to do this.

My advice would be to look around for something like a java curses library or just write your own - formatters like this are pretty common homework for programming classes, so I'd be surprised if you can't find some kind of libraries floating around.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

roadhead posted:

Since a customer could have any model of printer, the width of the form is defined run-time, which is why I wanted to use HTML and set the width of the table with a resolvable variable.

Does this explain it better at all ?

yeah. You'll kill yourself trying to make the html layout engine do this properly. Dig up a java curses library, it shouldn't be too hard.

Unless your input is HTML ... in which case my advice would be to strip out the html and then find a java curses library.

I just don't see how you're going to take an html renderer and get it to spit out fixed-width font layouts in any kind of reasonable way. This is what console-based apps are really good at, so I'd go back and look at the display libraries for those - i.e. curses.

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

BELL END posted:

I've never understood the big hullabaloo about this.

Me neither. It's one of those things that just comes down to readability. Multiple return statements are bad when they're bad - ie hard to read - and not when they're not. Just like everything else.

Adbot
ADBOT LOVES YOU

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

such a nice boy posted:

Don't say orientated.

I find it really disorientating when people pronounce it that way.

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