Archive for the ‘Coding and Projects’ Category

Winter Break Project

Wednesday, December 19th, 2012

I have found myself with some time off from work for the holidays so I decided to embark on a winter break project. I must admit it is a bit ambitious of a project so I am not sure if I will be able to finish it to my satisfaction.

The basic concept is to create a web application that uses a Genetic Algorithm to approximate a target image using SVG vector shapes. My inspiration is from Roger Alsing’s post on Genetic Programming: Evolution of Mona Lisa. I thought it would be fun to see how well it works as a web application. This project gives me an excuse to play around with HTML5 SASS + Compass, and responsive design concepts.

To follow my progress see my github project.

OpenRule 2.0

Friday, April 16th, 2010

Released OpenRule 2.0 (Venus) into the wild. Lots of new features including:

* Transparency controls
* Can measure in Inches, Centimeters, Pica and Pixels
* Custom measurements can be created
* The new Preference dialog allows you to customize the functionality and look of the ruler
* The tick leader line — a small line that hangs off the ruler — helps you keep track of where your mouse is on the ruler
* The ruler can be nudged by one pixel using the arrow keys and moved by 10 pixels by holding down the control key and using the arrow keys
* New about information
* Pressing F1 takes you to the user guide page
* Window and Mac executable are available

Java System Property Files

Wednesday, March 18th, 2009

The pass few days I have been trying to figure out how to work with property files. A project I am working with uses Java DB and I want to have a property file that customizes where the database is located. Finding and loading the file has proven a bit difficult because I am trying to call the property file from the static main function of my program. So I can’t use the usual static functions to call the resource file in a physical independent way. I am hoping that encapslating it in a class might solve my problem.

Derby

Friday, March 6th, 2009

The past few days I have been consumed with trying to figure out how Derby works. Derby is Java’s DBMS coded entirely in Java. I want to use Derby as part of the deliciousBlogger project to manage profile and scheduling information.

Derby has some very cool features if you are developing with Java. You are able to start it up as an embedded or server database. The embedded mode means you dont need a separate process to be running for the database system. It will run in the same space as the JVM. From what I have figured out you can pretty much do all the basic functions as other database servers though not always the same way. It does support core SQL commands to keep it standard.

I finally figured out how to start up the database in embedded mode (or at least i think it is); create a table; insert a few items; then query the table and print out the results.

