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.

DimensionPropertyMaker.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.fo.properties;
  19. import org.apache.fop.fo.Constants;
  20. import org.apache.fop.fo.PropertyList;
  21. import org.apache.fop.fo.expr.PropertyException;
  22. /**
  23. * @author me
  24. *
  25. * To change the template for this generated type comment go to
  26. * Window - Preferences - Java - Code Generation - Code and Comments
  27. */
  28. public class DimensionPropertyMaker extends CorrespondingPropertyMaker {
  29. private int[][] extraCorresponding = null;
  30. /**
  31. * Construct a dimension property maker.
  32. * @param baseMaker the base property maker
  33. */
  34. public DimensionPropertyMaker(PropertyMaker baseMaker) {
  35. super(baseMaker);
  36. }
  37. /**
  38. * Set extra correspondences.
  39. * @param extraCorresponding the extra correspondences
  40. */
  41. public void setExtraCorresponding(int[][] extraCorresponding) {
  42. this.extraCorresponding = extraCorresponding;
  43. }
  44. /**
  45. * Determine if corresponding property is forced.
  46. * @param propertyList the property list to use
  47. * @return true if it is forced
  48. */
  49. public boolean isCorrespondingForced(PropertyList propertyList) {
  50. if (super.isCorrespondingForced(propertyList)) {
  51. return true;
  52. }
  53. for (int i = 0; i < extraCorresponding.length; i++) {
  54. int wmcorr = extraCorresponding[i][0]; //propertyList.getWritingMode()];
  55. if (propertyList.getExplicit(wmcorr) != null) {
  56. return true;
  57. }
  58. }
  59. return false;
  60. }
  61. /** {@inheritDoc} */
  62. public Property compute(PropertyList propertyList) throws PropertyException {
  63. // Based on [width|height]
  64. Property p = super.compute(propertyList);
  65. if (p == null) {
  66. p = baseMaker.make(propertyList);
  67. }
  68. // Based on min-[width|height]
  69. int wmcorr = propertyList.getWritingMode(extraCorresponding[0][0],
  70. extraCorresponding[0][1],
  71. extraCorresponding[0][2]);
  72. Property subprop = propertyList.getExplicitOrShorthand(wmcorr);
  73. if (subprop != null) {
  74. baseMaker.setSubprop(p, Constants.CP_MINIMUM, subprop);
  75. }
  76. // Based on max-[width|height]
  77. wmcorr = propertyList.getWritingMode(extraCorresponding[1][0],
  78. extraCorresponding[1][1],
  79. extraCorresponding[1][2]);
  80. subprop = propertyList.getExplicitOrShorthand(wmcorr);
  81. // TODO: Don't set when NONE.
  82. if (subprop != null) {
  83. baseMaker.setSubprop(p, Constants.CP_MAXIMUM, subprop);
  84. }
  85. return p;
  86. }
  87. }