Rendering graphical elements through command line interface in Java - java

Is there a way to render graphical objects in console using standard jdk API?
For instance I want to render moving image in console (not via awt/swing).

The console itself can only render characters..
But if you mean you want to render an image from a command line app. (that is later displayed in other apps.) then yes, though the 'moving' part does not make much sense unless you mean an animated GIF.

No you cannot. The console renders characters so ASCII-art is your best choice.
Also this has been answered before: displaying-images-in-a-console-application

Related

Is text rendering possible onto 2D images with Javascript/PHP?

I own a sports apparel company and I'm looking to have an applet built that will allow customers to see how their team names will look in certain colors on jerseys. Below you can see the final result of a competitor site's Flash applet where text is rendered on 2D surfaces/images.
My requirements: I need users to be able to set the font, primary text color, outline text color, and text style (arched or straight).
So my question-- Is this sort of text rendering possible with only Javascript/PHP?
If so, what limitations do you for see? I've been told the arching and outline text color may be issues. I've also been told that I may have to upload library files to a server where the actual rendering may take place.
If not, what scripting would you guys recommend? I'm trying to stay away from Flash because it's slow and costly.
I'll be passing this onto our developers so please feel free to be as detailed as possible. I figure'd I'd save them some leg work!
Thank you!
Depending on how complex you want your graphics to be, html5 drawing abilities could be used. Check Raphaƫl library, for instance, webGL/canvas renderers already have a lot of features in modern browsers.
As of the solution with server rendering, it's also possible with gd2(php), but imho that would be less convenient, at least try something different from php (btw, what's your backend running on?)
Your competitor's solution with java applet honestly seems the easiest, except that it requires jre, which few people are eager to install =)
That's kind-of a high level question, but yes you can definitely use javascript for it.
If there's a problem with getting characters to look right, you can always save each letter as a separate image and have javascript place them next to each other in preview. I'd try to see how close you could get with the existing fonts first.
Layering the text: one color large font, then a different color smaller font will give you the outline effect your looking for.

What is the best way to display ASCII in a grid with panels using Java?

I don't have much experience in Java, but I am attempt to write a simple rogue-like game to familiarize myself with it, and I am just wondering how I would go about creating an interface like this:
Are there any obvious ways that you would go about something like this? Being new to Java, I really have no idea what the best method would be.
Sorry to be vague!
Thanks
There is no such (simple) component in the JDK - if you don't need color, a JTextArea can be used to display ASCII-Art (after setting a fixed-width font). You will need to take care not to run into characterset issues (if you don't stick to US-ASCII 7-bit).
Writing a component that handles color display (and maybe escape sequences, in essence emulates a console window) wouldn't be too hard, but if you just started with Java it may prove to be an unwelcome challenge.
You could also just write your game in Java and leave displaying the ASCII to the system console (your game would simple output to stdout).
Edit: Color ASCII could be acieved by converting your internal format to (simple) HTML and that HTML could be displayed using a JLabel. Its probably not the most elegant method, but it should be reasonably simple to implement (and with nowadays hardware speed should not be an issue with this approach either). This approach builds on the capability that you can just use JLabel.setText() and pass a string that starts with a HTML tag. The JLabel then interprets the whole text as HTML.
Check out Trystan's Ascii Panel, and his blog and tutorial on making a roguelike here.
Better late than never, right? You may want to check Zircon Project.

Continuous Updating in Java Panel or Dialog Box

I am a huge newbie and I have a program that normally prints items to the Java console window. I would like this program to become a window in which the user can interact with. The reason why I have not resorted to dialog boxes and panels is because this program require multiple prints to the console window. A traditional dialog box does not continuously update or compound on data that has already been printed on the box. I realize that there is another way of doing this by creating a program that mimics the Java console window. Because I am a noob, all of the java console redirecting questions and answers on this site have blown over my head. Can anyone please help me?
See maybe How to Use Editor Panes and Text Panes will be helpful and give you some ideas.
The short answer is, every time you want to update the contents of a text box, call the setText function again. There's no "append" function on the contents: you have to give the entire contents each time. If you want something that mimics a console window, where messages continue to scroll, the simplest thing to do is to keep the entire contents in a StringBuilder. Each time you get new text append to the StringBuilder, then setText(myStringBuilder.toString).
You could, I supppose, write mybox.setText(mybox.getText()+"new contents"). That would be a little inefficient but probably not a big deal.
I don't know exactly what you're up to, but trying to redirect console output to a text box sounds like more nuisance that it's worth. Just put your data in the text box: don't write it somewhere else, then try to get it back and put it where you want it. I suppose if you have thousands of lines of code writing to the console and now you want it to go a text box, there might be value in not having to change all that code. But the structure of a console app is so different from the structure of a GUI app that changing the output statements would probably be the least of the things you'd have to rework.

Signature capture on windows mobile java application

The company I work for has an java application that runs on esmertec jbed JVM on windows mobile 6.
There is a requirement to capture a user's signature as part of some new functionality. One option is to try and implement this in java. This has been tried previously and has been found to be a bit slow.
I think the better option would be to get a native component to handle the drawing of the signature and save it to file. Does anyone know of a component that I would be able to use?
Creating our own component is an option as well but if there is one available already, I would prefer to use that.
For completeness, I'll answer my own question.
I could not find an existing component that done this. We ended up writing some c++ code that would handle this.
The code would get a handle to the Java canvas and register our own callback function with it. This callback function would record any mouse movement within the canvas and draw a line when necessary (either on mouse up or after a number of points had been drawn). Once the user leaves the screen we would save the canvas to file and re-register the original canvas callback function.

How do you specify to display a diamond in a NSMenuItem (minimized window indicator)?

I'm creating a JNI to display an application wide menu bar instead of the JFrame specific one. This allows me to keep a menubar displayed even when no JFrames are present. I've hit a small snag, in my window menu I can't figure out how to display a diamond for the windows that are minimized. As far as I can tell in the standard API there's only three states available On, Off, and Mixed where mixed is a dash. Is there a way to show the minimized diamond using standard API? Or am I going to have to create a diamond image and use that?
AppKit isn't using a public API to get this image. It's using _NSGetThemeImage which pulls an image out of the old HIToolbox Appearance Manager theme resources and converts it an NSImage. I wan't able to find an equivalent public API.
If you want to mimic how AppKit does it, use:
NSImage* _NSGetThemeImage(int num);
[menuitem setState:NSOnState];
[menuitem setOnStateImage:_NSGetThemeImage(155)];
Better yet, use this code to grab the NSImage, save it to a TIFF file, and then include that TIFF in your program. That way you avoid using private APIs in the shipping code. I doubt Apple would complain that you're stealing their diamond. ;)

Categories

Resources