Index: /applications/editors/josm/plugins/pdfimport/.classpath
===================================================================
--- /applications/editors/josm/plugins/pdfimport/.classpath	(revision 23862)
+++ /applications/editors/josm/plugins/pdfimport/.classpath	(revision 23863)
@@ -4,5 +4,4 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
-	<classpathentry kind="lib" path="lib/PDFClown.jar"/>
 	<classpathentry kind="lib" path="lib/pdfbox.jar" sourcepath="D:/Projects/Community/OSM/josm/pdfimport/pdfbox-1.3.1/pdfbox/src/main/java"/>
 	<classpathentry kind="output" path="bin"/>
Index: /applications/editors/josm/plugins/pdfimport/build.xml
===================================================================
--- /applications/editors/josm/plugins/pdfimport/build.xml	(revision 23862)
+++ /applications/editors/josm/plugins/pdfimport/build.xml	(revision 23863)
@@ -45,4 +45,5 @@
 	<property name="plugin.dist.dir" value="../../dist" />
 	<property name="plugin.name" value="${ant.project.name}" />
+	<property name="libpdf" value="lib/pdfbox.jar"/>		
 	<property name="plugin.jar" value="${plugin.dist.dir}/${plugin.name}.jar" />
 
@@ -65,4 +66,5 @@
 			<classpath>
 				<pathelement location="${josm}"/>
+				<pathelement location="${libpdf}"/>				
 			</classpath>			
 		</javac>
@@ -81,4 +83,5 @@
 
 	<target name="dist" depends="compile,revision">
+		<unjar dest="${plugin.build.dir}" src="${libpdf}"/>
 		<copy todir="${plugin.build.dir}/images">
 			<fileset dir="images" />
