Updates from August, 2007 Toggle Comment Threads | Keyboard Shortcuts

  • Subinkrishna Gopi 3:40 pm on August 14, 2007 Permalink |  

    PushRegistry SMS Listener 

    I have attached a small code snippet which implements an SMS listener. For more details on PushRegistry click here. This will invoke notifyIncomingMessage() of the MessageListener. This code will not create a permanent entry in the registry, but will listen to the specified port as long as the application is alive.

    package subin.rnd.mobile.game;
    
    import javax.microedition.io.Connector;
    import javax.wireless.messaging.MessageConnection;
    import javax.wireless.messaging.MessageListener;
    import javax.wireless.messaging.TextMessage;
    
    public class SmsListener
    implements MessageListener
    {
        private int port;
        private MessageConnection messageConnection;
    
        public SmsListener(int port)
        {
            try
            {
                this.messageConnection = (MessageConnection) Connector.open("sms://:" + port);
                this.messageConnection.setMessageListener(this);
            }
            catch (Exception e)
            {
                System.out.println("Exception: " + e);
            }
        }
    
        public void notifyIncomingMessage(MessageConnection messageConnection)
        {
            System.out.println("Recieved SMS from " + messageConnection);
    
            new Thread()
            {
                MessageConnection conn;
                Thread set(MessageConnection conn)
                {
                    this.conn = conn;
                    return (this);
                }
                public void run()
                {
                    try
                    {
                        TextMessage msg = (TextMessage) conn.receive();
                        System.out.println("Recieved SMS: " + msg.getPayloadText());
                    }
                    catch (Exception e)
                    {
                        System.out.println("SMS recieve Exception " + e);
                    }
                }
            }.set(messageConnection).start();
        }
    }
    
    Advertisements
     
  • Subinkrishna Gopi 2:47 pm on August 13, 2007 Permalink |
    Tags: , , mobile download, sms   

    Zlango 

    Zlango has created a new, inspiring icon based language which transforms web and mobile messaging into an expressive, juicy, colorful icon-based experience.
    Zlango is a revolutionary, simple and practical language. It’s made up of over 200 icons divided into intuitive and memorable categories. Words, concepts or feelings can be expressed by the different icons.

    Users love Zlango. They find Zlango easy to learn and master, and find that learning the language is unbelievably fast and amusing. They also say that using Zlango always generates a good and playful mood. Zlango is a privately owned company founded in 2003. It is headquartered in Israel with a team of designers, engineers and other extremely nice people.

    Source: zlango.com
    Zlango Links: Zlango on mobile | Zlango Blog

     
  • Subinkrishna Gopi 10:09 am on August 9, 2007 Permalink |  

    Microsoft & Open source 

    Guys, this is not a joke. Microsoft website says:

    “Microsoft is focused on helping customers and partners succeed in a heterogeneous technology world. This starts with participating and contributing to a broad range of choices for developing and deploying software, including open source approaches and applications. From thousands of lines of code and scripts on MSDN and TechNet, to open source applications like IronPython, ASP.NET AJAX, SharePoint Learning Kit, and WiX on CodePlex and SourceForge, Microsoft is continually growing the number of products released with open source access.

    By embracing diverse application development and business models, Microsoft provides a world of choice in which individuals and organizations can pursue their goals based on what uniquely inspires them. Whether you are a developer who wants to learn new skills, connect with the community, or build a business—or a systems administrator dealing with complex interoperability and business demands—Microsoft participates in an ecosystem that offers you the tools, resources, and programs to help you succeed.”

    We wanted to create a foundation for development, knowing we couldn’t address the challenges of every developer or project. Open Sourcing the software was the best way to support adoption and ongoing development of ASP.NET AJAX.”
    —Shawn Burke, Director, .NET Developer Platform

    Source: http://www.microsoft.com/opensource/default.mspx
    Feed: http://www.microsoft.com/opensource/opensource-rss.xml

     
  • Subinkrishna Gopi 4:33 pm on August 6, 2007 Permalink |  

    An Introduction to JavaFX Script – http://java.sun.com/ 

    The JavaFX Script programming language (hereinafter referred to as JavaFX) is a declarative, statically typed scripting language from Sun Microsystems, Inc. As mentioned on the Open JavaFX (OpenJFX) web site, JavaFX technology has a wealth of features, including the ability to make direct calls to Java technology APIs. Because JavaFX Script is statically typed, it also has the same code structuring, reuse, and encapsulation features — such as packages, classes, inheritance, and separate compilation and deployment units — that make it possible for your to create and maintain very large programs using Java technology.

    Find this article: http://java.sun.com/developer/technicalArticles/scripting/javafxpart1/
    Source: http://java.sun.com/

     
  • Subinkrishna Gopi 12:13 pm on August 6, 2007 Permalink |
    Tags:   

    Creating Pie Charts using JFreeChart with custom colors 

    I have attached a sample code snippet for creating a Pie Chart using JFreeChart with custom colors. There is a PieReneder (a static inner class) which can be used to achieve the same. The PieRenderer takes an array of java.awt.Color in its constructor.

    package subin.rnd.chart;
    import java.awt.Color; 
    import java.io.File; 
    import java.util.List;
    import org.jfree.chart.ChartFactory; 
    import org.jfree.chart.ChartUtilities; 
    import org.jfree.chart.JFreeChart; 
    import org.jfree.chart.plot.PiePlot; 
    import org.jfree.data.general.DefaultPieDataset;
    public class PieChartWithCustomColours 
    { 
        public static void main(String[] args) 
        { 
            DefaultPieDataset dataset = new DefaultPieDataset(); 
            JFreeChart chart; 
            
            // Defining the dataset 
            dataset.setValue("Windows", 60); 
            dataset.setValue("Linux", 20); 
            dataset.setValue("Mac", 10); 
            dataset.setValue("Unix", 5); 
            dataset.setValue("DOS", 5); 
            
            chart = ChartFactory.createPieChart( 
                    "OS Chart", dataset, false, false, false); 
            
            PiePlot plot = (PiePlot)chart.getPlot(); 
            
            // Specify the colors here 
            Color[] colors = {Color.blue, Color.yellow, Color.green}; 
            PieRenderer renderer = new PieRenderer(colors); 
            renderer.setColor(plot, dataset); 
            
            try 
            { 
                // This will create a PNG image 
                ChartUtilities.saveChartAsPNG(new File("chart.png"), chart, 400, 
                        220); 
            } 
            catch (Exception e) 
            { 
                System.out.println("Exception while creating the chart"); 
            } 
        } 
        
        
        /* 
         * A simple renderer for setting custom colors 
         * for a pie chart. 
         */ 
        
        public static class PieRenderer 
        { 
            private Color[] color; 
            
            public PieRenderer(Color[] color) 
            { 
                this.color = color; 
            }        
            
            public void setColor(PiePlot plot, DefaultPieDataset dataset) 
            { 
                List <Comparable> keys = dataset.getKeys(); 
                int aInt; 
                
                for (int i = 0; i < keys.size(); i++) 
                { 
                    aInt = i % this.color.length; 
                    plot.setSectionPaint(keys.get(i), this.color[aInt]); 
                } 
            } 
        } 
    }

    Sample Output

    Pie Chart With Custom Colors (JFreeChart)

    Here the colors are repeating, right? Its b’ coz there is only three entries in the input color array to the PieRenderer.

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel