Picking question.

I have been beating my head on this for days and can't see what the problem is. All I want to do is to pick a point on a sphere and then at that point project a cylinder into the sphere.
I can get the thing to place the pont in the sphere, but not at the point I pick. If I keep picking other points, the cylinder will move slightly one way or the other, but not to the extent it needs to.
Any help is REALLY appreciated.
Here is the code:
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.media.j3d.AmbientLight;
import javax.media.j3d.Appearance;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.DirectionalLight;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.HiResCoord;
import javax.media.j3d.Locale;
import javax.media.j3d.PhysicalBody;
import javax.media.j3d.PhysicalEnvironment;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.View;
import javax.media.j3d.ViewPlatform;
import javax.media.j3d.VirtualUniverse;
import javax.swing.JFrame;
import javax.vecmath.AxisAngle4d;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;
import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
import com.sun.j3d.utils.behaviors.mouse.MouseTranslate;
import com.sun.j3d.utils.geometry.Cylinder;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.universe.SimpleUniverse;
//import com.tornadolabs.j3dtree.Java3dTree;
public class DisplayFrame extends JFrame implements PointSelectedReceiver
    private Transform3D     pointT3D = new Transform3D();
    private TransformGroup  pointTG;
    private VirtualUniverse universe;
    //private Java3dTree      j3dTree;
    private Canvas3D        canvas3D;
    private Vector3d        pointCurrTrans = new Vector3d();
    private Transform3D     pointRotT3D    = new Transform3D();
    private static final Vector3d ORIGIN = new Vector3d(0, 0, 0);
     * @param args
    public static void main(String[] args)
        DisplayFrame mainframe = new DisplayFrame();
        mainframe.init();
        mainframe.setPreferredSize(new Dimension(1280, 1024));
        mainframe.setMinimumSize(new Dimension(1024, 768));
        mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        mainframe.pack();
        mainframe.setVisible(true);
    private void init()
         universe = new VirtualUniverse();
         canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
         int[] xPos = {0,0,0,0,0,0,0,0};
         int[] yPos = {0,0,0,0,0,0,0,0};
         int[] zPos = {0,0,1,5,0,0,0,0};
         HiResCoord hiResCoord = new HiResCoord(xPos, yPos, zPos);
         //j3dTree  = new Java3dTree();
         Locale locale = new Locale(universe, hiResCoord);
         BranchGroup scene = createSceneGraph();
         //j3dTree.recursiveApplyCapability(scene);
         scene.compile();
         locale.addBranchGraph(scene);
         BranchGroup vpBranchGroup = new BranchGroup();
         TransformGroup tg = new TransformGroup();
         ViewPlatform vp = new ViewPlatform();
         vp.setViewAttachPolicy(View.RELATIVE_TO_FIELD_OF_VIEW);
         tg.addChild(vp);
         vpBranchGroup.addChild(tg);
         locale.addBranchGraph(vpBranchGroup);
         View view = new View();
         view.setProjectionPolicy(View.PARALLEL_PROJECTION);
         PhysicalBody        pb = new PhysicalBody();
         PhysicalEnvironment pe = new PhysicalEnvironment();
         view.setPhysicalEnvironment(pe);
         view.setPhysicalBody(pb);
         view.attachViewPlatform(vp);
         view.setBackClipDistance(110);
         view.setFrontClipPolicy(View.VIRTUAL_EYE);
         view.addCanvas3D(canvas3D);
         this.setLayout( new BorderLayout() );
         this.setSize(new Dimension(1024,768));
         this.setMinimumSize(new Dimension(1024, 768));
         this.add("Center", canvas3D);  
         //j3dTree.updateNodes(universe);
    private BranchGroup createSceneGraph()
        BranchGroup objRoot = new BranchGroup();
        double scale = 0.02d;
        Transform3D myTransform3D = new Transform3D();
        myTransform3D.setScale(scale);
        TransformGroup mainTG = new TransformGroup(myTransform3D);
        mainTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        mainTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        mainTG.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);
        mainTG.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
        //Test a color cube
        Sphere sphere = new Sphere(10.0f);
        sphere.setPickable(true);
        sphere.getShape().setCapability(Shape3D.ENABLE_PICK_REPORTING);
        sphere.getShape().setCapability(Shape3D.ALLOW_GEOMETRY_READ);
        sphere.getShape().getGeometry().setCapability(GeometryArray.ALLOW_COUNT_READ);
        sphere.getShape().getGeometry().setCapability(GeometryArray.ALLOW_FORMAT_READ);
        sphere.getShape().getGeometry().setCapability(GeometryArray.ALLOW_COORDINATE_READ);
        sphere.getShape().getGeometry().setCapability(GeometryArray.ALLOW_REF_DATA_READ);
        sphere.setCapability(Sphere.ALLOW_PICKABLE_READ);
        Transform3D sphereT3D = new Transform3D();
        sphereT3D.setTranslation(new Vector3d(0.0f, 0.0f, 0.0f));
        TransformGroup sphereTG = new TransformGroup(sphereT3D);
        sphereTG.addChild(sphere);
        mainTG.addChild(sphereTG);
        //Add lighting
        BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
        Color3f ambientColor          = new Color3f(0.9f, 0.9f, 0.9f);
        Color3f directionalLightColor = new Color3f(0.6f, 0.6f, 0.6f);
        AmbientLight ambientLightNode = new AmbientLight(ambientColor);
        ambientLightNode.setInfluencingBounds(bounds);
        mainTG.addChild(ambientLightNode);
        DirectionalLight directionalLight = new DirectionalLight(directionalLightColor, new Vector3f(+0.0f, +0.10f, +0.00f) );
        directionalLight.setInfluencingBounds(bounds);
        mainTG.addChild(directionalLight);
        //Add an object to indicate the point picked
        pointTG = new TransformGroup();
        pointTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        pointTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        pointT3D.setTranslation(new Vector3d(-20.0f, 0.0f, 0.0f));
        pointTG.setTransform(pointT3D);
        Appearance         pickAp    = new Appearance();
        ColoringAttributes colorAtt  = new ColoringAttributes();
        Color3f            pickColor = new Color3f(0.0f, 0.5f, 0.8f);
        colorAtt.setColor( pickColor );
        pickAp.setColoringAttributes( colorAtt );
        Cylinder pointIndicator = new Cylinder(0.25f, 25.0f, pickAp); 
        pointIndicator.setPickable(false);
        pointTG.addChild(pointIndicator);
        mainTG.addChild(pointTG);  
        //Add the picking behavior next
        PointPickBehaviour picking = new PointPickBehaviour(canvas3D,
                                                            objRoot,
                                                            bounds,
                                                            DisplayFrame.this);
        mainTG.addChild(picking);
        MouseRotate behavior = new MouseRotate();
        behavior.setTransformGroup(mainTG);
        mainTG.addChild(behavior);
        behavior.setSchedulingBounds(bounds);
        MouseTranslate behavior2 = new MouseTranslate();
        behavior2.setTransformGroup(mainTG);
        mainTG.addChild(behavior2);
        behavior2.setSchedulingBounds(bounds);
        objRoot.addChild(mainTG);
        objRoot.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
        return objRoot;
    public void receiveSelectedPoint(Point3d point)
        pointT3D.setTranslation(new Vector3d(point.x, point.y, point.z));
        pointTG.setTransform(pointT3D);
    public void receivePickRotation(AxisAngle4d rotAxis)
        pointTG.getTransform( pointT3D );
        pointT3D.get( pointCurrTrans ); 
        pointT3D.setTranslation( ORIGIN );
        pointT3D.setRotation( rotAxis ); 
        pointT3D.mul(pointRotT3D);
        pointT3D.setTranslation( pointCurrTrans );
        pointTG.setTransform( pointT3D );
}Now the code to the pick itself:
import javax.vecmath.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.picking.*;
import com.sun.j3d.utils.picking.behaviors.PickMouseBehavior;
public class PointPickBehaviour extends PickMouseBehavior
  private PointSelectedReceiver receiver;
  private boolean               firstRotation;
  private AxisAngle4d           rotAxisAngle   = new AxisAngle4d();
  private Vector3d              clickVec       = new Vector3d();
  private Vector3d              axisVec        = new Vector3d();
  private double                pickAngle;
  private Point3d               startPt;
  // initial orientation of pick pointer: straight up
  private static final Vector3d UPVEC = new Vector3d(0.0, 1.0, 0.0);
  // for repeated calculations
  public PointPickBehaviour(Canvas3D    canvas,
                            BranchGroup root,
                            Bounds      bounds,
                            PointSelectedReceiver receiver)
    super(canvas, root, bounds);
    setSchedulingBounds(bounds);
    pickCanvas.setMode(PickCanvas.GEOMETRY_INTERSECT_INFO);
    this.receiver = receiver;
  public void updateScene(int xpos, int ypos)
  /* This method is called when something is picked.
       pickCanvas.setShapeLocation(xpos, ypos);
       Point3d eyePos = pickCanvas.getStartPosition();
      startPt = eyePos;
       PickResult pickResult = null;
       pickResult = pickCanvas.pickClosest();
       if (pickResult != null)
           PickIntersection pi = pickResult.getClosestIntersection(eyePos); 
          System.out.println("Picked coordinates: " + pi.getClosestVertexCoordinates());
          Point3d intercept = pi.getPointCoordinatesVW();
          rotateToPoint(intercept);
          receiver.receiveSelectedPoint(intercept);
  } // end of updateScene()
  private void rotateToPoint(Point3d intercept)
  /* Turn the picked point to point at the point where the
     mouse was clicked.
        if (!firstRotation)
        {   // undo previous rotations to gun and beam
            axisVec.negate();
            rotAxisAngle.set( axisVec, pickAngle );
            receiver.receivePickRotation(rotAxisAngle);
        clickVec.set( intercept.x - startPt.x,
                      intercept.y - startPt.y,
                      intercept.z - startPt.z);
        clickVec.normalize();
        axisVec.cross( UPVEC, clickVec);
        pickAngle = UPVEC.angle(clickVec);
        rotAxisAngle.set(axisVec, pickAngle);     // build rotation
        receiver.receivePickRotation(rotAxisAngle);
        firstRotation = false;
  } // end of rotateToPoint()
} Fianlly the interface to tie the two:
import javax.vecmath.AxisAngle4d;
import javax.vecmath.Point3d;
public interface PointSelectedReceiver
    public void receiveSelectedPoint(Point3d point);
    public void receivePickRotation(AxisAngle4d rotation);
}

Well I have it sort of working (the pick indicator cylinder gets placed at the right point, but if you rotate the sphere and then select another point the cylinder isn't drawn toward the user).
The fix was to change getPointCoordinatesVW to getClosestVertexCoordinates.

Similar Messages

  • How do I get the file name to print up closer to a horizontal photo?

    Kind of a nit-picking question, but here goes anyway:
    I use Lightroom's Print module to create contact sheets (three rows by three columns). I check the "Photo Info" check box and select "Filename" to have the file names printed with each photo. When the photo is shot vertically, the file name prints at the lower edge of the photo, as you would expect. However, when the photo is shot horizontally, the file name still prints down in the same place where it would print if the photo were vertical. That can be confusing because if the next photo down on the sheet is vertical, a file name can end up being much closer to the vertical photo below it--to which it is completely unrelated--than to the horizontal photo above it, to which it actually refers.
    Is there any way to get Lightroom to print file names closer to horizontal photos?

    Thanks to both of you for your speedy responses. Making all the shots horizontal or vertical (i. e., unchecking the "Rotate to Fit" box on the right) is not what I want. Increasing the vertical spacing is a possibility, but that'll make the vertical shots smaller. There's a program called "ImageBuddy" which does exactly what I want LIghtroom to do in this instance: print the filenames of only the horizontal shots higher and therefore closer to the photos to which they refer. It's quite cheap, but I'd rather not use Lightroom for everything else and ImageBuddy just for contact sheets, so if anybody knows of a way to do what I want to do within Lightroom, please do clue me in.

  • Please help with UIPickerView didSelectRow logic.

    Hello all,
    Im still a noob so forgive me if these are way off base.
    My app is coming along thanks to the help of Ray and others in this forum so thanks for that!
    I have a Q&A type app with 3 separate question formats, ie... Multiple Choice, True and False and Combo, and more to come in the future...
    Each type of question has its own view controller and its own plist of questions. So... MultipleChoiceViewController loads the MultipleChoice.plist and off it goes.
    My current app flow...
    QuestionFormatViewController with 3 buttons for each type of question.
    So when the user picks the MultipleChoice button I take them to MultipleChoiceViewController as I mentioned above.
    example...
    - (IBAction) mcFormatSelected:(id)sender {
    NSLog (@"mcFormatSelected ");
    MCQuestionsViewController *mcQuestionsViewController = [[MCQuestionsViewController alloc] initWithNibName:@"QuestionsViewController" bundle:nil];
    mcQuestionsViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:mcQuestionsViewController animated:YES];
    [mcQuestionsViewController release];
    I wanted a way to let the user not only choose the question format but also the number of questions returned. So I thought a UIPickerView with 2 components would work well for this.
    So I went on the hunt for some UIPickerView examples and found one that presents itself in an action sheet which is perfect because I can also provide a Done button.
    This particular sample code found here... http://discussions.apple.com/thread.jspa?threadID=1674641&start=15&tstart=0
    has me subclass UIActionSheet and then upon a button press it presents the action sheet with the UIPickerView. Thats as far as I can get on my own.
    PickerActionSheet.h
    #import <UIKit/UIKit.h>
    @interface PickerActionSheet : UIActionSheet {
    UIPickerView *picker;
    BOOL layoutDone;
    @property (nonatomic, retain) UIPickerView *picker;
    @end
    PickerActionSheet.m
    #import "PickerActionSheet.h"
    @implementation PickerActionSheet
    @synthesize picker;
    - (id)initWithTitle:(NSString *)title delegate:(id < UIActionSheetDelegate >)delegate
    cancelButtonTitle:(NSString *)cancelButtonTitle
    destructiveButtonTitle:(NSString *)destructiveButtonTitle
    otherButtonTitles:(NSString *)otherButtonTitles, ... {
    self = [super initWithTitle:title delegate:delegate cancelButtonTitle:cancelButtonTitle
    destructiveButtonTitle:destructiveButtonTitle otherButtonTitles:otherButtonTitles];
    if (self) {
    UIPickerView *p = [[UIPickerView alloc] initWithFrame:CGRectZero];
    [self addSubview:p];
    self.picker = p;
    [p release];
    return self;
    - (void)dealloc {
    [super dealloc];
    * Determine maximum y-coordinate of UILabel objects. This method assumes that only
    * following objects are contained in subview list:
    * - UILabel
    * - UITextField
    * - UIThreePartButton (Private Class)
    - (CGFloat) maxLabelYCoordinate {
    // Determine maximum y-coordinate of labels
    CGFloat maxY = 0;
    for( UIView *view in self.subviews ){
    if([view isKindOfClass:[UILabel class]]) {
    CGRect viewFrame = [view frame];
    CGFloat lowerY = viewFrame.origin.y + viewFrame.size.height;
    if(lowerY > maxY)
    maxY = lowerY;
    return maxY;
    - (void)layoutSubviews {
    [super layoutSubviews];
    if(!layoutDone) {
    CGRect frame = [self frame];
    CGFloat alertWidth = frame.size.width;
    CGFloat pickerHeight = self.picker.frame.size.height;
    CGFloat labelMaxY = [self maxLabelYCoordinate];
    // Insert UIPickerView below labels and move other fields down accordingly
    for(UIView *view in self.subviews){
    if([view isKindOfClass:[UIPickerView class]]){
    CGRect viewFrame = CGRectMake(0, labelMaxY, alertWidth, pickerHeight);
    [view setFrame:viewFrame];
    } else if(![view isKindOfClass:[UILabel class]]) {
    CGRect viewFrame = [view frame];
    viewFrame.origin.y += pickerHeight;
    [view setFrame:viewFrame];
    // size UIAlertView frame by height of UIPickerView
    frame.size.height += pickerHeight + 2.0;
    frame.origin.y -= pickerHeight + 2.0;
    [self setFrame:frame];
    layoutDone = YES;
    @end
    I implemented this in my HomeScreenViewController when the user presses the test button. At this point I would like to present my UIPickerView, have the user select a test type and number of questions then click Done and be taken to the appropriate viewController.
    HomeScreenViewController.h (some items omitted to conserve on space...)
    #import <UIKit/UIKit.h>
    @interface HomeScreenViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource, UIActionSheetDelegate> {
    NSMutableArray *numberOfQuestionsArray;
    NSMutableArray *questionFormatArray;
    @property (nonatomic, retain) NSMutableArray *numberOfQuestionsArray;
    @property (nonatomic, retain) NSMutableArray *questionFormatArray;
    - (IBAction) showPicker:(id)sender;
    @end
    HomeScreenViewController.m (again, omitted some code...)
    @implementation HomeScreenViewController
    @synthesize numberOfQuestionsArray;
    @synthesize questionFormatArray;
    - (void)dealloc {
    [super dealloc];
    [numberOfQuestionsArray release];
    [questionFormatArray release];
    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    - (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"Activities loaded");
    numberOfQuestionsArray = [[NSMutableArray alloc] init];
    [numberOfQuestionsArray addObject:@"10"];
    [numberOfQuestionsArray addObject:@"20"];
    [numberOfQuestionsArray addObject:@"30"];
    [numberOfQuestionsArray addObject:@"40"];
    [numberOfQuestionsArray addObject:@"50"];
    [numberOfQuestionsArray addObject:@"60"];
    [numberOfQuestionsArray addObject:@"70"];
    [numberOfQuestionsArray addObject:@"80"];
    [numberOfQuestionsArray addObject:@"90"];
    [numberOfQuestionsArray addObject:@"100"];
    [numberOfQuestionsArray addObject:@"All"];
    questionFormatArray = [[NSMutableArray alloc] init];
    [questionFormatArray addObject:@"True and False];
    [questionFormatArray addObject:@"Multiple Choice"];
    [questionFormatArray addObject:@"Combo"];
    - (IBAction) showPicker:(id)sender {
    PickerActionSheet * sheet = [[PickerActionSheet alloc] initWithTitle:@"Pick Question Format and Number of Questions"
    delegate:self cancelButtonTitle:@"Done" destructiveButtonTitle:nil otherButtonTitles:nil];
    sheet.picker.delegate = self;
    sheet.picker.dataSource = self;
    [sheet showInView:self.view];
    [sheet release];
    - (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
    return 2;
    - (NSInteger) pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
    if (component == 0) {
    return [questionFormatArray count];
    return [numberOfQuestionsArray count];
    - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    if (component == 0) {
    return [questionFormatArray objectAtIndex:row];
    return [numberOfQuestionsArray objectAtIndex:row];
    - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    NSLog(@"didSelectRow");
    if (component == 0) {
    NSLog(@"Selected Format: %@. Index of selected format: %i", [questionFormatArray objectAtIndex:row], row);
    NSLog(@"Selected number of questions: %@. Index of selected number of questions: %i", [numberOfQuestionsArray objectAtIndex:row], row);
    @end
    All is good with this code. It builds and runs and shows the ActionSheet with the UIPickerView in it. However, Im not sure how to get that Done button to accept the users choices and take me to the appropriate viewController for the type they select. And...
    question 2 - Once the value for numberOfQuestions is selected, how do I pass that into the QuestionsViewController to limit my questions array to the selected amount??
    What I think I need...
    In QuestionsViewController.h
    #import "HomeScreenViewController.h"
    and a variable in my QuestionsViewController of numberOfQuestions then when I transition from the HomeScreenViewController to my QuestionViewController Ill set the amount but thats where Im not sure how to implement it.
    Here is my current code for setting the questions array which is an NSMutableArray...
    QuestionsViewController.m
    - (void)viewDidLoad {
    [super viewDidLoad];
    NSString *comboPath = [[NSBundle mainBundle] pathForResource:@"ComboQuestions" ofType:@"plist"];
    NSLog(@"%s: path=%@", _func_, comboPath);
    NSMutableArray* tmpComboArray = [[NSMutableArray alloc]initWithContentsOfFile:comboPath];
    self.questions = tmpComboArray;
    [tmpComboArray release];
    [self reset];
    Any help would be appreciated!!!

    Ray, I cant thank you enough for all your help man. Fricken awesome!
    RayNewbie wrote:
    Hi Merlin -
    I'll try to outline the answers to your explicit questions, but I have some reservations about the code you found to subclass UIActionSheet. I'm also not sure I understand the controller hierarchy you described. So I'd like to wait for your response before getting into any working example code. In other words, the code in this post is only for the purpose of clarifying the text, ok?
    See this is a perfect example of me still not knowing the ins and outs of this. Im still a little unclear on documented and undocumented info. So in order to find out if a method or class is documented, do you simply search the apple reference docs for it and make sure all the instances are accounted for?
    My current control hierarchy has the HomeScreenViewController that passes the user off to the QuestionFormatViewController which upon selection of a format passes the user to the QuestionsViewController. In the spirit of KISS (Keep it simple stupid) I was attempting to get rid of the QuestionFormatViewController and present those options after a selection was made on the HomeScreenViewController. Hope that makes sense.
    iMerlin wrote:
    [question 1 -] Im not sure how to get that Done button to accept the users choices and take me to the appropriate viewController for the type they select.
    I would give the action sheet delegate responsibility for getting the picker view selections. If the delegate is the controller that created the action sheet, you might do something like this:
    - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == kActionIndexDone) {
    UIPickerView *picker = actionSheet.picker;
    // assume this controller has int ivars to store the question format and the number of questions
    self.questionFormat = [picker selectedRowInComponent:0];
    self.questionCount = [picker selectedRowInComponent:1];
    // maybe convert questionCount in some way here or later; e.g.:
    // self.questionCount = [[numberOfQuestionsArray objectAtIndex:questionCount] intValue];
    - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == kActionIndexDone) {
    switch (questionFormat) {
    case kQuestionFormatMultipleChoice:
    MultipleChoiceViewController *mcvc = [[MultipleChoiceViewController alloc]
    initWithNibName:@"MultipleChoiceViewController", bundle:nil];
    mcvc.questionCount = questionCount;
    mcvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:mcvc animated:YES];
    [mcvc release];
    break;
    case kQuestionFormatTrueFalse:
    break;
    This is perfect Ray. But one question on yet another area Im slightly confused by... delegates! I see you are initializing an instance of the MultipleChoiceViewCOntroller here...
    switch (questionFormat) {
    case kQuestionFormatMultipleChoice:
    MultipleChoiceViewController *mcvc = [[MultipleChoiceViewController alloc]
    initWithNibName:@"MultipleChoiceViewController", bundle:nil];
    mcvc.questionCount = questionCount;
    mcvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:mcvc animated:YES];
    [mcvc release];
    break;
    But I was under the impression that to "set" a value in another class I would have to make it a delegate to the class Im "getting" it from. So the whole thing like...
    @protocol ActionSheetDelegate...
    id<ActionSheetDelegate> delegate;
    Then make MCVC conform to that protocol. Am I overcomplicating things again?
    Also, do the kValues need to be defined?
    question 2 - Once the value for numberOfQuestions is selected, how do I pass that into the QuestionsViewController to limit my questions array to the selected amount??
    I'm not sure I understand which controller is which, or if you need all the controller classes you mentioned (QuestionFormatViewController, QuestionsViewController, HomeScreenViewController, etc.), but the above example shows how to pass the no. of questions to the MultipleChoiceViewController. The same delegate method could send that same question count to any other controller (assuming you've provided a way for the delegate to find the address of the other controller(s).
    As to subclassing UIActionSheet, I"m not comfortable with the code you found because it implicitly relies on some undocumented details. For example, in this code:
    - (CGFloat) maxLabelYCoordinate {
    // Determine maximum y-coordinate of labels
    CGFloat maxY = 0;
    for( UIView *view in self.subviews ){
    if([view isKindOfClass:[UILabel class]]) {
    CGRect viewFrame = [view frame];
    CGFloat lowerY = viewFrame.origin.y + viewFrame.size.height;
    if(lowerY > maxY)
    maxY = lowerY;
    return maxY;
    I don't see anything in the doc about UILabel objects as components of UIActionSheet. I certainly could've missed that in the doc, or misunderstood the subclass code, but at first glance it looks like the programmer manually enumerated the subviews, discovered the "buttons" were labels, and used this information accordingly. That's going to work nicely so long as UIActionSheet continues to be implemented in the same way. But if Apple decides to make a UIActionSheel without UILabel objects in the future, this subclass might not produce the view you want.
    Completely understand now that you've explained it this way. I would hate to spend any time on something Ill ultimately have to fix anyway.
    The decision to use undocumented info is up to you. I would agree UIActionSheet will likely continue to be costructed the way it is now. But a product based on this assumption doesn't give me a really warm, fuzzy feeling. I might accept the risk if there were no other alternative, and the desired feature were really important. In this case though, there are plenty of choices that don't require any fancy subclassing. For example, it's very easy to slide in a half-screen subview containing the picker view and any control layout you want. You can add other action-sheet like behaviors as needed (e.g. tinting and disabling the covered view).
    Since you already have your subclass working, I guess it might make sense to finish up the current design and upgrade to something safer in a later version (or not).
    - Ray
    No, Im with you on this one 100%. I noticed someone mentioned it was undocumented in the other thread but I kinda skipped right over that for some reason. The reason I found this method fitting to my implementation is because it also provides the Done button. I think Im going to play with the actionSheet code you provided just to see if I can get it working. But Ill ultimately go in a new direction, like you said.
    After spending a lot of last night looking into UIPickerView and the like, not to mention your last statement, I realized I dont need an action sheet to get that Done button. I can just build a new view and present that. I think Ill go that route instead of the subclass of actionsheet. Do the above examples still fit if I build a regular view? Of course Ill have to write those setters into the didSelectRow method of the UIPickerView, right?
    Here I go again letting the implementation drive the concept! Am I on the right track by thinking I can just build a new view with a picker and a done button on it, then present that as a subView when the user selects an option on the HomeScreen?
    Sorry if Im all over the map here Ray, but you are really helping me stay on course!

  • Is that possible?? give me idea, How??

    Hi all,
    I am implementing online examination using Struts. ....
    Is that possible that different-different candidates get same questions but in different order.
    what i am trying to say is , I fetched the list of questions from DB and iterate it in the JSP but what i want is different candidates get it in a random order. means questions should b same but not in same order for each candidate.
    Is that possible if yes then how give me some idea..
    thanx

    thanx for replying.....
    but that would not work bcause I hit the DB only one time na for every candidates. My list is one(common) which display the Questions on the candidate screen.
    even if it picks question randomly but at front-end it display all the quest in a same order to all the candidates.

  • Headset as headset gives poor quality, as headphones good, who to blame?

    I bought a very cheap Bluetooth headset for my MacBook Pro Retina, that got recommended by other buyers, just to find that when using Skype the audio guality is just too bad to be usable. I then decided not to be cheap and bought a Logitech H800 and a Philips SHB7000. The Logitech sounds "ok" but not really acceptable and the Philips almost as bad as the noname.
    Now, if I start VLC and watch a movie I found that they sound very good if I pick the "stereo" variants in the device list. Not sure it is OS X 10.8.3 fault, but I had to select, deselect, reselt a couple of times before I could hear anything when switching headset during my test.
    So I now have three headsets that all somehow dropped down to bad audio making them useless for me to talk in Skype. To me the audio quality matters a lot when talking to someone over Skype. Partly a bit spoiled by my Sennheiser PC-36 USB headset that sounds excellent.
    Wikipedia writes
    There are two types of Bluetooth headset. Headsets using Bluetooth 1.0 or 1.1 often have a single monaural earpiece, which can only access Bluetooth's headset/handsfree profile. Depending on the phone's operating system, this type of headset will either play music at a very low quality (suitable for voice), or will be unable to play music at all. Headsets with the A2DP profile can play stereo music with acceptable quality. Some A2DP-equipped headsets automatically de-activate the microphone function while playing music; if these headsets are paired to a computer via Bluetooth connection, the headset may disable either the stereo or the microphone function.
    This is not very comforting, that when using as a headset "some" A2DP headsets might de-activet the microphone and some might drop down to the low quality.
    So the bad audio is likely from the poor quality Bluetooth standard is picked, question is who picks it? And does it have to be at the poor quality setting?
    Is it the headsets I bought that has this limitation? If so, is there some way to see in the specification before buying that it will drop to low quality if used as a headset?
    Or is it my MacBook Pro Retina hardware that is limited so it has to pick the low quality setting? Or is it OS X that does this and an OS update might fix this problem? Or is it Skype that does this, i.e. an application bug?
    I would appreciate if someone could clarify where this limitation really is located and possible work-arounds, preferably without buying yet another pair of headsets....

    Skype is the problem, nothing you can do.
    i posted about it in 2010 and they dont seem in any rush to fix it.
    I still use it even with the crappy audio, simply for the convenience. What is really frustrating is randomly i will get a skype call that STAYS in pefect audio quality. It doesnt switch.
    So its obviously possible to fix, i just don't thing they have it on their 'to do' list

  • Canon Printing - Window stays open

    This is a nit-picking question but bothersome none the less. Ever since I upgraded to Leopard, when I print something the printer window opens while printing then STAYS open and I would have to manually close the window. In Tiger it used to close automatically when the print job was complete. I have all the latest software and drivers. Is there a quick fix for this?
    Thanks

    There are several threads on this here. This is a new feature in Leopard, and you can set it to close by using the Auto Quit menu item in the printer's dock menu. Some have had to delete and re-add the printer for the Auto Quit to stick.
    Hope this helps.

  • Networking problem with server

    Hi i a have developed a client server application,where a students logs in using agui to aestablish a connection with the server.When mu server is up and running waiting for clients and when i run my client program and the GUI appears then the folowing error appears on my server outpurt
    java.lang.ArrayIndexout of bounds exception
    at lines,38,69,and 151.Here is my server code
    import java.io.*;
    import java.net.*;
    import java.util.Random;
    public class Server extends Thread {
    //private static final int portnumber = 4444;
    private static final int waitforclient = 0;//represents when the server is idle and is waiting for a client connection
    private static final int waitforanswer = 1;//
    private static final int waitforconfirm = 2;//represents the server waiting for conformation from client
    private ServerSocket serverSocket; //keeps up with the server-socket connection
    private String[] questions;
    private JDBC jdbc;
    private int numQuestions; //stores the number of questions
    private int num = 0; //num is the number of the current question been asked
    private int state = waitforclient; //hold the cueent state of the server
    private Random rand = new Random(); //pick questions at random
    //creating server socket
    public Server(){
    super("Server");
    try{
    serverSocket = new ServerSocket(4444);
    System.out.print("Socket created and server now waits for clients");
    catch (IOException e)
    System.out.print("Error:couldn't create socket");
    System.exit(1);
    public static void main(String[] args){
    Server obj = new Server();
    obj.run();
    public void run(){
    Socket client = null;
    if (!initQnA()){
    System.out.println("couldn't initialise questions");
    return;
    while (true){
    if (serverSocket==null)
    return;
    try{
    client = serverSocket.accept();
    jdbc = new JDBC();
    jdbc.getPassword();
    catch(IOException e){
    System.out.println("couldn't connect to client socket");
    System.exit(1);
    try
    InputStreamReader isr =new InputStreamReader(client.getInputStream());
    BufferedReader is = new BufferedReader(isr);
    PrintWriter os = new PrintWriter(new BufferedOutputStream(client.getOutputStream()),false);
    String outLine;
    outLine = processInput(null); //communication between the client and server is handdddled by this method
    os.println(outLine);
    os.flush();
    while (true){
    String inLine = is.readLine();
    if(inLine.length() > 0){
    outLine = processInput(inLine);
    os.println(outLine);
    os.flush();
    if(outLine.equals("invalid"))
    break;
    //Clean up
    os.close();
    is.close();
    client.close();
    catch(Exception e){
    System.err.println("Exception: "+e);
    e.printStackTrace();
    private boolean initQnA(){
    try{
    File infile = new File("password.txt");
    FileInputStream inStream = new FileInputStream(infile);
    byte[] data = new byte[(int)infile.length()];
    if (inStream.read(data) <= 0){
    System.err.println("error: couldn't read file");
    return false;
    //used to find the number of users
    for (int i=0; i< data.length; i++) {
    if (data[i] == (byte)'\n') {
    numQuestions++;
    questions = new String[numQuestions];
    //stores the users in a array called questions
    int start = 0, index = 0;
    for (int j=0; j< data.length; j++) {
    if (data[j] == (byte)'\n'){
    questions[index] = new String(data, start, j-start-1);
    index++;
    start =j+1;
    catch (FileNotFoundException e){
    System.err.println("Exception: couldn't find the question file");
    return false;
    catch(IOException e){
    System.err.println("Exception: io error");
    return false;
    return true;
    String processInput(String inStr){//Each case stement in process statement reperesents
                                                           //the server leaving the given state
    String outStr = null;
    switch (state){
    case waitforclient:
    outStr = questions[num];
    state = waitforanswer;
    break;
    case waitforanswer:
    outStr = "invalid";
    //int con = inStr.charAt('=');
    //String re = inStr.substring(0,con);
    for (int y=0; y< numQuestions; y++){
    System.out.println(inStr);
    if (inStr.equalsIgnoreCase(questions[y])){
    outStr = "valid";
    System.out.println("valid user");
    break; // if he is a valid user then create a txt file using his username as the name of the file
    case waitforconfirm:
    if (inStr.equalsIgnoreCase("stop server")){
    state = waitforclient;
    num = Math.abs(rand.nextInt())%
    questions.length;
    outStr = questions[num];
    state = waitforanswer;
    else{
    //outStr ="Bye";
    state = waitforclient;
    break;
    return outStr;
    }

    Line 38? I'm not about to count lines in your code. You find line 38 yourself. You'll find it has an array index taking place in it somewhere. That index is either less than zero or greater than or equal to the array size. If you want to post this again, please do us the courtesy of indicating those lines and formatting the code properly.

  • Two questions: Event on a Date Picker and Read Only on a full page?

    Hello,
    I make use of this very informative board to develop an application but i have been unable to find info on these two topics. Sorry if it has been already discussed extensively.
    Using HTMLDB 2.2 for now.
    =>First question:
    I have a date picker item with an event
    onChange="resaStatusChange();"
    in the HTML Form Element Attribute field.
    The event is triggerring if i put a new data in the field but does not trigger if i use the picker.
    Is it a standart behaviour? Is there a way to trigger the event when new data is provided through the date picker?
    => Second question:
    One page in my application has to be used either to only display information or as a mixed displaying/entering data sheet.
    When the context is appropriate to use the page as a simple display (testing both global authorization and data to be displayed), is there a way to put a read only attribute on the full page instead of putting the read only conditions through each and every item of the page?
    Sorry if the questions are not clear and apologize for what should be newbie questions.
    Any link or info will be appreciated.
    Regards,
    Daniel Gureghian

    Hi Daniel,
    I'm not sure about your first question, but I can hopefully give you a helpfull answer for your second one.
    I'm handling it this way:
    var elInput = document.getElementsByTagName('input');
    var elTextArea = document.getElementsByTagName('textarea');
    var elSelect = document.getElementsByTagName('select');
    for (i = 0; i < elInput.length; i++)
      setReadOnly(elInput, true);
    for (i = 0; i < elTextArea.length; i++)
    setReadOnly(elTextArea[i], true);
    for (i = 0; i < elSelect.length; i++)
    setReadOnly(elSelect[i], true);
    function setReadOnly(pThis, pRead)
         if (pThis && pRead)
              pThis.disabled = pRead;
              pThis.style.emptyCells = "show";
              pThis.style.color = "black";
              pThis.style.backgroundColor = "#DDDDDD";
         else if (pThis && !pRead)
              pThis.disabled = pRead;
              pThis.style.emptyCells = "show";
              pThis.style.color = "black";
              pThis.style.backgroundColor = "#FFFFFF";
    I never used it on a whole page, only for regions. So maybe you have to make some changes.
    chrissy

  • HT1688 when trying to download apps on my daughters new iphone it is asking for answers to my security questions.  this account was set up a few years back, and the questions its giving me, i do not think they are the questions that i picked. need help

    my daughter is trying to download apps on her iphone and it keeps asking for answers to my security questions. the problem is, the questions its asking are not the questions i picked....i do not know the answers. how can i get around this?

    I was told that if you reset the password then u can get in and reset the security questions, but I am having problems with it. Apple also has a page on it in there support area, u just have to type it into the search engine and it gives u a list a messages about security questions and support pages.

  • HT201272 I have recently picked up an Apple TV. When I go to the movies tab, there are less movies available there than there are in my i-Tunes account. I've done some looking around at questions from others, but haven't found an answer that works for me.

    I have recently picked up an Apple TV. When I go to the movies tab, there less movies available there than what is available in my i-Tunes library. I have 38 movies showing in my library but only 23 are showing in the Movies tab on the Apple TV. After researching this a little, there are only 23 movies showing under Purchased in the Quicklinks of my i-Tunes account. The majority of my collection are digital copy downloads that came from DVD purchases. Some of the missing movies were added in the past couple of months, the rest are a year-or-so old. I have done some looking around at questions from others, but I have not found an answer that will fix my situation. How do I update my library to get ALL of my movies to reflect that they were "Purchased"(as it says they were in their Properties)?

    Biggles Lamb wrote:
    Chill out guys, getting personal will never ever change another persons view, right or wrong, they are entitled to them .
    The pros and cons of to CC or not to CC have been done to death
    Its a fact the CC model will work for some, especially newbies and small businesses.
    The risks associated with the CC model have been well documented.
    For long term users of CS perpetuals its generally a large hike up in cost compared to the upgrade system.
    Then there are the....... Adobe can rot it hell...... group who will never subscribe
    To each their own, you do the math to suit your cashflow whatever that is and then make an informed decision
    To those on the CC model, I'd like to offer some practical advice.........do not allow automatic updates.........make regular backups............develop an exit strategy of alternatives for when you can no longer afford the subscription costs............never ever assume that the Adobe update is bug free
    Enjoy your cloud
    Col
    Thank you for that post, and the advice. I just happen to be one of those who it does work for. I've been around long enough to know that CC isn't going to work for everyone(the large publishing/radio/web company I work for isn't upgrading to CC because of the costs involved). But it does for me as I potentially venture out into the full-time freelancing world and away from the more structured big office environment. I can't make decisions based on what is best for anyone else, or what will hurt or help Adobe. Just what affects me, and that's all.
    Brent

  • Ive Had  32gb IPOD Touch n now just got an 8gb IPHONE 4S. My question is how am I supposed to sync my iphone without it syncing my current library that is well over 32gb of info? In other words, can i pick and choose what I want to put on just iphone?

    Ive Had  32gb IPOD Touch n now just got an 8gb IPHONE 4S. My question is how am I supposed to sync my iphone without it syncing my current library that is well over 32gb of info? In other words, can i pick and choose what I want to put on just iphone?

    thanks but if Im using iCloud For my Iphone and backing my ipod touch to my computer is that ok or would I have to back both up to ICloud. As u can telll, I want to kep the 2 devices seperate as much as possible, only putting on my phone what i choose to download, buy, or take from my current itunes library most importantly.

  • Picked up a B/W.. have some questions

    Hey guys. I picked up a B/W yesterday for a nice spare computer and i have some questions.
    1. The former owner upgraded to 10.3 but the computer is lacking serious speed. I know it's not going to be fast but i have a feeling the Memory and video card is holding it back. It only has 256 megs of ram and i would like to add some more. What the max amount i can add? I heard 1GB but is it possible to do more? THe video card is the original and seriously *****. Whats a great card everyone runs? I was looking at the new HD series on new egg but i think it's designed for a pc. Will it work?
    Also.. What's the best place to buy pieces for this mac? Any good online retailers? Thanks again
    Ron

    Before you even think about investing in this computer you might want to check if it is a Rev. 1 or Rev. 2 model. I can't tell you how because I have never laid hands on a BW but apparently the Rev. 1 starts behaving really erratically when you try to upgrade things like the hard drive, and you may quickly tire of a tiny hard drive.
    As for parts, there's the old standby www.mac-sales.com but once you start buying new upgrades for that computer you will quickly outstrip just buying a used G4 instead. LowEndMac Google groups is a good place for aged machines, and of course there's e-bay. There's also a variety of used Mac and parts retailers, though I think a BW is even outside their interest range now since nobody wants to pay for parts for a G3 what they have to charge to stay in business.

  • PLD and Pick List question

    Hello
    I am trying to add ShipToCode from the RDR1 table to the PLD for Pick List, but it gives me a blank column when it should display the text values that are in ShipToCode..
    Is there a way to display the values for ShipToCode?
    Any help is appreciated, thank you

    Hi David,
    Check this thread for your answer:
    Add Order Quantity to Pick List PLD
    If you still have questions, just ask.
    Thanks,
    Gordon

  • Where do I go to pick 3 security questions?  I can only find the option for one.

    I really want to redeem my code for my free movie, but it wants me to pick three security questions.  When I manage my id it only gives me the option for one.  Please help.

    Usually you will need to contact iTunes store support but this workaround may help:
    -On the device/computer that is asking you for the security questions go to "settings", > "store" > tap the Apple ID and choose view"Apple ID" and sign in.
    - Tap on payment information and add a credit/debit card of your preference then select "done", in the upper right corner
    - Sign out and back into iTunes on the device by going to "settings"> "store" > tap the Apple ID and choose "sign-out" > Tap "sign -in" > "use existing Apple ID" and you should be asked to verify your security code for the credit/debit card and NOT the security questions.
    - At this time you can remove the card by going back in to edit the payment info and selecting "none" as the card type then saving the changes by selecting "done". You should now be able to use your iTunes store credit without answering the security questions.

  • Mobile WMS Pick Load - Question in MWA application

    Hi ,
    I am not very much familiar with OAF, MWA technologies. I am given a requirement as detailed below. Please help me with the solution.
    In the page "Mobile WMS Pick Load" , there are some fields like Sub Inventory, Item, Req_Qty etc fields and all of them have a "Confirm" field for each of them.
    But there is a field called "Xfer LPN" but there is no "Confirm" field for that. My customer wants to have "Confirm" field for "Xfer LPN".
    So I tried to look at the field definitions and noticed that there is a field "MAIN.XFER_LPN_CONFIRM" field. So I checked the properties for this filed. Especially, the "Rendered" is set to True. But this fioeld is not seen on screen.
    So My question to you is :
    1) Is that teh correct fieeld that captures the "Confirmation" for the Xfer_LPN"? If so, why is it not displayed on the screen inspite of the "endered " is set to True?
    2) How can we meet this requirements?
    Please help me with this issue. Thanks
    Regards,
    ..

    Rather than directly answering to this question, we will first understand the requirement.
    Why we need a confirm field for Subinventory and locator etc.
    - Whenever you do picking, the pick rules suggest you the sub, loc etc on the mobile screen. Now the picker need to confirm the above details to say the system that he is ok with the suggestions that are shown on the mobile screen. In some cases, they may need to override the suggestions suggested by the system. To allow that, we are having one extra field to confirm all the details that got populated automatically.
    whereas in your case it is xferLPN field which is already an editable field. Except in few cases, this field won't get the value populated. User need to enter the details manually. If system suggests the value but the picker need to override, then we can do it on the same field. So there is no question of having one extra field to confirm the XferLPN.
    Thanks,
    Kamesh,
    Senior Consultant,
    Intelligroup

Maybe you are looking for

  • Table for Tax amount in MIR7

    Dear Experts, I have parked an invoice in MIR7.I need the table where tax data in MIR7 are updated. Is there any such table, where tax amount are stored when parking the invoices. It is very Urgent issue for me. Thanks Prasant sekhar

  • Record not in plsql but appears in report

    Hi, I am trying to check why certain records are appearing in a Discoverer aging report but not in the Trial Balances. The Discoverer report is based on an sql custom folder with a join to po_vendors with the vendor_id (1 to 1, no outer joins...) . I

  • How to change Image source file name

    Hi, I have a logo image on my report that I want to change based on value of my query item. Can someone help me .....how can I change the source of my image item dynamically. Thanks Aali

  • Audio burp after idvd burn, but fine on computer preview

    Help. I created a dvd using idvd 6 for a wedding with 179 slides and 4 songs. First burn with 140 slides and 3 songs was fine. Second burn after 40 additional slides and 4th song has a burp in the 3rd song. Removed songs and re-added but has the exac

  • 10.1.3.2 and Database access

    In version 5.x, you could bring data into MS Word directly from the database. Is this still an option in 10.1.3.? If not, what is the recommended approach. Do I login into the web tool, build the report and then export the xml? Thanks.