Results 1 to 6 of 6
Thread: My Chinese character project
- 04-08-2011, 11:24 PM #1
Member
- Join Date
- Apr 2011
- Location
- London
- Posts
- 5
- Rep Power
- 0
My Chinese character project
I'm having trouble figuring out on how about to do this project I chose to do. I want to create a program that basically teaches people about Kanji and their correct stroke order (they must draw the character in a certain way like from top to bottom for the first stroke, left to right for the second etc.). The user will first be presented with some pictures or something that shows them the correct stroke order and then they have to attempt it.
I think I can figure out how to bring up those images to the user, but my real problem is how about to do the characters. The user would basically have to draw using the mouse starting from one set of co-ordinates (that would be pre-defined of course) to another set and the program has to know that the user passed through the correct co-ordinates thereby letting the user move on to the next stroke.
I think I'm going way over my head with this since I don't have a great deal of Java experience (I took a course and am currently watching a lot of tutorial vids), so I'm thinking there might be an easier way like a connect the correct dots kind of system where the points the user clicks would act like the start/end points of the strokes.
I haven't looked into it much yet but I came across a MouseMotionListener interface that seems to deal with something like what I want to do, but I have no clue how I would set the predefined co-ordinates using that.
Does anyone have any advice on what I should be focusing on? Does anyone have any experience doing something similar? It seems I can't find anyone else doing this sort of thing..
Thanks.:confused:
- 04-09-2011, 08:22 AM #2
Member
- Join Date
- Apr 2010
- Posts
- 55
- Rep Power
- 0
Before you even attempt to write it in Java, you need to have in mind what algorithms you are going to use and write them down. Take into account trailing mistakes and how much error a user can make.
Secondly please look up JPanels and JFrames before you start implementing listeners. Also this forum is for helping people with Java problems not teaching people new concepts. Please learn the concept and make an attempt to solve it and post here if you face any problems.
-
you need to create your own custom Class for taking an image of a character, tracing its outline to vectors to make a path, and then pass the path vectors to another Class of your own which will create an order in which the strokes must be written by the user. When solving the user input, you'd have to have another Class just to allow variations in handwriting to match to the vectors.
- 04-17-2011, 09:41 AM #4
Member
- Join Date
- Apr 2011
- Location
- London
- Posts
- 5
- Rep Power
- 0
Thanks for the reply guys, sorry I didn't answer back sooner. Anyway due to the complexity of what I was attempting I decided to take a different route and opt for something more simpler. Basically I want to create the characters out of polygons, each polygon represents a "stroke" and the user needs to click them in the correct order. Upon clicking on them I would like the polygon to change colour, however I'm having trouble just getting the classes to interact with each other in the way I want.
I've managed to get some Polgons on the screen and stuff, but I don't know how to use the mouseClicked method to change the colour of a polygon. Any help would be appreciated.
Java Code:import javax.swing.*; public class KanjiGame { public static void main(String args[]) { new KanjiInterface (); } }Java Code:import javax.swing.* ; import java.awt.* ; import java.awt.event.* ; public class KanjiInterface extends JFrame implements MouseListener { JMenuBar menuBar ; JMenu menuSession ; JMenuItem subNewGame, subLoadGame ; KanjiPanel graphArea ; //JPanel graphArea ; //Polygon poly ; KanjiInterface(){ //Creates the window super("Kanji Game") ; setLocation( new Point(100, 100) ) ; //this.getContentPane().setBackground( Color.white ) ; setSize( 600, 600 ) ; setResizable( true ) ; //Creates the Menu Bar along with sub-menus menuBar = new JMenuBar() ; menuSession = new JMenu("Session") ; subNewGame = new JMenuItem("New Session") ; subLoadGame = new JMenuItem("Load Session") ; menuBar.add(menuSession) ; menuSession.add( subNewGame ) ; menuSession.add( subLoadGame ) ; this.setJMenuBar(menuBar) ; //Create Panel for graphics graphArea = new KanjiPanel() ; graphArea.setBackground(Color.WHITE) ; add(graphArea, BorderLayout.CENTER) ; setVisible( true ) ; //Adding mouseListener to panel graphArea.addMouseListener(this) ; } public void mouseClicked(MouseEvent e) { graphArea.paintComponent(setColor(Color.BLACK)) ; } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } /*private class MouseCatcher extends MouseAdapter{ public void mouseClicked(MouseEvent event){ } } */ }I'm getting an error "The method setColor(Color) is undefined for the type KanjiInterface" which is annoying since I'm trying to call the method via an object of type KanjiPanel which has the method. I've tried a number of things but all I get is errors..Java Code:import javax.swing.* ; import java.awt.* ; import java.awt.event.* ; public class KanjiPanel extends JPanel { public KanjiPanel(){ } public void paintComponent(Graphics g){ super.paintComponent(g) ; Polygon poly = new Polygon() ; Polygon poly2 = new Polygon() ; Polygon poly3 = new Polygon() ; g.setColor(Color.RED) ; poly.addPoint(100,100) ; poly.addPoint(150,150) ; poly.addPoint(50,150) ; g.fillPolygon(poly) ; //g.fillRect(25, 25, 100, 30) ; g.setColor(Color.blue) ; poly2.addPoint(200, 50); poly2.addPoint(300, 50); poly2.addPoint(300, 100); poly2.addPoint(200, 100); g.fillPolygon(poly2); g.setColor(Color.blue) ; poly3.addPoint(200, 150); poly3.addPoint(300, 150); poly3.addPoint(300, 200); poly3.addPoint(200, 200); g.fillPolygon(poly3); } }
- 04-17-2011, 09:49 AM #5
when you call a method without specifing a class then java search the method in the current object and because the call is made in this interace KanjiInterface java is looking in the interface. but there is no method named setColor in the interface. question: which component do you want to set the color?
- 04-17-2011, 10:00 AM #6
Member
- Join Date
- Apr 2011
- Location
- London
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Unable to export chinese character in excel use ExcelCSVPrinter file open inline brow
By Thendral in forum Advanced JavaReplies: 4Last Post: 02-01-2010, 11:13 AM -
Help with DND Character Creator project
By legendofyams in forum New To JavaReplies: 3Last Post: 12-08-2009, 04:26 PM -
To display chinese/japanese language Character filename - Java Programming
By bngkrish in forum Java ServletReplies: 0Last Post: 04-19-2009, 06:38 PM -
this looks chinese to me
By xgi1008 in forum New To JavaReplies: 18Last Post: 10-05-2008, 07:03 PM -
reading text character by character
By bugger in forum New To JavaReplies: 2Last Post: 11-09-2007, 08:54 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks