If you think the Android project DolphinOES listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*******************************************************************************
* Copyright 2015 See AUTHORS file.//fromwww.java2s.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/package com.sidereal.dolphinoes.behaviors.renderer;
import com.sidereal.dolphinoes.behaviors.renderer.scml.SCMLDrawer;
/** Responsible for drawing in an individual matter an image or set of images
* over a number of frames. A {@link Drawer} instance is retrieved using
* {@link DrawerBuilder#build(String)}.
*
* @author Claudiu Bele */publicabstractclass Drawer
{
// region fields
/** Whether the renderer to use the real raw delta (if applicable) is passed
* in {@link DrawerBuilder#build(String)} from the builder if the
* constructor requests the value, otherwise set to false.
* <p>
* If the constructor does not require a variable to assign to this field ,
* the value should not matter. */privateboolean useRealDeltaTime;
/** The renderer that the Drawer is attached to. Set in
* {@link #Drawer(Renderer, String, boolean)}. */protected Renderer renderer;
/** If the Drawer is enabled, it will be drawn. */privateboolean enabled;
/** Name of the drawer. Assigned in
* {@link Renderer#addDrawer(String, DrawerBuilder)}. */protected String name;
// endregion
// region Constructor
/** Base constructor for Drawer. In the extensions of a Drawer, all
* constructors must contain the non-optional parameters, such as the
* filepath to the animation in {@link SCMLDrawer#SpriterDrawer(Renderer)}
* and the name of the Drawer, passed in
* {@link Renderer#addDrawer(String, DrawerBuilder)}.
*
* @param renderer
* @param name
* The name of the drawer.
* @param useRawDelta */public Drawer(Renderer renderer, String name, boolean useRawDelta)
{
this.enabled = true;
this.name = name;
this.useRealDeltaTime = useRawDelta;
}
// endregion
// region methods
// region internal
finalvoid drawInternal(float delta)
{
if (enabled && !isOutOfBounds())
draw(delta);
}
publicboolean getUseRealDeltaTime(){
return useRealDeltaTime;
}
// endregion
// region abstract
/** Disposes values that might need to be disposed. It is up to the
* implementation of Drawer classes to handle this.
* <p>
* It is called from
* {@link com.sidereal.dolphinoes.behaviors.renderer.Renderer#removeDrawer(String)} */protectedabstractvoid dispose();
/** Called from within {@link #drawInternal(float)} by the
* {@link com.sidereal.dolphinoes.behaviors.renderer.Renderer}.
*
* @param delta
* time between frames */protectedabstractvoid draw(float delta);
/** Whether or not the object is out of bounds. If it is, do not render.
* Handled in {@link #drawInternal(float)}.
*
* @return Whether the object is visible on the screen */protectedabstractboolean isOutOfBounds();
// endregion
// region getters and setters
public Renderer getRenderer()
{
return renderer;
}
publicvoid setRenderer(Renderer renderer)
{
this.renderer = renderer;
}
publicboolean isEnabled()
{
return enabled;
}
publicvoid setEnabled(boolean enabled)
{
this.enabled = enabled;
}
// endregion
// endregion methods
}