package model;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.derby.drda.NetworkServerControl;
import java.net.InetAddress;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
*
* @author leadiv
*/
public class testing {
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
NetworkServerControl server;
Connection conn;

try {
server = new NetworkServerControl(InetAddress.getByName(“localhost”), 1527);
server.start(null);

System.out.println(server.getSysinfo());
String nsURL=”jdbc:derby://localhost:1527/testing;create=true”;
java.util.Properties props = new java.util.Properties();
props.setProperty(“user”,”dbo1337″);
props.setProperty(“password”,”fnpbz”);

/*
If you are running on JDK 6 or higher, you do not
need to invoke Class.forName(). In that environment, the
ClientDriver loads automatically.
*/
Class.forName(“org.apache.derby.jdbc.ClientDriver”);
conn = DriverManager.getConnection(nsURL, props);

/*interact with Derby*/
Statement s = conn.createStatement();
s.execute(“create table \”MYTABLE\” (\”ID\” INTEGER not null primary key, \”NAME\” VARCHAR(50))”);
s.execute(“insert into mytable values(1, ‘Paul’)”);
s.execute(“insert into mytable values(2, ‘Ashley’)”);

ResultSet rs = s.executeQuery(“select NAME from MYTABLE”);

while (rs.next()) {
System.out.println(“Name: ” + rs.getString(1));
}

rs.close();
s.close();
conn.close();
server.shutdown();

} catch(Exception ex) {
Logger.getLogger(ProfileSQL.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
}

Here are some links talking about Derby: Java Databasing with Derby, Derby’s Documentation

Delicious Blogger

Tuesday, January 20th, 2009

I have been working on a project recently to allow bloggers a way to post delicious links on their blogspot blog as a post automaticly. This first version will not be to useful for those who only use Google’s Blogger site or do not have access to a server with php. It is more of trying to understand what the process looks like in living breathing code. This will be a simpified prototype that is usable by anyone that has access to a server with php and cronjobs.

Today I just started on the script to access Google’s Blogger API. It seems to be so far much easier then working with Delicious either that or I have gotten better at reading and working with APIs.

Comment if you have any questions, concerns or ideas for this project.

OpenRule Mercury

Friday, October 31st, 2008

About 2 months of coding has finally paid off. Mercury has been release earlier this week. This is the first stable version of the screen ruler OpenRule. It is a very basic version of the popular freeware program JRuler. One of my favorite features is the snap to zero functionality, which will snap the ruler to your cursor at pixel zero. More information can be found on the project page.

OpenRule roadmap

Monday, October 27th, 2008

This is the overall roadmap for the OpenRule software. The current status version of OpenRule is marked below in orange-yellow. Hopefully, by the time we reach Mars status OpenRule can be marked as mature and will not need any more additional features. As always you can get the most up to date version on the project page.

Mercury (1.x)

  • Must be always on top
  • Have ruler ticks counting off the units
  • Displays the number of pixels from the beginning of the ruler (pixel 0)
  • Ruler should be easily re-sizable
  • A fast key for flipping between horizontal and vertical modes.
  • Close and minimize buttons
  • Snap beginning of ruler to cursor
  • The ruler is drag-able

Venus (2.x)

  • Add Program icon to replace the default Java Icon.
  • Allow the ruler to be transparent
  • Allow the ruler to be different colors.
  • Nudge the whole ruler by a pixel using arrow keys    (left, right, top and bottom)
  • A leader hangs off of the ruler which easily shows where your cursor is on the ruler
  • About menu item
  • Help menu item
  • Change the tick units (px, inch, cm, pica, custom)
  • Add Default Preferences for: color and transparency, orientation, always on top, tick units,

Earth (3.x)

  • Reorganize code to be more efficient and faster
  • Measure anywhere on the ruler
  • Change the color of the tick leader
  • Change the color of the ticks and measurements
  • Default Preference for bar layout
  • Bookmark option to mark points on the ruler
  • Snap end of the ruler to cursor
  • Snap ruler to cursor at pixel position X
  • Snap cursor to end of ruler
  • Snap cursor to beginning of ruler
  • Snap cursor to nearest tick
  • Snap cursor to nearest tick mode
  • Click, click measure mode (The mouse click defines the beginning and ending positions)
  • Swap the info bar and tick bar

Mars (4.x)

  • Rotate ruler
  • Click, click measure at an angle (The mouse click defines the beginning and ending positions)

Revision List*

• Must be always on top — Make this optional but default to “always on top”
• Nudge by 5 pixels when using ctrl+arrow keys

Bug List*

Does not work on Mac (Java 1.5.x)

Found a Bug? Report it!

Ongoing Tasks

• Code documentation
• Getting started and Help sections
• Streamlining code making it efficient

*A significant amount of minor revisions and bugs can count for a version or significant internal code revision.

OpenRule update

Thursday, October 23rd, 2008

This past week has seen lots of effort in getting the basic version of OpenRule up and running. Here are some highlights:

  • Developed the vertical version of the ruler
  • Added the RulerEvent and RulerListener claases to address
    • flipping between the two Ruler modes
    • form controls (minimizing, exiting)
    • global keyboard commands
  • Allow the ruler to resize

You can download the newest version of the ruler here and the code here. Have comments or questions about OpenRule? Email us at paul(at)leadiv(dot)com or post a comment on this post.
Always welcome other developers to help make OpenRule even better. If you are interested please contact me here paul(at)leadiv(dot)com

OpenRule notes

Monday, October 20th, 2008

While working on open rule I ran into an interesting issue. I created a TickBar object that draws the ticks on the ruler (the lines marking off individual units). This was extended from the JPanel class so that I could easily draw on it using the paintComponent function. After creating TickBar I wanted to extend it to create a vertical version. The only problem was when I went to draw on the vertical version, it drew the horizontal and vertical ticks. The reason why is because I have to make a call to the super of this function to make sure that the component is clean and ready to be drawn on. However, when I am in the Vertical version of the TickBar the call to the super causes the horizontal ticks to be drawn as well.

To solve this delimma I created an interface called Drawable. Drawable separates out the drawing function from the paintComponent function so that the child object could easily over-ride the draw function.
I thought that was kind of cool.

popup menu trouble

Saturday, October 18th, 2008

I ran into some trouble when I tried putting the popup menu on the ruler. It rendered the dragging functionality useless. I was unable to attach the menu to the frame which where the draggable functionality is implemented. The solution I found was to apply the draggable events to the main ruler panel which is where the popup menu resides as well. This way the popup menu listeners do not consume all of the mouse listening events.