Monday, February 26, 2007

Netzero, Windows Vista

If you use Netzero for your dial up internet connection and plan on upgrading to Windows Vista you may want to postpone the upgrade for a bit. As I talked about in my last post, upgrading to Windows Vista is causing all sorts of incompatibility problems. Apparently the Norton AntiVirus and Internet Security products are not compatible with Vista. The makers of Norton AntiVirus and Internet Security will be providing NetZero an updated version in the coming weeks, so if you do upgrade, send Netzero an email to request a CD with the updated security software.
I think I'm going to wait until at least the spring before I order my new laptop.
BTW, check out this blog for more Windows Vista woes.



Friday, February 23, 2007

Windows Vista

I was thinking of buying myself a laptop when I receive my tax refund. Maybe I should have bought one before Windows Vista came out though. A recent review I read reports many problems with Vista. Apparently "upgrades can be a pain, games might not play properly, a financial software, Quickbooks, for businesses can fail, MP3 players might not work & even software architects use, CAD, may slow to a crawl". Hmmm, well that's not good.
Apparently Korea's banking system has already suffered sporadic computer failures. Vista's security restrictions are causing the gaming problems.
Microsoft took out an option allowing easy upgrades from one version of Windows to a newer version. Apparently now in order to upgrade to Vista, you need an old version installed first. So if your hard drive with XP crashes you can't just upgrade to Vista while you're fixing everything. First you have to reinstall XP & then upgrade to Vista. That's a pain in the butt.
Well, here's a link to a Vista guide if you do decide to upgrade. I may wait until the spring before buying my laptop. Maybe most of Vista's problems will be fixed by then. One can hope anyways.


Wednesday, February 21, 2007

SVG, Apache Batik

The Java Drawing with Apache Batik tutorial book I ordered from Amazon arrived, very fast by the way. It seems pretty good. I think it is a must have for anybody starting out with batik. I'm only half way through, but so far I'm glad I bought it. Examples are good. Covers the main parts of Batik: Generator, Transcoder, PrettyPrinter, JSVGCanvas. Also covers DOM, how to save to a file. Doesn't seem to do much with glyphs though or get into how to use it in specific areas such as GIS. Although I'm not finished yet, so maybe in later chapters. Here's the table of contents:

Introduction

Chapter 1 Getting Started with Batik
Batik Overview
Batik in Real World Projects
Your First SVG Document
Using SVG Rasterizer
Using Pretty-Printer
What Else Comes with Batik?
Summary

Chapter 2 Creating SVG
Drawing in Java
Using SVG Creator
Other Features of SVG Generator
Summary

Chapter 3 Viewing SVG
Displaying Generated SVG Documents
JSVGCanvas Interactivity
Saving the Generated Document
Displaying an SVG File
Summary

Chapter 4 Working with Transcoders
The Transcoder API
Using Transcoders in Applications
Setting the Area of Interest
Using the SVGTranscoder for Pretty Printing
The Enhanced Version of the SVG File Viewer
Summary

Chapter 5 Document Object Model
SVG Document as a DOM Tree
Creating Documents with the DOM API
Building an SVG Document
Working with Gradients
Using the DOM API
Other Thoughts
Summary

Chapter 6 Working with Text and Fonts
Using the text Element
SVG Fonts
Using the Font Converter
Using SVG Fonts in a Document
Text Workbench: SVG Writer
Text Elements, Text Nodes, and Text Content
Characters Positioning
Using tspan elements
Text Layout
Text on A Path
Text Selection
Summary

Chapter 7 Batik on the Server Side
The SVG Graph Web Application
SVG Filter Effects
SVG Filters Web Application
Summary

Chapter 8 Batik Interactive
SVG and Scripts
Interactivity
Animation
Scripting Alternatives
Using Java for Scripting
Adding Animation 205 Summary

Appendix A Introduction to XML
Benefits of XML
Well-Formed XML Documents
Validating XML Documents
Related XML Resources