Index: plications/editors/josm/plugins/pdfimport/src/pdfimport/GraphicsProcessor.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/GraphicsProcessor.java	(revision 23862)
+++ 	(revision )
@@ -1,469 +1,0 @@
-package pdfimport;
-
-import java.awt.Color;
-import java.awt.Composite;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
-import java.awt.Image;
-import java.awt.Paint;
-import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.Shape;
-import java.awt.Stroke;
-import java.awt.RenderingHints.Key;
-import java.awt.font.FontRenderContext;
-import java.awt.font.GlyphVector;
-import java.awt.geom.AffineTransform;
-import java.awt.image.BufferedImage;
-import java.awt.image.BufferedImageOp;
-import java.awt.image.ImageObserver;
-import java.awt.image.RenderedImage;
-import java.awt.image.renderable.RenderableImage;
-import java.text.AttributedCharacterIterator;
-import java.util.Map;
-
-public class GraphicsProcessor extends Graphics2D {
-
-	public PathOptimizer target;
-
-	public GraphicsProcessor(PathOptimizer target)
-	{
-		this.target = target;
-
-	}
-
-	@Override
-	public void addRenderingHints(Map<?, ?> hints) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void clip(Shape s) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void draw(Shape s) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawGlyphVector(GlyphVector g, float x, float y) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawString(String str, int x, int y) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawString(String str, float x, float y) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawString(AttributedCharacterIterator iterator, int x, int y) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawString(AttributedCharacterIterator iterator, float x,
-			float y) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void fill(Shape s) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public Color getBackground() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Composite getComposite() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public GraphicsConfiguration getDeviceConfiguration() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public FontRenderContext getFontRenderContext() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Paint getPaint() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Object getRenderingHint(Key hintKey) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public RenderingHints getRenderingHints() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Stroke getStroke() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public AffineTransform getTransform() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public void rotate(double theta) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void rotate(double theta, double x, double y) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void scale(double sx, double sy) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setBackground(Color color) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setComposite(Composite comp) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setPaint(Paint paint) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setRenderingHint(Key hintKey, Object hintValue) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setRenderingHints(Map<?, ?> hints) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setStroke(Stroke s) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setTransform(AffineTransform Tx) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void shear(double shx, double shy) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void transform(AffineTransform Tx) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void translate(int x, int y) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void translate(double tx, double ty) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void clearRect(int x, int y, int width, int height) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void clipRect(int x, int y, int width, int height) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void copyArea(int x, int y, int width, int height, int dx, int dy) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public Graphics create() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void dispose() {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawArc(int x, int y, int width, int height, int startAngle,
-			int arcAngle) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public boolean drawImage(Image img, int x, int y, Color bgcolor,
-			ImageObserver observer) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public boolean drawImage(Image img, int x, int y, int width, int height,
-			ImageObserver observer) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public boolean drawImage(Image img, int x, int y, int width, int height,
-			Color bgcolor, ImageObserver observer) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
-			int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
-			int sx1, int sy1, int sx2, int sy2, Color bgcolor,
-			ImageObserver observer) {
-		// TODO Auto-generated method stub
-		return false;
-	}
-
-	@Override
-	public void drawLine(int x1, int y1, int x2, int y2) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawOval(int x, int y, int width, int height) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void drawRoundRect(int x, int y, int width, int height,
-			int arcWidth, int arcHeight) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void fillArc(int x, int y, int width, int height, int startAngle,
-			int arcAngle) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void fillOval(int x, int y, int width, int height) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void fillRect(int x, int y, int width, int height) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void fillRoundRect(int x, int y, int width, int height,
-			int arcWidth, int arcHeight) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public Shape getClip() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Rectangle getClipBounds() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Color getColor() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public Font getFont() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public FontMetrics getFontMetrics(Font f) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void setClip(Shape clip) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setClip(int x, int y, int width, int height) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setColor(Color c) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setFont(Font font) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setPaintMode() {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void setXORMode(Color c1) {
-		// TODO Auto-generated method stub
-
-	}
-
-}
Index: plications/editors/josm/plugins/pdfimport/src/pdfimport/PDFStreamProcessor.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/PDFStreamProcessor.java	(revision 23862)
+++ 	(revision )
@@ -1,327 +1,0 @@
-package pdfimport;
-
-import it.stefanochizzolini.clown.documents.Document;
-import it.stefanochizzolini.clown.documents.contents.ContentScanner;
-import it.stefanochizzolini.clown.documents.contents.ContentScanner.GraphicsState;
-import it.stefanochizzolini.clown.documents.contents.colorSpaces.ColorSpace;
-import it.stefanochizzolini.clown.documents.contents.colorSpaces.DeviceGrayColorSpace;
-import it.stefanochizzolini.clown.documents.contents.colorSpaces.DeviceRGBColorSpace;
-import it.stefanochizzolini.clown.documents.contents.objects.BeginSubpath;
-import it.stefanochizzolini.clown.documents.contents.objects.CloseSubpath;
-import it.stefanochizzolini.clown.documents.contents.objects.ContainerObject;
-import it.stefanochizzolini.clown.documents.contents.objects.ContentObject;
-import it.stefanochizzolini.clown.documents.contents.objects.DrawCurve;
-import it.stefanochizzolini.clown.documents.contents.objects.DrawLine;
-import it.stefanochizzolini.clown.documents.contents.objects.DrawRectangle;
-import it.stefanochizzolini.clown.documents.contents.objects.EndPathNoOp;
-import it.stefanochizzolini.clown.documents.contents.objects.Fill;
-import it.stefanochizzolini.clown.documents.contents.objects.FillEvenOdd;
-import it.stefanochizzolini.clown.documents.contents.objects.FillStroke;
-import it.stefanochizzolini.clown.documents.contents.objects.FillStrokeEvenOdd;
-import it.stefanochizzolini.clown.documents.contents.objects.GenericOperation;
-import it.stefanochizzolini.clown.documents.contents.objects.ModifyClipPath;
-import it.stefanochizzolini.clown.documents.contents.objects.Path;
-import it.stefanochizzolini.clown.documents.contents.objects.Stroke;
-import it.stefanochizzolini.clown.documents.contents.objects.Text;
-import it.stefanochizzolini.clown.objects.PdfDirectObject;
-import it.stefanochizzolini.clown.objects.PdfInteger;
-import it.stefanochizzolini.clown.objects.PdfReal;
-
-import java.awt.Color;
-import java.awt.geom.Point2D;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class PDFStreamProcessor {
-
-	private final LayerInfo info;
-	int pathNo = 0;
-
-	PathOptimizer optimizer;
-	Map<LayerInfo, LayerInfo> multipathLayers = new HashMap<LayerInfo, LayerInfo>();
-	private GraphicsState state;
-	private DeviceRGBColorSpace rgbSpace;
-	private DeviceGrayColorSpace graySpace;
-
-	public PDFStreamProcessor(PathOptimizer target, Document doc) {
-
-		this.optimizer = target;
-		this.rgbSpace = new DeviceRGBColorSpace(doc);
-		this.graySpace = new DeviceGrayColorSpace(doc);
-		this.info = new LayerInfo();
-	}
-
-	public void finish() {
-		this.rgbSpace = null;
-		this.graySpace = null;
-		this.state = null;
-	}
-
-	public void process(ContentScanner level) {
-		if(level == null)
-			return;
-
-		while(level.moveNext()) {
-			ContentObject object = level.getCurrent();
-			if(object instanceof ContainerObject) {
-				// Scan the inner level!
-				process(level.getChildLevel());
-			}
-			else {
-				addObject(level);
-			}
-		}
-	}
-
-	public void addObject(ContentScanner level){
-
-		ContentObject obj = level.getCurrent();
-
-		if (obj instanceof Path)
-		{
-			this.state = level.getChildLevel().getState();
-			this.parsePath((Path)obj);
-		}
-		else if (obj instanceof Text){
-			//maybe something here
-		}
-		else if (obj instanceof EndPathNoOp){
-			//nothing here
-			this.info.divider ++;
-		}
-		else if (obj instanceof GenericOperation) {
-			this.state = level.getState();
-			//operations PDF clown cannot handle
-			parseGO((GenericOperation) obj, false);
-		}
-		else {
-			int a = 10;
-			a++;
-		}
-	}
-
-	private void parseGO(GenericOperation go, boolean setDivider) {
-		String op = go.getOperator();
-		boolean parsed = true;
-		//FIXME - currently mapping ICC colors (SCN) to device RGB.
-
-		if (op.equals("RG") || op.equals("SCN")) {
-			this.state.strokeColorSpace = this.rgbSpace;
-			this.state.strokeColor = this.rgbSpace.getColor(go.getOperands().toArray(new PdfDirectObject[3]));
-		}
-		else if (op.equals("G")) {
-			this.state.strokeColorSpace = this.graySpace;
-			this.state.strokeColor = this.graySpace.getColor(go.getOperands().toArray(new PdfDirectObject[3]));
-		}
-		else if (op.equals("rg") || op.equals("scn")) {
-			this.state.fillColorSpace = this.rgbSpace;
-			this.state.fillColor = this.rgbSpace.getColor(go.getOperands().toArray(new PdfDirectObject[3]));
-		}
-		else if (op.equals("g")) {
-			this.state.fillColorSpace = this.graySpace;
-			this.state.fillColor = this.graySpace.getColor(go.getOperands().toArray(new PdfDirectObject[3]));
-		}
-		else {
-			parsed = false;
-			//nothing here
-			int a = 10;
-			a++;
-			a++;
-		}
-
-		if (parsed && setDivider) {
-			this.info.divider ++;
-		}
-	}
-
-	private void parsePath(Path path) {
-
-		List<PdfPath> paths = this.getPathNodes(path);
-		this.updateInfoFromState();
-
-		for (PdfPath p: paths){
-			p.nr = pathNo;
-		}
-
-		pathNo ++;
-
-		if (paths.size() > 1) {
-			this.optimizer.addMultiPath(this.info, paths);
-		}
-		else if (paths.size() == 1) {
-			this.optimizer.addPath(this.info, paths.get(0));
-		}
-	}
-
-	private List<PdfPath> getPathNodes(Path path) {
-		List<PdfPath> result = new ArrayList<PdfPath>(2);
-		List<Point2D> points = new ArrayList<Point2D>(2);
-		this.info.fill = false;
-		this.info.stroke = true;
-
-		for (ContentObject obj:path.getObjects()) {
-			Point2D point = null;
-
-			if (obj instanceof BeginSubpath) {
-				if (points.size() >= 2) {
-					result.add(new PdfPath(points));
-					points = new ArrayList<Point2D>(2);
-				}
-
-				BeginSubpath b = (BeginSubpath)obj;
-				point = b.getPoint();
-			} else if (obj instanceof DrawLine) {
-				DrawLine l = (DrawLine)obj;
-				point = l.getPoint();
-			}
-			else if (obj instanceof DrawCurve) {
-
-				DrawCurve c = (DrawCurve) obj;
-				point = c.getPoint();
-			}
-			else if (obj instanceof Stroke) {
-				//draw line mode..
-			}
-			else if (obj instanceof EndPathNoOp) {
-				if (points.size() >= 2) {
-					result.add(new PdfPath(points));
-					points = new ArrayList<Point2D>(2);
-				}
-			}
-			else if (obj instanceof CloseSubpath) {
-				if (points.size() >= 2) {
-					result.add(new PdfPath(points));
-					points = new ArrayList<Point2D>(2);
-				}
-			}
-			else if (obj instanceof FillEvenOdd || obj instanceof Fill) {
-				this.info.fill = true;
-				this.info.stroke = false;
-			}
-			else if (obj instanceof FillStrokeEvenOdd || obj instanceof FillStroke){
-				this.info.fill = true;
-				this.info.stroke = true;
-			}
-			else if (obj instanceof GenericOperation) {
-				this.parseGO((GenericOperation)obj, false);
-			}
-			else if (obj instanceof DrawRectangle) {
-				if (points.size() >= 2)
-				{
-					result.add(new PdfPath(points));
-					points = new ArrayList<Point2D>(2);
-				}
-
-				DrawRectangle r = (DrawRectangle) obj;
-
-				points.add(this.parsePoint(new Point2D.Double(r.getX(), r.getY())));
-				points.add(this.parsePoint(new Point2D.Double(r.getX()+r.getWidth(), r.getY())));
-				points.add(this.parsePoint(new Point2D.Double(r.getX()+r.getWidth(), r.getY()+r.getHeight())));
-				points.add(this.parsePoint(new Point2D.Double(r.getX(), r.getY()+r.getHeight())));
-				points.add(points.get(0));
-				result.add(new PdfPath(points));
-				points = new ArrayList<Point2D>(2);
-			}
-			else if (obj instanceof ModifyClipPath) {
-				//nothign here
-			}
-			else {
-				int a = 10;
-				a++;
-			}
-
-			//add point
-			if (point != null)
-			{
-				boolean sameAsPrevPoint = (points.size() > 0) &&points.get(points.size() - 1).equals(point);
-				if (!sameAsPrevPoint) {
-					points.add(this.parsePoint(point));
-				}
-			}
-		}
-
-		if (points.size() >= 2)
-		{
-			result.add(new PdfPath(points));
-		}
-
-		return result;
-	}
-
-	private Point2D parsePoint(Point2D point) {
-		point = this.state.userToDeviceSpace(point);
-		return this.optimizer.getUniquePoint(point);
-	}
-
-
-
-	private void updateInfoFromState() {
-		this.info.color = getColor(this.state.strokeColor);
-		this.info.fillColor = getColor(this.state.fillColor);
-		this.info.width = this.state.lineWidth;
-	}
-
-	private Color getColor(
-			it.stefanochizzolini.clown.documents.contents.colorSpaces.Color col) {
-		if (col == null) {
-			return Color.BLACK;
-		}
-
-		ColorSpace space = col.getColorSpace();
-
-		if (space == null){
-			return new Color(
-					(float)col.getComponents()[0],
-					(float)col.getComponents()[1],
-					(float)col.getComponents()[2]);
-		}
-		else if (space instanceof DeviceRGBColorSpace) {
-			return new Color(
-					(float)col.getComponents()[0],
-					(float)col.getComponents()[1],
-					(float)col.getComponents()[2]);
-		}
-		else if (space instanceof DeviceGrayColorSpace) {
-			return new Color(
-					(float)col.getComponents()[0],
-					(float)col.getComponents()[0],
-					(float)col.getComponents()[0]);
-		}
-		else {
-			throw new RuntimeException("Unexpected colour space: "+space.toString());
-		}
-	}
-
-	private Color addColor(GenericOperation go) {
-		List<PdfDirectObject> operands = go.getOperands();
-		PdfDirectObject o1 = operands.get(0);
-		PdfDirectObject o2 = operands.get(1);
-		PdfDirectObject o3 = operands.get(2);
-		Color c =new Color(parseFloat(o1), parseFloat(o2), parseFloat(o3));
-		return c;
-	}
-
-
-	private Color addGrayColor(GenericOperation go) {
-		List<PdfDirectObject> operands = go.getOperands();
-		PdfDirectObject o1 = operands.get(0);
-		Color c =new Color(parseFloat(o1), parseFloat(o1), parseFloat(o1));
-		return c;
-	}
-
-
-	private float parseFloat(PdfDirectObject obj) {
-		if (obj instanceof PdfReal) {
-			return (float)((PdfReal)obj).getNumberValue();
-		}
-		else if (obj instanceof PdfInteger) {
-			return (float)((PdfInteger)obj).getNumberValue();
-		}
-		else {
-			return 0.0f;
-		}
-	}
-
-}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/GraphicsProcessor.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/GraphicsProcessor.java	(revision 23863)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/GraphicsProcessor.java	(revision 23863)
@@ -0,0 +1,644 @@
+package pdfimport.pdfbox;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.RenderingHints.Key;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ImageObserver;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+import java.text.AttributedCharacterIterator;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import pdfimport.LayerInfo;
+import pdfimport.PathOptimizer;
+import pdfimport.PdfPath;
+
+public class GraphicsProcessor extends Graphics2D {
+
+	public PathOptimizer target;
+	private Shape clipShape;
+	private List<PdfPath> clipPath;
+	private final LayerInfo info = new LayerInfo();
+	int pathNo = 0;
+	private boolean complexClipShape;
+	private boolean clipAreaDrawn;
+	private final double height;
+
+	private final AffineTransform transform;
+
+	public GraphicsProcessor(PathOptimizer target, int rotation, double height)
+	{
+		this.height = height;
+		this.target = target;
+		this.transform = new AffineTransform();
+		this.transform.rotate(Math.toRadians(rotation));
+	}
+
+	private void addPath(Shape s, boolean fill) {
+		List<PdfPath> paths = this.parsePath(s);
+		if (fill) {
+			this.info.fill = true;
+			this.info.stroke = false;
+		}
+		else {
+			this.info.fill = false;
+			this.info.stroke = true;
+		}
+
+		for (PdfPath p: paths){
+			p.nr = pathNo;
+		}
+
+		pathNo ++;
+
+		if (paths.size() > 1) {
+			this.target.addMultiPath(this.info, paths);
+		}
+		else if (paths.size() == 1) {
+			this.target.addPath(this.info, paths.get(0));
+		}
+	}
+
+
+	private List<PdfPath> parsePath(Shape s) {
+		List<PdfPath> result = new ArrayList<PdfPath>(2);
+		List<Point2D> points = new ArrayList<Point2D>(2);
+
+
+		PathIterator iter = s.getPathIterator(null);
+		double[] coords = new double[6];
+
+		while (!iter.isDone()) {
+			int type = iter.currentSegment(coords);
+
+			if (type == PathIterator.SEG_CLOSE) {
+				//close polygon
+				this.addPoint(points, points.get(0));
+				if (points.size() > 1) {
+					result.add(new PdfPath(points));
+				}
+				points = new ArrayList<Point2D>(2);
+			} else if (type == PathIterator.SEG_CUBICTO) {
+				//cubic curve
+				this.addPoint(points, this.parsePoint(coords, 4));
+			}
+			else if (type == PathIterator.SEG_LINETO) {
+				this.addPoint(points, this.parsePoint(coords, 0));
+			}
+			else if (type == PathIterator.SEG_MOVETO) {
+				//new path
+				if (points.size() > 1){
+					result.add(new PdfPath(points));
+				}
+				points = new ArrayList<Point2D>(2);
+				this.addPoint(points, this.parsePoint(coords, 0));
+			}
+			else if (type == PathIterator.SEG_QUADTO) {
+				//quadratic curve
+				this.addPoint(points, this.parsePoint(coords, 2));
+			}
+			else if (type == PathIterator.WIND_EVEN_ODD) {
+				//fill even odd
+			}
+			else if (type == PathIterator.WIND_NON_ZERO) {
+				//fill all
+			}
+			else
+			{
+				//Unexpected operation
+				int a = 10;
+				a++;
+			}
+
+			iter.next();
+		}
+
+		if (points.size() > 1 )
+		{
+			result.add(new PdfPath(points));
+		}
+
+
+
+		return result;
+	}
+
+	private void addPoint(List<Point2D> points, Point2D point) {
+		if (points.size() > 0) {
+			Point2D prevPoint = points.get(points.size() - 1);
+
+			if (prevPoint.getX() == point.getX() && prevPoint.getY() == point.getY()) {
+				return;
+			}
+		}
+
+		points.add(point);
+	}
+
+	private Point2D parsePoint(double[] buffer, int offset) {
+		//invert Y.
+		Point2D point = new Point2D.Double(buffer[offset], this.height - buffer[offset + 1]);
+		Point2D dest = new Point2D.Double();
+		this.transform.transform(point, dest);
+		return this.target.getUniquePoint(dest);
+	}
+
+
+	@Override
+	public void draw(Shape s) {
+
+		if (complexClipShape)
+		{
+			if (!this.clipAreaDrawn)
+			{
+				this.addPath(this.clipShape, true);
+				this.clipAreaDrawn = true;
+			}
+		}
+		else
+		{
+			this.addPath(s, false);
+		}
+	}
+
+
+	@Override
+	public void fill(Shape s) {
+		this.addPath(s, true);
+	}
+
+	@Override
+	public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
+
+		if (!this.clipAreaDrawn)
+		{
+			this.addPath(this.clipShape, true);
+			this.clipAreaDrawn = true;
+		}
+		return true;
+	}
+
+
+	@Override
+	public void setClip(Shape clip) {
+		if (this.clipShape == clip)
+			return;
+
+		this.clipPath = this.parsePath(clip);
+
+		boolean complexClipPath = false;
+
+		if (clipPath.size() > 1)
+		{
+			complexClipPath = true;
+		}
+		else if (clipPath.size() == 1 && clipPath.get(0).points.size() > 5)
+		{
+			//more than 4 points.
+			complexClipPath = true;
+		}
+
+		this.complexClipShape = complexClipPath;
+		this.clipAreaDrawn = false;
+		this.clipShape = clip;
+	}
+
+	@Override
+	public void setColor(Color c) {
+		this.info.color = c;
+		this.info.fillColor = c;
+	}
+
+
+	@Override
+	public void setStroke(Stroke s) {
+		BasicStroke stroke = (BasicStroke) s;
+		this.info.width = stroke.getLineWidth();
+		this.info.dash = 0;
+
+		if (stroke.getDashArray() != null) {
+			this.info.dash = stroke.getDashArray().hashCode();
+		}
+	}
+
+
+	@Override
+	public void clip(Shape s) {
+		//TODO:
+	}
+
+
+	@Override
+	public void addRenderingHints(Map<?, ?> hints) {
+		// TODO Auto-generated method stub
+	}
+
+
+	@Override
+	public void drawGlyphVector(GlyphVector g, float x, float y) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawString(String str, int x, int y) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawString(String str, float x, float y) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawString(AttributedCharacterIterator iterator, int x, int y) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawString(AttributedCharacterIterator iterator, float x,
+			float y) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	@Override
+	public Color getBackground() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Composite getComposite() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public GraphicsConfiguration getDeviceConfiguration() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public FontRenderContext getFontRenderContext() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Paint getPaint() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Object getRenderingHint(Key hintKey) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public RenderingHints getRenderingHints() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Stroke getStroke() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public AffineTransform getTransform() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public void rotate(double theta) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void rotate(double theta, double x, double y) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void scale(double sx, double sy) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void setBackground(Color color) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void setComposite(Composite comp) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void setPaint(Paint paint) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void setRenderingHint(Key hintKey, Object hintValue) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void setRenderingHints(Map<?, ?> hints) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void setTransform(AffineTransform Tx) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void shear(double shx, double shy) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void transform(AffineTransform Tx) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void translate(int x, int y) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void translate(double tx, double ty) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void clearRect(int x, int y, int width, int height) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void clipRect(int x, int y, int width, int height) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void copyArea(int x, int y, int width, int height, int dx, int dy) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public Graphics create() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void dispose() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawArc(int x, int y, int width, int height, int startAngle,
+			int arcAngle) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean drawImage(Image img, int x, int y, Color bgcolor,
+			ImageObserver observer) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean drawImage(Image img, int x, int y, int width, int height,
+			ImageObserver observer) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean drawImage(Image img, int x, int y, int width, int height,
+			Color bgcolor, ImageObserver observer) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
+			int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
+			int sx1, int sy1, int sx2, int sy2, Color bgcolor,
+			ImageObserver observer) {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public void drawLine(int x1, int y1, int x2, int y2) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawOval(int x, int y, int width, int height) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void drawRoundRect(int x, int y, int width, int height,
+			int arcWidth, int arcHeight) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void fillArc(int x, int y, int width, int height, int startAngle,
+			int arcAngle) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void fillOval(int x, int y, int width, int height) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void fillRect(int x, int y, int width, int height) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void fillRoundRect(int x, int y, int width, int height,
+			int arcWidth, int arcHeight) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public Shape getClip() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Rectangle getClipBounds() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Color getColor() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Font getFont() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public FontMetrics getFontMetrics(Font f) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+
+	@Override
+	public void setClip(int x, int y, int width, int height) {
+		// TODO Auto-generated method stub
+
+	}
+
+
+	@Override
+	public void setFont(Font font) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void setPaintMode() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void setXORMode(Color c1) {
+		// TODO Auto-generated method stub
+
+	}
+
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PdfBoxParser.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PdfBoxParser.java	(revision 23862)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PdfBoxParser.java	(revision 23863)
@@ -40,6 +40,7 @@
 		PDRectangle pageSize = page.findMediaBox();
 		Dimension pageDimension = pageSize.createDimension();
+		int rotation = page.getRotation();
 
-		GraphicsProcessor p = new GraphicsProcessor(target, pageDimension.getHeight());
+		GraphicsProcessor p = new GraphicsProcessor(target, rotation, pageDimension.getHeight());
 		PageDrawer drawer = new PageDrawer();
 		drawer.drawPage(p, page, pageDimension);
