Index: /applications/editors/josm/plugins/pdfimport/build.xml
===================================================================
--- /applications/editors/josm/plugins/pdfimport/build.xml	(revision 23990)
+++ /applications/editors/josm/plugins/pdfimport/build.xml	(revision 23991)
@@ -86,4 +86,7 @@
 		<copy todir="${plugin.build.dir}/images">
 			<fileset dir="images" />
+		</copy>
+		<copy todir="${plugin.build.dir}">
+			<fileset dir="resources" />
 		</copy>
 
Index: /applications/editors/josm/plugins/pdfimport/resources/pdfimport/pdfbox/PageDrawer.properties
===================================================================
--- /applications/editors/josm/plugins/pdfimport/resources/pdfimport/pdfbox/PageDrawer.properties	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/resources/pdfimport/pdfbox/PageDrawer.properties	(revision 23991)
@@ -0,0 +1,92 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# this Table is a correspondance Map of the PDF stream operators with concretes class of the
+# OperatorProcessor abstract class for the stategy pattern used in the 
+# org.apache.pdfbox.util.PDFStreamEngine class.
+# To change the behaviour of the system, remplace the class name by a new class name.
+b=pdfimport.pdfbox.operators.CloseFillNonZeroAndStrokePath
+B=pdfimport.pdfbox.operators.FillNonZeroAndStrokePath
+b*=pdfimport.pdfbox.operators.CloseFillEvenOddAndStrokePath
+B*=pdfimport.pdfbox.operators.FillEvenOddAndStrokePath
+#BDC org.apache.pdfbox.util.operator.NotImplemented ##Begin Marked Content -- section 10.5
+BI=pdfimport.pdfbox.operators.BeginInlineImage
+#BMC org.apache.pdfbox.util.operator.NotImplemented ##Begin Marked Content -- section 10.5
+BT=org.apache.pdfbox.util.operator.BeginText
+#BX org.apache.pdfbox.util.operator.NotImplemented
+c=pdfimport.pdfbox.operators.CurveTo
+cm=org.apache.pdfbox.util.operator.Concatenate
+CS=org.apache.pdfbox.util.operator.SetStrokingColorSpace
+cs=org.apache.pdfbox.util.operator.SetNonStrokingColorSpace
+d=pdfimport.pdfbox.operators.SetLineDashPattern
+#d0 org.apache.pdfbox.util.operator.NotImplemented
+#d1 org.apache.pdfbox.util.operator.NotImplemented
+Do=pdfimport.pdfbox.operators.Invoke
+#DP org.apache.pdfbox.util.operator.NotImplemented ##Marked Content Point-- section 10.5
+#El org.apache.pdfbox.util.operator.NotImplemented
+#EMC org.apache.pdfbox.util.operator.NotImplemented ##End Marked Content -- section 10.5
+ET=org.apache.pdfbox.util.operator.EndText
+#EX org.apache.pdfbox.util.operator.NotImplemented
+f=pdfimport.pdfbox.operators.FillNonZeroRule
+F=pdfimport.pdfbox.operators.FillNonZeroRule
+f*=pdfimport.pdfbox.operators.FillEvenOddRule
+G=org.apache.pdfbox.util.operator.SetStrokingGrayColor
+g=org.apache.pdfbox.util.operator.SetNonStrokingGrayColor
+gs=org.apache.pdfbox.util.operator.SetGraphicsStateParameters
+h=pdfimport.pdfbox.operators.ClosePath
+#i org.apache.pdfbox.util.operator.NotImplemented
+#ID org.apache.pdfbox.util.operator.NotImplemented
+j=pdfimport.pdfbox.operators.SetLineJoinStyle
+J=pdfimport.pdfbox.operators.SetLineCapStyle
+K=org.apache.pdfbox.util.operator.SetStrokingCMYKColor
+k=org.apache.pdfbox.util.operator.SetNonStrokingCMYKColor
+l=pdfimport.pdfbox.operators.LineTo
+m=pdfimport.pdfbox.operators.MoveTo
+M=pdfimport.pdfbox.operators.SetLineMiterLimit
+#MP org.apache.pdfbox.util.operator.NotImplemented ##Marked Content Point-- section 10.5
+n=pdfimport.pdfbox.operators.EndPath
+q=org.apache.pdfbox.util.operator.GSave
+Q=org.apache.pdfbox.util.operator.GRestore
+re=pdfimport.pdfbox.operators.AppendRectangleToPath
+RG=org.apache.pdfbox.util.operator.SetStrokingRGBColor
+rg=org.apache.pdfbox.util.operator.SetNonStrokingRGBColor
+#ri org.apache.pdfbox.util.operator.NotImplemented
+s=org.apache.pdfbox.util.operator.CloseAndStrokePath
+S=pdfimport.pdfbox.operators.StrokePath
+SC=org.apache.pdfbox.util.operator.SetStrokingColor
+sc=org.apache.pdfbox.util.operator.SetNonStrokingColor
+SCN=org.apache.pdfbox.util.operator.SetStrokingColor
+scn=org.apache.pdfbox.util.operator.SetNonStrokingColor
+sh=pdfimport.pdfbox.operators.SHFill
+T*=org.apache.pdfbox.util.operator.NextLine
+Tc=org.apache.pdfbox.util.operator.SetCharSpacing
+Td=org.apache.pdfbox.util.operator.MoveText
+TD=org.apache.pdfbox.util.operator.MoveTextSetLeading
+Tf=org.apache.pdfbox.util.operator.SetTextFont
+Tj=org.apache.pdfbox.util.operator.ShowText
+TJ=org.apache.pdfbox.util.operator.ShowTextGlyph
+TL=org.apache.pdfbox.util.operator.SetTextLeading
+Tm=org.apache.pdfbox.util.operator.SetMatrix
+Tr=org.apache.pdfbox.util.operator.SetTextRenderingMode
+Ts=org.apache.pdfbox.util.operator.SetTextRise
+Tw=org.apache.pdfbox.util.operator.SetWordSpacing
+Tz=org.apache.pdfbox.util.operator.SetHorizontalTextScaling
+v=pdfimport.pdfbox.operators.CurveToReplicateInitialPoint
+w=pdfimport.pdfbox.operators.SetLineWidth
+W pdfimport.pdfbox.operators.ClipNonZeroRule
+W* pdfimport.pdfbox.operators.ClipEvenOddRule
+y=pdfimport.pdfbox.operators.CurveToReplicateFinalPoint
+\'=org.apache.pdfbox.util.operator.MoveAndShow
+\"=org.apache.pdfbox.util.operator.SetMoveAndShow
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/LayerContents.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/LayerContents.java	(revision 23990)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/LayerContents.java	(revision 23991)
@@ -13,4 +13,4 @@
 	List<PdfPath> paths = new ArrayList<PdfPath>();
 	List<PdfMultiPath> multiPaths = new ArrayList<PdfMultiPath>();