Appendix B Introduction to JavaScript
Your First Script
Variables
Arrays
Operators
Loops
Branching in JavaScript
Functions
Objects

and a description:
This guide to Apache Batik, the Java library that can be used to read SVG files and translate the instructions in the files into graphics, shows how Batik can also be used to save the graphics as JPEG, TIFF, PNG, GIF, and other formats, so that the graphics can be transferred. Using Batik to create animation similar to Flash movies and its use for creating a drawing program such as Corel DRAW are also covered.

Scalable Vector Graphics (SVG) is an XML-based language for describing two-dimensional vector graphics and vector/raster graphics. The SVG specification describes in great detail how different shapes can be created, manipulated, transformed, and animated. In particular, SVG 1.1 defines:
Basic shape elements such as rectangle, circle, ellipse, line, polyline, and polygon.
Basic data types, such as integer, number, length, and angle.
The structure of an SVG document.
How to apply styles in an SVG document.
How to deal with text and how to use fonts.
How to work with colors, gradients, and patterns.
How and in which order elements should be rendered.
Which filter effects should be available and how to apply them.
How to animate images.

Apache Batik is a free and open-sourced implementation of SVG. It comes with tools and sample applications that demonstrate the power of SVG and Batik. This book is an easy-to-read tutorial on Batik. It teaches you how to use the tools in Batik and gets you started with Batik programming. In addition, it explains the following topics:
Batik implementation of the SVG specification
Batik API
SVG viewer
Transcoder and image format transcoding
Rasterizer
Document Object Model API
Text and fonts
Using Batik on the server side
Interactivity
Animation
Gradients
Filter effects

This info was taken from here.


Yes, I was able to get batik to draw a polygon, using an svg as the stroke and to do it correctly, not with the fill setting.
What you do is, first create a skeleton svg which contains a script to get the paths, calculate each path length, get the width of the svg you want to use as stroke. Divide path length by that to get the number of glyphs & then do a loop creating the glyph string.

?xml version="1.0" standalone="no"?>
!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
svg onload="load(evt)" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">

script type="text/ecmascript">![CDATA[

var svgNS = "http://www.w3.org/2000/svg";

function load(evt)
{
var doc = evt.target.ownerDocument;

var geometryGroup = doc.getElementById("geometryGroup");
var pathList = geometryGroup.getElementsByTagNameNS(svgNS, "path");
var numPaths = pathList.length;
for (var i = 0; i < numPaths; i++)
{
var path = pathList.item(i);

var pathLength = path.getTotalLength();
//var pt = path.getPointAtLength(dist);

var glyphDefs = doc.getElementById("glyphDefs");
var symbolSVG = glyphDefs.getElementsByTagNameNS(svgNS, "svg").item(0);
var widthAttribute = symbolSVG.getAttributeNS(null, "width");
var patternWidth = parseFloat(widthAttribute.substring(0, widthAttribute.length - 2));

var numGlyphs = Math.floor((pathLength / patternWidth) * 2);

var glyphsStr = "";

for (var j = 0; j <= numGlyphs; j++)
{
glyphsStr += "A";
}

var glyphTextPath = document.getElementById("glyphTextPath" + i);
glyphTextPath.appendChild(document.createTextNode(glyphsStr));
}
}


]]>/script>


defs id="glyphDefs">

font id="myFont">
font-face font-family="myFont"/>
missing-glyph/>
glyph unicode="A">
g>
use/>
/g>
/glyph>
/font>
/defs>


g id="geometryGroup">
/g>




Using batik, you create a group for each path, add that info to the skeleton svg using the dom, add the svg you want to use as the stroke to the defs section, fill in units-per-em & horiz-adv-x info & any other missing info. Add that to the canvas & draw. Very cool.
This site is also invaluable.


Monday, February 19, 2007

IrfanView

IrfanView. This is a free image viewing program I have been using for a very long time. I mainly use it to crop and resize images and to batch convert one image form to another. Many image types are supported, too many to list. Apparently you can also create slideshows and use it as a multimedia player. Great product and it's free.

