Monday, May 26, 2008

Not much going on

Just wanted to make sure all of you know that I am still alive and kicking. Not much going on in my computing life. I did leave my position at ITT April 14 and started a new job at ???. Not sure I can tell you much other than the number of question marks equal the number of letters in the name of the place..I'll let you do the math.

I did pick up an iMac a few months ago and really like it. I have a .mac account and my username is 'iammarkwebb' if you would like to check it out.

Sunday, February 24, 2008

Photographer site from hockey tournament

Here is a link
to the site of the photographer that took tons of pictures at Brandon's hockey tournament this weekend at Oswego.

Thursday, February 14, 2008

Safe HashMap

This is a really cool class that allows for lazy initialization and removed the possibility of having null values in the HashMap. Another nice feature is that it is generics-capable.

Now if this class was thread safe, we would have a complete solution....


Wednesday, October 03, 2007

CopyOnWriteMap

I finally got around to writing an implementation of java.util.Map, which provides a fast, concurrent way to access a Map. Write operations are more expensive, but you would only want to use this class if reading is your primary objective. I had found a few other implementations of a copy-on-write Map, but I did not think they were quite right. With some help from the MINA team, I have the class in the trunk of MINA and all is well.

Thursday, September 13, 2007

Andy McKee

This guy is simply amazing. If you appreciate music even a little, you will love what Andy Mckee
can do with a guitar. He has many of his songs on youtube, and you can also get his music on iTunes.

Tuesday, September 11, 2007

Abstract Dialog Class

Here is the code from a class that I have used for years. This class extends JDialog in a way that adding components to it is very painless, since it uses GridBagLayout. I hope to soon comment it better and add an example, but for now you will have to look at the code to see what is going on.


package org.markwebb.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

/**
* This is an abstract class which takes many of the pains out of
* GridBagLayout. The Dialog is set to modal.
*
* @author Mark Webb
*
*/
public abstract class AbstractDialog extends JDialog implements ActionListener {

protected static final String ACCEPT = "Accept";
protected static final String CANCEL = "Cancel";
protected static final String CLOSE = "Close";

protected JPanel mainPanel;

protected GridBagConstraints c;
private int row, col;

public AbstractDialog( JFrame parent, String title, String borderTitle ){
super( parent, title, true );

setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );

c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(5,5,5,5);

row = 0;
col = 0;

mainPanel = new JPanel();
mainPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black, 1),
borderTitle, TitledBorder.LEFT, TitledBorder.TOP ));

mainPanel.setLayout( new GridBagLayout() );
add( mainPanel, BorderLayout.CENTER );

JPanel buttons = new JPanel();
JButton accept = new JButton( ACCEPT );
accept.addActionListener( this );
buttons.add( accept );
JButton cancel = new JButton( CANCEL );
cancel.addActionListener( this );
buttons.add( cancel );
JButton close = new JButton( CLOSE );
close.addActionListener( this );
buttons.add( close );

add( buttons, BorderLayout.SOUTH );
}

public void addToRow( JComponent comp, int width ){

// add the component
addItem( col, row, width , comp );

// increment the column number
col++;
}

public void addToNewRow( JComponent comp, int width ){

// increment the row number
row++;

// reset the column number
col = 0;

// add the component
addItem( col, row, width , comp );

// increment the column number
col++;
}

private void addItem( int x, int y, int w, JComponent comp )
{
c.gridx = x;
c.gridy = y;
c.gridwidth = w;
mainPanel.add( comp, c );
}

public void actionPerformed( ActionEvent e ){
if( e.getActionCommand().equals( ACCEPT )){
doAccept();
} else if( e.getActionCommand().equals( CANCEL )){
doCancel();
} else if( e.getActionCommand().equals( CLOSE )){
doClose();
}
}

private void doClose(){
setVisible( false );
}

protected abstract void doAccept();
protected abstract void doCancel();
}

Sunday, September 09, 2007

My Visual DNA

I tried this site, and it is amazing how well it works. Try it out! http://dna.imagini.net/friends

Java Design Patterns

Here are a couple links that talk about design patterns using java. Design patterns are a great way for engineers to standardize the methods they use when designing and writing software systems.

Free Database Models

At this site - Library of Free Data Models, you can find database schemas for just about anything that you can think of. I find this the most important part of creating a database driven system. If you don''t get the database back-end set up right, your program will not work to its potential.

Photoshop tutorial

This guys puts together the most incredible, step-by-step photoshop tutorial I have ever seen. The image is so lifelike at the end. Really a must see...Me & Louie''s Sister - Page 1

Spring Framework

This is a great introduction to the Spring Framework. It describes a basic Java application that uses JDBC, and then the same program using Spring. java.net: Why Spring JDBC? As for JDBC, using Spring and Hibernate together makes the most sense. There is an article in the May 2006 edition covering Hibernate, Eclipse, WTP and Struts. Check it out.

C++ for java programmers

Here is a great C++ tutorial for Java programmers. Click here to check out the tutorial. There are many references to the differences between C++ and Java. Most of the time, programmers migrate from C++ to Java, but I have found that this site is a great start for Java developers to learn, or in my case, re-learn C++.

Try and beat this...

  1. Pool table installed
  2. Bar nearly complete
  3. Bar stocked
Check it out. So far, so good. If you are in town, stop by. Maybe someday I will document what I did, and how I did it.