1 | /*
|
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | * contributor license agreements. See the NOTICE file distributed with
|
---|
4 | * this work for additional information regarding copyright ownership.
|
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | * (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | *
|
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 | *
|
---|
11 | * Unless required by applicable law or agreed to in writing, software
|
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | * See the License for the specific language governing permissions and
|
---|
15 | * limitations under the License.
|
---|
16 | */
|
---|
17 | package pdfimport.pdfbox.operators;
|
---|
18 |
|
---|
19 | import java.awt.geom.Point2D;
|
---|
20 | import java.io.IOException;
|
---|
21 | import java.util.List;
|
---|
22 |
|
---|
23 | import org.apache.commons.logging.Log;
|
---|
24 | import org.apache.commons.logging.LogFactory;
|
---|
25 | import org.apache.pdfbox.cos.COSBase;
|
---|
26 | import org.apache.pdfbox.cos.COSNumber;
|
---|
27 | import org.apache.pdfbox.util.PDFOperator;
|
---|
28 | import org.apache.pdfbox.util.operator.OperatorProcessor;
|
---|
29 |
|
---|
30 | import pdfimport.pdfbox.PageDrawer;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Implementation of content stream operator for page drawer.
|
---|
34 | *
|
---|
35 | * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
|
---|
36 | * @version $Revision: 1.2 $
|
---|
37 | */
|
---|
38 | public class MoveTo extends OperatorProcessor
|
---|
39 | {
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Log instance.
|
---|
43 | */
|
---|
44 | private static final Log log = LogFactory.getLog(MoveTo.class);
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * process : m : Begin new subpath.
|
---|
48 | * @param operator The operator that is being executed.
|
---|
49 | * @param arguments List
|
---|
50 | * @throws IOException If there is an error processing the operator.
|
---|
51 | */
|
---|
52 | @Override
|
---|
53 | public void process(PDFOperator operator, List<COSBase> arguments) throws IOException
|
---|
54 | {
|
---|
55 | try
|
---|
56 | {
|
---|
57 | PageDrawer drawer = (PageDrawer)context;
|
---|
58 | COSNumber x = (COSNumber)arguments.get( 0 );
|
---|
59 | COSNumber y = (COSNumber)arguments.get( 1 );
|
---|
60 | Point2D pos = drawer.transformedPoint(x.doubleValue(), y.doubleValue());
|
---|
61 | drawer.getLinePath().moveTo((float)pos.getX(), (float)pos.getY());
|
---|
62 | }
|
---|
63 | catch (Exception exception)
|
---|
64 | {
|
---|
65 | log.warn( exception, exception);
|
---|
66 | }
|
---|
67 | }
|
---|
68 | }
|
---|