aspose file tools*
The moose likes Beginning Java and the fly likes Need help with equation editor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help with equation editor" Watch "Need help with equation editor" New topic
Author

Need help with equation editor

Slawomir Wieczorek
Greenhorn

Joined: Dec 07, 2011
Posts: 20

Hi guys,
I've been asked to write an applet or an application that will create a simple equation (using basic signs like /*+-). At the moment I don't really know where to start. Especially how to render the equation after lets say typing it in a text field or something. Should I use JLabels or java graphics drawstring or maybe something else?
Preferably I would use an MVC. Any suggestions? Please help!
P.S. I don't want to use ready made frameworks. I need to write all on my own...
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11302
    
  16

Many folks will tell you this: StopCoding

Read that VERY carefully and thoroughly. Then read it again.


Any time someone says "I want to use X", they are putting the cart before the horse. That's like going to a construction site and saying "I am going to use a saw" - when what may be needed is a tool to drive nails into wood.

You should not let the technology drive your design, but let your design drive the technology.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Slawomir Wieczorek
Greenhorn

Joined: Dec 07, 2011
Posts: 20

Okay the idea is to make a model class that will break the string onto separate signs/variables. The view part will use JPanels of nested JLabel inside with a sign or a variable. But how to arrange such blocks? What layout should I use?
for example:
A/B*A/B=B+B

should give:
http://postimage.org/image/5psqkhmc1/
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7772
    
  21

Slawomir Wieczorek wrote:Okay the idea is to make a model class that will break the string onto separate signs/variables. The view part will use JPanels of nested JLabel inside with a sign or a variable.

Whoa there. You haven't even described what the "break the string into separate signs/variables" part is supposed to do, and you're already deciding how you're going to display it?

This is precisely what Fred was talking about:
Describe your solution in English (or your native language), NOT in Java-ese. The second you start putting Java class names into a description, we know that you've leapt to an implementation far too soon, so DON'T DO IT.

But how to arrange such blocks? What layout should I use?

My advice: Don't worry about it for the moment.

Your problem appears to have two major parts:
1. Breaking up the String.
2. Displaying the result.
and neither one has anything much to do with the other.

Get part 1 working properly first, and then deal with part 2. And even then, keep them as separate as you possibly can.

HIH

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Slawomir Wieczorek
Greenhorn

Joined: Dec 07, 2011
Posts: 20

You were right. It's just sometimes noobs like me need to declare some focus and patience. Problem solved...
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7772
    
  21

Slawomir Wieczorek wrote:You were right. It's just sometimes noobs like me need to declare some focus and patience. Problem solved...

Glad to hear it. Sometimes, the best way to solve a problem is to StopCoding.

Winston
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Winston Gutkowski wrote:StopCoding

*don't write more than 10 lines or so without compiling* . it varies people capacity though . I would say write 1000 lines ..even never worry about compiler..it is just language dependent ;-)
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7772
    
  21

Seetharaman Venkatasamy wrote:I would say write 1000 lines ..even never worry about compiler..it is just language dependent ;-)

You've obviously never run into compiler vomit. I wouldn't stake my life on it, but I'm pretty sure it increases quadratically with uncompiled content

Winston
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38756
    
  23
It doesn’t matter whether compiler vomit increases quadratically or linearly. Once the lines of compiler errors are more than the scroll capacity of the terminal, you are really up the creek.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help with equation editor