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.

OCAColor.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.util;
  19. import java.awt.Color;
  20. import java.awt.color.ColorSpace;
  21. /**
  22. * OCAColor is a single component color representation that is mostly used
  23. * in AFP documents to represent text foreground color.
  24. * See also {@link OCAColorSpace}.
  25. *
  26. */
  27. public class OCAColor extends Color {
  28. private static final long serialVersionUID = 1L;
  29. public enum OCAColorValue {
  30. BLUE(0x1),
  31. RED(0x2),
  32. MAGENTA(0x3),
  33. GREEN(0x4),
  34. CYAN(0x5),
  35. YELLOW(0x6),
  36. BLACK(0x8),
  37. BROWN(0x10),
  38. DEVICE_DEFAULT(0xFF07),
  39. MEDIUM_COLOR(0xFF08);
  40. final int value;
  41. OCAColorValue(int value) {
  42. this.value = value;
  43. }
  44. }
  45. public OCAColor(OCAColorValue oca) {
  46. super(oca.value);
  47. }
  48. public int getOCA() {
  49. return this.getRGB() & 0xFFFF;
  50. }
  51. public ColorSpace getColorSpace() {
  52. return new OCAColorSpace();
  53. }
  54. public float[] getColorComponents(ColorSpace cspace, float[] compArray) {
  55. if (cspace.isCS_sRGB()) {
  56. ColorSpace oca = new OCAColorSpace();
  57. return oca.toRGB(new float[]{getOCA()});
  58. }
  59. return null;
  60. }
  61. }