Skip to main content

Posts

Example to draw “Time Series Line Chart” using jfreechart in Java

A very good example of “Time Series Chart” is available here : www.java2s.com/Code/Java/Chart/JFreeChartTimeSeriesDemo12.htm I am writing this example to explore it further means to describe which settings you can change as per your requirements. I have tried my best to document everything. Please let me know if you have any questions after going through the code. Let's start... TimeSeriesChart.java //Code Starts here /*  * To change this template, choose Tools | Templates  * and open the template in the editor.  */ package jfreecharts; /**  *  * @author sshankar  */ import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Stroke; import java.io.File; import java.text.SimpleDateFormat; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; i...

Calculate effective size of the window(excluding taskbar) in Java

Yesterday, I was working with generating a graph using jfreechart library. The requirement was to show a window with graph on full screen. When i used the following code it didn't give me the desired results. Taskbar was overlapping bottom part of the screen. this.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height)); After searching over internet i found the solution and following code snippet worked properly as per my requirements. //Calculate height of the task bar Insets scnMax = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration()); int taskBarSize = scnMax.bottom; this.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height-taskBarSize)); Thanks!!!!!!!!!!!! Enjoy Programming :) 

Use bit.ly API in PHP : Part2

Before going forward I assume that you had already gone through first part of the post  " Usebit.ly to create shorten urls in PHP : Part1 ". So now you have the parameters named  with username and api key .  In this part we would discuss over using bitly Applications with API.  "If you are looking to work with multiple end-users, or to pull any information on a user  level for your own account (including link history, bundle history, and/or analytics), you  will need to register an application with us to authenticate with our API." - bitly website.  So if you wanna fetch information of multiple users you have to create an application.    Follow following steps : 1) Go to bitly developer section http://dev.bitly.com/ 2) Click on "Manage My Apps" button or link. 3) Click on Advanced tab. Go to Registered OAuth applications section and click on "Register OAuth Application" link. Following screen would ...

Use bit.ly to create shorten urls in PHP : Part1

Bit.ly is the most popular service to create shorten urls. In 2010, they had announced  Version 3 of the bit.ly API. They had come with some new features like click counts,  getting bundle information, query bitly information etc... All V3 methods support identical  JSON and XML response formats. JSONP is likewise universally supported, and many  methods support an additional plain text response format. I have divided the bitly session into two parts. 1) Use bit.ly to create shorten urls in PHP : Part1 2) Use bit.ly API in PHP : Part2 Let’s start with first part. Please follow these steps: a)  Register yourself with https://bitly.com/   b)  Go to developers section : http://dev.bitly.com/   c)  On top navigation bar click on My Apps link. d)  Go to Manage My Apps->Advanced Tab  e)  Note down your  API Key (Click on Show legacy API   ...

Capture website screenshots in PHP using grabzit library

Near about 1 year ago, one of our project’s requirement was to take screenshot of some website pages at run time and save them, but at that moment our team didn’t find any proper solution. Today while I was going through Google Reader found a article “ Sreenshots in PHP with GrabzIt ”, went into detail of that and found useful. Although it’s properly documented on the website even then I will try to summaries in few easy steps. 1)  Register yourself : http://grabz.it/register.aspx 2)  After successful completion of registration you will get Application Key and        Application Secret . Store it somewhere. 3)  Download Simple PHP Library from : http://grabz.it/api/php/download.aspx 4)  Assign write and read permissions to images folder. 5) G o to GrabzItConfig.php file and set the values of configuration variables :      $grabzItApplicationKey , $grabzItApplicationSecret and       $grabz...

Draw 3D Line Chart Using JFreeChart in Java

Hi all, following is the example of how to draw 3D Line Chart in Java using JFreeChart library. LineChart3DDemo.java /*  * To change this template, choose Tools | Templates  * and open the template in the editor.  */ package drawgraph; /**  *  * @author sshankar  */ import java.awt.Color; import java.awt.Dimension; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPositions; /**  * A simple demonstration application showing how to create a line char...