本文整理汇总了Java中org.darkstorm.minecraft.gui.component.ProgressBar.getArea方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressBar.getArea方法的具体用法?Java ProgressBar.getArea怎么用?Java ProgressBar.getArea使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.darkstorm.minecraft.gui.component.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.getArea方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderComponent
import org.darkstorm.minecraft.gui.component.ProgressBar; //导入方法依赖的package包/类
@Override
protected void renderComponent(ProgressBar component) {
Rectangle area = component.getArea();
int fontSize = theme.getFontRenderer().FONT_HEIGHT;
FontRenderer fontRenderer = theme.getFontRenderer();
translateComponent(component, false);
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
glDisable(GL_TEXTURE_2D);
RenderUtil.setColor(component.getBackgroundColor());
glLineWidth(0.9f);
glBegin(GL_LINE_LOOP);
{
glVertex2d(0, 0);
glVertex2d(area.width, 0);
glVertex2d(area.width, area.height);
glVertex2d(0, area.height);
}
glEnd();
double barPercentage = (component.getValue() - component.getMinimumValue()) / (component.getMaximumValue() - component.getMinimumValue());
RenderUtil.setColor(component.getForegroundColor());
glBegin(GL_QUADS);
{
glVertex2d(0, 0);
glVertex2d(area.width * barPercentage, 0);
glVertex2d(area.width * barPercentage, area.height);
glVertex2d(0, area.height);
}
glEnd();
glEnable(GL_TEXTURE_2D);
String content = null;
switch(component.getValueDisplay()) {
case DECIMAL:
content = String.format("%,.3f", component.getValue());
break;
case INTEGER:
content = String.format("%,d", Long.valueOf(Math.round(component.getValue())));
break;
case PERCENTAGE:
int percent = (int) Math.round((component.getValue() - component.getMinimumValue()) / (component.getMaximumValue() - component.getMinimumValue()) * 100D);
content = String.format("%d%%", percent);
default:
}
if(content != null) {
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
fontRenderer.drawString(content, component.getWidth() / 2 - fontRenderer.getStringWidth(content) / 2, component.getHeight() / 2 - fontSize / 2, RenderUtil.toRGBA(component.getForegroundColor()));
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
translateComponent(component, true);
}
示例2: renderComponent
import org.darkstorm.minecraft.gui.component.ProgressBar; //导入方法依赖的package包/类
@Override
protected void renderComponent(ProgressBar component) {
Rectangle area = component.getArea();
int fontSize = theme.getFontRenderer().FONT_HEIGHT;
FontRenderer fontRenderer = theme.getFontRenderer();
translateComponent(component, false);
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
glDisable(GL_TEXTURE_2D);
RenderUtil.setColor(component.getBackgroundColor());
glLineWidth(0.9f);
glBegin(GL_LINE_LOOP);
{
glVertex2d(0, 0);
glVertex2d(area.width, 0);
glVertex2d(area.width, area.height);
glVertex2d(0, area.height);
}
glEnd();
double barPercentage = (component.getValue() - component.getMinimumValue()) /
(component.getMaximumValue() - component.getMinimumValue());
RenderUtil.setColor(component.getForegroundColor());
glBegin(GL_QUADS);
{
glVertex2d(0, 0);
glVertex2d(area.width * barPercentage, 0);
glVertex2d(area.width * barPercentage, area.height);
glVertex2d(0, area.height);
}
glEnd();
glEnable(GL_TEXTURE_2D);
String content = null;
switch (component.getValueDisplay()) {
case DECIMAL:
content = String.format("%,.3f", component.getValue());
break;
case INTEGER:
content = String.format("%,d", Math.round(component.getValue()));
break;
case PERCENTAGE:
int percent = (int) Math.round((component.getValue() - component.getMinimumValue()) /
(component.getMaximumValue() - component.getMinimumValue()) * 100D);
content = String.format("%d%%", percent);
default:
}
if (content != null) {
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
fontRenderer.drawString(content, component.getWidth() / 2 - fontRenderer.getStringWidth(content) / 2,
component.getHeight() / 2 - fontSize / 2, RenderUtil.toRGBA(component.getForegroundColor()));
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
translateComponent(component, true);
}