linking contents frm a file to another file that i'm werkin on.....


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: linking contents frm a file to another file that i'm werkin on.....

  1. #1
    Join Date
    Nov 2005
    Posts
    6

    linking contents frm a file to another file that i'm werkin on.....

    hi..... i really need ur expertise.... i'm a newbie to tis......
    Qn: how do u get a whole bunch of contents from a file... let's say ProteinViewer.java into a file that i'm werkin on (MenuMgr.java). Bt i dun wan everything from that file....

    The idea of my work is to call out the contents from ProteinViewer.java into the JButton in the MenuMgr.java. So that when i click on the button, the dialog will ask "plz input a number" and aft puttin in a num and pressing enter, it will display the contents of the ProteinViewer.

    plz plz help me....... i'm in desperate situations here!!
    if you want to see the code i would gladly show it to u...

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    How are you storing the "content" of your ProteinViewer class?

    Can you expose that content to "outsiders"? Such as myProteinViewer.getInfo( int choice) which could be called by the MenuMgr class?

    If you are storing your content in a file on a disk, can't you access that content directly in read-only mode?

  3. #3
    Join Date
    Nov 2005
    Posts
    6
    hmmm....... i nt sure wat u mean..... nvm...
    i'll put up my coding fer a clearer picture...

    MenuMgr:
    class MenuMgr extends ProteinViewer {
    protected static Action depthAction;

    .
    .
    .
    .

    depthAction = new AbstractAction("Depth") {
    public void actionPerformed(ActionEvent e) {
    if (fileOpened == false) {

    String result;

    result = JOptionPane.showInputDialog(ViewerMain.theOuterframe,
    "Please enter a number.","Atom Depth", JOptionPane.OK_CANCEL_OPTION);

    if(result != null) {
    //This is where i must call the contents of the proteinviewer file }
    }
    }
    };

    .
    .
    .
    .
    .
    }
    Last edited by remy; 11-28-2005 at 09:39 PM.

  4. #4
    Join Date
    Nov 2005
    Posts
    6
    ProteinViewer:

    public class ProteinViewer extends Java3DPanel implements
    RotationChangeListener {

    .
    .
    .
    .
    .

    public TransformGroup getSpaceFillDisplay(int colorBy, int label,
    BoundingSphere bounds) throws StructureException {

    // create a new transform group
    TransformGroup objRoot = new TransformGroup();

    // loop through the chains, groups, and atoms.

    Appearance appearance = new Appearance();

    // give them appearance, get the atom color from the CONFIG
    // class


    for (int i = 0; i < PDBReader.originalMatrix.size(); i++) {


    String string = PDBReader.input[i][5];
    double d = Double.valueOf(string).doubleValue();

    if(d<2.4){
    System.out.println("wee Depth: " + PDBReader.input[i][5]);

    double x, y, z;

    // get x, y, z coordiantes from the pdb file and multiply it
    // against a scale factor
    x = ((Matrix3d) (PDBReader.originalMatrix.get(i))).m00;

    y = ((Matrix3d) (PDBReader.originalMatrix.get(i))).m11;

    z = ((Matrix3d) (PDBReader.originalMatrix.get(i))).m22;

    String atomName = PDBReader.atomList.get(i).toString();

    String atomno = PDBReader.atomnolist.get(i).toString();

    //System.out.println("~~ atomName: " +atomName);
    //System.out.println("~~ atomno: " +atomno);

    double radius = CONFIG.getAtomRadius(atomName);

    if (colorBy == CPK_COLOR) {
    appearance = CONFIG.getAppearanceByAtom(atomName);
    } else if (colorBy == CHARGES_COLOR) {
    appearance = CONFIG.getAppearanceByCharge(atomName);
    } else if (colorBy == DISTANCE_COLOR) {
    appearance = CONFIG.getAppearanceByDistance(z);
    }

    Sphere atomSphere;
    atomSphere = new Sphere((float) radius, Sphere.GENERATE_NORMALS,
    appearance);

    //The Transform3D object is represented internally as a
    //4 x 4 double-precision floating-point matrix.
    Transform3D atomXform = new Transform3D();
    TransformGroup atomGroup = new TransformGroup(atomXform);
    atomXform.set(new Vector3d(x, y, z));
    atomGroup.setTransform(atomXform);
    atomGroup.addChild(atomSphere);
    objRoot.addChild(atomGroup);

    if (label == LABEL) {

    String codeName = PDBReader.atomList.get(i).toString();

    codeName += i;

    System.out.println("codeName " + codeName);

    TransformGroup labelGroup = putLabel(codeName, x, y, z, bounds,
    0.4);
    objRoot.addChild(labelGroup);
    }

    }//(treshold)

    }
    // return the transform group
    return objRoot;
    }

    .
    .
    .
    .
    .
    }

    The portion in bold is what i want to call into MenuMgr.
    Hope this is clearer.....

  5. #5
    Join Date
    Nov 2005
    Posts
    6
    oh ya... when i mean display the contents of the proteinviewer.... i dun really mean the words of it.... the contents of my proteinviewer creates a rotatable atom. I wan to display the rotatable atom.

  6. #6
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    so you are adding a "TransformGroup" object into your MenuMgr? Then declare the TransformGroup object's instance, and define it by the copy constructor implemented when you a return object from the current instance of your ProteinViewer class.

    TransformGroup myTG = myProteinViewer.getSpaceFillDisplay(colorBy, label, bounds);

  7. #7
    Join Date
    Nov 2005
    Posts
    6
    hmm..... could u show me hw u do it if possible? coz i dun exactly noe wat u mean.... i'm new u see.... it would be a great help...... thx u........

  8. #8
    Join Date
    Nov 2005
    Posts
    6
    Quote Originally Posted by nspils
    so you are adding a "TransformGroup" object into your MenuMgr? Then declare the TransformGroup object's instance, and define it by the copy constructor implemented when you a return object from the current instance of your ProteinViewer class.

    TransformGroup myTG = myProteinViewer.getSpaceFillDisplay(colorBy, label, bounds);
    ok.... i see ur pt...... bt there still an error tat appears.....

    error:
    MenuMgr.java:254: non-static method getSpaceFillDisplay(int,int,javax.media.j3d.BoundingSphere) cannot be referenced from a static context

  9. #9
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Your code must create an instance of the ProteinViewer class, and then you invoke that instance's .getSpaceFillDisplay() method ... or else make the method "static".

Similar Threads

  1. Replies: 5
    Last Post: 05-27-2008, 12:17 PM
  2. Linking to a regular URL from an xml file
    By B.Horvath in forum XML
    Replies: 2
    Last Post: 09-30-2005, 05:36 PM
  3. Linking to a changing file name
    By Dan in forum Web
    Replies: 2
    Last Post: 12-11-2001, 08:26 PM
  4. Replies: 0
    Last Post: 07-17-2001, 03:13 PM
  5. Replies: 3
    Last Post: 05-31-2000, 11:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center