001    /*----------------------------------------------------------------------------*/
002    /* Copyright (c) FIRST 2008-2012. All Rights Reserved.                        */
003    /* Open Source Software - may be modified and shared by FRC teams. The code   */
004    /* must be accompanied by the FIRST BSD license file in the root directory of */
005    /* the project.                                                               */
006    /*----------------------------------------------------------------------------*/
007    
008    package edu.wpi.first.wpilibj.image;
009    
010    import com.sun.cldc.jna.Structure;
011    
012    /**
013     *
014     * @author dtjones
015     */
016    public class EllipseDescriptor extends Structure {
017    
018        double m_minMajorRadius;
019        double m_maxMajorRadius;
020        double m_minMinorRadius;
021        double m_maxMinorRadius;
022    
023        public EllipseDescriptor(double m_minMajorRadius, double m_maxMajorRadius, double m_minMinorRadius, double m_maxMinorRadius) {
024            this.m_minMajorRadius = m_minMajorRadius;
025            this.m_maxMajorRadius = m_maxMajorRadius;
026            this.m_minMinorRadius = m_minMinorRadius;
027            this.m_maxMinorRadius = m_maxMinorRadius;
028            allocateMemory();
029            write();
030        }
031    
032        /**
033         * Free the c memory associated with this object.
034         */
035        public void free() {
036            release();
037        }
038    
039        public void read() {
040            m_minMajorRadius = backingNativeMemory.getDouble(0);
041            m_maxMajorRadius = backingNativeMemory.getDouble(8);
042            m_minMinorRadius = backingNativeMemory.getDouble(16);
043            m_maxMinorRadius = backingNativeMemory.getDouble(24);
044        }
045    
046        public void write() {
047            backingNativeMemory.setDouble(0, m_minMajorRadius);
048            backingNativeMemory.setDouble(8, m_maxMajorRadius);
049            backingNativeMemory.setDouble(16, m_minMinorRadius);
050            backingNativeMemory.setDouble(24, m_maxMinorRadius);
051    
052        }
053    
054        public int size() {
055            return 32;
056        }
057    }