Here's a tip. See an image you like? Ctrl+prt screen will copy into memory the active window. Ctrl+V into IrfanView. will paste the active screen, allowing you to save or crop & edit as you wish.

Wednesday, February 14, 2007

Apache Batik, Element ID, Width value

Using Apache Batik & need to get the ID of an element? Try doing this:

// Get ID of first g element
NodeList gElements = symbolSVGRoot.getElementsByTagNameNS(svgNS, "g");
Element firstGElement = (Element)gElements.item(0);
String gID = firstGElement.getAttribute("id");

Need to get the width value of the svg element? Try doing this:

String widthAttribute = symbolSVGRoot.getAttribute("width");
If the value has units specified, such as mm, do this to get the actual value:

String patternWidth = widthAttribute.substring(0, widthAttribute.length()-2);

Now to figure out my next problem:
How to use Batik to get the total length of a path. Apparently you can use SVGPathElement.getTotalLength, but it's just not working for me yet.


Tuesday, February 13, 2007

Apache Batik, VMWare Workstation

Ah ha, I figured out why I couldn't get apache batik to draw. In the java code, I was adding a child element to the wrong parent. Did discover batik doesn't support the textpath method=stretch feature and the font-face font-stretch feature. That sucks. For the most part, what I'm getting looks good, but there's either a gap or an overhang due to not being able to stretch the glyph. Let's hope at least one of those features becomes available in a future batik release.

Oh, and I discovered the batik mail archive is searchable at a different link than what's given at the batik site. Try this site or this site. What a puzzle. Thank goodness for the internet. I really hope the batik tutorial book I ordered is useful.

VMWare Workstation. One of the best tools ever. It's an application which lets you run one operating system on another. For example, I have the windows version of vmware. Inside that I can run linux, solaris, or another version of windows. I can run multiple operating systems at once too, share files between windows & linux, access the internet. It's awesome! Pretty cheap too, for what it does. There's a free VMWare Player available which gives you an idea what VMWare Workstation does. Check it out if you're interested in running linux, but also want to use windows, or vice versa. If you're a developer, it comes in really handy testing your applications on multiple platforms. One thing to note: solaris support is still limited.

Friday, February 9, 2007

Batik Tutorial, Dell Small Business 360

So I ordered the batik tutorial book from Amazon. I hope it comes soon because it's a pain in the butt trying to figure things out without a good tutorial. After wasting all day debugging, it looks like batik doesn't like my custom font-family definition. Syntax looks fine, function calls seem. Just don't know yet what's wrong.

Dell has opened a free small business advice site. Has links to dell forums, info on starting a business. Seems like it might be useful once it gets going. You can check it out here.


Thursday, February 8, 2007

Glyphs along a path, Apache Batik, SVG, Memory test

Finally got glyphs along a path working using hard coded values in an svg. Now I have to port it to batik to make things dynamic. Having problems so far. The svg has been ported over using all the hard coded values, but the applet won't init. I've got things narrowed down & it appears to have something to do with the textPath. I really wish you could search the apache batik mailing list. If anyone knows how, please let me know, maybe I'm missing something.
I did discover the syntax needed when nesting an svg within a defs statement:

defs.appendChild(internalSVGDoc.importNode(symbolDoc.getRootElement(), true));

Somebody really needs to write an in depth batik book or tutorial on how calls such as this are made. The batik javadoc is useless for beginners. Us beginners need to know how to put calls together. We need links to dom tutorials. Something good to get us started. It's tough putting pieces together.

Wow, I spoke too soon. This book at Amazon is finally available. Woohoo, guess I know what I'll be ordering next. Looks like it is going fast, only 3 left in stock.

If you are in need of more memory for your computer, check out this site. It will analyze your system & tell you how much memory you have & how much more you could add. Pretty cool. I have a gig, but could max out at 4 gig. The more memory, the better. Definitely a worthwhile investing if you're planning on keeping your machine for a while.

Tuesday, February 6, 2007

Microsoft, Zip software, Download.com