-	LayerInfo info;		
+	LayerInfo info;
 }
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/LayerInfo.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/LayerInfo.java	(revision 23990)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/LayerInfo.java	(revision 23991)
@@ -4,13 +4,12 @@
 
 public class LayerInfo{
+	public Color fill;
+	public Color stroke;
+	public int dash;
 	public double width;
-	public Color color;
-	public Color fillColor;
-	public boolean fill;
-	public boolean stroke;
+	public int divider;
+	public boolean isGroup;
 
 	public int nr;
-	public int divider;
-	public int dash;
 
 	@Override
@@ -19,10 +18,10 @@
 		int code =  Double.toString(width).hashCode() ^ this.divider ^ this.dash;
 
-		if (this.fill) {
-			code ^= this.fillColor.hashCode();
+		if (this.fill != null) {
+			code ^= this.fill.hashCode();
 		}
 
-		if (this.stroke) {
-			code ^= this.color.hashCode();
+		if (this.stroke != null) {
+			code ^= this.stroke.hashCode();
 		}
 
@@ -34,17 +33,15 @@
 	{
 		LayerInfo l = (LayerInfo) o;
-		boolean eq =
-			this.width == l.width &&
-			this.divider == l.divider &&
-			this.fill == l.fill &&
-			this.stroke == l.stroke &&
-			this.dash == l.dash;
+		boolean eq = this.width == l.width &&
+		this.divider == l.divider &&
+		this.dash == l.dash;
 
-		if (this.fill){
-			eq &= this.fillColor.equals(l.fillColor);
+
+		if (this.fill != null){
+			eq &= this.fill.equals(l.fill);
 		}
 
-		if (this.stroke) {
-			eq &= this.color.equals(l.color);
+		if (this.stroke != null) {
+			eq &= this.stroke.equals(l.stroke);
 		}
 
@@ -54,11 +51,9 @@
 	public LayerInfo copy() {
 		LayerInfo result = new LayerInfo();
-		result.color = this.color;
-		result.fillColor = this.fillColor;
-		result.width = this.width;
-		result.divider = this.divider;
 		result.fill = this.fill;
 		result.stroke = this.stroke;
 		result.dash = this.dash;
+		result.width = this.width;
+		result.divider = this.divider;
 		return result;
 	}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java	(revision 23990)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java	(revision 23991)
@@ -19,4 +19,5 @@
 import javax.swing.BorderFactory;
 import javax.swing.JButton;
+import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JFileChooser;
@@ -67,4 +68,5 @@
 	private JButton showButton;
 	private JButton saveButton;
+	private JCheckBox debugModeCheck;
 
 	public LoadPdfDialog() {
@@ -159,4 +161,6 @@
 		this.getMaxButton = new JButton(tr("Take X and Y from selected node"));
 
+		this.debugModeCheck = new JCheckBox(tr("Debug info"));
+
 
 		JPanel selectFilePanel = new JPanel(new GridBagLayout());
@@ -164,4 +168,7 @@
 		c.gridx = 0; c.gridy = 0; c.gridwidth = 1;
 		selectFilePanel.add(this.loadFileButton, c);
+
+		c.gridx = 0; c.gridy = 1; c.gridwidth = 1;
+		selectFilePanel.add(this.debugModeCheck, c);
 
 		JPanel projectionPanel = new JPanel(new GridBagLayout());
@@ -208,5 +215,4 @@
 		projectionPanel.add(this.getMaxButton, c);
 
-
 		JPanel okCancelPanel = new JPanel(new GridLayout(1,3));
 		okCancelPanel.add(this.cancelButton);
@@ -246,6 +252,7 @@
 					public void actionPerformed(ActionEvent e) {
 						if (data!= null) {
+							OsmBuilder.Mode mode = LoadPdfDialog.this.debugModeCheck.isSelected() ? OsmBuilder.Mode.Debug: OsmBuilder.Mode.Draft;
 							LoadPdfDialog.this.fileName = fileName.getAbsolutePath();
-							LoadPdfDialog.this.makeLayer(tr("PDF file preview"), false);
+							LoadPdfDialog.this.makeLayer(tr("PDF file preview"), mode);
 							LoadPdfDialog.this.loadFileButton.setText(tr("Loaded"));
 							LoadPdfDialog.this.loadFileButton.setEnabled(true);
@@ -264,5 +271,5 @@
 
 		//rebuild layer with latest projection
-		this.makeLayer(tr("Imported PDF: ") + this.fileName, true);
+		this.makeLayer(tr("Imported PDF: ") + this.fileName, OsmBuilder.Mode.Final);
 		this.setVisible(false);
 	}
@@ -480,5 +487,5 @@
 	}
 
-	private void makeLayer(String name, boolean isFinal) {
+	private void makeLayer(String name, OsmBuilder.Mode mode) {
 		this.removeLayer();
 
@@ -487,5 +494,5 @@
 		}
 
-		DataSet data = builder.build(this.data.getLayers(), isFinal);
+		DataSet data = builder.build(this.data.getLayers(), mode);
 		this.layer = new OsmDataLayer(data, name, null);
 
@@ -510,5 +517,5 @@
 
 	private void saveLayer(java.io.File file) {
-		DataSet data = builder.build(this.data.getLayers(), true);
+		DataSet data = builder.build(this.data.getLayers(), OsmBuilder.Mode.Final);
 		OsmDataLayer layer = new OsmDataLayer(data, file.getName(), file);
 
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/OsmBuilder.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/OsmBuilder.java	(revision 23990)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/OsmBuilder.java	(revision 23991)
@@ -20,4 +20,6 @@
 public class OsmBuilder {
 
+	enum Mode {Draft, Final, Debug};
+
 	public Projection projection = null;
 	public double minX = 0;
@@ -31,5 +33,8 @@
 	public double maxNorth = 10000;
 
-	private final Map<String, String> stringsMap = new HashMap<String, String>();
+	private String layerName;
+	private String fillName;
+	private String lineName;
+	private Mode mode;
 
 
@@ -59,10 +64,11 @@
 	}
 
-	public DataSet build(List<LayerContents> data, boolean full) {
-
+	public DataSet build(List<LayerContents> data, Mode mode) {
+
+		this.mode = mode;
 		DataSet result = new DataSet();
 
 		for (LayerContents layer: data) {
-			this.addLayer(result, layer, full);
+			this.addLayer(result, layer);
 		}
 		return result;
@@ -70,6 +76,10 @@
 
 
-	private void addLayer(DataSet target, LayerContents layer, boolean full) {
+	private void addLayer(DataSet target, LayerContents layer) {
 		Map<Point2D, Node> point2Node = new HashMap<Point2D, Node>();
+
+		this.fillName = this.printColor(layer.info.fill);
+		this.lineName = this.printColor(layer.info.stroke);
+		this.layerName = "" + layer.info.nr;
 
 		//insert nodes
@@ -86,5 +96,5 @@
 
 		for (PdfPath path: layer.paths){
-			Way w = this.insertWay(path, point2Node, -1, full, false);
+			Way w = this.insertWay(path, point2Node, -1, false);
 			target.addPrimitive(w);
 			path2Way.put(path, w);
@@ -94,5 +104,5 @@
 		for (PdfMultiPath mpath: layer.multiPaths) {
 			for (PdfPath path: mpath.paths){
-				Way w = this.insertWay(path, point2Node, pathId, full, true);
+				Way w = this.insertWay(path, point2Node, pathId, true);
 				target.addPrimitive(w);
 				path2Way.put(path, w);
@@ -101,5 +111,5 @@
 		}
 
-		if (full) {
+		if (this.mode != Mode.Draft) {
 			//insert relations
 			for (PdfMultiPath mpath: layer.multiPaths) {
@@ -121,5 +131,5 @@
 	}
 
-	private Way insertWay(PdfPath path, Map<Point2D, Node> point2Node, int multipathId, boolean full, boolean multipolygon) {
+	private Way insertWay(PdfPath path, Map<Point2D, Node> point2Node, int multipathId, boolean multipolygon) {
 
 		List<Node> nodes = new ArrayList<Node>(path.points.size());
@@ -136,7 +146,7 @@
 		Map<String, String> keys = new HashMap<String, String>();
 
-		if (full) {
+		if (this.mode != Mode.Draft) {
 			keys.put("PDF_nr", "" + path.nr);
-			keys.put("PDF_layer", this.getString("" + path.layer.info.nr));
+			keys.put("PDF_layer", this.layerName);
 
 			if (path.isClosed()){
@@ -144,10 +154,10 @@
 			}
 
-			if (path.layer.info.fill){
-				keys.put("PDF_fillColor", printColor(path.layer.info.fillColor));
-			}
-
-			if (path.layer.info.stroke) {
-				keys.put("PDF_lineColor", printColor(path.layer.info.color));
+			if (this.fillName != null){
+				keys.put("PDF_fillColor", this.fillName);
+			}
+
+			if (this.lineName != null) {
+				keys.put("PDF_lineColor", this.lineName);
 			}
 
@@ -155,7 +165,16 @@
 				keys.put("PDF_multipath", ""+ multipathId);
 			}
-			else if (path.layer.info.fill && !multipolygon) {
+			else if (path.layer.info.fill != null && !multipolygon) {
 				keys.put("area", "yes");
 			}
+		}
+
+		if (this.mode == Mode.Debug) {
+
+			keys.put("PDF_pathLayer", ""+path.layer.info.nr);
+			keys.put("PDF_lineWidth", ""+path.layer.info.width);
+			keys.put("PDF_lineDash", ""+path.layer.info.dash);
+			keys.put("PDF_layerHash", ""+path.layer.info.hashCode());
+			keys.put("PDF_layerDivider", ""+path.layer.info.divider);
 		}
 
@@ -167,16 +186,16 @@
 
 
-	private String getString(String string) {
-		if (this.stringsMap.containsKey(string)) {
-			return this.stringsMap.get(string);
-		} else {
-			this.stringsMap.put(string, string);
-			return string;
-		}
-	}
 
 	private String printColor(Color col){
-		String s = "#" + Integer.toHexString(col.getRGB() & 0xffffff);
-		return getString(s);
+		if (col == null){
+			return null;
+		}
+
+		String s = Integer.toHexString(col.getRGB());
+		while (s.length() < 6) {
+			s = "0" + s;
+		}
+
+		return "#" + s;
 	}
 
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/PathOptimizer.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/PathOptimizer.java	(revision 23990)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/PathOptimizer.java	(revision 23991)
@@ -4,4 +4,5 @@
 import java.awt.geom.Rectangle2D;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -68,18 +69,28 @@
 	public void optimize()
 	{
+
 		for(LayerContents layer: this.layers) {
-			this.concatenataPaths(layer);
+			this.concatenatePaths(layer);
 		}
 
 
 		List<LayerContents> newLayers = new ArrayList<LayerContents>();
-		int nr = 0;
-
+		/*
+		for(LayerContents l: this.layers) {
+			List<LayerContents> splitResult = splitBySimilarGroups(l);
+
+			for(LayerContents ll: splitResult) {
+				newLayers.add(ll);
+			}
+		}
+		this.layers = newLayers;
+		 */
+
+
+		newLayers = new ArrayList<LayerContents>();
 		for(LayerContents l: this.layers) {
 			List<LayerContents> splitResult = splitBySegmentKind(l);
 
 			for(LayerContents ll: splitResult) {
-				ll.info.nr = nr;
-				nr ++;
 				newLayers.add(ll);
 			}
@@ -87,6 +98,8 @@
 
 		this.layers = newLayers;
-
+		int nr = 0;
 		for(LayerContents layer: this.layers) {
+			layer.info.nr = nr;
+			nr++;
 			finalizeLayer(layer);
 		}
@@ -127,5 +140,5 @@
 	 * @param layer the layer to process.
 	 */
-	private void concatenataPaths(LayerContents layer) {
+	private void concatenatePaths(LayerContents layer) {
 		Map<Point2D, PdfPath> pathEndpoints = new HashMap<Point2D, PdfPath>();
 		Set<PdfPath> mergedPaths = new HashSet<PdfPath>();
@@ -140,5 +153,11 @@
 
 				if (pathEndpoints.containsKey(path.firstPoint())) {
+
 					PdfPath p1 = pathEndpoints.get(path.firstPoint());
+
+					if (this.isSubpathOf(p1, path)){
+						continue;
+					}
+
 					pathEndpoints.remove(p1.firstPoint());
 					pathEndpoints.remove(p1.lastPoint());
@@ -159,4 +178,9 @@
 				if (pathEndpoints.containsKey(path.lastPoint())) {
 					PdfPath p1 = pathEndpoints.get(path.lastPoint());
+
+					if (this.isSubpathOf(p1, path)){
+						continue;
+					}
+
 					pathEndpoints.remove(p1.firstPoint());
 					pathEndpoints.remove(p1.lastPoint());
@@ -184,4 +208,23 @@
 
 		layer.paths = resultPaths;
+	}
+
+	/**
+	 * Tests if sub is subpath of main.
+	 * @param main
+	 * @param sub
+	 * @return
+	 */
+	private boolean isSubpathOf(PdfPath main, PdfPath sub) {
+
+		Set<Point2D> points = new HashSet<Point2D>(main.points);
+
+		for(Point2D point: sub.points) {
+			if (!points.contains(point)){
+				return false;
+			}
+		}
+
+		return true;
 	}
 
@@ -232,4 +275,61 @@
 	}
 
+	private List<LayerContents> splitBySimilarGroups(LayerContents layer) {
+		List<List<PdfPath>> subparts = new ArrayList<List<PdfPath>>();
+
+		//split into similar parts
+		for (PdfPath path: layer.paths) {
+			List<PdfPath> sublayer = null;
+
+			for(List<PdfPath> ll: subparts){
+				if (this.pathsSimilar(ll.get(0).points, path.points))
+				{
+					sublayer = ll;
+					break;
+				}
+			}
+
+			if (sublayer == null) {
+				sublayer = new ArrayList<PdfPath>();
+				subparts.add(sublayer);
+			}
+
+			sublayer.add(path);
+		}
+
+		//get groups
+		int minGroupTreshold = 10;
+
+		List<PdfPath> independantPaths = new ArrayList<PdfPath>();
+		List<LayerContents> result = new ArrayList<LayerContents>();
+
+		for(List<PdfPath> list: subparts){
+			if (list.size() >= minGroupTreshold) {
+				LayerContents l = new LayerContents();
+				l.paths = list;
+				l.info = layer.info.copy();
+				l.info.isGroup = true;
+				l.multiPaths = Collections.EMPTY_LIST;
+				result.add(l);
+			}
+			else
+			{
+				independantPaths.addAll(list);
+			}
+		}
+
+		if (independantPaths.size() > 0 || layer.multiPaths.size() > 0) {
+			LayerContents l = new LayerContents();
+			l.paths = independantPaths;
+			l.info = layer.info.copy();
+			l.info.isGroup = false;
+			l.multiPaths = layer.multiPaths;
+			result.add(l);
+		}
+
+
+		return result;
+	}
+
 
 
@@ -277,3 +377,39 @@
 	}
 
+	/**
+	 * Test if paths are different only by offset.
+	 * @return
+	 */
+	private boolean pathsSimilar(List<Point2D> path1, List<Point2D> path2) {
+		if (path1.size() != path2.size()) {
+			return false;
+		}
+
+		if (path1.size() < 3) {
+			return false;
+			//cannot judge so small paths
+		}
+
+		Point2D p1 = path1.get(0);
+		Point2D p2 = path2.get(0);
+
+		double offsetX = p1.getX() - p2.getX();
+		double offsetY = p1.getY() - p2.getY();
+		double tolerance = 1e-4;
+
+		for(int pos = 0; pos < path1.size(); pos ++) {
+			p1 = path1.get(pos);
+			p2 = path2.get(pos);
+
+			double errorX = p1.getX() - p2.getX() - offsetX;
+			double errorY = p1.getY() - p2.getY() - offsetY;
+
+			if (Math.abs(errorX) + Math.abs(errorY) > tolerance){
+				return false;
+			}
+		}
+
+		return true;
+	}
+
 }
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/GraphicsProcessor.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/GraphicsProcessor.java	(revision 23990)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/GraphicsProcessor.java	(revision 23991)
@@ -3,31 +3,11 @@
 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;
@@ -35,5 +15,5 @@
 import pdfimport.PdfPath;
 
-public class GraphicsProcessor extends Graphics2D {
+public class GraphicsProcessor{
 
 	public PathOptimizer target;
@@ -44,28 +24,19 @@
 	private boolean complexClipShape;
 	private boolean clipAreaDrawn;
-	private final double height;
 
 	private final AffineTransform transform;
 
-	public GraphicsProcessor(PathOptimizer target, int rotation, double height)
+	public GraphicsProcessor(PathOptimizer target, int rotation)
 	{
-		this.height = height;
 		this.target = target;
 		this.transform = new AffineTransform();
-		this.transform.rotate(Math.toRadians(rotation));
-		this.info.color = Color.BLACK;
-		this.info.fillColor = Color.BLACK;
-	}
-
-	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;
-		}
+		this.transform.rotate(-Math.toRadians(rotation));
+		this.info.stroke = Color.BLACK;
+		this.info.fill = Color.BLACK;
+	}
+
+
+	private void addPath(Shape s, boolean closed) {
+		List<PdfPath> paths = this.parsePath(s, closed);
 
 		for (PdfPath p: paths){
@@ -84,8 +55,7 @@
 
 
-	private List<PdfPath> parsePath(Shape s) {
+	private List<PdfPath> parsePath(Shape s, boolean closed) {
 		List<PdfPath> result = new ArrayList<PdfPath>(2);
 		List<Point2D> points = new ArrayList<Point2D>(2);
-
 
 		PathIterator iter = s.getPathIterator(null);
@@ -139,8 +109,10 @@
 		if (points.size() > 1 )
 		{
+			if (closed) {
+				this.addPoint(points, points.get(0));
+			}
+
 			result.add(new PdfPath(points));
 		}
-
-
 
 		return result;
@@ -161,5 +133,5 @@
 	private Point2D parsePoint(double[] buffer, int offset) {
 		//invert Y.
-		Point2D point = new Point2D.Double(buffer[offset], this.height - buffer[offset + 1]);
+		Point2D point = new Point2D.Double(buffer[offset], buffer[offset + 1]);
 		Point2D dest = new Point2D.Double();
 		this.transform.transform(point, dest);
@@ -167,46 +139,40 @@
 	}
 
-
-	@Override
-	public void draw(Shape s) {
-
-		if (complexClipShape)
-		{
-			if (!this.clipAreaDrawn)
-			{
+	public void drawPath(Shape path, Color stroke, Color fill,
+			int windingRule) {
+
+		if (complexClipShape) {
+			if (!this.clipAreaDrawn) {
+				this.info.stroke = null;
+				this.info.fill = Color.CYAN;
 				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)
-		{
+
+		if (!complexClipShape || fill != null) {
+			this.info.stroke = stroke;
+			this.info.fill = fill;
+			this.addPath(path, fill != null);
+		}
+	}
+
+
+	public void drawImage() {
+
+		if (!this.clipAreaDrawn) {
+			this.info.stroke = null;
+			this.info.fill = Color.CYAN;
 			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);
+		this.clipPath = this.parsePath(clip, true);
 
 		boolean complexClipPath = false;
@@ -227,12 +193,5 @@
 	}
 
-	@Override
-	public void setColor(Color c) {
-		this.info.color = c;
-		this.info.fillColor = c;
-	}
-
-
-	@Override
+
 	public void setStroke(Stroke s) {
 		BasicStroke stroke = (BasicStroke) s;
@@ -245,402 +204,6 @@
 	}
 
-
-	@Override
-	public void clip(Shape s) {
-		//TODO:
-	}
-
-
-	@Override
-	public void addRenderingHints(Map<?, ?> hints) {
+	public void drawString(float x, float y, String character, Color color) {
 		// 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/PageDrawer.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PageDrawer.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PageDrawer.java	(revision 23991)
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.geom.Area;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Path2D;
+import java.awt.geom.Point2D;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.PDResources;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.graphics.PDGraphicsState;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream;
+import org.apache.pdfbox.pdmodel.text.PDTextState;
+import org.apache.pdfbox.util.Matrix;
+import org.apache.pdfbox.util.PDFStreamEngine;
+import org.apache.pdfbox.util.ResourceLoader;
+import org.apache.pdfbox.util.TextPosition;
+
+
+/**
+ * This will paint a page in a PDF document to a graphics context.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.22 $
+ */
+public class PageDrawer extends PDFStreamEngine
+{
+
+	private GraphicsProcessor graphics;
+	private BasicStroke stroke;
+	protected PDPage page;
+
+	private final GeneralPath linePath = new GeneralPath();
+
+	/**
+	 * Default constructor, loads properties from file.
+	 *
+	 * @throws IOException If there is an error loading properties from the file.
+	 */
+	public PageDrawer() throws IOException
+	{
+		super( ResourceLoader.loadProperties(
+				"pdfimport/pdfbox/PageDrawer.properties", true ) );
+	}
+
+	/**
+	 * This will draw the page to the requested context.
+	 *
+	 * @param g The graphics context to draw onto.
+	 * @param p The page to draw.
+	 * @param pageDimension The size of the page to draw.
+	 *
+	 * @throws IOException If there is an IO error while drawing the page.
+	 */
+	public void drawPage( GraphicsProcessor g, PDPage p) throws IOException
+	{
+		graphics = g;
+		page = p;
+		// Only if there is some content, we have to process it.
+		// Otherwise we are done here and we will produce an empty page
+		if ( page.getContents() != null)
+		{
+			PDResources resources = page.findResources();
+			processStream( page, resources, page.getContents().getStream() );
+		}
+		List annotations = page.getAnnotations();
+		for( int i=0; i<annotations.size(); i++ )
+		{
+			PDAnnotation annot = (PDAnnotation)annotations.get( i );
+			PDRectangle rect = annot.getRectangle();
+			String appearanceName = annot.getAppearanceStream();
+			PDAppearanceDictionary appearDictionary = annot.getAppearance();
+			if( appearDictionary != null )
+			{
+				if( appearanceName == null )
+				{
+					appearanceName = "default";
+				}
+				Map appearanceMap = appearDictionary.getNormalAppearance();
+				if (appearanceMap != null) {
+					PDAppearanceStream appearance =
+						(PDAppearanceStream)appearanceMap.get( appearanceName );
+					if( appearance != null )
+					{
+						processSubStream( page, appearance.getResources(), appearance.getStream() );
+					}
+				}
+			}
+		}
+
+	}
+
+	/**
+	 * You should override this method if you want to perform an action when a
+	 * text is being processed.
+	 *
+	 * @param text The text to process
+	 */
+	@Override
+	protected void processTextPosition( TextPosition text )
+	{
+
+		Color color = null;
+
+		try
+		{
+			switch(this.getGraphicsState().getTextState().getRenderingMode()) {
+			case PDTextState.RENDERING_MODE_FILL_TEXT:
+				color = this.getGraphicsState().getNonStrokingColor().getJavaColor();
+				break;
+			case PDTextState.RENDERING_MODE_STROKE_TEXT:
+				color = this.getGraphicsState().getStrokingColor().getJavaColor();
+				break;
+			case PDTextState.RENDERING_MODE_NEITHER_FILL_NOR_STROKE_TEXT:
+				//basic support for text rendering mode "invisible"
+				Color nsc = this.getGraphicsState().getStrokingColor().getJavaColor();
+				float[] components = {Color.black.getRed(),Color.black.getGreen(),Color.black.getBlue()};
+				color =  new Color(nsc.getColorSpace(),components,0f);
+				break;
+			default:
+				color = this.getGraphicsState().getNonStrokingColor().getJavaColor();
+			}
+
+			Matrix textPos = text.getTextPos().copy();
+			float x = textPos.getXPosition();
+			float y = textPos.getYPosition();
+			graphics.setClip(getGraphicsState().getCurrentClippingPath());
+			graphics.drawString(x,y,text.getCharacter(), color);
+		}
+		catch( IOException io )
+		{
+			io.printStackTrace();
+		}
+	}
+
+
+	/**
+	 * Get the page that is currently being drawn.
+	 *
+	 * @return The page that is being drawn.
+	 */
+	public PDPage getPage()
+	{
+		return page;
+	}
+
+
+	/**
+	 * Get the current line path to be drawn.
+	 *
+	 * @return The current line path to be drawn.
+	 */
+	public GeneralPath getLinePath()
+	{
+		return linePath;
+	}
+
+
+	/**
+	 * This will set the current stroke.
+	 *
+	 * @param newStroke The current stroke.
+	 * 
+	 */
+	public void setStroke(BasicStroke newStroke)
+	{
+		this.stroke = newStroke;
+	}
+
+	public BasicStroke getStroke() {
+		return this.stroke;
+	}
+
+
+	public void drawPath(boolean stroke, boolean fill, int windingRule) throws IOException
+	{
+		graphics.setClip(getGraphicsState().getCurrentClippingPath());
+		GeneralPath path = getLinePath();
+
+		Color strokeColor = getGraphicsState().getStrokingColor().getJavaColor();
+		Color fillColor = getGraphicsState().getNonStrokingColor().getJavaColor();
+		graphics.drawPath(path, stroke ? strokeColor : null, fill ? fillColor : null, windingRule);
+
+		path.reset();
+	}
+
+
+	/**
+	 * Draw the AWT image. Called by Invoke.
+	 * Moved into PageDrawer so that Invoke doesn't have to reach in here for Graphics as that breaks extensibility.
+	 *
+	 * @param awtImage The image to draw.
+	 * @param at The transformation to use when drawing.
+	 * 
+	 */
+	public void drawImage(){
+		graphics.setClip(getGraphicsState().getCurrentClippingPath());
+		graphics.drawImage( );
+	}
+
+	/**
+	 * Fill with Shading.  Called by SHFill operator.
+	 *
+	 * @param ShadingName  The name of the Shading Dictionary to use for this fill instruction.
+	 *
+	 * @throws IOException If there is an IO error while shade-filling the path/clipping area.
+	 */
+	public void SHFill(COSName ShadingName) throws IOException
+	{
+		this.drawPath(false, true, Path2D.WIND_NON_ZERO);
+	}
+
+
+
+	//This code generalizes the code Jim Lynch wrote for AppendRectangleToPath
+	/**
+	 * use the current transformation matrix to transform a single point.
+	 * @param x x-coordinate of the point to be transform
+	 * @param y y-coordinate of the point to be transform
+	 * @return the transformed coordinates as Point2D.Double
+	 */
+	public java.awt.geom.Point2D.Double transformedPoint(double x, double y)
+	{
+		double[] position = {x,y};
+		getGraphicsState().getCurrentTransformationMatrix().createAffineTransform().transform(
+				position, 0, position, 0, 1);
+		return new Point2D.Double(position[0],position[1]);
+	}
+
+	/**
+	 * Set the clipping Path.
+	 *
+	 * @param windingRule The winding rule this path will use.
+	 * 
+	 */
+	public void setClippingPath(int windingRule)
+	{
+		PDGraphicsState graphicsState = getGraphicsState();
+		GeneralPath clippingPath = (GeneralPath)getLinePath().clone();
+		clippingPath.setWindingRule(windingRule);
+		// If there is already set a clipping path, we have to intersect the new with the existing one
+		if (graphicsState.getCurrentClippingPath() != null)
+		{
+			Area currentArea = new Area(getGraphicsState().getCurrentClippingPath());
+			Area newArea = new Area(clippingPath);
+			currentArea.intersect(newArea);
+			graphicsState.setCurrentClippingPath(currentArea);
+		}
+		else
+		{
+			graphicsState.setCurrentClippingPath(clippingPath);
+		}
+		getLinePath().reset();
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PdfBoxParser.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PdfBoxParser.java	(revision 23990)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/PdfBoxParser.java	(revision 23991)
@@ -2,10 +2,8 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.Dimension;
 import java.awt.geom.Rectangle2D;
 import java.io.File;
 import java.util.List;
 
-import org.apache.pdfbox.pdfviewer.PageDrawer;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
@@ -39,5 +37,4 @@
 		PDPage page = (PDPage)allPages.get(0);
 		PDRectangle pageSize = page.findMediaBox();
-		Dimension pageDimension = pageSize.createDimension();
 		Integer rotationVal = page.getRotation();
 		int rotation = 0;
@@ -46,7 +43,7 @@
 		}
 
-		GraphicsProcessor p = new GraphicsProcessor(target, rotation, pageDimension.getHeight());
+		GraphicsProcessor p = new GraphicsProcessor(target, rotation);
 		PageDrawer drawer = new PageDrawer();
-		drawer.drawPage(p, page, pageDimension);
+		drawer.drawPage(p, page);
 		this.target.bounds = new Rectangle2D.Double(pageSize.getLowerLeftX(), pageSize.getLowerLeftY(), pageSize.getWidth(), pageSize.getHeight());
 	}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/AppendRectangleToPath.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/AppendRectangleToPath.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/AppendRectangleToPath.java	(revision 23991)
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.3 $
+ */
+public class AppendRectangleToPath extends OperatorProcessor
+{
+
+
+	/**
+	 * process : re : append rectangle to path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments)
+	{
+		PageDrawer drawer = (PageDrawer)context;
+
+		COSNumber x = (COSNumber)arguments.get( 0 );
+		COSNumber y = (COSNumber)arguments.get( 1 );
+		COSNumber w = (COSNumber)arguments.get( 2 );
+		COSNumber h = (COSNumber)arguments.get( 3 );
+
+		double x1 = x.doubleValue();
+		double y1 = y.doubleValue();
+		// create a pair of coordinates for the transformation
+		double x2 = w.doubleValue()+x1;
+		double y2 = h.doubleValue()+y1;
+
+		Point2D startCoords = drawer.transformedPoint(x1,y1);
+		Point2D endCoords = drawer.transformedPoint(x2,y2);
+
+		float width = (float)(endCoords.getX()-startCoords.getX());
+		float height = (float)(endCoords.getY()-startCoords.getY());
+		float xStart = (float)startCoords.getX();
+		float yStart = (float)startCoords.getY();
+
+		// To ensure that the path is created in the right direction,
+		// we have to create it by combining single lines instead of
+		// creating a simple rectangle
+		GeneralPath path = drawer.getLinePath();
+		path.moveTo(xStart, yStart);
+		path.lineTo(xStart+width, yStart);
+		path.lineTo(xStart+width, yStart+height);
+		path.lineTo(xStart, yStart+height);
+		path.lineTo(xStart, yStart);
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/BeginInlineImage.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/BeginInlineImage.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/BeginInlineImage.java	(revision 23991)
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.2 $
+ */
+public class BeginInlineImage extends OperatorProcessor
+{
+
+	/**
+	 * process : BI : begin inline image.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 * @throws IOException If there is an error displaying the inline image.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments)  throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.drawImage();
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/ClipEvenOddRule.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/ClipEvenOddRule.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/ClipEvenOddRule.java	(revision 23991)
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.GeneralPath;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:Daniel.Wilson@BlackLocustSoftware.com">Daniel Wilson</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClipEvenOddRule extends OperatorProcessor
+{
+
+	/**
+	 * Log instance.
+	 */
+	private static final Log log = LogFactory.getLog(ClipEvenOddRule.class);
+
+	/**
+	 * process : W* : set clipping path using even odd rule.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException if there is an error during execution.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+
+		try
+		{
+			PageDrawer drawer = (PageDrawer)context;
+			drawer.setClippingPath(GeneralPath.WIND_EVEN_ODD);
+		}
+		catch (Exception e)
+		{
+			log.warn(e, e);
+		}
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/ClipNonZeroRule.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/ClipNonZeroRule.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/ClipNonZeroRule.java	(revision 23991)
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.GeneralPath;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:Daniel.Wilson@BlackLocustSoftware.com">Daniel Wilson</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClipNonZeroRule extends OperatorProcessor
+{
+
+	/**
+	 * Log instance.
+	 */
+	private static final Log log = LogFactory.getLog(ClipNonZeroRule.class);
+
+	/**
+	 * process : W : Set the clipping path using non zero winding rule.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If there is an error during the processing.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+
+		try
+		{
+			PageDrawer drawer = (PageDrawer)context;
+			drawer.setClippingPath(GeneralPath.WIND_NON_ZERO);
+		}
+		catch (Exception e)
+		{
+			log.warn(e, e);
+		}
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CloseFillEvenOddAndStrokePath.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CloseFillEvenOddAndStrokePath.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CloseFillEvenOddAndStrokePath.java	(revision 23991)
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.Path2D;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:andreas@lehmi.de">Andreas Lehmkühler</a>
+ * @version $Revision: 1.0 $
+ */
+public class CloseFillEvenOddAndStrokePath extends org.apache.pdfbox.util.operator.OperatorProcessor
+{
+
+	/**
+	 * fill and stroke the path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.getLinePath().closePath();
+		drawer.drawPath(true, true, Path2D.WIND_EVEN_ODD);
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CloseFillNonZeroAndStrokePath.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CloseFillNonZeroAndStrokePath.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CloseFillNonZeroAndStrokePath.java	(revision 23991)
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.Path2D;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.1 $
+ */
+public class CloseFillNonZeroAndStrokePath extends OperatorProcessor
+{
+
+	/**
+	 * fill and stroke the path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.getLinePath().closePath();
+		drawer.drawPath(true, true, Path2D.WIND_NON_ZERO);
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/ClosePath.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/ClosePath.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/ClosePath.java	(revision 23991)
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.3 $
+ */
+public class ClosePath extends OperatorProcessor
+{
+
+	/**
+	 * process : h : Close path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 * 
+	 * @throws IOException if something went wrong during logging
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.getLinePath().closePath();
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CurveTo.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CurveTo.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CurveTo.java	(revision 23991)
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.2 $
+ */
+public class CurveTo extends OperatorProcessor
+{
+
+
+	/**
+	 * process : c : Append curved segment to path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments)
+	{
+		PageDrawer drawer = (PageDrawer)context;
+
+		COSNumber x1 = (COSNumber)arguments.get( 0 );
+		COSNumber y1 = (COSNumber)arguments.get( 1 );
+		COSNumber x2 = (COSNumber)arguments.get( 2 );
+		COSNumber y2 = (COSNumber)arguments.get( 3 );
+		COSNumber x3 = (COSNumber)arguments.get( 4 );
+		COSNumber y3 = (COSNumber)arguments.get( 5 );
+
+		Point2D point1 = drawer.transformedPoint(x1.doubleValue(), y1.doubleValue());
+		Point2D point2 = drawer.transformedPoint(x2.doubleValue(), y2.doubleValue());
+		Point2D point3 = drawer.transformedPoint(x3.doubleValue(), y3.doubleValue());
+
+		drawer.getLinePath().curveTo((float)point1.getX(), (float)point1.getY(),
+				(float)point2.getX(), (float)point2.getY(), (float)point3.getX(), (float)point3.getY());
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CurveToReplicateFinalPoint.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CurveToReplicateFinalPoint.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CurveToReplicateFinalPoint.java	(revision 23991)
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.2 $
+ */
+public class CurveToReplicateFinalPoint extends OperatorProcessor
+{
+
+
+	/**
+	 * process : y : Append curved segment to path (final point replicated).
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments)
+	{
+		PageDrawer drawer = (PageDrawer)context;
+
+		COSNumber x1 = (COSNumber)arguments.get( 0 );
+		COSNumber y1 = (COSNumber)arguments.get( 1 );
+		COSNumber x3 = (COSNumber)arguments.get( 2 );
+		COSNumber y3 = (COSNumber)arguments.get( 3 );
+
+		Point2D point1 = drawer.transformedPoint(x1.doubleValue(), y1.doubleValue());
+		Point2D point3 = drawer.transformedPoint(x3.doubleValue(), y3.doubleValue());
+
+		drawer.getLinePath().curveTo((float)point1.getX(), (float)point1.getY(),
+				(float)point3.getX(), (float)point3.getY(), (float)point3.getX(), (float)point3.getY());
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CurveToReplicateInitialPoint.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CurveToReplicateInitialPoint.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/CurveToReplicateInitialPoint.java	(revision 23991)
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.2 $
+ */
+public class CurveToReplicateInitialPoint extends OperatorProcessor
+{
+
+
+	/**
+	 * process : v : Append curved segment to path (initial point replicated).
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments)
+	{
+		PageDrawer drawer = (PageDrawer)context;
+
+		COSNumber x2 = (COSNumber)arguments.get( 0 );
+		COSNumber y2 = (COSNumber)arguments.get( 1 );
+		COSNumber x3 = (COSNumber)arguments.get( 2 );
+		COSNumber y3 = (COSNumber)arguments.get( 3 );
+		GeneralPath path = drawer.getLinePath();
+		Point2D currentPoint = path.getCurrentPoint();
+
+		Point2D point2 = drawer.transformedPoint(x2.doubleValue(), y2.doubleValue());
+		Point2D point3 = drawer.transformedPoint(x3.doubleValue(), y3.doubleValue());
+
+		drawer.getLinePath().curveTo((float)currentPoint.getX(), (float)currentPoint.getY(),
+				(float)point2.getX(), (float)point2.getY(), (float)point3.getX(), (float)point3.getY());
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/EndPath.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/EndPath.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/EndPath.java	(revision 23991)
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.2 $
+ */
+public class EndPath extends OperatorProcessor
+{
+
+
+	/**
+	 * process : n : End path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments)
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.getLinePath().reset();
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillEvenOddAndStrokePath.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillEvenOddAndStrokePath.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillEvenOddAndStrokePath.java	(revision 23991)
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.Path2D;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:andreas@lehmi.de">Andreas Lehmkühler</a>
+ * @version $Revision: 101 $
+ */
+public class FillEvenOddAndStrokePath extends org.apache.pdfbox.util.operator.OperatorProcessor
+{
+
+	/**
+	 * fill and stroke the path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.drawPath(true, true, Path2D.WIND_EVEN_ODD);
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillEvenOddRule.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillEvenOddRule.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillEvenOddRule.java	(revision 23991)
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.GeneralPath;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.5 $
+ */
+public class FillEvenOddRule extends OperatorProcessor
+{
+
+	/**
+	 * Log instance.
+	 */
+	private static final Log log = LogFactory.getLog(FillEvenOddRule.class);
+
+	/**
+	 * process : f* : fill path using even odd rule.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException if there is an error during execution.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		try
+		{
+			///dwilson refactoring
+			PageDrawer drawer = (PageDrawer)context;
+			drawer.drawPath(false, true, GeneralPath.WIND_EVEN_ODD);
+		}
+		catch (Exception e)
+		{
+			log.warn(e, e);
+		}
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillNonZeroAndStrokePath.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillNonZeroAndStrokePath.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillNonZeroAndStrokePath.java	(revision 23991)
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.Path2D;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.1 $
+ */
+public class FillNonZeroAndStrokePath extends org.apache.pdfbox.util.operator.OperatorProcessor
+{
+
+	/**
+	 * fill and stroke the path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.drawPath(true, true, Path2D.WIND_NON_ZERO);
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillNonZeroRule.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillNonZeroRule.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/FillNonZeroRule.java	(revision 23991)
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.GeneralPath;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.5 $
+ */
+public class FillNonZeroRule extends OperatorProcessor
+{
+
+	/**
+	 * process : F/f : fill path using non zero winding rule.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If there is an error during the processing.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.drawPath(false, true, GeneralPath.WIND_NON_ZERO);
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/Invoke.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/Invoke.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/Invoke.java	(revision 23991)
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSStream;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.PDResources;
+import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObject;
+import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm;
+import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage;
+import org.apache.pdfbox.util.Matrix;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.4 $
+ */
+public class Invoke extends OperatorProcessor
+{
+
+
+	/**
+	 * process : Do : Paint the specified XObject (section 4.7).
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 * @throws IOException If there is an error invoking the sub object.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		PDPage page = drawer.getPage();
+		COSName objectName = (COSName)arguments.get( 0 );
+		Map xobjects = drawer.getResources().getXObjects();
+		PDXObject xobject = (PDXObject)xobjects.get( objectName.getName() );
+		if( xobject instanceof PDXObjectImage )
+		{
+			drawer.drawImage();
+		}
+		else if(xobject instanceof PDXObjectForm)
+		{
+			PDXObjectForm form = (PDXObjectForm)xobject;
+			COSStream invoke = (COSStream)form.getCOSObject();
+			PDResources pdResources = form.getResources();
+			if(pdResources == null)
+			{
+				pdResources = page.findResources();
+			}
+			// if there is an optional form matrix, we have to
+			// map the form space to the user space
+			Matrix matrix = form.getMatrix();
+			if (matrix != null)
+			{
+				Matrix xobjectCTM = matrix.multiply( context.getGraphicsState().getCurrentTransformationMatrix());
+				context.getGraphicsState().setCurrentTransformationMatrix(xobjectCTM);
+			}
+			getContext().processSubStream( page, pdResources, invoke );
+		}
+		else
+		{
+			//unknown xobject type
+		}
+
+
+		//invoke named object.
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/LineTo.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/LineTo.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/LineTo.java	(revision 23991)
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.2 $
+ */
+public class LineTo extends OperatorProcessor
+{
+
+
+	/**
+	 * process : l : Append straight line segment to path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments)
+	{
+		PageDrawer drawer = (PageDrawer)context;
+
+		//append straight line segment from the current point to the point.
+		COSNumber x = (COSNumber)arguments.get( 0 );
+		COSNumber y = (COSNumber)arguments.get( 1 );
+
+		Point2D pos = drawer.transformedPoint(x.doubleValue(), y.doubleValue());
+		drawer.getLinePath().lineTo((float)pos.getX(), (float)pos.getY());
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/MoveTo.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/MoveTo.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/MoveTo.java	(revision 23991)
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.Point2D;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.2 $
+ */
+public class MoveTo extends OperatorProcessor
+{
+
+	/**
+	 * Log instance.
+	 */
+	private static final Log log = LogFactory.getLog(MoveTo.class);
+
+	/**
+	 * process : m : Begin new subpath.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 * @throws IOException If there is an error processing the operator.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		try
+		{
+			PageDrawer drawer = (PageDrawer)context;
+			COSNumber x = (COSNumber)arguments.get( 0 );
+			COSNumber y = (COSNumber)arguments.get( 1 );
+			Point2D pos = drawer.transformedPoint(x.doubleValue(), y.doubleValue());
+			drawer.getLinePath().moveTo((float)pos.getX(), (float)pos.getY());
+		}
+		catch (Exception exception)
+		{
+			log.warn( exception, exception);
+		}
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SHFill.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SHFill.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SHFill.java	(revision 23991)
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.geom.Path2D;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of sh operator for page drawer.
+ *  See section 4.6.3 of the PDF 1.7 specification.
+ *
+ * @author <a href="mailto:Daniel.Wilson@BlackLocustSoftware.com">Daniel Wilson</a>
+ * @version $Revision: 1.0 $
+ */
+public class SHFill extends OperatorProcessor
+{
+
+	/**
+	 * process : sh : shade fill the path or clipping area.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException if there is an error during execution.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.drawPath(false, true, Path2D.WIND_NON_ZERO);
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineCapStyle.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineCapStyle.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineCapStyle.java	(revision 23991)
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.BasicStroke;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:andreas@lehmi.de>Andreas Lehmkühler</a>
+ * @version $Revision: 1.0 $
+ */
+public class SetLineCapStyle extends org.apache.pdfbox.util.operator.SetLineCapStyle
+{
+
+	/**
+	 * Set the line cap style.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		super.process( operator, arguments );
+		int lineCapStyle = context.getGraphicsState().getLineCap();
+		PageDrawer drawer = (PageDrawer)context;
+		BasicStroke stroke = drawer.getStroke();
+		if (stroke == null)
+		{
+			drawer.setStroke( new BasicStroke(1,lineCapStyle,BasicStroke.JOIN_MITER) );
+		}
+		else
+		{
+			drawer.setStroke( new BasicStroke(stroke.getLineWidth(), lineCapStyle, stroke.getLineJoin(),
+					stroke.getMiterLimit(), stroke.getDashArray(), stroke.getDashPhase()));
+		}
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineDashPattern.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineDashPattern.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineDashPattern.java	(revision 23991)
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.BasicStroke;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.pdmodel.graphics.PDLineDashPattern;
+import org.apache.pdfbox.util.PDFOperator;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:andreas@lehmi.de">Andreas Lehmkühler</a>
+ * @version $Revision: 1.0 $
+ */
+public class SetLineDashPattern extends org.apache.pdfbox.util.operator.SetLineDashPattern
+{
+
+	/**
+	 * Set the line dash pattern.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		super.process( operator, arguments );
+		PDLineDashPattern lineDashPattern = context.getGraphicsState().getLineDashPattern();
+		PageDrawer drawer = (PageDrawer)context;
+		BasicStroke stroke = drawer.getStroke();
+		if (stroke == null)
+		{
+			if (lineDashPattern.isDashPatternEmpty())
+			{
+				drawer.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f) );
+			}
+			else
+			{
+				drawer.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
+						lineDashPattern.getCOSDashPattern().toFloatArray(), lineDashPattern.getPhaseStart()) );
+			}
+		}
+		else
+		{
+			if (lineDashPattern.isDashPatternEmpty())
+			{
+				drawer.setStroke( new BasicStroke(stroke.getLineWidth(), stroke.getEndCap(),
+						stroke.getLineJoin(), stroke.getMiterLimit()) );
+			}
+			else
+			{
+				drawer.setStroke( new BasicStroke(stroke.getLineWidth(), stroke.getEndCap(), stroke.getLineJoin(),
+						stroke.getMiterLimit(), lineDashPattern.getCOSDashPattern().toFloatArray(),
+						lineDashPattern.getPhaseStart()) );
+			}
+		}
+	}
+
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineJoinStyle.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineJoinStyle.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineJoinStyle.java	(revision 23991)
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.BasicStroke;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:andreas@lehmi.de>Andreas Lehmkühler</a>
+ * @version $Revision: 1.0 $
+ */
+public class SetLineJoinStyle extends org.apache.pdfbox.util.operator.SetLineJoinStyle
+{
+
+	/**
+	 * Set the line cap style.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		super.process( operator, arguments );
+		int lineJoinStyle = context.getGraphicsState().getLineJoin();
+		PageDrawer drawer = (PageDrawer)context;
+		BasicStroke stroke = drawer.getStroke();
+		if (stroke == null)
+		{
+			drawer.setStroke( new BasicStroke(1,BasicStroke.CAP_SQUARE,lineJoinStyle) );
+		}
+		else
+		{
+			drawer.setStroke( new BasicStroke(stroke.getLineWidth(), stroke.getEndCap(), lineJoinStyle,
+					stroke.getMiterLimit(), stroke.getDashArray(), stroke.getDashPhase()) );
+		}
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineMiterLimit.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineMiterLimit.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineMiterLimit.java	(revision 23991)
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.BasicStroke;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:andreas@lehmi.de">Andreas Lehmkühler</a>
+ * @version $Revision: 1.0 $
+ */
+public class SetLineMiterLimit extends org.apache.pdfbox.util.operator.SetLineMiterLimit
+{
+
+	/**
+	 * Set the line dash pattern.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		super.process(operator, arguments);
+		float miterLimit = (float)context.getGraphicsState().getMiterLimit();
+		PageDrawer drawer = (PageDrawer)context;
+		BasicStroke stroke = drawer.getStroke();
+		if (stroke == null)
+		{
+			drawer.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER,
+					miterLimit, null, 0.0f));
+		}
+		else
+		{
+			drawer.setStroke( new BasicStroke(stroke.getLineWidth(), stroke.getEndCap(), stroke.getLineJoin(),
+					miterLimit, null, 0.0f));
+		}
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineWidth.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineWidth.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/SetLineWidth.java	(revision 23991)
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.awt.BasicStroke;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.2 $
+ */
+public class SetLineWidth extends org.apache.pdfbox.util.operator.SetLineWidth
+{
+
+	/**
+	 * w Set line width.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		super.process( operator, arguments );
+		float lineWidth = (float)context.getGraphicsState().getLineWidth();
+		if (lineWidth == 0)
+		{
+			lineWidth = 1;
+		}
+		PageDrawer drawer = (PageDrawer)context;
+		BasicStroke stroke = drawer.getStroke();
+		if (stroke == null)
+		{
+			drawer.setStroke( new BasicStroke( lineWidth ) );
+		}
+		else
+		{
+			drawer.setStroke( new BasicStroke(lineWidth, stroke.getEndCap(), stroke.getLineJoin(),
+					stroke.getMiterLimit(), stroke.getDashArray(), stroke.getDashPhase()) );
+		}
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/StrokePath.java
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/StrokePath.java	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/StrokePath.java	(revision 23991)
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pdfimport.pdfbox.operators;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.util.operator.OperatorProcessor;
+
+import pdfimport.pdfbox.PageDrawer;
+
+/**
+ * Implementation of content stream operator for page drawer.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.3 $
+ */
+public class StrokePath extends OperatorProcessor
+{
+
+	/**
+	 * S stroke the path.
+	 * @param operator The operator that is being executed.
+	 * @param arguments List
+	 *
+	 * @throws IOException If an error occurs while processing the font.
+	 */
+	@Override
+	public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
+	{
+		PageDrawer drawer = (PageDrawer)context;
+		drawer.drawPath(true, false, 0);
+	}
+}
Index: /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/package.html
===================================================================
--- /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/package.html	(revision 23991)
+++ /applications/editors/josm/plugins/pdfimport/src/pdfimport/pdfbox/operators/package.html	(revision 23991)
@@ -0,0 +1,25 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one or more
+ ! contributor license agreements.  See the NOTICE file distributed with
+ ! this work for additional information regarding copyright ownership.
+ ! The ASF licenses this file to You under the Apache License, Version 2.0
+ ! (the "License"); you may not use this file except in compliance with
+ ! the License.  You may obtain a copy of the License at
+ !
+ !      http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing, software
+ ! distributed under the License is distributed on an "AS IS" BASIS,
+ ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ! See the License for the specific language governing permissions and
+ ! limitations under the License.
+ !-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+
+</head>
+<body>
+This package contains implementations of all of the PDF operators.
+</body>
+</html>
