在我的(OpenGL!)Java程序中,我需要3种类型的对象:纹理,帧缓冲,屏幕。这三个都有一些共同的特征(宽度,高度,唯一ID),但在一个基本方面也有所不同:
如果C ++具有多重继承,我会有一个基类' Surface'然后是两个派生类' InputSurface'和' OutputSurface' ,并使Texture类扩展InputSurface,Screen OutputSurface和Framebuffer。
Down to Earth-它的Java,所以我想出了以下怪物:
interface InputSurface
{
/**
* Return the width of this Surface.
*/
int getWidth();
/**
* Return the height of this Surface.
*/
int getHeight();
/**
* Take the underlying rectangle of pixels and bind this texture to OpenGL.
*/
boolean setAsInput();
}
abstract class Surface
{
/**
* Return the width of this Surface.
*
* @return width of the Object, in pixels.
*/
public int getWidth() {...}
/**
* Return the height of this Surface.
*
* @return height of the Object, in pixels.
*/
public int getHeight() {...}
}
public class Texture extends Surface implements InputSurface
{
/**
* Bind the underlying rectangle of pixels as a OpenGL Texture.
*/
public boolean setAsInput() {...}
}
abstract class OutputSurface extends Surface
{
abstract void setAsOutput();
}
public class Screen extends OutputSurface
{
setAsOutput() {...}
}
public class Framebuffer extends OutputSurface implements InputSurface
{
setAsInput() {...}
setAsOutput() {...}
}
(我需要InputSurface接口,因为稍后我需要能够接受Framebuffer和Texture作为这样的泛型方法的输入
void renderFrom(InputSurface surface)
{
(...)
}
以上工作,唯一的问题是它在Javadoc生成的文档中引入了一个混乱。在它的Texture和Framebuffer文档中,Javadoc基本上复制了' getWidth / Height' metods,因为它认为Surface类中有一个,InputSurface接口中有另一个。
这是它提供的文档:
http://distorted.org/javadoc-library/org/distorted/library/DistortedTexture.html
有什么建议吗?