commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IMAGING-157) Add method to color classes to convert colors to other color spaces
Date Sat, 10 Jan 2015 10:18:34 GMT

    [ https://issues.apache.org/jira/browse/IMAGING-157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14272431#comment-14272431
] 

Benedikt Ritter commented on IMAGING-157:
-----------------------------------------

What is {{Color.Hsl}}? Is it an enum? That would duplicate the class hierarchy wie already
have (every class would need an equivalent enum value). So I'd vote for the second solution.
The problem here is, that we need to restrict the range of allowed classes, hence we need
a common interface or class, that all color classes share. We can not use an interface, because
it is not possible to restrict clients from implementing it, so we'll need a base class. I
propose this:

{code:java}
public abstract class Color {

   Color() {
      // package private constructor so that only we can create sub classes
   }

   public T convertTo(Class<T extends Color> targetClass) {
      // implement logic here?
      // make this abstract and implement logic in individual color classes?
      // delegate to ColorConversions?
   }
}
{code}

> Add method to color classes to convert colors to other color spaces
> -------------------------------------------------------------------
>
>                 Key: IMAGING-157
>                 URL: https://issues.apache.org/jira/browse/IMAGING-157
>             Project: Commons Imaging
>          Issue Type: Improvement
>            Reporter: Stephan K├Âninger
>             Fix For: Discussion
>
>
> Instead of having a static util class it would be nice to have a method available to
all Color types which allows one to convert a color to another color space. See following
example for clearance:
> {code:java}
> ColorCmyk cymk = new ColorCmyk(100, 0, 100, 0);
> ColorHsl colorHsl = cymk.convertTo(Color.Hsl); 
> // or
> ColorHsl colorHsl = cymk.convertTo(ColorHsl.class); 
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message