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.

GraphicsPainter.java 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. /* $Id$ */
  18. package org.apache.fop.render.intermediate;
  19. import java.awt.Color;
  20. import java.awt.Point;
  21. import java.io.IOException;
  22. import org.apache.fop.traits.RuleStyle;
  23. /**
  24. * Used primarily by {@link BorderPainter}, implementations are created for rendering
  25. * primitive graphical operations.
  26. *
  27. */
  28. public interface GraphicsPainter {
  29. /**
  30. * Draws a border line.
  31. * @param x1 X coordinate of the upper left corner
  32. * of the line's bounding rectangle (in millipoints)
  33. * @param y1 start Y coordinate of the upper left corner
  34. * of the line's bounding rectangle (in millipoints)
  35. * @param x2 end X coordinate of the lower right corner
  36. * of the line's bounding rectangle (in millipoints)
  37. * @param y2 end y coordinate of the lower right corner
  38. * of the line's bounding rectangle (in millipoints)
  39. * @param horz true if it is a horizontal line
  40. * @param startOrBefore true if the line is the start or end edge of a border box
  41. * @param style the border style
  42. * @param color the border color
  43. * @throws IOException if an I/O error occurs
  44. */
  45. void drawBorderLine(int x1, int y1, int x2, int y2,
  46. boolean horz, boolean startOrBefore, int style, Color color) throws IOException;
  47. /**
  48. * Draws a line/rule.
  49. * @param start start point (coordinates in millipoints)
  50. * @param end end point (coordinates in millipoints)
  51. * @param width width of the line
  52. * @param color the line color
  53. * @param style the rule style
  54. * @throws IOException if an I/O error occurs
  55. */
  56. void drawLine(Point start, Point end,
  57. int width, Color color, RuleStyle style) throws IOException;
  58. /**
  59. * Moves the cursor to the given coordinate.
  60. * @param x the X coordinate (in millipoints)
  61. * @param y the Y coordinate (in millipoints)
  62. * @throws IOException if an I/O error occurs
  63. */
  64. void moveTo(int x, int y) throws IOException;
  65. /**
  66. * Draws a line from the current cursor position to the given coordinates.
  67. * @param x the X coordinate (in millipoints)
  68. * @param y the Y coordinate (in millipoints)
  69. * @throws IOException if an I/O error occurs
  70. */
  71. void lineTo(int x, int y) throws IOException;
  72. /**
  73. * Draws an arc on the ellipse centered at (cx, cy) with width width and height height
  74. * from start angle startAngle (with respect to the x-axis counter-clockwise)
  75. * to the end angle endAngle.
  76. * The ellipses major axis are assumed to coincide with the coordinate axis.
  77. * The current position MUST coincide with the starting position on the ellipse.
  78. * @param startAngle the start angle
  79. * @param endAngle the end angle
  80. * @param cx the x coordinate of the ellipse center
  81. * @param cy the y coordinate of the ellipse center
  82. * @param width the extent of the ellipse in the x direction
  83. * @param height the extent of the ellipse in the y direction
  84. * @throws IOException if an I/O error occurs
  85. */
  86. void arcTo(final double startAngle, final double endAngle, final int cx, final int cy,
  87. final int width, final int height) throws IOException;
  88. /**
  89. * Rotate the coordinate frame
  90. * @param angle angle in radians to rotate the coordinate frame
  91. * @throws IOException if an I/O error occurs
  92. */
  93. void rotateCoordinates(double angle) throws IOException;
  94. /**
  95. * Translate the coordinate frame
  96. * @param xTranslate translation in the x direction
  97. * @param yTranslate translation in the y direction
  98. * @throws IOException if an I/O error occurs
  99. */
  100. void translateCoordinates(int xTranslate, int yTranslate) throws IOException;
  101. /**
  102. * Scale the coordinate frame
  103. * @param xScale scale factor in the x direction
  104. * @param yScale scale factor in the y direction
  105. * @throws IOException if an I/O error occurs
  106. */
  107. void scaleCoordinates(float xScale, float yScale) throws IOException;
  108. /**
  109. * Closes the current path.
  110. * @throws IOException if an I/O error occurs
  111. */
  112. void closePath() throws IOException;
  113. /**
  114. * Reduces the current clipping region to the current path.
  115. * @throws IOException if an I/O error occurs
  116. */
  117. void clip() throws IOException;
  118. /**
  119. * Save the graphics state on the stack.
  120. * @throws IOException if an I/O error occurs
  121. */
  122. void saveGraphicsState() throws IOException;
  123. /**
  124. * Restore the last graphics state from the stack.
  125. * @throws IOException if an I/O error occurs
  126. */
  127. void restoreGraphicsState() throws IOException;
  128. }