diva.canvas.toolbox
Class GraphicsParser

java.lang.Object
  extended by diva.canvas.toolbox.GraphicsParser

public class GraphicsParser
extends java.lang.Object

A collection of utilities to help parsing graphics from strings and other kinds of external storage.

Version:
$Id: GraphicsParser.java 48923 2008-03-25 21:19:29Z cxh $
Author:
John Reekie

Constructor Summary
GraphicsParser()
           
 
Method Summary
static PaintedObject createPaintedObject(java.lang.String type, java.util.Map attributes)
          Create a new painted object.
static PaintedObject createPaintedObject(java.lang.String type, java.util.Map attributes, java.lang.String content)
          Create a new painted object.
static PaintedObject createPaintedObject(java.lang.String type, java.lang.String attributes, java.lang.String content)
          Create a new painted object.
static void hashAttributes(java.lang.String s, java.util.Map map)
          Given a XML-style attribute string and a hash-table, add each attribute and its value to the table.
private static java.awt.Color lookupColor(java.lang.String color)
          Given a string, return a color.
private static double[] parseCoordString(java.lang.String s)
          Parse a string of numbers into an array of double
private static void processPaintedPathAttributes(PaintedPath pp, java.util.Map attributes)
          Set the attributes of a PaintedPath from a hash-table
private static void processPaintedShapeAttributes(PaintedShape ps, java.util.Map attributes)
          Set the attributes of a PaintedShape from a hash-table
private static void processPaintedStringAttributes(PaintedString pp, java.util.Map attributes)
          Set the attributes of a PaintedString from a hash-table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphicsParser

public GraphicsParser()
Method Detail

createPaintedObject

public static PaintedObject createPaintedObject(java.lang.String type,
                                                java.lang.String attributes,
                                                java.lang.String content)
Create a new painted object. The element is parsed from two strings, the first being a representation of the element type, and the second being an XML-style attribute string. Any attributes that are not recognized will be ignored. Legal types and their attributes are:


createPaintedObject

public static PaintedObject createPaintedObject(java.lang.String type,
                                                java.util.Map attributes,
                                                java.lang.String content)
Create a new painted object. The first argument is a string representation of the element type, and the second is a hash-table containing attributes of the object. Any attributes that are not recognized will be ignored. See the add(String, String) for a description of legal types and their attributes.


createPaintedObject

public static PaintedObject createPaintedObject(java.lang.String type,
                                                java.util.Map attributes)
Create a new painted object. The first argument is a string representation of the element type, and the second is a hash-table containing attributes of the object. Any attributes that are not recognized will be ignored. See the add(String, String) for a description of legal types and their attributes.


hashAttributes

public static void hashAttributes(java.lang.String s,
                                  java.util.Map map)
Given a XML-style attribute string and a hash-table, add each attribute and its value to the table.

FIXME: this sucks.


lookupColor

private static java.awt.Color lookupColor(java.lang.String color)
Given a string, return a color.


parseCoordString

private static double[] parseCoordString(java.lang.String s)
Parse a string of numbers into an array of double


processPaintedShapeAttributes

private static void processPaintedShapeAttributes(PaintedShape ps,
                                                  java.util.Map attributes)
Set the attributes of a PaintedShape from a hash-table


processPaintedPathAttributes

private static void processPaintedPathAttributes(PaintedPath pp,
                                                 java.util.Map attributes)
Set the attributes of a PaintedPath from a hash-table


processPaintedStringAttributes

private static void processPaintedStringAttributes(PaintedString pp,
                                                   java.util.Map attributes)
Set the attributes of a PaintedString from a hash-table