Wednesday, 17 March 2010

Lesiurely voyage of discovery

The more I work this application, the more I learn about the standard java classes, and the more I learn about the example application I've used as a muse till now. I now understand enough about the mouse interfaces and co-ordinates etc to see that the in the example, each drawing object had it's own mouse listeners, whereas I've implemented one for the whole view.

Given the number of graphic objects that will appear on the canvas the mouse listener interface would need to be very scalable indeed if there were several hundred listeners in one app! As it is I implement my own mechanisms to see if mouse gestures impact any of the widgets. Not sure what OOP purists would say but after the work put in, it stays my way for now. Drag and drop might be interesting though when I come to implement that.

Time for the apps first dialogue boxes I think. One for the preferences e.g.

  • Title
  • Orientation
  • Margins

The other is for the attributes of a text adornment:
  • Font family
  • Font name?
  • Size
  • Bold?
  • Italic?
  • Underline?
  • Alignment, right, left, centre - tricky - no code to handle that yet, maybe v2 ;-)

Tuesday, 16 March 2010

Guess who's back?

Managed to get some time this week to pick this project up again. Getting there! Now got zoom working for both the view and the mouse controller, a few gray areas for me cleared up but I'm storing info in the Model now because it needs to be referenced by the Controller and the View, even though you could argue the View is the thing that should be worried about coordinates etc. Anyway, in the past now, decisions made.

Working on getting proper bounds checking in place for when objects are moved about, i.e. setting the margins up and not moving an object outside those bounds. Tricky bit is the point at which the mouse is pressed is within the rectangle which defines the object, not the top left corner so lots of offset arithmetic which makes it all looks complicated, and confuddles my brain trying to work it all out. It will happen though.

Current question is by having each graphic item expose its boundary so the code which moves things around can decide whether it's a good thing or not to move it, is fine for adornments whose constraints are the edge of the margins. For notes etc, they will be constrained by bar alignment, so I suspect there'll be more rewriting coming up when those challenges reveal themselves!!