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.

PDFTransitionAction.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.pdf;
  19. import java.io.IOException;
  20. import java.io.OutputStream;
  21. public class PDFTransitionAction extends PDFNavigatorAction {
  22. public abstract static class Resolver {
  23. private boolean resolved;
  24. private PDFTransitionAction action;
  25. private Object extension;
  26. public Resolver(PDFTransitionAction action, Object extension) {
  27. this.action = action;
  28. this.extension = extension;
  29. }
  30. public PDFTransitionAction getAction() {
  31. return action;
  32. }
  33. public Object getExtension() {
  34. return extension;
  35. }
  36. public void resolve() {
  37. if (!resolved) {
  38. performResolution();
  39. resolved = true;
  40. }
  41. }
  42. protected void performResolution() {
  43. }
  44. }
  45. private Resolver resolver;
  46. public PDFTransitionAction(String id) {
  47. super(id);
  48. put("Type", new PDFName("Action"));
  49. put("S", new PDFName("Trans"));
  50. }
  51. @Override
  52. public int output(OutputStream stream) throws IOException {
  53. if (resolver != null) {
  54. resolver.resolve();
  55. }
  56. return super.output(stream);
  57. }
  58. public void setResolver(Resolver resolver) {
  59. this.resolver = resolver;
  60. }
  61. public void populate(Object transition, Object nextAction) {
  62. if (transition != null) {
  63. put("Trans", transition);
  64. }
  65. if (nextAction != null) {
  66. put("Next", nextAction);
  67. }
  68. }
  69. }