Changeset 1102 for trunk/src/org/expeditee/io/PDF2Writer.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/io/PDF2Writer.java
r919 r1102 19 19 package org.expeditee.io; 20 20 21 import java.awt.Color;22 import java.awt.Dimension;23 import java.awt.Image;24 import java.awt.Polygon;25 import java.awt.geom.AffineTransform;26 21 import java.io.FileOutputStream; 27 22 import java.io.IOException; … … 34 29 import java.util.Set; 35 30 31 import org.expeditee.core.Colour; 32 import org.expeditee.core.Dimension; 33 import org.expeditee.core.Image; 34 import org.expeditee.core.bounds.PolygonBounds; 35 import org.expeditee.gio.swing.SwingConversions; 36 import org.expeditee.gio.swing.SwingMiscManager; 37 import org.expeditee.gui.DisplayController; 36 38 import org.expeditee.gui.Frame; 37 39 import org.expeditee.gui.FrameGraphics; … … 145 147 146 148 public PDF2Writer() { 147 _pageSize = FrameGraphics.getMaxSize();149 _pageSize = DisplayController.getFramePaintArea().getSize(); 148 150 _pdfDocument = new Document(new Rectangle(_pageSize.width, _pageSize.height)); 149 151 } … … 233 235 // set bg color 234 236 PdfContentByte cb = _pdfWriter.getDirectContent(); 235 cb.setColorFill( starting.getPaintBackgroundColor());237 cb.setColorFill(SwingConversions.toSwingColor(starting.getPaintBackgroundColor())); 236 238 cb.rectangle(0, 0, _pageSize.width, _pageSize.height); 237 239 cb.fill(); … … 239 241 } 240 242 241 private void drawPolygon(PdfContentByte cb, Polygon poly, Color fill, Color line, float lineThickness) {243 private void drawPolygon(PdfContentByte cb, PolygonBounds poly, Colour fill, Colour line, float lineThickness) { 242 244 if(poly != null) { 243 cb.moveTo(poly. xpoints[0], _height - poly.ypoints[0]);244 for(int i = 1; i < poly. npoints; i++) {245 cb.lineTo(poly. xpoints[i], _height - poly.ypoints[i]);245 cb.moveTo(poly.toArray()[0].x, _height - poly.toArray()[0].y); 246 for(int i = 1; i < poly.toArray().length; i++) { 247 cb.lineTo(poly.toArray()[i].x, _height - poly.toArray()[i].y); 246 248 } 247 249 cb.closePath(); 248 250 if(fill != null) { 249 cb.setColorFill( fill);251 cb.setColorFill(SwingConversions.toSwingColor(fill)); 250 252 if(lineThickness > 0) { 251 253 cb.setLineWidth(lineThickness); 252 cb.setColorStroke( line);254 cb.setColorStroke(SwingConversions.toSwingColor(line)); 253 255 cb.fillStroke(); 254 256 } else { … … 257 259 } else { 258 260 cb.setLineWidth(lineThickness); 259 cb.setColorStroke( line);261 cb.setColorStroke(SwingConversions.toSwingColor(line)); 260 262 cb.stroke(); 261 263 } … … 269 271 if (hasLink) { 270 272 271 Color lineColor = Color.BLACK, fillColor = null; 272 Polygon poly = i.getLinkPoly(); 273 poly = new Polygon(poly.xpoints, poly.ypoints, poly.npoints); 273 Colour lineColor = Colour.BLACK, fillColor = null; 274 PolygonBounds poly = new PolygonBounds(i.getLinkBounds().getPolygon(16)); 274 275 poly.translate((int) (x - Item.LEFT_MARGIN), (int) (_height - y - i.getBoundsHeight() / 2)); 275 276 … … 298 299 protected void writeText(Text text) throws IOException { 299 300 PdfContentByte cb = _pdfWriter.getDirectContent(); 300 Font font = FontFactory.getFont( 301 Conversion.getPdfFont(text.getFamily()), text.getSize(), text 302 .getPaintFont().getStyle(), text.getPaintColor()); 301 Font font = FontFactory.getFont(Conversion.getPdfFont(text.getFamily()), 302 text.getSize(), 303 SwingConversions.toSwingFontStyle(text.getPaintFont().getStyle()), 304 SwingConversions.toSwingColor(text.getPaintColor())); 303 305 304 306 // we draw some text on a certain position … … 318 320 try { 319 321 PdfContentByte cb = _pdfWriter.getDirectContent(); 320 com.lowagie.text.Image iTextImage = com.lowagie.text.Image.getInstance( image, null);322 com.lowagie.text.Image iTextImage = com.lowagie.text.Image.getInstance(SwingMiscManager.getIfUsingSwingImageManager().getInternalImage(image), null); 321 323 float angle = (float) (pic.getRotate() * Math.PI / 180); 322 324 double sin = Math.sin(angle), cos = Math.cos(angle); … … 339 341 PdfContentByte cb = _pdfWriter.getDirectContent(); 340 342 cb.circle(circle.getCenter().getX(), _pdfWriter.getPageSize().getHeight() - circle.getCenter().getY(), (float) circle.getRadius()); 341 cb.setColorFill( circle.getFillColor());343 cb.setColorFill(SwingConversions.toSwingColor(circle.getFillColor())); 342 344 if(circle.getThickness() > 0) { 343 345 cb.setLineWidth(circle.getThickness()); 344 cb.setColorStroke( circle.getPaintColor());346 cb.setColorStroke(SwingConversions.toSwingColor(circle.getPaintColor())); 345 347 cb.fillStroke(); 346 348 } else { … … 377 379 } 378 380 cb.closePath(); 379 Colo r fill = currentItem.getFillColor();381 Colour fill = currentItem.getFillColor(); 380 382 if(fill != null) { 381 cb.setColorFill( fill);383 cb.setColorFill(SwingConversions.toSwingColor(fill)); 382 384 if(currentItem.getThickness() > 0) { 383 385 cb.setLineWidth(currentItem.getThickness()); 384 cb.setColorStroke( currentLine.getPaintColor());386 cb.setColorStroke(SwingConversions.toSwingColor(currentLine.getPaintColor())); 385 387 cb.fillStroke(); 386 388 } else { … … 389 391 } else if(currentItem.getThickness() > 0) { 390 392 cb.setLineWidth(currentItem.getThickness()); 391 cb.setColorStroke( currentLine.getPaintColor());393 cb.setColorStroke(SwingConversions.toSwingColor(currentLine.getPaintColor())); 392 394 cb.stroke(); 393 395 } … … 403 405 if(l.getThickness() >= 0) { 404 406 cb.setLineWidth(l.getThickness()); 405 cb.setColorStroke( l.getPaintColor());407 cb.setColorStroke(SwingConversions.toSwingColor(l.getPaintColor())); 406 408 cb.stroke(); 407 409 }
Note:
See TracChangeset
for help on using the changeset viewer.