Scaling with Focus

You can set a particular spot on the map to zoom into. In this example, the center or focus of zooming is set to wherever you click with the mouse. It is helpful to have a graphic representation of where the focus is. To that end we add a hairline glyph.

Try clicking and zooming on the map below.

The source reveals small changes to our previous program. We add a VisibleRange named zoomPoint. We create a Shadow on our map and add our zoomPoint as a listener. Next we adjust the zoomPoint from a mouse listener when we get mouse clicks. The zoomPoint then turns around and notifies its listeners. One of them is the shadow glyph which gets repositioned. The other is an internal class that sets our map's zoom behavior.

Exercises

  1. Set it up so that the zoomPoint starts in the middle.
  2. Add a sequence glyph to see how the hairline (Shadow) is the width of one residue.
    Hint: since the parseInputString method inherited from SimpleMap0.java is executing a map.clearWidget() method, you'll need to override the parseInputString method. Call the super.parseInputString() method, then use map.configure() and map.addItem() to add your SequenceGlyph.

Next: Styling