Did you know Microsoft automatically sets aside 20% of your bandwidth for things such as windows updates? I didn't either until I read it here. I did what the post said to, but I haven't really noticed any difference in my connection speed. It's worth a try though.

I've been using winzip for a long time & it's always been free. Well, no longer. The last upgrade I did now says my 45 day trial has expired & I can no longer unzip files with it. I am now in search of a free zip program. So far I have tried coffee cup. That's a pain because you have to restart the application for every new zip file you want to open. 7-Zip looked good until I needed to unzip a file in the top level Desktop/MyDocuments directory. It wasn't listed, just C:\ so I had to dig down to find the file. If anyone has any recommendations, let me know. I'll have to visit download.com and see what else they have. By the way, that is the best site for downloads. They have everything you need in terms of free software. The software is also free of viruses, spyware, etc. Great site.

Monday, February 5, 2007

Glyphs and TextPath, Open Office

Got some good tips from the batik users group mailing list on how to solve my pattern along a path problem. One tip involves using glyphs and textPaths thanks to Andreas Neumann. Here's an example. Played around a bit & have gotten the basic idea working, need to tweak it though as far as glyph spacing. The other tip involves markers. Haven't tried it yet though. SVG is very cool. There's a ton of stuff you can do with it. One bad thing is you can't link to an external svg element. Say you have a moon defined in one svg. You can't link directly to that moon element from another svg. SVG is still evolving though, so maybe in a future release that will be supported.

When I get my income tax check, I'm planning on buying myself a laptop. Not sure yet what I'm going with though. My desktop is a Dell I bought a little over a year ago. Adding Microsoft Office was an extra couple hundred dollars. I was on a budget, so I went with Microsoft Works Suite. That includes Microsoft Word. The spreadsheet program doesn't support tabbed worksheets though. For me, that's a problem. I decided to look into open office. It's free, I think open source too. That is a great product. It includes programs which are similar to word, excel, power point, access. The spreadsheet program also supports tabbed worksheets. These imitation programs seem to do pretty much what the more expensive programs do, so when I get my laptop I don't think I will even bother with Works Suite. I'm just going to download the latest free, version of open office and save myself some money. Some of the best software is free. Stay tuned for links to other useful free software.

Friday, February 2, 2007

Apache Batik

I'm currently using Apache Batik to draw an svg in the browser window. Part of what I need to do is create a pattern for an area using a third party svg. I was having problems creating the image tag in batik. Apparently for images you need to explicitly set the namespace for the attribute like this:

Element image = document.createElementNS("http://www.w3.org/2000/svg","image");
image.setAttributeNS(null,"width",imageWidth);
image.setAttributeNS(null,"height",imageWidth);
image.setAttributeNS("http://www.w3.org/1999/xlink","href","name.svg");
parentGroup.appendChild(image); //parentGroup needs to be an existing
node reference to a group where the images should be appended

Cool. Works now, just wish I could find a site with some good advanced batik tutorials. Like where do I find info that tells me images need the namespace explicitly set. The batik site has a few tutorials, but are basically getting started tutorials. BTW, the Apache Batik site has been re-designed. I definitely like it better than the old design.

Thursday, February 1, 2007

Inkscape, Sketsa 4.0

So I downloaded the latest .45 pre-release version of Inkscape, so I could check out the pattern along path option. Drop down options in dialog box are empty, do some searching & turns out you'll need to edit pathalongpath.inx in the share/extensions subdirectory of your installation directory. Change all _item values to item and restart Inkscape if running. Voila, options. Played around a bit, seems to do what I need. Looks like the source code to do it is included in the download in pathalongpath.py. It's a python script. Took a look. Hard to decode, but looks like it's doing what I thought you'd need to do. Divide the path into small pieces, rotate, translate your symbol along the path. The key part, use a group for the symbol, which is what these 3rd party svg's I have use. I think I can do it, but I need to play around a little more.

The latest version of the svg graphics editor, Sketsa 4.0 has been released. I've got the old version. It's a good tool, but you need java 1.5 in order to install it.