MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Difficulties with LocatorPanel

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112153] Difficulties with LocatorPanel
  • From: David Carraher <david_carraher at terc.edu>
  • Date: Thu, 2 Sep 2010 02:32:05 -0400 (EDT)

Hi All,

I've been struggling to implement a locator, located at {1,0} that 
rescales the x-axis by stretching/shrinking.
I want to use LocatorPane rather than Locator because I eventually to add 
another half-dozen locators that have different behaviors and appearance.

The solution in LocatorPane would work more or less like the following 
instance  of Locator[]. 
The red and blue points position themselves dynamically as the scale 
stretches and shrinks (as desired).
The Locator dynamically rescales the x-axis by stretching and shrinking.
And It is always positioned at {1,0}.

Manipulate[ 

Graphics[{ 
 Locator[Dynamic[p, (p = Scaled[{#[[1, 1]], .5}]) &], ImageSize -> 25], 
 {PointSize -> Large, Blue, Point[{.5, 0}], Red, Point[{2.5, 0}]}}, 
ImageSize -> {350, 150}, 
AspectRatio -> 1/4, 
PlotRange -> {{0, maxX = Dynamic[Abs[1/p[[1, 1]]]]}, {-6, 6}}, Axes -> 
True], 
{{p, Scaled[{0.01, 0.5}]}, ControlType -> None}

]


The LocatorPane, In addition to having these features, and the inherent 
ability to hold several locators,  would:
not be dependent on Scale[], because some locators will work with the 
Coordinate values themselves. (unless LocatorPanel can work with both 
scaled and regular locators.)

Here's the best I've been able to come up with:

Manipulate[ 
Dynamic@Grid[{ 
 {LocatorPane[Dynamic[pLoc], 
Graphics[{
{PointSize -> Large, Blue, Point[{.5, 0}], Red,          Point[{2.5, 
0}]}}, 
 ImageSize -> {350, 150}, 
AspectRatio -> 1/4, 
Axes -> True, 
PlotRange -> {{0, 1/Dynamic[pLoc[[1, 1]]]}, {-6, 6}}], 
(*Allowable roving of the Locators *)      {{{1/20, 0}, {20, 0}}}, 

(*Appearance of Locatos *) 
Appearance -> {        Framed["x1", Background -> LightBlue, 
RoundingRadius -> 3,          FrameMargins -> 1]}]}    }], 

 (*Locator*) 
{{x1, {1, 0}}, ControlType -> None}, 
{{pLoc, {x1}}, ControlType -> None}, 

Alignment -> {Center, Center} ]


I read the documentation carefully and worked on it until I can get no 
further ahead by myself.  But as you shall see, the locator in LocatorPane 
moves to  positions other than {1, 0}.
I'm not sure whether my problem lies with the mathematics or with 
Mathematica.

Any help would be appreciated.

 
  thanks,

David Carraher


  • Prev by Date: Re: 2 dimensional engineering problem
  • Next by Date: Re: coordinates in LogLogPlots
  • Previous by thread: Re: Import polynomial from file and define function
  • Next by thread: nonlinearfit for data with errors in both coordinates