Vector.addElement problem to 4.6.0

I'm having a problem with addElement incoherent adding items to a vector vChecklists. When the program is run, the following code runs as I predicted for the first couple of iterations. However, on the third iteration, the addElement method adds an additional null element at the end of the vector vChecklists. So now this third iteration, the addElement operating increases the capacity() of the vector of 2 to 4. What could be the problem?

Checklist clNewChecklist = new Checklist();
clNewChecklist.sDescription = efTestField1.getText ();
vChecklists.addElement (clNewChecklist);

I am simulating on a "BOLD".

Thank you

Check the vectors size() method.
a vector resize dynamically if it grows, the null elements are a feature. the size does not change.

Tags: BlackBerry Developers

Similar Questions

  • Problems of persistent storage...

    Hello

    I was hesitant to post this because I thought it was a simple solution, so I tried to work around him. Basically, what happens is it saves, I can close my application and then reopen and it works. That is until I do a battery pull and everything disappears. Is this a problem with my source?

    updated source code

    public static ProjectVector get() {}

    Active = true;

    Vector ProjectVector = new ProjectVector();

    PersistentObject persist = PersistentStore.getPersistentObject (key);

    The object [] = (Object []) persist.getContents ();

    If (item! = null)

    vector = decode (object);

    Active = false;

    return vector;

    }

    {} public static Boolean save()

    If (active)

    Returns false;

    PersistentObject persist = PersistentStore.getPersistentObject (key);

    The object [] = encode (HomeScreen.projects);

    persist.setContents (object);

    persist.forceCommit ();

    Returns true;

    }

    Private Shared Object [] encode (Vector vector) {}

    The object [] = Object [vector.size (new)];

    for (int i = 0; i)< object.length;="">

    object [i] = ((Project) vector.elementAt (i)) .toObject ();

    Returns the object;

    }

    Private static ProjectVector decode (Object, object []) {}

    Vector ProjectVector = new ProjectVector();

    for (int i = 0; i)< object.length;="">

    vector.addElement (new object [i] ((Object[]) Project), true);

    return vector;

    }

    I got a vector that contains another vector with objects of string inside, but who do not also have. I then moved to multi dimensional object, but that is a failure. Does anyone have advice? Should I try the channels and divide them?

    I had experience where to stop persistent objects appeared updated for all applications to look at one, but updates are lost on a battery pull.  So I agree with the comment by BBDev which lacked the first variation of the code you have posted.

    I guess you've proven that encoding, followed by a decoding does not cause a problem, in other words, the data is not lost in this process.  I have to say it seems a bit weird how you convert a vector into an array of objects, why you not store just the ProjectVector?

    In any case, I would do the following:

    Split lines

    The object [] = (Object []) persist.getContents ();

    If (item! = null)

    in what follows:

    Object o = persist.getContents ();

    If (o! = null & o instanceof (Object [])) {}

    The object [] = (Object []) o;

    Now add a breakpoint to

    Object o = persist.getContents ();

    Check at this stage that the key is correct, then to let the getContents() proceed and check the returned object and watching the treatment whose object is in.

    Finally, a break point to:

    persist.setContents (object);

    At this point, check the key is correct, and this is what you expect it to be.  With these two points of rupture in place, through battery pull (i.e. to restart the Simulator) and make sure that the object you return to the get() method is what you expect.  This will determine if the problem is in the persistence or the logic of encode/decode.

    I hope this helps.

  • vector graphics: fuzzy in preview, accurate in the final rendering?

    Hi all

    I was hitting my head for awhile on my fuzzy vector graphics problem - vectors imported in AE since Illustrator, which include text, text describes, clipping, masks, etc.. I had checked and checked my "continuously rasterize ', my"condense transformations", even went to adjust anti-aliasing for best quality: no help

    Well, I had a breakthrough today: when I do a final, my fuzzy vector graphics becomes clear.  Huh?  Well, very well!  But now my question is: am I stuck fuzzy vectors edition?  That seems like an odd limitation.

    a little more information on what I'm doing: I'm animating between pieces of text which are of different sizes, some text is solid, some contours, some with fillings created with clipping masks - and I did a little experiment with taking on masks, etc., because I learned that certain Illustrator effects out properly and cause an immediate pixelation in AE - but that didn't seem to do much for my preview quality. I have configured my illustrator file with the preset of film/video, so I have 2 work plans - and I let the text bigger spill over into this larger arboard.  I save as illustrator CS5, compatible PDF file and bring AE as a composition w / "keep the sizes of layer".

    any thoughts? is it just the nature of the beast? Maybe I'll put up my illustrator bad file?

    Thank you

    the love of my life

    You could see artifacts due to the Correction of the Pixel format if you use non square BY in your comp (s). In your preferences, check to see if you have the Zoom quality setting designated for "more precise".

    If this is not the case, then, as you noted, you probably have an effect enabled in Illustrator on one or more of your layers/objects which causes aliasing.

  • Analysis sax XML parser

    Hello...

    I would like to publish this example to help pasring xml or live feed from a URL.

    SAXParserFactory plant = SAXParserFactory.newInstance ();
    SAXParser saxParser = factory.newSAXParser ();

    DefaultHandler Manager = new DefaultHandler() {}

    ' public void startElement (String uri, String localName, String qName,
    Attributes attributes) throws SAXException {}
    If (qName.equalsIgnoreCase ("an element of xml"))
    {

    vector.addElement (attributes.getValue ("attribute of an element"));

    }

    ElseIf (qName.equalsIgnoreCase ("second item FRO xml"))
    {

    attributteValue = attributes.getValue ("title");

    }

    ' public void endElement (String uri, String localName, String qName)
    throws SAXException {}

    currentElement = false;

    If (qName.equalsIgnoreCase ("end of the element"))
    {
    do something
    }

    }

    };
    S StreamConnection = null;

    s = (StreamConnection) Connector.open ("enter the url that provides the xml file");
    HttpConnection httpConn s = (HttpConnection);

    If (httpConn.getResponseCode () is 400)

    {
    Dialog.Alert ("internett noaccess");

    }

    InputStream input = null;
    entry = s.openInputStream ();

    Reader reader = new InputStreamReader(input,"UTF-8");
    InputSource is = new InputSource (reader);
    is.setEncoding("UTF-8");

    saxParser.parse (, Manager);
    }

    Add the required elements of the XML in the analysis to the vectors and do something.

    SAX (Simple API for XML) is a parser based on the events in sequential access API developed by the XML - DEV list for XML documents. SAX provides a mechanism for reading data from an XML document that is an alternative to that provided by the DOM (Document Object). When the DOM works on the document as a whole, SAX parsers function on each element of the XML document in order.

    SAX parsers have certain advantages over DOM-style parsers. A SAX parser doesn't need to declare every event analysis what happens and almost all of these once-reported information normally rejects (he does, however, keep some things, for example a list of all the elements that have not been closed yet, in order to intercept errors later as the end tags in the wrong order). Thus, the minimum memory required for a SAX parser is proportional to the maximum depth of the XML (i.e. the XML tree) and the maximum data involved in a single XML event (for example, the name and the attributes of a single tag start, or the content of a processing instruction, etc.).

    This amount of memory is generally regarded as negligible. A DOM parser, however, usually built a representation of the tree of the entire document in memory at first, using memory that increases with the length of the entire document. It takes a lot of time and space for large documents (memory allocation and the construction of data structures take time). The advantage of compensation, of course, is that once loaded no matter what part of the document are accessible in any order.

    I hope this post was helpful.



    Welcome on the support forums.

    Thank you for contributing. There is however a minor problem: all blocking operations must be made on a separate thread. You cannot use Dialog.alert on a thread without use invokelater or synchronization on the eventlock, you should fix that.

    In addition, there are a lot of response codes, and you should check for 200 continue, otherwise trigger an error.

    There is also a xmldemo in the samples provided with the eclipse plugin or JDE, but it uses DocumentBuilder, no Sax.

  • AbstractTreeModel

    I was told once in fishing forums it's a bad habit to call #. updateUI() #. revalidate() using abstractTableModel.

    I pulled treemodelevents however the JTree object does not seem to respond to these events without back updateUI and revalidate? Why is this?


    package Swing;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.Enumeration;
    import java.util.Observable;
    import javax.swing.*;
    import javax.swing.event.ListDataListener;
    import javax.swing.event.ListSelectionListener;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.table.*;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreeNode;
    import javax.swing.tree.TreePath;
    //import com.sun.java.swing.tree.*;
    //import com.sun.java.swing.event.*;
    import java.util.*;
    
    
    
    class TreeModelTest {
    
        public static void main(String[] args) {
            new GUI().createGui();
        }
    }
    
    class GUI  {
        private JTree tree;
        private PeopleTreeModel peopleModel = new PeopleTreeModel();
    
    
        public void createGui() {
            tree = new JTree(peopleModel);
            JPanel pane = new JPanel(new BorderLayout());
            pane.add(new JScrollPane(tree), BorderLayout.CENTER);
            pane.add(getButtonPanel(), BorderLayout.SOUTH);
    
            JFrame f = new JFrame("Abstract JTree Example");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(pane);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    
        }
    
        public JPanel getButtonPanel(){
            JPanel buttonPanel = new JPanel();
    
            JButton addPersonButton = new JButton("Add Person");
            addPersonButton.addActionListener(new ActionListener() {
    
                public void actionPerformed(ActionEvent e) {
                    System.out.println("Adding Person");
                    peopleModel.addPerson(new Person("New Person"));
                    tree.updateUI();
                    tree.revalidate();
                }
            });
    
            JButton removePersonButton = new JButton("Remove Person");
            removePersonButton.addActionListener(new ActionListener() {
    
                public void actionPerformed(ActionEvent e) {
                    System.out.println("Remove Person");
                    peopleModel.removePerson(0);
                    tree.updateUI();
                    tree.revalidate();
                }
            });
    
            JButton selectPersonButton = new JButton("Select Person");
            selectPersonButton.addActionListener(new ActionListener() {
    
                public void actionPerformed(ActionEvent e) {
                    System.out.println("Select Person");
                }
            });
    
            buttonPanel.add(addPersonButton);
            buttonPanel.add(removePersonButton);
            buttonPanel.add(selectPersonButton);
            return buttonPanel;
        }
    }
    
    
    
    
    
    
    
    class PeopleTreeModel extends AbstractTreeModel  implements TreeModel {
    
        private ArrayList<Person> peopleArray = new ArrayList<Person>();
    
    
        public PeopleTreeModel() {
            super();
            peopleArray.add(new Person("Chris"));
            peopleArray.add(new Person("Hary"));
            peopleArray.add(new Person("Boris"));
            peopleArray.add(new Person("lucy"));
            peopleArray.add(new Person("char"));
            this.print();
        }
    
        public void addPerson(Person person){
            peopleArray.add(person);
            //here I want to fire tree event??
            Object[] path = {"people",person.getName()};
            this.fireTreeNodesInserted(new TreeModelEvent(person.getName(),path));
    
    
        }
    
        public void removePerson(int index){
            if(index<peopleArray.size()){
                peopleArray.remove(index);
                Object[] path = {"people",this.peopleArray.get(index).getName()};
                this.fireTreeNodesInserted(new TreeModelEvent(this.peopleArray.get(index).getName(),path));
                
            }
        }
    
    
    
        public ArrayList<Person> getPeopleArray() {
            return peopleArray;
        }
    
        public void setPeopleArray(ArrayList<Person> people) {
            this.peopleArray = people;
        }
    
        public void print() {
            System.out.println("\nPrinting People Array");
            for (int i = 0; i < peopleArray.size(); i++) {
                System.out.println(peopleArray.get(i).toString());
            }
        }
    
        public Object getRoot() {
            return "people";
        }
    
        public Object getChild(Object parent, int index) {
            if(parent.toString().equals("people")){
                return this.peopleArray.get(index);
            }else{
                return null;
            }
        }
    
        public int getChildCount(Object parent) {
            if(parent.toString().equals("people")){
                System.out.println("Returning size "+this.peopleArray.size());
                return this.peopleArray.size();
            }else{
                return 0;
            }
        }
    
        public boolean isLeaf(Object node) {
            if(node.toString().equals("people")){
                return false;
            }else{
                return true;
            }
        }
    
        public void valueForPathChanged(TreePath path, Object newValue) {
            System.out.println(path + ", "+ newValue);
        }
    
        public int getIndexOfChild(Object parent, Object child) {
            return this.peopleArray.indexOf(child);
        }
    }
    
    
    
    
    
    class Person {
    
        private String name;
    
        public Person() {
            this("Chris");
        }
    
        public Person(String name) {
            super();
            this.name = name;
        }
    
        @Override
        public String toString() {
            return name;
        }
    
        public String getName() {
            return name;
        }
    
    
        public void setName(String name) {
            this.name = name;
        }
    
    }
    
    // This class takes care of the event listener lists required by TreeModel.
    // It also adds "fire" methods that call the methods in TreeModelListener.
    // Look in TreeModelSupport for all of the pertinent code.
    abstract class AbstractTreeModel extends TreeModelSupport implements TreeModel {
    }
    
    
    class TreeModelSupport {
       private Vector vector = new Vector();
    
       public void addTreeModelListener( TreeModelListener listener ) {
          if ( listener != null && !vector.contains( listener ) ) {
             vector.addElement( listener );
          }
       }
    
       public void removeTreeModelListener( TreeModelListener listener ) {
          if ( listener != null ) {
             vector.removeElement( listener );
          }
       }
    
       public void fireTreeNodesChanged( TreeModelEvent e ) {
          Enumeration listeners = vector.elements();
          while ( listeners.hasMoreElements() ) {
             TreeModelListener listener = (TreeModelListener)listeners.nextElement();
             listener.treeNodesChanged( e );
          }
       }
    
       public void fireTreeNodesInserted( TreeModelEvent e ) {
          Enumeration listeners = vector.elements();
          while ( listeners.hasMoreElements() ) {
             TreeModelListener listener = (TreeModelListener)listeners.nextElement();
             listener.treeNodesInserted( e );
          }
       }
    
       public void fireTreeNodesRemoved( TreeModelEvent e ) {
          Enumeration listeners = vector.elements();
          while ( listeners.hasMoreElements() ) {
             TreeModelListener listener = (TreeModelListener)listeners.nextElement();
             listener.treeNodesRemoved( e );
          }
       }
    
       public void fireTreeStructureChanged( TreeModelEvent e ) {
          Enumeration listeners = vector.elements();
          while ( listeners.hasMoreElements() ) {
             TreeModelListener listener = (TreeModelListener)listeners.nextElement();
             listener.treeStructureChanged( e );
          }
       }
    }

    847102 wrote:
    After a bit more research, it does not work because JTree does not implement TreeModelListener. That's why you add manually the listener IE

    This is not correct. JTree use an inner class as TreeModelListener and it works correctly for any model of tree.

    The problem is that you do not send the correct events:
    -to insert, you create a node changed event but calls the inserted node. Also the source would be better than the model of the tree.
    -to remove them, do you the same (which will obviously not work). Also it will fail with an IndexOutOfBoundsException if you delete the last one.

    I suggest you read the Javadoc for TreeModelEvent, especially the various manufacturers.

  • JDBC-fetch data - set and very big (table 35)

    Hello

    I'm trying to get a very large data set and the desired behaviour is that it continues to function without exception of lack of memory (that is, it's good that it takes days but don't blow up on out-of-memory exception) *.
    The task runs on a 64-bit with 16 processors computer.

    For testing purposes, I used a table 35 GB in size (of course this would not be our typical fetch but just to emphasize JDBC)

    +??? Java exception occurred: +.
    + means: Java heap space.
    + java.util.Arrays.copyOf (Unknown Source) +.
    + java.util.Vector.ensureCapacityHelper (Unknown Source) +.
    + java.util.Vector.addElement (Unknown Source) +.
    +          at+
    + com.mathworks.toolbox.database.fetchTheData.dataFetch(fetchTheData.java:737) +.
    + Error in == > cursor.fetch at 114 +.
    + dataFetched = +.
    + dataFetch (fet, resultSetMetaData, p.NullStringRead, tmpNullNumberRead);

    In the light of this problem, I added jdbc-fetch-size = 999999999 on my JDBC connection string.
    ' com.microsoft.sqlserver.jdbc.SQLServerDriver ',' jdbc:sqlserver://SomeDatabaseServer:1433; databaseName = SomeDatabase; integratedSecurity = true; JDBC-fetch-size = 999999999; »

    Slightly different error reported.

    +??? Java exception occurred: +.
    + means: GC overhead limit exceeded+.

    + java.lang.Integer.toString (Unknown Source) +.

    + java.sql.Timestamp.toString (Unknown Source) +.

    +          at+
    + com.mathworks.toolbox.database.fetchTheData.dataFetch(fetchTheData.java:721) +.
    +          +

    + Error in == > cursor.fetch at 114 +.
    + dataFetched = +.
    + dataFetch (fet, resultSetMetaData, p.NullStringRead, tmpNullNumberRead); +

    Any suggestion?

    REF:
    JDBC http://msdn.microsoft.com/en-us/library/ms378526.aspx
    32 bit vs 64 bit: http://support.microsoft.com/kb/294418

    Published by: devvvy may 6, 2011 01:10

    There is one thing to go too far. You won't push ever that a lot of data in memory at a time, which seems to happen due to the vector between the two. The amount of objects that must be created would be already staggering.

    Best is to use a result set and browse results instead, treat the rows one at a time, or maybe a batch. Who will use only as much memory as necessary to keep a line / a lot of lines in memory unless the driver not just preloading of magic.

  • The application to display very slowly, please give me advice, thanks.

    Dear all,

    Could someone give me some advice? Thanks, I'm new developer in the development of a program administered for BB bold 9000, but when I run the application, it was display very slowly. Thank you.

    My code is displayed as follows:

    Main:

    import net.rim.blackberry.api.browser.Browser;
    import net.rim.blackberry.api.browser.BrowserSession;
    import net.rim.device.api.servicebook.ServiceBook;
    import net.rim.device.api.servicebook.ServiceRecord;
    import net.rim.device.api.system.Characters;
    import net.rim.device.api.system.EncodedImage;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.BitmapField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.HorizontalFieldManager;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    import net.rim.device.api.ui.decor.Background;
    import net.rim.device.api.ui.decor.BackgroundFactory;
    
    public class SmartoneVodafoneServices extends UiApplication {
    
        public static void main(String arg[]) throws Throwable {
            SmartoneVodafoneServices application = null;
            application = new SmartoneVodafoneServices();
            application.enterEventDispatcher();
        }
    
        public SmartoneVodafoneServices() throws Throwable {
                pushScreen(new SmartoneVodafoneServicesScreen());
        }
    }
    
    class SmartoneVodafoneServicesScreen extends MainScreen {
    
        //private TableLayoutManager table = TableDefine();
        private String url = "http://202.140.96.134:8080/Hero/shortcuts_demo.xml";
        private static ServiceBook sb = ServiceBook.getSB();
        private static ServiceRecord[] records = sb.findRecordsByCid("BrowserConfig");
    
        public SmartoneVodafoneServicesScreen() throws Throwable {
            super();
            LabelField title = new LabelField("Smartone Vodafone Services",
                    DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.HCENTER);
            setTitle(title);
    
            Background bg = BackgroundFactory.createSolidBackground(Color.BLACK);
            getMainManager().setBackground(bg);
            String[][] arr = null;EncodedImage pic = null;int p = 0;
            UiApplication.getUiApplication().getScreenCount();
            arr = Conn.WorkForXML(url);
            HorizontalFieldManager mainHManager = new HorizontalFieldManager(Field.FIELD_VCENTER);
            VerticalFieldManager col1 = new VerticalFieldManager(Field.FIELD_HCENTER);
            VerticalFieldManager col2 = new VerticalFieldManager(Field.FIELD_HCENTER);
            VerticalFieldManager col3 = new VerticalFieldManager(Field.FIELD_HCENTER);
            VerticalFieldManager col4 = new VerticalFieldManager(Field.FIELD_HCENTER);
            VerticalFieldManager col5 = new VerticalFieldManager(Field.FIELD_HCENTER);
    
            for (int i = 0; i < arr.length; i++) {
                if (arr[i][0] != null || arr[i][1] != null || arr[i][2] != null) {      
    
                    LabelField name = showName(arr[i][0]);
                    pic = Conn.GetPngField(arr[i][1]);
                    final String link = arr[i][2];
                    //final String link = "http://202.140.96.134:8080/blackberry/index.html";
                    BitmapField myBitmapField = new BitmapField(pic.getBitmap(),Field.FOCUSABLE|FIELD_VCENTER){
                        protected boolean invokeAction(int status){
                            //BrowserSession site = Browser.getDefaultSession();
                            BrowserSession site = createWAPBrowserSession();
                            site.displayPage(link);
                            return true;
                        }
    
                        protected void paint(Graphics g) {
                            g.setBackgroundColor(Color.BLACK);
                            g.drawRoundRect(0, 0, getWidth(), getHeight(), 10, 10);
                            g.setColor(Color.WHITE);
                            super.paint(g);
    
                        }
                    };
    
                    switch (p) {
                        case 0:
                            col1.add(new LabelField(" ",LabelField.NON_FOCUSABLE));
                            col1.add(myBitmapField);
                            col1.add(name);
                            break;
                        case 1:
                            col2.add(new LabelField(" ",LabelField.NON_FOCUSABLE));
                            col2.add(myBitmapField);
                            col2.add(name);
                            break;
                        case 2:
                            col3.add(new LabelField(" ",LabelField.NON_FOCUSABLE));
                            col3.add(myBitmapField);
                            col3.add(name);
                            break;
                        case 3:
                            col4.add(new LabelField(" ",LabelField.NON_FOCUSABLE));
                            col4.add(myBitmapField);
                            col4.add(name);
                            break;
                        case 4:
                            col5.add(new LabelField(" ",LabelField.NON_FOCUSABLE));
                            col5.add(myBitmapField);
                            col5.add(name);
                            break;
                    }
                    p ++;
                    if ( p == 5 ){
                        p = 0;
                    }
                }
            }
            mainHManager.add(col1);
            mainHManager.add(col2);
            mainHManager.add(col3);
            mainHManager.add(col4);
            mainHManager.add(col5);
            add(mainHManager);
        } 
    
        public LabelField showName(String name) {
            return new LabelField(name,LabelField.NON_FOCUSABLE|LabelField.FIELD_VCENTER){
                protected void paint(Graphics g) {
                    Font myFont = Font.getDefault().derive(Font.PLAIN, 7);
                    g.setColor(Color.WHITE);
                    g.setFont(myFont);
                    super.paint(g);
                }
            };
        }
    
        public static BrowserSession createWAPBrowserSession()
        {
            // If there are browser services found - search for the WAP2
            // Service Record
            String uid = null;
            int numRecords = records.length;
            for( int i = 0; i < numRecords; i++ )
            {
                ServiceRecord myRecord = records[i];
                //if (myRecord.getName()){
                if (myRecord.getUid().equals("WAP Browser Smartone")==true){
                    uid = myRecord.getUid();
                }
            }
            return Browser.getSession(uid);
        }
    
        public boolean keyChar(char key, int status, int time)
           {
               switch (key) {
                   case Characters.ESCAPE:
                        System.exit(0);
                        break;
               }
               return true;
               //return true to indicate that a key was pressed
           }
    }
    

    Conn.Java

    import java.io.*;
    
    import javax.microedition.io.*;
    
    import net.rim.blackberry.api.browser.Browser;
    import net.rim.blackberry.api.browser.BrowserSession;
    import net.rim.device.api.math.*;
    import net.rim.device.api.servicebook.ServiceRecord;
    import net.rim.device.api.system.*;
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.BitmapField;
    import net.rim.device.api.ui.decor.Border;
    import net.rim.device.api.ui.decor.BorderFactory;
    import net.rim.device.api.xml.parsers.*;
    
    import org.w3c.dom.*;
    
    public class Conn {
    
        /**
         * @return
         * @throws IOException
         * @throws Throwable
         * @throws Throwable
         */
    
        public static String[][] WorkForXML(String url) throws IOException, Throwable {
            // TODO Auto-generated method stub
            String[][] arr = null;
            HttpConnection conn = null;
            Document doc;
    
                conn = (HttpConnection) Connector.open(url);
                conn.setRequestMethod(HttpConnection.GET);
    
            try {
                if (conn.getResponseCode() == HttpConnection.HTTP_OK) {
    
                    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    
                    docBuilder.isValidating();
                    doc = docBuilder.parse(conn.openInputStream());
                    conn.close();
                    doc.getDocumentElement().normalize();
    
                    NodeList list = doc.getElementsByTagName("item");
                    arr = new String[list.getLength()][3];
    
                    for (int i = 0; i < list.getLength(); i++) {
                        Node nNode = list.item(i);
                        NodeList sList = nNode.getChildNodes();
    
                        if (sList.item(1).getFirstChild().getNodeValue().equals("0")) {
    
                            arr[i][0] = sList.item(3).getFirstChild().getNodeValue();
                            arr[i][1] = sList.item(7).getFirstChild().getNodeValue();
                            arr[i][2] = sList.item(11).getFirstChild().getNodeValue();
    
                        }
                    }
                    conn=null;
                    docBuilderFactory = null;
                    docBuilder = null;
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ParserConfigurationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
            return arr;
        }
    
        public static EncodedImage GetPngField(String pic) throws IOException {
    
            EncodedImage imageField = null;
            HttpConnection picon = null;
    
                picon = (HttpConnection) Connector.open(pic);
                picon.setRequestMethod(HttpConnection.GET);
    
            try {
                if (picon.getResponseCode() == HttpConnection.HTTP_OK) {
    
                    DataInputStream inputStream = picon.openDataInputStream();
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    
                    byte[] buffer = new byte[5120];
                    int len = 0, imageSize = 0;
    
                    while (-1 != (len = inputStream.read(buffer))) {
                        byteArrayOutputStream.write(buffer);
                        imageSize += len;
                    }
    
                    byteArrayOutputStream.flush();
                    picon.close();
                    picon=null;
                    byte[] imageData = byteArrayOutputStream.toByteArray();
                    byteArrayOutputStream.close();
                    byteArrayOutputStream = null;
                    inputStream = null;
                    //imageField = PNGEncodedImage.createEncodedImage(imageData, 0, imageSize);
                    EncodedImage pngImage = PNGEncodedImage.createEncodedImage(imageData, 0, imageSize);
                    imageField = resizeImage(pngImage,55,55);
    
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
            return imageField;
        }
    
        public static EncodedImage resizeImage (EncodedImage png,int Height, int Width) {
    
            int currHeight,currWidth,multH = 0,multW = 0;
    
            try {
    
                currHeight = png.getHeight();
                currWidth = png.getWidth();
                multH = Fixed32.div(Fixed32.toFP(currHeight),Fixed32.toFP(Height));
                multW = Fixed32.div(Fixed32.toFP(currWidth),Fixed32.toFP(Width));
    
            } catch (Exception e) {}
    
            return png.scaleImage32(multH,multW);
        }
    }
    

    I have

    hyoryeo wrote:

    Thanks ydarishy & peter_strange, I just point the programmer SR. is not recommended to use the wire in my workplace. But I think that the wire is the good way to make my faster program because I found that the wire would be used in many places in the Blackberry. Then I would practice the Thread in the test project.

    have been changes to the program and use the wire, saw the fastest forward speed. I would add the bar of charge process if necessary of the head. Thanks ydarishy & peter_strange,.

    SmartoneVodafoneServices.java

    import java.util.Vector;
    
    import net.rim.blackberry.api.browser.Browser;import net.rim.blackberry.api.browser.BrowserSession;import net.rim.device.api.servicebook.ServiceBook;import net.rim.device.api.servicebook.ServiceRecord;import net.rim.device.api.system.Characters;import net.rim.device.api.ui.Color;import net.rim.device.api.ui.DrawStyle;import net.rim.device.api.ui.Field;import net.rim.device.api.ui.UiApplication;import net.rim.device.api.ui.component.LabelField;import net.rim.device.api.ui.container.HorizontalFieldManager;import net.rim.device.api.ui.container.MainScreen;import net.rim.device.api.ui.container.VerticalFieldManager;import net.rim.device.api.ui.decor.Background;import net.rim.device.api.ui.decor.BackgroundFactory;
    
    public class SmartoneVodafoneServices extends UiApplication {
    
       public static void main(String arg[]) throws Throwable {      SmartoneVodafoneServices application = null;      application = new SmartoneVodafoneServices();     application.enterEventDispatcher();   }
    
       public SmartoneVodafoneServices() throws Throwable {          pushScreen(new SmartoneVodafoneServicesScreen()); }}
    
    class SmartoneVodafoneServicesScreen extends MainScreen {
    
      private String url = "http://202.140.96.134:8080/Hero/shortcuts_demo.xml";
    
      private static ServiceBook sb = ServiceBook.getSB();  private static ServiceRecord[] records = sb.findRecordsByCid("BrowserConfig");    private HorizontalFieldManager mainHManager = new HorizontalFieldManager(Field.FIELD_VCENTER);    private VerticalFieldManager colum1 = new VerticalFieldManager(Field.FIELD_HCENTER);  private VerticalFieldManager colum2 = new VerticalFieldManager(Field.FIELD_HCENTER);  private VerticalFieldManager colum3 = new VerticalFieldManager(Field.FIELD_HCENTER);  private VerticalFieldManager colum4 = new VerticalFieldManager(Field.FIELD_HCENTER);  private VerticalFieldManager colum5 = new VerticalFieldManager(Field.FIELD_HCENTER);
    
        private Vector col = new Vector();
    
      public SmartoneVodafoneServicesScreen() throws Throwable {        super();      LabelField title = new LabelField("Smartone Vodafone Services",               DrawStyle.ELLIPSIS | Field.USE_ALL_WIDTH | DrawStyle.HCENTER);        setTitle(title);      col.addElement(colum1);col.addElement(colum2);col.addElement(colum3);col.addElement(colum4);col.addElement(colum5);       Background bg = BackgroundFactory.createSolidBackground(Color.BLACK);     getMainManager().setBackground(bg);       SmartoneVodafoneServicesScreen screen = this;     ConnectXMLThread startMainThread = new ConnectXMLThread(url,col,mainHManager, screen);        startMainThread.start();      //startMainThread.wait(30000);
    
      } 
    
      public BrowserSession createWAPBrowserSession()   {     // If there are browser services found - search for the WAP2      // Service Record     String uid = null;        int numRecords = records.length;      for( int i = 0; i < numRecords; i++ )      {         ServiceRecord myRecord = records[i];          if (myRecord.getUid().equals("WAP Browser Smartone")==true){              uid = myRecord.getUid();          }     }     return Browser.getSession(uid);   } public boolean keyChar(char key, int status, int time)       {         switch (key) {            case Characters.ESCAPE:                    System.exit(0);                   break;           }         return true;          //return true to indicate that a key was pressed      }}
    

    ConnectXMLThread.java

    import java.util.Vector;
    
    import javax.microedition.io.Connector;import javax.microedition.io.StreamConnection;
    
    import net.rim.device.api.ui.UiApplication;import net.rim.device.api.ui.container.HorizontalFieldManager;import net.rim.device.api.ui.container.VerticalFieldManager;import net.rim.device.api.xml.parsers.DocumentBuilder;import net.rim.device.api.xml.parsers.DocumentBuilderFactory;
    
    import org.w3c.dom.Document;import org.w3c.dom.Node;import org.w3c.dom.NodeList;
    
    public class ConnectXMLThread extends Thread {
    
      private StreamConnection conn;    private Document doc; private Vector vector = new Vector(); private String url;   private Vector col;   private HorizontalFieldManager mainHManager;  private SmartoneVodafoneServicesScreen screen;
    
      //public ConnectXMLThread(long startApplication) {    public ConnectXMLThread(String url, Vector col, HorizontalFieldManager mainHManager, SmartoneVodafoneServicesScreen screen) {     // TODO Auto-generated constructor stub       //this.starttime = startApplication;      this.url = url;       this.col = col;       this.mainHManager = mainHManager;     this.screen = screen;
    
       }
    
       public void run() {       try {         conn = (StreamConnection) Connector.open(url);            DocumentBuilderFactory docFac = DocumentBuilderFactory.newInstance();         DocumentBuilder docBui = docFac.newDocumentBuilder();         doc = docBui.parse(conn.openInputStream());           NodeList list = doc.getElementsByTagName("item");
    
               for (int i = 0; i < list.getLength(); i++) {               Node nNode = list.item(i);                NodeList sList = nNode.getChildNodes();
    
                 if (sList.item(1).getFirstChild().getNodeValue().equals("0")) {                   String[] arr = new String[3];                 arr[0] = sList.item(3).getFirstChild().getNodeValue();                    arr[1] = sList.item(7).getFirstChild().getNodeValue();                    arr[2] = sList.item(11).getFirstChild().getNodeValue();                   vector.addElement(arr);               }         }         Vector threadList = new Vector(vector .size());           for (int i = 0; i < vector.size(); i++) {              String[] arr = (String[]) vector.elementAt(i);                String img = arr[1];              String url = arr[2];
    
                    ConnectPNGThread requestThread = new ConnectPNGThread(img, url, i,col,screen);                requestThread.start();
    
                  threadList.addElement(requestThread);
    
               }
    
               //System.out.println("Wait for threads to complete");         boolean isComplete = false;           while (!isComplete) {             // NetworkThread.sleep(500);              for (int i = 0; i < threadList.size(); i++) {                  if (((ConnectPNGThread) threadList.elementAt(i)).isAlive()) {                     isComplete = false;                       break;                    }                 if (i == threadList.size() - 1) {                     isComplete = true;                    }             }         }         //final long endApplication = System.currentTimeMillis();         UiApplication.getUiApplication().invokeLater(new Runnable() {             public void run() {                   for (int num = 0; num < 5; num++) {                        mainHManager.add((VerticalFieldManager) col.elementAt(num % 5));                  }                 screen.add(mainHManager);                 //Dialog.alert(Long.toString((endApplication - starttime)));              }         });
    
             System.out.println("All threads are complete");       } catch (Exception e) {
    
         }
    
       }
    
    }
    

    ConnectPNGThread

    import java.io.ByteArrayOutputStream;import java.io.DataInputStream;import java.util.Vector;
    
    import javax.microedition.io.Connector;import javax.microedition.io.StreamConnection;
    
    import net.rim.blackberry.api.browser.BrowserSession;import net.rim.device.api.system.EncodedImage;import net.rim.device.api.system.PNGEncodedImage;import net.rim.device.api.ui.Color;import net.rim.device.api.ui.Field;import net.rim.device.api.ui.Graphics;import net.rim.device.api.ui.component.BitmapField;import net.rim.device.api.ui.component.LabelField;import net.rim.device.api.ui.container.VerticalFieldManager;
    
       public class ConnectPNGThread extends Thread {
    
          private StreamConnection picon;       private int p;        private Vector col;       private String img;       private String url;       private SmartoneVodafoneServicesScreen screen;
    
            public ConnectPNGThread(String img, String url, int i, Vector col, SmartoneVodafoneServicesScreen screen) {           // TODO Auto-generated constructor stub           super();          this.img = img;           this.url = url;           this.p = i%5;         this.col = col;           this.screen = screen;     }
    
         public void run() {       //public NetworkThread() {            try {             picon = (StreamConnection) Connector.open(img);               DataInputStream inputStream = picon.openDataInputStream();                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();                byte[] buffer = new byte[5120];               int len = 0, imageSize = 0;               while (-1 != (len = inputStream.read(buffer))) {                  byteArrayOutputStream.write(buffer);                  imageSize += len;             }             picon.close();                byteArrayOutputStream.flush();                byte[] imageData = byteArrayOutputStream.toByteArray();               final EncodedImage pngImage = PNGEncodedImage.createEncodedImage(imageData, 0, imageSize);                final BitmapField myBitmapField = new BitmapField(pngImage                        .getBitmap(), Field.FIELD_VCENTER | Field.FOCUSABLE) {                    protected boolean invokeAction(int status) {                      // BrowserSession site = Browser.getDefaultSession();                     BrowserSession site = screen.createWAPBrowserSession();                       site.displayPage(url);                        return true;                  }
    
                       protected void paint(Graphics g) {                        g.setBackgroundColor(Color.BLACK);                        g.drawRoundRect(0, 0, getWidth(), getHeight(), 10, 10);                       g.setColor(Color.WHITE);                      super.paint(g);
    
                     }
    
                   };
    
                  VerticalFieldManager c = (VerticalFieldManager) col.elementAt(p);             c.add(new LabelField(" ", LabelField.NON_FOCUSABLE));             c.add(myBitmapField);
    
                  } catch (Exception e) {               //e.printStackTrace();                System.out.println(e.toString());         }     }
    
        }
    
    
    
  • Could not read XML nodes

    Hi, I have a simple xml file:

    
    
      
      
      
      
    
    

    but I can't not only to what is in the first line, I mean: the values A, B, C, D and e. by this code:

    _fileConnection = (FileConnection)
                    Connector.open("file:///store/home/user/"+_fileName, Connector.READ);
    
                _documentBuilderFactory = DocumentBuilderFactory.newInstance();
                _documentBuilder = _documentBuilderFactory.newDocumentBuilder();
        _is = _fileConnection.openInputStream();
        _document = _documentBuilder.parse(_is);
        _rootElement = _document.getDocumentElement();
        _rootElement.normalize();
    
    vector.addElement(_rootElement.getAttribute("A")); //and so on
    

    but then, when I want to access to the:


     
     
     

    I can't. I do something like this:

    _nodeList = _rootElement.getChildNodes ();

    for (_i int = 0; _i<_nodeList.getLength();>

    System.out.println ("type" + _nodeList.item (_i) .getNodeValue ());

    }

    and what I get is:

    type

    value of type null

    type

    value of type null

    and so on...

    What's wrong? How can I get these items?

    concerning

    OK, I got it solved:

     for( int _i = 0; _i < _nodeList.getLength(); _i++ ){
    
            _node = _nodeList.item(_i);
    
            if( _node.getNodeName().equals("item") ){
    
     System.out.println.("value "+_node.getAttributes().getNamedItem("max_ammount"));
    
                    }
    
                }//end of for
    

    Java docs are very useful. but when you don't know how to start and are not even getting the general idea - you ask on the forum

    best regards and thx for the help!

  • Precomposed layer does not recognize the opacity setting (bug)

    Hello

    I have a very simple layer précomposé including a layer of unique text with a shadow (layer style). However, it does not recognize the opacity setting in the layer main, even when the value to 0%, and the playhead is not yet on the layer. If I change the opacity in the precomposed layer I see come to the main layer, but change the opacity in the main layer does nothing.

    I reported this to Adobe as a bug, someone at - it any other ideas?

    Thank you

    Antony

    Adobe-After-Effects-CC-2014.0-(13.0)ScreenSnapz001.png

    There is a difficulty. Apply a layer to your demo style, then turns off all styles. CR will now evaluate the layer styles in your source model and make them in the proper order.

    Why it works? You must understand the operation of the CR. When you turn on the continuous rasterization the layer type is identified before any effect or transformations take place. That's why you can scale a vector without problems layer if CR is turned on. This explains why a 3D demo that contains a 2D layer will be rendered as a 2D layer.

    When you apply a layer Style you change the layer type in the same way you edit a type of layer from 2D to 3D. If you want to have transformations applied to the layer style in the source file, you must change the type of the pre-comp Layer Styles layer layer.

  • Illustrator CC PDF opens in the drive with the error message

    When I save an Illustrator file in PDF format, Adobe Reader users get a message error when you open the file - "there is an error on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem. "Why this is happening?

    You can export directly to a BPA from Design.

    Export of files then choose on the menu drop down.

    I think that I am perhaps mixed initially thinking layotu as .ai

    from indesign, I usually do what to get problem free printing.

    I know that people will complain with raster images, but its safe and IV ' e never had a printer complain of my files.

    which is my goal - on my desk and on the next job...

    organize all your content design so that anything really like vector type and shapes etc are on the layers above the other substance.

    they will remain intact as a vehicle right the way through.

    on the lower layers, you keep everything which is an image, or effects such as shadows, transparency or drop, edges, feathers etc..

    strange things. These all introduce rasterised pieces when you go to PDF in any case...

    According to your design, you can have a few items that you can't turn back to vector layers due to accumulation of other elements of design etc.

    but I hope that you can get stuff all this beautiful eigenvector on top of background images etc.

    Then, you perform a new layer between the bits of vector, and everything below that is going to get nuked in rasters by pdf anyway.

    hide you the top vector layers of the page, then export the rest below, high-resolution jpeg or eps and open files in photoshop,

    Look for visible problems where transparency interacts or are grown images and fix them up (rarely needed).

    then save as a tif and place that in InDesign on this new layer 'average' I usually name "Rasterised the layers.

    That hide the layers below that you just exported

    (I keep everything what it changes for future - but we have finished with it because todays print pdf creation loan) but you have now transformed into a nice neat tif.

    Basically, cela nukes all raster stuff and he keeps here vectors free problem neat and text.

    view vector above stuff and save your pdf file.

    You can open the PDF in acrobat and convert the text to outlines text and verify that the output of color was as expected etc.

    Then you have a pretty dumbed-down pdf that can't go wrong - I found...

  • Matrix and problems to own/vector values

    I would like to know if someone has developed the VB script for problem solving, values own and vectors matrices own.

    Al,

    Thanks for the link.  I had already found this information before but has been checked to see if someone had already coded something for ready use.

  • Why the outline of pathfinder is not crispy in the last update HERE? Problems describing the vector form

    Please can someone help.  I am trying to sketch a vector shape to then export to DXF for laser cutting.  For some strange reason, this latest version of influenza avian gives an outline of disorder that is not a crisp clean line, please visit the 2 images below before and after. How to solve this problem? Is there a way to export a form of loan file DXF/DWG for autocad/excision?  I always presented forms in the past, but I have to?

    I hope you can help! Thank you!

    abcd.JPG

    abc.JPG

    by car,

    It may be too far away, but have you tried to switch between GPU and CPU by pressing Ctrl / Cmd + E?

  • Conversion of fonts vectorized in .ttf - Illustrator to Fontlab Studio problems

    Screen Shot 2016-03-04 at 10.06.09 PM.jpgI have a problem with my CC 2015 of fontlab studio 5 Crossover illustrator - I have a policy of design completely vectorized and I have adjusted completely two platforms for the right size, but when I paste illustrator police into fontlab, my fonts custom loses its thickness in some areas and loses filled circles. How can I copy from illustrator to fontlab without losing all of the traits, so that it is exactly how it was in illustrator? EPS & Bitmap does not, either.

    Otherwise, anyone know one easier way (other software) to make a design fully vectorized in illustrator, a .ttf font?

    Much appreciated!

    I thought about it - once you have developed, United and pasted into fontlab, select the entire shape and show--> contour filling layers.

  • Rendered inDesign error/Bug - not adding vector source causes a slight rendering problem

    Very well; This has bothered me for some time and just recently was able to identify the source of this problem.

    Sometimes, you will notice the same layouts with very small displacements, problems of weight and other adjustments case loosed. I can see these slightly in InDesign views, but it is very spectacular inside a PDF file... I noticed this slight mistake throughout the presentations all the time.

    I was able to recreate the problem and find out the reason. There was a single image, a scan of my signature, placed as a psd, that appears on my front page and not on the second page of my CV. Remove this immediately resolved image rendering problem involving displacements of the hairlines and weight problems, that I had with the cover page. Replaces the psd placed with other images didn't help.

    I replaced the image of the signature with a vector trace and Yahtzee - no bug rendering more. As much as I can say that the problem is with raster images.
    Pages with only the vector components and display of pixelated text data.

    I did not have the opportunity to play with Adobe Creative Cloud, I hope that this is no longer a problem.

    Sounds like well-known transparency rendering effects.

  • Problem of 'create vector shapes.

    Hi all

    If I do a file have in Illustrator and import this file into After Effects and select 'Create vector shapes', I get on each channel, the work plans of the AI. It's very very very annoying.

    Please help me!

    -Adobe CC 2014

    -iMac mid 2011

    Greetings,

    Roy

    @ Dave-, it makes no difference how to import the file have (comp, footage, size of the layer comp or comp

    @Rick:

    I use it all the time... but I've found so far three solutions to this problem:

    -the file I should be CC2014

    -Opacity everything must be 100%

    -All the blending Modes must be set to 'Normal '.

Maybe you are looking for

  • iPhone will not charge!

    Why my iphone doesn't load when I plugged in? Normally, I push the on button / stop by myself to ensure that it runs? Help me solve this problem. TQ

  • Satellite A210-1AO - RAM max support

    Processor: AMD Turion 64 X 2 Dual-Core Mobile Technology TL-60/motherboard: IAALA LA-3631 P/RAM complectation: 2 048 (1 024 + 1 024) MB, DDR2 RAM 667 MHz/Vista 32-bit. For the optimization of the system PC Max RAM can I replace inside? And don't ship

  • Series-1073807298 error

    Hello I have a serial rs232 interface configuration base to send and receive commands to a microcontroller.  Vi simply sends a command for formatting when the button is pressed and data are received port data will be read in variable entry stack size

  • Why isn't my computer stay in mode 'sleep'

    After a few minutes, when I put my computer in mode 'sleep' my screen saver turns on

  • Laptop HP 2000 HD repair CD

    I have a laptop of 2000 HP who is diagnosed with a failure in the short DST HD.  I found a post which orders to burning a CD to repair, but I don't know whether my system is 32-bit (Windows 7). Failure ID: 9374GW-0006SD-MFKTOJ-60XW03 (guessing on the