You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PDFState.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.pdf;
  8. import java.awt.Shape;
  9. import java.util.ArrayList;
  10. import java.util.HashMap;
  11. /**
  12. * This keeps information about the current state when writing to pdf.
  13. * It allows for creating new graphics states with the q operator.
  14. *
  15. * When setting the state for pdf there are three possible ways of
  16. * handling the situation.
  17. * The values can be set to override previous or default values.
  18. * A new state can be added and then the values set.
  19. * The current state can be popped and values will return to a
  20. * previous state then the necessary values can be overridden.
  21. * The current transform behaves differently to other values as the
  22. * matrix is combined with the current resolved value.
  23. * It is impossible to optimise the result without analysing the all
  24. * the possible combinations after completing.
  25. */
  26. public class PDFState {
  27. private final static String COLOR = "color";
  28. private final static String BACKCOLOR = "backcolor";
  29. private final static String PATTERN = "pattern";
  30. private final static String BACKPATTERN = "backpattern";
  31. private final static String LINECAP = "lineCap";
  32. private final static String LINEJOIN = "lineJoin";
  33. private final static String LINEWIDTH = "lineWidth";
  34. private final static String MITERLIMIT = "miterLimit";
  35. private final static String TEXT = "text";
  36. private final static String DASHOFFSET = "dashOffset";
  37. private final static String DASHARRAY = "dashArray";
  38. private final static String TRANSFORM = "transform";
  39. private final static String FONTSIZE = "fontSize";
  40. private final static String FONTNAME = "fontName";
  41. private final static String CLIP = "clip";
  42. PDFColor color = new PDFColor(0, 0, 0);
  43. PDFColor backcolor = new PDFColor(255, 255, 255);
  44. PDFPattern pattern = null;
  45. PDFPattern backPattern = null;
  46. int lineCap = 0;
  47. int lineJoin = 0;
  48. float lineWidth = 1;
  49. float miterLimit = 0;
  50. boolean text = false;
  51. int dashOffset = 0;
  52. int[] dashArray = new int[0];
  53. double[] transform = new double[]{1, 0, 0, 1, 0, 0};
  54. float fontSize = 0;
  55. String fontName = "";
  56. Shape clip = null;
  57. ArrayList stateStack = new ArrayList();
  58. public PDFState() {
  59. }
  60. // this call should be used when the q operator is used
  61. // so that the state is known when popped
  62. public void push() {
  63. HashMap changedMap = new HashMap();
  64. }
  65. public void pop() {
  66. if (getStackLevel() > 0) {
  67. stateStack.remove(stateStack.size() - 1);
  68. }
  69. }
  70. public int getStackLevel() {
  71. return stateStack.size();
  72. }
  73. public boolean setLineDash(int[] array, int offset) {
  74. return false;
  75. }
  76. }